summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2016-08-03 18:01:49 -0400
committer AJR <ajrhacker@users.noreply.github.com>2016-08-05 19:05:01 -0400
commitda754c80782425a4c63d2da0a2635ca4fbaf16a5 (patch)
tree22e55dc4ec81a097a24346d2d735ad8348315933 /src/devices
parent1317019974231191a0a42d732ef9b603dcd00896 (diff)
Devfind revision phase 2 (nw)
- Eliminate read_safe as a global function and make it a method of optional_ioport (and required_ioport, for which it makes less sense). - New constructor for optional_ioport_array and required_ioport_array using std::initializer_list to specify tag list - Remove pointer/reference conversion operators for required_ioport and optional_ioport. Explicit getters like found() and target() are now required when dereferencing isn't wanted. Many drivers have been changed to use required_ioport_array and optional_ioport_array to make this cleaner. - Update numerous drivers that were using read_safe to use I/O port finders generally. Port names have been kept the same as far as possible to avoid breaking saves.(Some of the optional finders should probably be required.) - Give edfbl and monkelf their own memory maps so hacky input reading routines can be removed. - Clean up some legacy static handlers in amiga.cpp and cubo.cpp.
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/bus/coco/coco_dwsock.cpp2
-rw-r--r--src/devices/bus/coco/coco_fdc.cpp10
-rw-r--r--src/devices/bus/coco/coco_fdc.h1
-rw-r--r--src/devices/bus/coco/coco_pak.cpp10
-rw-r--r--src/devices/bus/coco/coco_pak.h2
-rw-r--r--src/devices/bus/megadrive/jcart.cpp16
-rw-r--r--src/devices/bus/sg1000_exp/sk1100.cpp44
-rw-r--r--src/devices/bus/sg1000_exp/sk1100.h17
-rw-r--r--src/devices/machine/pckeybrd.cpp18
-rw-r--r--src/devices/video/snes_ppu.cpp17
-rw-r--r--src/devices/video/snes_ppu.h5
11 files changed, 60 insertions, 82 deletions
diff --git a/src/devices/bus/coco/coco_dwsock.cpp b/src/devices/bus/coco/coco_dwsock.cpp
index fb2e18a23fb..6525cbaa97b 100644
--- a/src/devices/bus/coco/coco_dwsock.cpp
+++ b/src/devices/bus/coco/coco_dwsock.cpp
@@ -203,6 +203,6 @@ WRITE8_MEMBER(beckerport_device::write)
void beckerport_device::update_port(void)
{
device_stop();
- m_dwtcpport = read_safe(m_dwconfigport, 65504);
+ m_dwtcpport = m_dwconfigport.read_safe(65504);
device_start();
}
diff --git a/src/devices/bus/coco/coco_fdc.cpp b/src/devices/bus/coco/coco_fdc.cpp
index a5ee7a6d689..46ee2bb8d93 100644
--- a/src/devices/bus/coco/coco_fdc.cpp
+++ b/src/devices/bus/coco/coco_fdc.cpp
@@ -116,7 +116,7 @@ SLOT_INTERFACE_END
coco_rtc_type_t coco_fdc_device::real_time_clock()
{
- coco_rtc_type_t result = coco_rtc_type_t(read_safe(machine().root_device().ioport("real_time_clock"), RTC_NONE));
+ coco_rtc_type_t result = coco_rtc_type_t(m_rtc.read_safe(RTC_NONE));
/* check to make sure we don't have any invalid values */
if (((result == RTC_DISTO) && (m_disto_msm6242 == nullptr))
@@ -183,7 +183,8 @@ coco_fdc_device::coco_fdc_device(const machine_config &mconfig, device_type type
m_wd17xx(*this, WD_TAG),
m_wd2797(*this, WD2797_TAG),
m_ds1315(*this, CLOUD9_TAG),
- m_disto_msm6242(*this, DISTO_TAG), m_msm6242_rtc_address(0)
+ m_disto_msm6242(*this, DISTO_TAG), m_msm6242_rtc_address(0),
+ m_rtc(*this, ":real_time_clock")
{
}
@@ -193,8 +194,9 @@ coco_fdc_device::coco_fdc_device(const machine_config &mconfig, const char *tag,
m_wd17xx(*this, WD_TAG),
m_wd2797(*this, WD2797_TAG),
m_ds1315(*this, CLOUD9_TAG),
- m_disto_msm6242(*this, DISTO_TAG), m_msm6242_rtc_address(0)
- {
+ m_disto_msm6242(*this, DISTO_TAG), m_msm6242_rtc_address(0),
+ m_rtc(*this, ":real_time_clock")
+{
}
//-------------------------------------------------
diff --git a/src/devices/bus/coco/coco_fdc.h b/src/devices/bus/coco/coco_fdc.h
index 2799d15e0ee..067fd3fde19 100644
--- a/src/devices/bus/coco/coco_fdc.h
+++ b/src/devices/bus/coco/coco_fdc.h
@@ -76,6 +76,7 @@ protected:
optional_device<msm6242_device> m_disto_msm6242; /* 6242 RTC on Disto interface */
offs_t m_msm6242_rtc_address;
+ optional_ioport m_rtc;
};
diff --git a/src/devices/bus/coco/coco_pak.cpp b/src/devices/bus/coco/coco_pak.cpp
index 1a861fa3bed..c091606027d 100644
--- a/src/devices/bus/coco/coco_pak.cpp
+++ b/src/devices/bus/coco/coco_pak.cpp
@@ -41,13 +41,15 @@ const device_type COCO_PAK = &device_creator<coco_pak_device>;
//-------------------------------------------------
coco_pak_device::coco_pak_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_cococart_interface( mconfig, *this ), m_cart(nullptr), m_owner(nullptr)
+ device_cococart_interface( mconfig, *this ), m_cart(nullptr), m_owner(nullptr),
+ m_autostart(*this, ":" CART_AUTOSTART_TAG)
{
}
coco_pak_device::coco_pak_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, COCO_PAK, "CoCo Program PAK", tag, owner, clock, "cocopak", __FILE__),
- device_cococart_interface( mconfig, *this ), m_cart(nullptr), m_owner(nullptr)
+ device_cococart_interface( mconfig, *this ), m_cart(nullptr), m_owner(nullptr),
+ m_autostart(*this, ":" CART_AUTOSTART_TAG)
{
}
@@ -87,9 +89,7 @@ const rom_entry *coco_pak_device::device_rom_region() const
void coco_pak_device::device_reset()
{
if (m_cart->exists()) {
- cococart_line_value cart_line;
-
- cart_line = read_safe(machine().root_device().ioport(CART_AUTOSTART_TAG), 0x01)
+ cococart_line_value cart_line = m_autostart.read_safe(0x01)
? COCOCART_LINE_VALUE_Q
: COCOCART_LINE_VALUE_CLEAR;
diff --git a/src/devices/bus/coco/coco_pak.h b/src/devices/bus/coco/coco_pak.h
index 7915fd9923d..ed531943242 100644
--- a/src/devices/bus/coco/coco_pak.h
+++ b/src/devices/bus/coco/coco_pak.h
@@ -36,6 +36,8 @@ protected:
// internal state
device_image_interface *m_cart;
cococart_slot_device *m_owner;
+
+ optional_ioport m_autostart;
};
diff --git a/src/devices/bus/megadrive/jcart.cpp b/src/devices/bus/megadrive/jcart.cpp
index 85fb7c373b4..e3182fca414 100644
--- a/src/devices/bus/megadrive/jcart.cpp
+++ b/src/devices/bus/megadrive/jcart.cpp
@@ -180,14 +180,14 @@ READ16_MEMBER(md_jcart_device::read)
if (m_jcart_io_data[0] & 0x40)
{
- joy[0] = read_safe(m_jcart3, 0);
- joy[1] = read_safe(m_jcart4, 0);
+ joy[0] = m_jcart3.read_safe(0);
+ joy[1] = m_jcart4.read_safe(0);
return (m_jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
else
{
- joy[0] = ((read_safe(m_jcart3, 0) & 0xc0) >> 2) | (read_safe(m_jcart3, 0) & 0x03);
- joy[1] = ((read_safe(m_jcart4, 0) & 0xc0) >> 2) | (read_safe(m_jcart4, 0) & 0x03);
+ joy[0] = ((m_jcart3.read_safe(0) & 0xc0) >> 2) | (m_jcart3.read_safe(0) & 0x03);
+ joy[1] = ((m_jcart4.read_safe(0) & 0xc0) >> 2) | (m_jcart4.read_safe(0) & 0x03);
return (m_jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
}
@@ -223,14 +223,14 @@ READ16_MEMBER(md_seprom_codemast_device::read)
if (m_jcart_io_data[0] & 0x40)
{
- joy[0] = read_safe(m_jcart3, 0);
- joy[1] = read_safe(m_jcart4, 0);
+ joy[0] = m_jcart3.read_safe(0);
+ joy[1] = m_jcart4.read_safe(0);
return (m_jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
else
{
- joy[0] = ((read_safe(m_jcart3, 0) & 0xc0) >> 2) | (read_safe(m_jcart3, 0) & 0x03);
- joy[1] = ((read_safe(m_jcart4, 0) & 0xc0) >> 2) | (read_safe(m_jcart4, 0) & 0x03);
+ joy[0] = ((m_jcart3.read_safe(0) & 0xc0) >> 2) | (m_jcart3.read_safe(0) & 0x03);
+ joy[1] = ((m_jcart4.read_safe(0) & 0xc0) >> 2) | (m_jcart4.read_safe(0) & 0x03);
return (m_jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
}
diff --git a/src/devices/bus/sg1000_exp/sk1100.cpp b/src/devices/bus/sg1000_exp/sk1100.cpp
index aee9e3c09f7..b6c2e037748 100644
--- a/src/devices/bus/sg1000_exp/sk1100.cpp
+++ b/src/devices/bus/sg1000_exp/sk1100.cpp
@@ -104,6 +104,9 @@ static INPUT_PORTS_START( sk1100_keys )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(UTF8_UP) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
+ PORT_START("PA7")
+ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) // keyboard disabled
+
PORT_START("PB0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
PORT_BIT( 0x06, IP_ACTIVE_LOW, IPT_UNUSED )
@@ -134,6 +137,9 @@ static INPUT_PORTS_START( sk1100_keys )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("GRAPH") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT))
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL))
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
+
+ PORT_START("PB7")
+ PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED ) // keyboard disabled
INPUT_PORTS_END
@@ -185,20 +191,8 @@ sega_sk1100_device::sega_sk1100_device(const machine_config &mconfig, const char
device_sg1000_expansion_slot_interface(mconfig, *this),
m_cassette(*this, "cassette"),
m_ppi(*this, UPD9255_0_TAG),
- m_pa0(*this, "PA0"),
- m_pa1(*this, "PA1"),
- m_pa2(*this, "PA2"),
- m_pa3(*this, "PA3"),
- m_pa4(*this, "PA4"),
- m_pa5(*this, "PA5"),
- m_pa6(*this, "PA6"),
- m_pb0(*this, "PB0"),
- m_pb1(*this, "PB1"),
- m_pb2(*this, "PB2"),
- m_pb3(*this, "PB3"),
- m_pb4(*this, "PB4"),
- m_pb5(*this, "PB5"),
- m_pb6(*this, "PB6"),
+ m_pa(*this, {"PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7"}),
+ m_pb(*this, {"PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7"}),
m_keylatch(0)
{
}
@@ -210,24 +204,6 @@ sega_sk1100_device::sega_sk1100_device(const machine_config &mconfig, const char
void sega_sk1100_device::device_start()
{
- // find keyboard rows
- m_key_row[0] = m_pa0;
- m_key_row[1] = m_pa1;
- m_key_row[2] = m_pa2;
- m_key_row[3] = m_pa3;
- m_key_row[4] = m_pa4;
- m_key_row[5] = m_pa5;
- m_key_row[6] = m_pa6;
- m_key_row[7] = nullptr; // keyboard disabled
- m_key_row[8] = m_pb0;
- m_key_row[9] = m_pb1;
- m_key_row[10] = m_pb2;
- m_key_row[11] = m_pb3;
- m_key_row[12] = m_pb4;
- m_key_row[13] = m_pb5;
- m_key_row[14] = m_pb6;
- m_key_row[15] = nullptr; // keyboard disabled
-
/* register for state saving */
save_item(NAME(m_keylatch));
}
@@ -278,7 +254,7 @@ READ8_MEMBER( sega_sk1100_device::ppi_pa_r )
PA7 Keyboard input
*/
- return m_key_row[m_keylatch]->read();
+ return m_pa[m_keylatch]->read();
}
READ8_MEMBER( sega_sk1100_device::ppi_pb_r )
@@ -297,7 +273,7 @@ READ8_MEMBER( sega_sk1100_device::ppi_pb_r )
*/
/* keyboard */
- UINT8 data = m_key_row[m_keylatch + 8]->read();
+ UINT8 data = m_pb[m_keylatch]->read();
/* cartridge contact */
data |= 0x10;
diff --git a/src/devices/bus/sg1000_exp/sk1100.h b/src/devices/bus/sg1000_exp/sk1100.h
index 80cabb3f30d..8ee058e9d5e 100644
--- a/src/devices/bus/sg1000_exp/sk1100.h
+++ b/src/devices/bus/sg1000_exp/sk1100.h
@@ -54,23 +54,10 @@ protected:
virtual bool is_readable(UINT8 offset) override;
private:
- ioport_port* m_key_row[16];
required_device<cassette_image_device> m_cassette;
required_device<i8255_device> m_ppi;
- required_ioport m_pa0;
- required_ioport m_pa1;
- required_ioport m_pa2;
- required_ioport m_pa3;
- required_ioport m_pa4;
- required_ioport m_pa5;
- required_ioport m_pa6;
- required_ioport m_pb0;
- required_ioport m_pb1;
- required_ioport m_pb2;
- required_ioport m_pb3;
- required_ioport m_pb4;
- required_ioport m_pb5;
- required_ioport m_pb6;
+ required_ioport_array<8> m_pa;
+ required_ioport_array<8> m_pb;
/* keyboard state */
UINT8 m_keylatch;
diff --git a/src/devices/machine/pckeybrd.cpp b/src/devices/machine/pckeybrd.cpp
index 0650fc8cea3..b6aa0a1f8b9 100644
--- a/src/devices/machine/pckeybrd.cpp
+++ b/src/devices/machine/pckeybrd.cpp
@@ -528,39 +528,39 @@ UINT32 pc_keyboard_device::readport(int port)
switch(port)
{
case 0:
- if(m_ioport_0)
+ if (m_ioport_0.found())
result = m_ioport_0->read();
break;
case 1:
- if(m_ioport_1)
+ if (m_ioport_1.found())
result = m_ioport_1->read();
break;
case 2:
- if(m_ioport_2)
+ if (m_ioport_2.found())
result = m_ioport_2->read();
break;
case 3:
- if(m_ioport_3)
+ if (m_ioport_3.found())
result = m_ioport_3->read();
break;
case 4:
- if(m_ioport_4)
+ if (m_ioport_4.found())
result = m_ioport_4->read();
break;
case 5:
- if(m_ioport_5)
+ if (m_ioport_5.found())
result = m_ioport_5->read();
break;
case 6:
- if(m_ioport_6)
+ if (m_ioport_6.found())
result = m_ioport_6->read();
break;
case 7:
- if(m_ioport_7)
+ if (m_ioport_7.found())
result = m_ioport_7->read();
break;
}
- return result;
+ return 0;
}
void pc_keyboard_device::polling(void)
diff --git a/src/devices/video/snes_ppu.cpp b/src/devices/video/snes_ppu.cpp
index fa7c85e3f7c..603b19e1a93 100644
--- a/src/devices/video/snes_ppu.cpp
+++ b/src/devices/video/snes_ppu.cpp
@@ -203,7 +203,12 @@ const device_type SNES_PPU = &device_creator<snes_ppu_device>;
snes_ppu_device::snes_ppu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, SNES_PPU, "SNES PPU", tag, owner, clock, "snes_ppu", __FILE__),
device_video_interface(mconfig, *this),
- m_openbus_cb(*this)
+ m_openbus_cb(*this),
+ m_options(*this, ":OPTIONS"),
+ m_debug1(*this, ":DEBUG1"),
+ m_debug2(*this, ":DEBUG2"),
+ m_debug3(*this, ":DEBUG3"),
+ m_debug4(*this, ":DEBUG4")
{
}
@@ -1819,7 +1824,7 @@ void snes_ppu_device::refresh_scanline( bitmap_rgb32 &bitmap, UINT16 curline )
struct SNES_SCANLINE *scanline1, *scanline2;
UINT16 c;
UINT16 prev_colour = 0;
- int blurring = read_safe(machine().root_device().ioport("OPTIONS"), 0) & 0x01;
+ int blurring = m_options.read_safe(0) & 0x01;
g_profiler.start(PROFILER_VIDEO);
@@ -2831,13 +2836,13 @@ void snes_ppu_device::write(address_space &space, UINT32 offset, UINT8 data)
UINT8 snes_ppu_device::dbg_video( UINT16 curline )
{
int i;
- UINT8 toggles = read_safe(machine().root_device().ioport("DEBUG1"), 0);
+ UINT8 toggles = m_debug1.read_safe(0);
m_debug_options.select_pri[SNES_BG1] = (toggles & 0x03);
m_debug_options.select_pri[SNES_BG2] = (toggles & 0x0c) >> 2;
m_debug_options.select_pri[SNES_BG3] = (toggles & 0x30) >> 4;
m_debug_options.select_pri[SNES_BG4] = (toggles & 0xc0) >> 6;
- toggles = read_safe(machine().root_device().ioport("DEBUG2"), 0);
+ toggles = m_debug2.read_safe(0);
for (i = 0; i < 4; i++)
DEBUG_TOGGLE(i, m_debug_options.bg_disabled[i], ("Debug: Disabled BG%d.\n", i + 1), ("Debug: Enabled BG%d.\n", i + 1))
DEBUG_TOGGLE(4, m_debug_options.bg_disabled[SNES_OAM], ("Debug: Disabled OAM.\n"), ("Debug: Enabled OAM.\n"))
@@ -2845,11 +2850,11 @@ UINT8 snes_ppu_device::dbg_video( UINT16 curline )
DEBUG_TOGGLE(6, m_debug_options.colormath_disabled, ("Debug: Disabled Color Math.\n"), ("Debug: Enabled Color Math.\n"))
DEBUG_TOGGLE(7, m_debug_options.windows_disabled, ("Debug: Disabled Window Masks.\n"), ("Debug: Enabled Window Masks.\n"))
- toggles = read_safe(machine().root_device().ioport("DEBUG4"), 0);
+ toggles = m_debug4.read_safe(0);
for (i = 0; i < 8; i++)
DEBUG_TOGGLE(i, m_debug_options.mode_disabled[i], ("Debug: Disabled Mode %d drawing.\n", i), ("Debug: Enabled Mode %d drawing.\n", i))
- toggles = read_safe(machine().root_device().ioport("DEBUG3"), 0);
+ toggles = m_debug3.read_safe(0);
DEBUG_TOGGLE(2, m_debug_options.mosaic_disabled, ("Debug: Disabled Mosaic.\n"), ("Debug: Enabled Mosaic.\n"))
m_debug_options.sprite_reversed = BIT(toggles, 7);
m_debug_options.select_pri[SNES_OAM] = (toggles & 0x70) >> 4;
diff --git a/src/devices/video/snes_ppu.h b/src/devices/video/snes_ppu.h
index cc1f2a3311d..79bcf34f7b7 100644
--- a/src/devices/video/snes_ppu.h
+++ b/src/devices/video/snes_ppu.h
@@ -278,6 +278,11 @@ protected:
private:
devcb_read16 m_openbus_cb;
+ optional_ioport m_options;
+ optional_ioport m_debug1;
+ optional_ioport m_debug2;
+ optional_ioport m_debug3;
+ optional_ioport m_debug4;
};