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.
This commit is contained in:
AJR 2016-08-03 18:01:49 -04:00
parent 1317019974
commit da754c8078
168 changed files with 857 additions and 1051 deletions

View File

@ -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();
}

View File

@ -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,7 +194,8 @@ 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")
{
}

View File

@ -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;
};

View File

@ -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;

View File

@ -36,6 +36,8 @@ protected:
// internal state
device_image_interface *m_cart;
cococart_slot_device *m_owner;
optional_ioport m_autostart;
};

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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;
};

View File

@ -80,11 +80,6 @@ public:
: finder_base(base, tag),
m_target(nullptr) { }
// operators to make use transparent
operator _ObjectClass *() const { return m_target; }
virtual _ObjectClass *operator->() const { assert(m_target != nullptr); return m_target; }
// getters for explicit fetching
_ObjectClass *target() const { return m_target; }
bool found() const { return m_target != nullptr; }
@ -109,6 +104,10 @@ public:
device_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG)
: object_finder_base<_DeviceClass>(base, tag) { }
// operators to make pointer use transparent
operator _DeviceClass *() const { return object_finder_base<_DeviceClass>::m_target; }
virtual _DeviceClass *operator->() const { assert(object_finder_base<_DeviceClass>::m_target != nullptr); return object_finder_base<_DeviceClass>::m_target; }
// make reference use transparent as well
operator _DeviceClass &() { assert(object_finder_base<_DeviceClass>::m_target != nullptr); return *object_finder_base<_DeviceClass>::m_target; }
@ -153,6 +152,10 @@ public:
memory_region_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG)
: object_finder_base<memory_region>(base, tag) { }
// operators to make pointer use transparent
operator memory_region *() const { return m_target; }
virtual memory_region *operator->() const { assert(m_target != nullptr); return m_target; }
// make reference use transparent as well
operator memory_region &() const { assert(object_finder_base<memory_region>::m_target != nullptr); return *object_finder_base<memory_region>::m_target; }
@ -191,6 +194,10 @@ public:
memory_bank_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG)
: object_finder_base<memory_bank>(base, tag) { }
// operators to make pointer use transparent
operator memory_bank *() const { return m_target; }
virtual memory_bank *operator->() const { assert(m_target != nullptr); return m_target; }
// make reference use transparent as well
operator memory_bank &() const { assert(object_finder_base<memory_bank>::m_target != nullptr); return *object_finder_base<memory_bank>::m_target; }
@ -229,11 +236,12 @@ public:
ioport_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG)
: object_finder_base<ioport_port>(base, tag) { }
// make reference use transparent as well
operator ioport_port &() const { assert(object_finder_base<ioport_port>::m_target != nullptr); return *object_finder_base<ioport_port>::m_target; }
// operators to make use transparent
ioport_port &operator*() const { assert(m_target != nullptr); return *m_target; }
virtual ioport_port *operator->() const { assert(m_target != nullptr); return m_target; }
// allow dereference even when target is nullptr so read_safe() can be used
ioport_port *operator->() const override { return object_finder_base<ioport_port>::m_target; }
// read if found, or else return a default value
ioport_value read_safe(ioport_value defval) { return m_target != nullptr ? m_target->read() : defval; }
// finder
virtual bool findit(bool isvalidation = false) override
@ -284,6 +292,16 @@ public:
m_array[index] = std::make_unique<ioport_finder_type>(base, tags[index]);
}
ioport_array_finder(device_t &base, std::initializer_list<const char *> taglist)
{
assert(taglist.size() <= _Count);
int index = 0;
for (const char *tag : taglist)
m_array[index++] = std::make_unique<ioport_finder_type>(base, tag);
while (index < _Count)
m_array[index++] = std::make_unique<ioport_finder_type>(base, FINDER_DUMMY_TAG);
}
// array accessors
const ioport_finder_type &operator[](int index) const { assert(index < _Count); return *m_array[index]; }
ioport_finder_type &operator[](int index) { assert(index < _Count); return *m_array[index]; }
@ -301,6 +319,7 @@ class optional_ioport_array: public ioport_array_finder<_Count, false>
public:
optional_ioport_array(device_t &base, const char *basetag) : ioport_array_finder<_Count, false>(base, basetag) { }
optional_ioport_array(device_t &base, const char * const *tags) : ioport_array_finder<_Count, false>(base, tags) { }
optional_ioport_array(device_t &base, std::initializer_list<const char *> taglist) : ioport_array_finder<_Count, false>(base, taglist) { }
};
// required ioport array finder
@ -310,6 +329,7 @@ class required_ioport_array: public ioport_array_finder<_Count, true>
public:
required_ioport_array(device_t &base, const char *basetag) : ioport_array_finder<_Count, true>(base, basetag) { }
required_ioport_array(device_t &base, const char * const *tags) : ioport_array_finder<_Count, true>(base, tags) { }
required_ioport_array(device_t &base, std::initializer_list<const char *> taglist) : ioport_array_finder<_Count, true>(base, taglist) { }
};
@ -329,6 +349,7 @@ public:
m_length(length) { }
// operators to make use transparent
operator _PointerType *() const { return this->m_target; }
_PointerType operator[](int index) const { assert(index < m_length); return this->m_target[index]; }
_PointerType &operator[](int index) { assert(index < m_length); return this->m_target[index]; }
@ -387,6 +408,7 @@ public:
m_width(width) { }
// operators to make use transparent
operator _PointerType *() const { return this->m_target; }
_PointerType operator[](int index) const { return this->m_target[index]; }
_PointerType &operator[](int index) { return this->m_target[index]; }

View File

@ -1325,8 +1325,6 @@ private:
std::unique_ptr<ioport_port_live> m_live; // live state of port (nullptr if not live)
};
inline ioport_value read_safe(ioport_port *port, ioport_value defval) { return (port == nullptr) ? defval : port->read(); }
// ======================> analog_field

View File

@ -53,6 +53,7 @@ midway_ssio_device::midway_ssio_device(const machine_config &mconfig, const char
m_cpu(*this, "cpu"),
m_ay0(*this, "ay0"),
m_ay1(*this, "ay1"),
m_ports(*this, {"IP0", "IP1", "IP2", "IP3", "IP4"}),
m_status(0),
m_14024_count(0),
m_mute(0)
@ -113,8 +114,7 @@ WRITE_LINE_MEMBER(midway_ssio_device::reset_write)
READ8_MEMBER(midway_ssio_device::ioport_read)
{
static const char *const port[] = { "IP0", "IP1", "IP2", "IP3", "IP4" };
UINT8 result = read_safe(ioport(port[offset]), 0xff);
UINT8 result = m_ports[offset].read_safe(0xff);
if (!m_custom_input[offset].isnull())
result = (result & ~m_custom_input_mask[offset]) |
(m_custom_input[offset](space, offset, 0xff) & m_custom_input_mask[offset]);

View File

@ -104,6 +104,9 @@ private:
required_device<ay8910_device> m_ay0;
required_device<ay8910_device> m_ay1;
// I/O ports
optional_ioport_array<5> m_ports;
// internal state
UINT8 m_data[4];
UINT8 m_status;

View File

@ -2986,8 +2986,8 @@ INPUT_CHANGED_MEMBER(_8080bw_state::claybust_gun_trigger)
ana a
rz
*/
UINT8 const gunx = read_safe(ioport("GUNX"), 0x00);
UINT8 const guny = read_safe(ioport("GUNY"), 0x20);
UINT8 const gunx = m_gunx.read_safe(0x00);
UINT8 const guny = m_guny.read_safe(0x20);
m_claybust_gun_pos = ((gunx >> 3) | (guny << 5)) + 2;
m_claybust_gun_on->adjust(attotime::from_msec(250)); // timing is a guess
}

View File

@ -44,14 +44,7 @@ public:
m_reel1(*this, "reel1"),
m_reel2(*this, "reel2"),
m_reel3(*this, "reel3"),
m_io1_port(*this, "IO1"),
m_io2_port(*this, "IO2"),
m_io3_port(*this, "IO3"),
m_io4_port(*this, "IO4"),
m_io5_port(*this, "IO5"),
m_io6_port(*this, "IO6"),
m_io7_port(*this, "IO7"),
m_io8_port(*this, "IO8")
m_io_ports(*this, {"IO1", "IO2", "IO3", "IO4", "IO5", "IO6", "IO7", "IO8"})
{ }
int m_input_strobe;
int m_lamp_strobe;
@ -197,9 +190,7 @@ public:
DECLARE_READ8_MEMBER( ic37_read_b )
{
ioport_port * portnames[] = { m_io1_port, m_io2_port, m_io3_port, m_io4_port, m_io5_port, m_io6_port, m_io7_port, m_io8_port,m_io1_port, m_io2_port, m_io3_port, m_io4_port, m_io5_port, m_io6_port, m_io7_port, m_io8_port };
return (portnames[m_input_strobe])->read();
return (m_io_ports[m_input_strobe & 7])->read();
}
DECLARE_READ8_MEMBER( ic37_read_c )
@ -219,14 +210,7 @@ public:
required_device<stepper_device> m_reel1;
required_device<stepper_device> m_reel2;
required_device<stepper_device> m_reel3;
required_ioport m_io1_port;
required_ioport m_io2_port;
required_ioport m_io3_port;
required_ioport m_io4_port;
required_ioport m_io5_port;
required_ioport m_io6_port;
required_ioport m_io7_port;
required_ioport m_io8_port;
required_ioport_array<8> m_io_ports;
DECLARE_DRIVER_INIT(aces1);
virtual void machine_start() override;

View File

@ -87,8 +87,8 @@ int alg_state::get_lightgun_pos(int player, int *x, int *y)
{
const rectangle &visarea = m_screen->visible_area();
int xpos = (player == 0) ? m_gun1x->read() : (m_gun2x ? m_gun2x->read() : 0xffffffff);
int ypos = (player == 0) ? m_gun1y->read() : (m_gun2y ? m_gun2y->read() : 0xffffffff);
int xpos = (player == 0) ? m_gun1x->read() : m_gun2x.read_safe(0xffffffff);
int ypos = (player == 0) ? m_gun1y->read() : m_gun2y.read_safe(0xffffffff);
if (xpos == -1 || ypos == -1)
return FALSE;

View File

@ -309,21 +309,22 @@ class cd32_state : public amiga_state
public:
cd32_state(const machine_config &mconfig, device_type type, const char *tag) :
amiga_state(mconfig, type, tag),
m_p1_port(*this, "p1_cd32_buttons"),
m_p2_port(*this, "p2_cd32_buttons"),
m_player_ports(*this, {"p1_cd32_buttons", "p2_cd32_buttons"}),
m_cdda(*this, "cdda")
{ }
DECLARE_WRITE8_MEMBER( akiko_cia_0_port_a_write );
void handle_joystick_cia(UINT8 pra, UINT8 dra);
UINT16 handle_joystick_potgor(UINT16 potgor);
DECLARE_CUSTOM_INPUT_MEMBER( cd32_input );
DECLARE_CUSTOM_INPUT_MEMBER( cd32_sel_mirror_input );
DECLARE_DRIVER_INIT( pal );
DECLARE_DRIVER_INIT( ntsc );
required_ioport m_p1_port;
required_ioport m_p2_port;
required_ioport_array<2> m_player_ports;
int m_oldstate[2];
int m_cd32_shifter[2];
@ -849,40 +850,33 @@ void cd32_state::potgo_w(UINT16 data)
}
}
static void handle_cd32_joystick_cia(running_machine &machine, UINT8 pra, UINT8 dra)
void cd32_state::handle_joystick_cia(UINT8 pra, UINT8 dra)
{
cd32_state *state = machine.driver_data<cd32_state>();
int i;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
UINT8 but = 0x40 << i;
UINT16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
UINT16 p5dat = 0x0100 << (i * 4); /* data P5 */
if (!(state->m_potgo_value & p5dir) || !(state->m_potgo_value & p5dat))
if (!(m_potgo_value & p5dir) || !(m_potgo_value & p5dat))
{
if ((dra & but) && (pra & but) != state->m_oldstate[i])
if ((dra & but) && (pra & but) != m_oldstate[i])
{
if (!(pra & but))
{
state->m_cd32_shifter[i]--;
if (state->m_cd32_shifter[i] < 0)
state->m_cd32_shifter[i] = 0;
m_cd32_shifter[i]--;
if (m_cd32_shifter[i] < 0)
m_cd32_shifter[i] = 0;
}
}
}
state->m_oldstate[i] = pra & but;
m_oldstate[i] = pra & but;
}
}
static UINT16 handle_joystick_potgor(running_machine &machine, UINT16 potgor)
UINT16 cd32_state::handle_joystick_potgor(UINT16 potgor)
{
cd32_state *state = machine.driver_data<cd32_state>();
ioport_port * player_portname[] = { state->m_p1_port, state->m_p2_port };
int i;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
UINT16 p9dir = 0x0800 << (i * 4); /* output enable P9 */
UINT16 p9dat = 0x0400 << (i * 4); /* data P9 */
@ -891,16 +885,16 @@ static UINT16 handle_joystick_potgor(running_machine &machine, UINT16 potgor)
/* p5 is floating in input-mode */
potgor &= ~p5dat;
potgor |= state->m_potgo_value & p5dat;
if (!(state->m_potgo_value & p9dir))
potgor |= m_potgo_value & p5dat;
if (!(m_potgo_value & p9dir))
potgor |= p9dat;
/* P5 output and 1 -> shift register is kept reset (Blue button) */
if ((state->m_potgo_value & p5dir) && (state->m_potgo_value & p5dat))
state->m_cd32_shifter[i] = 8;
if ((m_potgo_value & p5dir) && (m_potgo_value & p5dat))
m_cd32_shifter[i] = 8;
/* shift at 1 == return one, >1 = return button states */
if (state->m_cd32_shifter[i] == 0)
if (m_cd32_shifter[i] == 0)
potgor &= ~p9dat; /* shift at zero == return zero */
if (state->m_cd32_shifter[i] >= 2 && ((player_portname[i])->read() & (1 << (state->m_cd32_shifter[i] - 2))))
if (m_cd32_shifter[i] >= 2 && ((m_player_ports[i])->read() & (1 << (m_cd32_shifter[i] - 2))))
potgor &= ~p9dat;
}
return potgor;
@ -908,13 +902,12 @@ static UINT16 handle_joystick_potgor(running_machine &machine, UINT16 potgor)
CUSTOM_INPUT_MEMBER( cd32_state::cd32_input )
{
return handle_joystick_potgor(machine(), m_potgo_value) >> 8;
return handle_joystick_potgor(m_potgo_value) >> 8;
}
CUSTOM_INPUT_MEMBER( cd32_state::cd32_sel_mirror_input )
{
ioport_port* ports[2]= { m_p1_port, m_p2_port };
UINT8 bits = ports[(int)(FPTR)param]->read();
UINT8 bits = m_player_ports[(int)(FPTR)param]->read();
return (bits & 0x20)>>5;
}
@ -926,7 +919,7 @@ WRITE8_MEMBER( cd32_state::akiko_cia_0_port_a_write )
// bit 1, power led
output().set_led_value(0, BIT(data, 1) ? 0 : 1);
handle_cd32_joystick_cia(machine(), data, m_cia_0->read(space, 2));
handle_joystick_cia(data, m_cia_0->read(space, 2));
}

View File

@ -334,7 +334,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(napple2_state::apple2_interrupt)
m_video->m_sysconfig = m_sysconfig->read();
// check reset
if (m_resetdip) // if reset DIP is present, use it
if (m_resetdip.found()) // if reset DIP is present, use it
{
if (m_resetdip->read() & 1)
{ // CTRL-RESET

View File

@ -265,7 +265,7 @@ READ8_MEMBER(astrocde_state::spacezap_io_r)
{
machine().bookkeeping().coin_counter_w(0, (offset >> 8) & 1);
machine().bookkeeping().coin_counter_w(1, (offset >> 9) & 1);
return m_p3handle ? m_p3handle->read() : 0xff;
return m_p3handle.read_safe(0xff);
}

View File

@ -198,7 +198,7 @@ void astrof_state::astrof_get_pens( pen_t *pens )
{
offs_t i;
UINT8 bank = (m_astrof_palette_bank ? 0x10 : 0x00);
UINT8 config = read_safe(ioport("FAKE"), 0x00);
UINT8 config = m_fake_port.read_safe(0x00);
UINT8 *prom = memregion("proms")->base();
/* a common wire hack to the pcb causes the prom halves to be inverted */
@ -234,7 +234,7 @@ void astrof_state::tomahawk_get_pens( pen_t *pens )
{
offs_t i;
UINT8 *prom = memregion("proms")->base();
UINT8 config = read_safe(ioport("FAKE"), 0x00);
UINT8 config = m_fake_port.read_safe(0x00);
for (i = 0; i < TOMAHAWK_NUM_PENS; i++)
{

View File

@ -566,7 +566,7 @@ READ8_MEMBER( st_state::ikbd_port2_r )
*/
UINT8 data = m_joy1 ? m_joy1->read() & 0x06 : 0x06;
UINT8 data = m_joy1.read_safe(0x06) & 0x06;
// serial receive
data |= m_ikbd_tx << 3;
@ -653,7 +653,7 @@ READ8_MEMBER( st_state::ikbd_port4_r )
if (m_ikbd_joy) return 0xff;
UINT8 data = m_joy0 ? m_joy0->read() : 0xff;
UINT8 data = m_joy0.read_safe(0xff);
if ((m_config->read() & 0x01) == 0)
{
@ -1941,7 +1941,8 @@ void st_state::machine_start()
m_maincpu->space(AS_PROGRAM).install_read_handler(0xfa0000, 0xfbffff, read16_delegate(FUNC(generic_slot_device::read16_rom),(generic_slot_device*)m_cart));
// allocate timers
if(m_mousex) {
if (m_mousex.found())
{
m_mouse_timer = timer_alloc(TIMER_MOUSE_TICK);
m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(500));
}

View File

@ -86,14 +86,7 @@ public:
m_palette(*this, "palette"),
m_floppy0(*this, "fdc:0:525dd"),
m_floppy1(*this, "fdc:1:525dd"),
m_kb_row0(*this, "row0"),
m_kb_row1(*this, "row1"),
m_kb_row2(*this, "row2"),
m_kb_row3(*this, "row3"),
m_kb_row4(*this, "row4"),
m_kb_row5(*this, "row5"),
m_kb_row6(*this, "row6"),
m_kb_row7(*this, "row7"),
m_kb_rows(*this, {"row0", "row1", "row2", "row3", "row4", "row5", "row6", "row7"}),
m_kb_mod(*this, "modifiers"),
m_membank1(*this, "bank1"),
m_membank2(*this, "bank2"),
@ -183,14 +176,7 @@ private:
required_device<palette_device> m_palette;
required_device<floppy_image_device> m_floppy0;
required_device<floppy_image_device> m_floppy1;
required_ioport m_kb_row0;
required_ioport m_kb_row1;
required_ioport m_kb_row2;
required_ioport m_kb_row3;
required_ioport m_kb_row4;
required_ioport m_kb_row5;
required_ioport m_kb_row6;
required_ioport m_kb_row7;
required_ioport_array<8> m_kb_rows;
required_ioport m_kb_mod;
required_memory_bank m_membank1;
required_memory_bank m_membank2;
@ -370,13 +356,12 @@ WRITE8_MEMBER(attache_state::rom_w)
UINT16 attache_state::get_key()
{
UINT8 row,bits,data;
ioport_port* keys[8] = { m_kb_row0, m_kb_row1, m_kb_row2, m_kb_row3, m_kb_row4, m_kb_row5, m_kb_row6, m_kb_row7 };
UINT8 res = 0;
// scan input ports
for(row=0;row<8;row++)
{
data = keys[row]->read();
data = m_kb_rows[row]->read();
for(bits=0;bits<8;bits++)
{
if(BIT(data,bits))

View File

@ -659,14 +659,14 @@ INPUT_PORTS_END
INPUT_CHANGED_MEMBER(bbc_state::monitor_changed)
{
m_monitortype = read_safe(ioport("BBCCONFIG"), 0) &0x03;
m_monitortype = m_bbcconfig.read_safe(0) &0x03;
}
INPUT_CHANGED_MEMBER(bbc_state::speech_changed)
{
// Switchable during runtime as some games (Hyper Sports, Space Fighter) are not compatible with Speech
m_Speech = read_safe(ioport("BBCCONFIG"), 0) & 0x04;
m_Speech = m_bbcconfig.read_safe(0) & 0x04;
}

View File

@ -110,13 +110,12 @@
UINT8 sc4_state::read_input_matrix(int row)
{
ioport_port* portnames[16] = { m_io1, m_io2, m_io3, m_io4, m_io5, m_io6, m_io7, m_io8, m_io9, m_io10, m_io11, m_io12 };
UINT8 value;
if (row<4)
value = (read_safe(portnames[row], 0x00) & 0x1f) + ((read_safe(portnames[row+8], 0x00) & 0x07) << 5);
value = (m_io_ports[row].read_safe(0x00) & 0x1f) + ((m_io_ports[row+8].read_safe(0x00) & 0x07) << 5);
else
value = (read_safe(portnames[row], 0x00) & 0x1f) + ((read_safe(portnames[row+4], 0x00) & 0x18) << 2);
value = (m_io_ports[row].read_safe(0x00) & 0x1f) + ((m_io_ports[row+4].read_safe(0x00) & 0x18) << 2);
return value;
}

View File

@ -264,9 +264,9 @@ READ8_MEMBER(bwidow_state::spacduel_IN3_r)
int res2;
int res3;
res1 = ioport("IN3")->read();
res2 = ioport("IN4")->read();
res3 = read_safe(ioport("DSW2"), 0);
res1 = m_in3->read();
res2 = m_in4->read();
res3 = m_dsw2.read_safe(0);
res = 0x00;
switch (offset & 0x07)
@ -315,7 +315,7 @@ CUSTOM_INPUT_MEMBER(bwidow_state::clock_r)
READ8_MEMBER(bwidow_state::bwidowp_in_r)
{
return (ioport("IN4")->read() & 0x0f) | ((ioport("IN3")->read() & 0x0f) << 4);
return (m_in4->read() & 0x0f) | ((m_in3->read() & 0x0f) << 4);
}
/*************************************

View File

@ -143,35 +143,35 @@ INPUT_CHANGED_MEMBER(cdi_state::mcu_input)
switch((FPTR)param)
{
case 0x39:
if(m_input1 && m_input1->read() & 0x01) send = true;
if (m_input1.read_safe(0) & 0x01) send = true;
break;
case 0x37:
if(m_input1 && m_input1->read() & 0x02) send = true;
if (m_input1.read_safe(0) & 0x02) send = true;
break;
case 0x31:
if(m_input1 && m_input1->read() & 0x04) send = true;
if (m_input1.read_safe(0) & 0x04) send = true;
break;
case 0x32:
if(m_input1 && m_input1->read() & 0x08) send = true;
if (m_input1.read_safe(0) & 0x08) send = true;
break;
case 0x33:
if(m_input1 && m_input1->read() & 0x10) send = true;
if (m_input1.read_safe(0) & 0x10) send = true;
break;
case 0x30:
if(m_input2 && m_input2->read() & 0x01) send = true;
if (m_input2.read_safe(0) & 0x01) send = true;
break;
case 0x38:
if(m_input2 && m_input2->read() & 0x02) send = true;
if (m_input2.read_safe(0) & 0x02) send = true;
break;
case 0x34:
if(m_input2 && m_input2->read() & 0x04) send = true;
if (m_input2.read_safe(0) & 0x04) send = true;
break;
case 0x35:
if(m_input2 && m_input2->read() & 0x08) send = true;
if (m_input2.read_safe(0) & 0x08) send = true;
break;
case 0x36:
if(m_input2 && m_input2->read() & 0x10) send = true;
if (m_input2.read_safe(0) & 0x10) send = true;
break;
}

View File

@ -151,7 +151,7 @@ READ8_MEMBER(cinemat_state::joystick_read)
else
{
int const xval = INT16(m_maincpu->state_int(CCPU_X) << 4) >> 4;
return (read_safe(ioport(m_mux_select ? "ANALOGX" : "ANALOGY"), 0) - xval) < 0x800;
return ((m_mux_select ? m_analog_x : m_analog_y).read_safe(0) - xval) < 0x800;
}
}

View File

@ -504,12 +504,16 @@ protected:
private:
int m_coin_counter[2];
optional_ioport m_test_port;
optional_ioport_array<2> m_player_ports;
};
const device_type COBRA_JVS = &device_creator<cobra_jvs>;
cobra_jvs::cobra_jvs(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: jvs_device(mconfig, COBRA_JVS, "JVS (COBRA)", tag, owner, clock, "cobra_jvs", __FILE__)
: jvs_device(mconfig, COBRA_JVS, "JVS (COBRA)", tag, owner, clock, "cobra_jvs", __FILE__),
m_test_port(*this, ":TEST"),
m_player_ports(*this, {":P1", ":P2"})
{
m_coin_counter[0] = 0;
m_coin_counter[1] = 0;
@ -551,13 +555,11 @@ bool cobra_jvs::switches(UINT8 *&buf, UINT8 count_players, UINT8 bytes_per_switc
if (count_players > 2 || bytes_per_switch > 2)
return false;
static const char* player_ports[2] = { ":P1", ":P2" };
*buf++ = read_safe(ioport(":TEST"), 0);
*buf++ = m_test_port.read_safe(0);
for (int i=0; i < count_players; i++)
{
UINT32 pval = read_safe(ioport(player_ports[i]), 0);
UINT32 pval = m_player_ports[i].read_safe(0);
for (int j=0; j < bytes_per_switch; j++)
{
*buf++ = (UINT8)(pval >> ((1-j) * 8));

View File

@ -231,18 +231,18 @@ READ8_MEMBER( coleco_state::cart_r )
UINT8 coleco_state::coleco_scan_paddles(UINT8 *joy_status0, UINT8 *joy_status1)
{
UINT8 ctrl_sel = (m_ctrlsel != nullptr) ? m_ctrlsel->read() : 0;
UINT8 ctrl_sel = m_ctrlsel.read_safe(0);
/* which controller shall we read? */
if ((ctrl_sel & 0x07) == 0x02) // Super Action Controller P1
*joy_status0 = (m_sac_slide1 != nullptr) ? m_sac_slide1->read() : 0;
*joy_status0 = m_sac_slide1.read_safe(0);
else if ((ctrl_sel & 0x07) == 0x03) // Driving Controller P1
*joy_status0 = (m_driv_wheel1 != nullptr) ? m_driv_wheel1->read() : 0;
*joy_status0 = m_driv_wheel1.read_safe(0);
if ((ctrl_sel & 0x70) == 0x20) // Super Action Controller P2
*joy_status1 = (m_sac_slide2 != nullptr) ? m_sac_slide2->read() : 0;
*joy_status1 = m_sac_slide2.read_safe(0);
else if ((ctrl_sel & 0x70) == 0x30) // Driving Controller P2
*joy_status1 = (m_driv_wheel2 != nullptr) ? m_driv_wheel2->read() : 0;
*joy_status1 = m_driv_wheel2.read_safe(0);
/* In principle, even if not supported by any game, I guess we could have two Super
Action Controllers plugged into the Roller controller ports. Since I found no info
@ -250,8 +250,8 @@ UINT8 coleco_state::coleco_scan_paddles(UINT8 *joy_status0, UINT8 *joy_status1)
the Roller trackball inputs and actually use the latter ones, when both are selected. */
if (ctrl_sel & 0x80) // Roller controller
{
*joy_status0 = (m_roller_x != nullptr) ? m_roller_x->read() : 0;
*joy_status1 = (m_roller_y != nullptr) ? m_roller_y->read() : 0;
*joy_status0 = m_roller_x.read_safe(0);
*joy_status1 = m_roller_y.read_safe(0);
}
return *joy_status0 | *joy_status1;
@ -260,7 +260,7 @@ UINT8 coleco_state::coleco_scan_paddles(UINT8 *joy_status0, UINT8 *joy_status1)
UINT8 coleco_state::coleco_paddle_read(int port, int joy_mode, UINT8 joy_status)
{
UINT8 ctrl_sel = (m_ctrlsel != nullptr ) ? m_ctrlsel->read() : 0;
UINT8 ctrl_sel = m_ctrlsel.read_safe(0);
UINT8 ctrl_extra = ctrl_sel & 0x80;
ctrl_sel = ctrl_sel >> (port*4) & 7;

View File

@ -268,13 +268,12 @@ READ8_MEMBER(combatsc_state::trackball_r)
if (offset == 0)
{
int i, dir[4];
static const char *const tracknames[] = { "TRACK0_Y", "TRACK0_X", "TRACK1_Y", "TRACK1_X" };
for (i = 0; i < 4; i++)
{
UINT8 curr;
curr = read_safe(ioport(tracknames[i]), 0xff);
curr = m_track_ports[i].read_safe(0xff);
dir[i] = curr - m_pos[i];
m_sign[i] = dir[i] & 0x80;

View File

@ -324,12 +324,12 @@ READ8_MEMBER(cosmic_state::cosmica_pixel_clock_r)
READ8_MEMBER(cosmic_state::cosmicg_port_0_r)
{
/* The top four address lines from the CRTC are bits 0-3 */
return (ioport("IN0")->read() & 0xf0) | ((m_screen->vpos() & 0xf0) >> 4);
return (m_in_ports[0]->read() & 0xf0) | ((m_screen->vpos() & 0xf0) >> 4);
}
READ8_MEMBER(cosmic_state::magspot_coinage_dip_r)
{
return (read_safe(ioport("DSW"), 0) & (1 << (7 - offset))) ? 0 : 1;
return (m_dsw.read_safe(0) & (1 << (7 - offset))) ? 0 : 1;
}
@ -337,8 +337,8 @@ READ8_MEMBER(cosmic_state::magspot_coinage_dip_r)
READ8_MEMBER(cosmic_state::nomnlnd_port_0_1_r)
{
int control = ioport(offset ? "IN1" : "IN0")->read();
int fire = ioport("IN3")->read();
int control = m_in_ports[offset]->read();
int fire = m_in_ports[3]->read();
/* If firing - stop tank */
if ((fire & 0xc0) == 0) return 0xff;

View File

@ -456,12 +456,6 @@ void cosmicos_state::machine_start()
/* initialize LED display */
m_led->rbi_w(1);
// find keyboard rows
m_key_row[0] = m_y1;
m_key_row[1] = m_y2;
m_key_row[2] = m_y3;
m_key_row[3] = m_y4;
/* register for state saving */
save_item(NAME(m_wait));
save_item(NAME(m_clear));

View File

@ -28,11 +28,7 @@ public:
m_i8155(*this, "i8155"),
m_i8155_cp3(*this, "i8155_cp3"),
m_cassette(*this, "cassette"),
m_io_line0(*this, "LINE0"),
m_io_line1(*this, "LINE1"),
m_io_line2(*this, "LINE2"),
m_io_line3(*this, "LINE3"),
m_io_line4(*this, "LINE4"),
m_io_lines(*this, {"LINE0", "LINE1", "LINE2", "LINE3", "LINE4"}),
m_io_config(*this, "CONFIG")
{ }
@ -40,11 +36,7 @@ public:
required_device<i8155_device> m_i8155;
required_device<i8155_device> m_i8155_cp3;
required_device<cassette_image_device> m_cassette;
required_ioport m_io_line0;
required_ioport m_io_line1;
required_ioport m_io_line2;
required_ioport m_io_line3;
required_ioport m_io_line4;
required_ioport_array<5> m_io_lines;
required_ioport m_io_config;
virtual void machine_reset() override;
@ -99,12 +91,11 @@ READ8_MEMBER(cp1_state::port2_r)
// ---x ---- I8155 CE
// ---- xxxx keyboard input
ioport_port* portnames[] = { m_io_line0, m_io_line1, m_io_line2, m_io_line3, m_io_line4 };
UINT8 data = 0;
for(int i=0; i<5; i++)
if (!(m_matrix & (1<<i)))
data |= portnames[i]->read();
data |= m_io_lines[i]->read();
return (data & 0x0f) | (m_port2 & 0xf0);
}

View File

@ -326,12 +326,14 @@ class cubo_state : public amiga_state
public:
cubo_state(const machine_config &mconfig, device_type type, const char *tag) :
amiga_state(mconfig, type, tag),
m_p1_port(*this, "P1"),
m_p2_port(*this, "P2"),
m_player_ports(*this, {"P1", "P2"}),
m_microtouch(*this, "microtouch"),
m_cdda(*this, "cdda")
{ }
void handle_joystick_cia(UINT8 pra, UINT8 dra);
UINT16 handle_joystick_potgor(UINT16 potgor);
DECLARE_CUSTOM_INPUT_MEMBER(cubo_input);
DECLARE_CUSTOM_INPUT_MEMBER(cd32_sel_mirror_input);
@ -347,8 +349,7 @@ public:
DECLARE_DRIVER_INIT(lasstixx);
DECLARE_DRIVER_INIT(lsrquiz);
optional_ioport m_p1_port;
optional_ioport m_p2_port;
optional_ioport_array<2> m_player_ports;
int m_oldstate[2];
int m_cd32_shifter[2];
@ -374,8 +375,6 @@ private:
void mgprem11_input_hack();
};
static void handle_cd32_joystick_cia(running_machine &machine, UINT8 pra, UINT8 dra);
/*************************************
*
@ -401,7 +400,7 @@ WRITE8_MEMBER( cubo_state::akiko_cia_0_port_a_write )
/* bit 2 = Power Led on Amiga */
output().set_led_value(0, (data & 2) ? 0 : 1);
handle_cd32_joystick_cia(machine(), data, m_cia_0->read(space, 2));
handle_joystick_cia(data, m_cia_0->read(space, 2));
}
@ -466,40 +465,33 @@ void cubo_state::potgo_w(UINT16 data)
}
}
static void handle_cd32_joystick_cia(running_machine &machine, UINT8 pra, UINT8 dra)
void cubo_state::handle_joystick_cia(UINT8 pra, UINT8 dra)
{
cubo_state *state = machine.driver_data<cubo_state>();
int i;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
UINT8 but = 0x40 << i;
UINT16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
UINT16 p5dat = 0x0100 << (i * 4); /* data P5 */
if (!(state->m_potgo_value & p5dir) || !(state->m_potgo_value & p5dat))
if (!(m_potgo_value & p5dir) || !(m_potgo_value & p5dat))
{
if ((dra & but) && (pra & but) != state->m_oldstate[i])
if ((dra & but) && (pra & but) != m_oldstate[i])
{
if (!(pra & but))
{
state->m_cd32_shifter[i]--;
if (state->m_cd32_shifter[i] < 0)
state->m_cd32_shifter[i] = 0;
m_cd32_shifter[i]--;
if (m_cd32_shifter[i] < 0)
m_cd32_shifter[i] = 0;
}
}
}
state->m_oldstate[i] = pra & but;
m_oldstate[i] = pra & but;
}
}
static UINT16 handle_joystick_potgor(running_machine &machine, UINT16 potgor)
UINT16 cubo_state::handle_joystick_potgor(UINT16 potgor)
{
cubo_state *state = machine.driver_data<cubo_state>();
ioport_port * player_portname[] = { state->m_p2_port, state->m_p1_port };
int i;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
UINT16 p9dir = 0x0800 << (i * 4); /* output enable P9 */
UINT16 p9dat = 0x0400 << (i * 4); /* data P9 */
@ -508,16 +500,16 @@ static UINT16 handle_joystick_potgor(running_machine &machine, UINT16 potgor)
/* p5 is floating in input-mode */
potgor &= ~p5dat;
potgor |= state->m_potgo_value & p5dat;
if (!(state->m_potgo_value & p9dir))
potgor |= m_potgo_value & p5dat;
if (!(m_potgo_value & p9dir))
potgor |= p9dat;
/* P5 output and 1 -> shift register is kept reset (Blue button) */
if ((state->m_potgo_value & p5dir) && (state->m_potgo_value & p5dat))
state->m_cd32_shifter[i] = 8;
if ((m_potgo_value & p5dir) && (m_potgo_value & p5dat))
m_cd32_shifter[i] = 8;
/* shift at 1 == return one, >1 = return button states */
if (state->m_cd32_shifter[i] == 0)
if (m_cd32_shifter[i] == 0)
potgor &= ~p9dat; /* shift at zero == return zero */
if (state->m_cd32_shifter[i] >= 2 && ((player_portname[i])->read() & (1 << (state->m_cd32_shifter[i] - 2))))
if (m_cd32_shifter[i] >= 2 && ((m_player_ports[1 - i])->read() & (1 << (m_cd32_shifter[i] - 2))))
potgor &= ~p9dat;
}
return potgor;
@ -525,13 +517,12 @@ static UINT16 handle_joystick_potgor(running_machine &machine, UINT16 potgor)
CUSTOM_INPUT_MEMBER( cubo_state::cubo_input )
{
return handle_joystick_potgor(machine(), m_potgo_value) >> 8;
return handle_joystick_potgor(m_potgo_value) >> 8;
}
CUSTOM_INPUT_MEMBER( cubo_state::cd32_sel_mirror_input )
{
ioport_port* ports[2]= { m_p1_port, m_p2_port };
UINT8 bits = ports[(int)(FPTR)param]->read();
UINT8 bits = m_player_ports[(int)(FPTR)param]->read();
return (bits & 0x20)>>5;
}

View File

@ -224,14 +224,13 @@ READ8_MEMBER(djmain_state::inp2_r)
READ32_MEMBER(djmain_state::turntable_r)
{
UINT32 result = 0;
static const char *const ttnames[] = { "TT1", "TT2" };
if (ACCESSING_BITS_8_15)
{
UINT8 pos;
int delta;
pos = read_safe(ioport(ttnames[m_turntable_select]), 0);
pos = m_turntable[m_turntable_select].read_safe(0);
delta = pos - m_turntable_last_pos[m_turntable_select];
if (delta < -128)
delta += 256;

View File

@ -40,7 +40,7 @@ public:
m_i8251(*this, "i8251"),
m_i8255(*this, "ppi8255"),
m_centronics(*this, "centronics"),
m_io_line8(*this, "LINE8"),
m_io_ports(*this, {"LINE7", "LINE6", "LINE5", "LINE4", "LINE3", "LINE2", "LINE1", "LINE0", "LINE8"}),
m_io_line9(*this, "LINE9"),
m_io_network_id(*this, "NETWORK ID")
{
@ -68,7 +68,7 @@ protected:
required_device<i8251_device> m_i8251;
required_device<i8255_device> m_i8255;
required_device<centronics_device> m_centronics;
required_ioport m_io_line8;
required_ioport_array<9> m_io_ports;
required_ioport m_io_line9;
required_ioport m_io_network_id;
@ -234,7 +234,6 @@ READ8_MEMBER(elwro800_state::elwro800jr_io_r)
int mask = 0x8000;
int data = 0xff;
int i;
ioport_port *io_ports[9] = { m_io_line7, m_io_line6, m_io_line5, m_io_line4, m_io_line3, m_io_line2, m_io_line1, m_io_line0, m_io_line8 };
if ( !m_NR )
{
@ -242,7 +241,7 @@ READ8_MEMBER(elwro800_state::elwro800jr_io_r)
{
if (!(offset & mask))
{
data &= io_ports[i]->read();
data &= m_io_ports[i]->read();
}
}

View File

@ -743,7 +743,7 @@ WRITE8_MEMBER(fidel6502_state::fexcel_ttl_w)
READ8_MEMBER(fidel6502_state::fexcel_ttl_r)
{
// a0-a2,d6: from speech board: language switches and TSI BUSY line, otherwise tied to VCC
UINT8 d6 = (read_safe(m_inp_matrix[9], 0xff) >> offset & 1) ? 0x40 : 0;
UINT8 d6 = (m_inp_matrix[9].read_safe(0xff) >> offset & 1) ? 0x40 : 0;
// a0-a2,d7: multiplexed inputs (active low)
return d6 | ((read_inputs(9) >> offset & 1) ? 0 : 0x80);

View File

@ -155,8 +155,8 @@ void firetrk_state::machine_reset()
READ8_MEMBER(firetrk_state::firetrk_dip_r)
{
UINT8 val0 = ioport("DIP_0")->read();
UINT8 val1 = ioport("DIP_1")->read();
UINT8 val0 = m_dips[0]->read();
UINT8 val1 = m_dips[1]->read();
if (val1 & (1 << (2 * offset + 0))) val0 |= 1;
if (val1 & (1 << (2 * offset + 1))) val0 |= 2;
@ -167,8 +167,8 @@ READ8_MEMBER(firetrk_state::firetrk_dip_r)
READ8_MEMBER(firetrk_state::montecar_dip_r)
{
UINT8 val0 = ioport("DIP_0")->read();
UINT8 val1 = ioport("DIP_1")->read();
UINT8 val0 = m_dips[0]->read();
UINT8 val1 = m_dips[1]->read();
if (val1 & (1 << (3 - offset))) val0 |= 1;
if (val1 & (1 << (7 - offset))) val0 |= 2;
@ -230,7 +230,7 @@ READ8_MEMBER(firetrk_state::firetrk_input_r)
/* update steering wheels */
for (i = 0; i < 2; i++)
{
UINT32 const new_dial = read_safe(ioport(i ? "STEER_2" : "STEER_1"), 0);
UINT32 const new_dial = m_steer[i].read_safe(0);
INT32 const delta = new_dial - m_dial[i];
if (delta != 0)
@ -242,9 +242,9 @@ READ8_MEMBER(firetrk_state::firetrk_input_r)
}
}
return ((read_safe(ioport("BIT_0"), 0) & (1 << offset)) ? 0x01 : 0) |
((read_safe(ioport("BIT_6"), 0) & (1 << offset)) ? 0x40 : 0) |
((read_safe(ioport("BIT_7"), 0) & (1 << offset)) ? 0x80 : 0);
return ((m_bit_0.read_safe(0) & (1 << offset)) ? 0x01 : 0) |
((m_bit_6.read_safe(0) & (1 << offset)) ? 0x40 : 0) |
((m_bit_7.read_safe(0) & (1 << offset)) ? 0x80 : 0);
}

View File

@ -1288,7 +1288,6 @@ void fm7_state::key_press(UINT16 scancode)
void fm7_state::fm7_keyboard_poll_scan()
{
ioport_port* portnames[3] = { m_key1, m_key2, m_key3 };
int bit = 0;
int x,y;
UINT32 keys;
@ -1297,7 +1296,7 @@ void fm7_state::fm7_keyboard_poll_scan()
for(x=0;x<3;x++)
{
keys = portnames[x]->read();
keys = m_kb_ports[x]->read();
for(y=0;y<32;y++) // loop through each bit in the port
{
@ -1333,14 +1332,13 @@ void fm7_state::fm7_keyboard_poll_scan()
TIMER_CALLBACK_MEMBER(fm7_state::fm7_keyboard_poll)
{
ioport_port* portnames[3] = { m_key1, m_key2, m_key3 };
int x,y;
int bit = 0;
int mod = 0;
UINT32 keys;
UINT32 modifiers = m_keymod->read();
if(m_key3->read() & 0x40000)
if (m_kb_ports[2]->read() & 0x40000)
{
m_break_flag = 1;
m_maincpu->set_input_line(M6809_FIRQ_LINE,ASSERT_LINE);
@ -1369,7 +1367,7 @@ TIMER_CALLBACK_MEMBER(fm7_state::fm7_keyboard_poll)
for(x=0;x<3;x++)
{
keys = portnames[x]->read();
keys = m_kb_ports[x]->read();
for(y=0;y<32;y++) // loop through each bit in the port
{

View File

@ -661,21 +661,21 @@ void towns_state::kb_sendcode(UINT8 scancode, int release)
case 0: // key press
m_towns_kb_output = 0x80;
m_towns_kb_extend = scancode & 0x7f;
if(m_key3->read() & 0x00080000)
if (m_kb_ports[2]->read() & 0x00080000)
m_towns_kb_output |= 0x04;
if(m_key3->read() & 0x00040000)
if (m_kb_ports[2]->read() & 0x00040000)
m_towns_kb_output |= 0x08;
if(m_key3->read() & 0x06400000)
if (m_kb_ports[2]->read() & 0x06400000)
m_towns_kb_output |= 0x20;
break;
case 1: // key release
m_towns_kb_output = 0x90;
m_towns_kb_extend = scancode & 0x7f;
if(m_key3->read() & 0x00080000)
if (m_kb_ports[2]->read() & 0x00080000)
m_towns_kb_output |= 0x04;
if(m_key3->read() & 0x00040000)
if (m_kb_ports[2]->read() & 0x00040000)
m_towns_kb_output |= 0x08;
if(m_key3->read() & 0x06400000)
if (m_kb_ports[2]->read() & 0x06400000)
m_towns_kb_output |= 0x20;
break;
case 2: // extended byte
@ -694,7 +694,6 @@ void towns_state::kb_sendcode(UINT8 scancode, int release)
void towns_state::poll_keyboard()
{
ioport_port* kb_ports[4] = { m_key1, m_key2, m_key3, m_key4 };
int port,bit;
UINT8 scan;
UINT32 portval;
@ -702,7 +701,7 @@ void towns_state::poll_keyboard()
scan = 0;
for(port=0;port<4;port++)
{
portval = kb_ports[port]->read();
portval = m_kb_ports[port]->read();
for(bit=0;bit<32;bit++)
{
if(((portval & (1<<bit))) != ((m_kb_prev[port] & (1<<bit))))

View File

@ -430,10 +430,10 @@ WRITE16_MEMBER(gaelco3d_state::analog_port_latch_w)
{
if (!(data & 0xff))
{
m_analog_ports[0] = read_safe(ioport("ANALOG0"), 0);
m_analog_ports[1] = read_safe(ioport("ANALOG1"), 0);
m_analog_ports[2] = read_safe(ioport("ANALOG2"), 0);
m_analog_ports[3] = read_safe(ioport("ANALOG3"), 0);
m_analog_ports[0] = m_analog[0].read_safe(0);
m_analog_ports[1] = m_analog[1].read_safe(0);
m_analog_ports[2] = m_analog[2].read_safe(0);
m_analog_ports[3] = m_analog[3].read_safe(0);
}
}
else

View File

@ -687,7 +687,7 @@ INTERRUPT_GEN_MEMBER(galaxian_state::fakechange_interrupt_gen)
{
interrupt_gen(device);
if (read_safe(ioport("FAKE_SELECT"), 0x00))
if (m_fake_select.read_safe(0x00))
{
m_tenspot_current_game++;
m_tenspot_current_game%=10;
@ -6589,9 +6589,10 @@ DRIVER_INIT_MEMBER(galaxian_state,pacmanbl)
READ8_MEMBER(galaxian_state::tenspot_dsw_read)
{
char tmp[64];
sprintf(tmp,"IN2_GAME%d", m_tenspot_current_game);
return read_safe(ioport(tmp), 0x00);
if (m_tenspot_current_game >= 0 && m_tenspot_current_game < 10)
return m_tenspot_game_dsw[m_tenspot_current_game]->read();
else
return 0x00;
}

View File

@ -32,11 +32,10 @@ todo:
READ8_MEMBER(gomoku_state::input_port_r)
{
int i, res;
static const char *const portnames[] = { "IN0", "IN1", "DSW", "UNUSED0", "UNUSED1", "UNUSED2", "UNUSED3", "UNUSED4" };
res = 0;
for (i = 0; i < 8; i++)
res |= ((read_safe(ioport(portnames[i]), 0xff) >> offset) & 1) << i;
res |= ((m_inputs[i].read_safe(0xff) >> offset) & 1) << i;
return res;
}

View File

@ -284,8 +284,8 @@ CUSTOM_INPUT_MEMBER(gottlieb_state::analog_delta_r)
WRITE8_MEMBER(gottlieb_state::gottlieb_analog_reset_w)
{
/* reset the trackball counters */
m_track[0] = read_safe(ioport("TRACKX"), 0);
m_track[1] = read_safe(ioport("TRACKY"), 0);
m_track[0] = m_track_x.read_safe(0);
m_track[1] = m_track_y.read_safe(0);
}

View File

@ -995,8 +995,8 @@ ADC12138_IPT_CONVERT_CB(hornet_state::adc12138_input_callback)
int value = 0;
switch (input)
{
case 0: value = (m_analog1) ? m_analog1->read() : 0; break;
case 1: value = (m_analog2) ? m_analog2->read() : 0; break;
case 0: value = m_analog1.read_safe(0); break;
case 1: value = m_analog2.read_safe(0); break;
}
return (double)(value) / 2047.0;

View File

@ -278,24 +278,6 @@ static const z80_daisy_config amu880_daisy_chain[] =
void amu880_state::machine_start()
{
// find keyboard rows
m_key_row[0] = m_y0;
m_key_row[1] = m_y1;
m_key_row[2] = m_y2;
m_key_row[3] = m_y3;
m_key_row[4] = m_y4;
m_key_row[5] = m_y5;
m_key_row[6] = m_y6;
m_key_row[7] = m_y7;
m_key_row[8] = m_y8;
m_key_row[9] = m_y9;
m_key_row[10] = m_y10;
m_key_row[11] = m_y11;
m_key_row[12] = m_y12;
m_key_row[13] = m_y13;
m_key_row[14] = m_y14;
m_key_row[15] = m_y15;
/* register for state saving */
save_item(NAME(m_key_d6));
save_item(NAME(m_key_d7));

View File

@ -87,7 +87,7 @@ Address Dir Data Description
READ8_MEMBER(jackal_state::jackalr_rotary_r)
{
return (1 << read_safe(ioport(offset ? "DIAL1" : "DIAL0"), 0x00)) ^ 0xff;
return (1 << m_dials[offset].read_safe(0x00)) ^ 0xff;
}
WRITE8_MEMBER(jackal_state::jackal_flipscreen_w)

View File

@ -136,8 +136,7 @@ WRITE8_MEMBER(laserbat_state_base::ct_io_w)
READ8_MEMBER(laserbat_state_base::rrowx_r)
{
ioport_port *const mux_ports[] = { m_row0, m_row1, m_sw1, m_sw2 };
return (m_mpx_p_1_2 ? m_row2 : mux_ports[m_input_mux])->read();
return (m_mpx_p_1_2 ? m_row2 : m_mux_ports[m_input_mux])->read();
}
/*

View File

@ -136,7 +136,7 @@ WRITE32_MEMBER( mac_state::rbv_ramdac_w )
if (m_model != MODEL_MAC_CLASSIC_II)
{
// Color Classic has no MONTYPE so the default gets us 512x384, which is right
if ((m_montype ? m_montype->read() : 2) == 1)
if (m_montype.read_safe(2) == 1)
{
m_palette->set_pen_color(m_rbv_clutoffs, rgb_t(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2]));
m_rbv_palette[m_rbv_clutoffs] = rgb_t(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2]);
@ -172,7 +172,7 @@ WRITE32_MEMBER( mac_state::ariel_ramdac_w ) // this is for the "Ariel" style RAM
if (m_model != MODEL_MAC_CLASSIC_II)
{
// Color Classic has no MONTYPE so the default gets us 512x384, which is right
if ((m_montype ? m_montype->read() : 2) == 1)
if (m_montype.read_safe(2) == 1)
{
m_palette->set_pen_color(m_rbv_clutoffs, rgb_t(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2]));
m_rbv_palette[m_rbv_clutoffs] = rgb_t(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2]);
@ -204,7 +204,7 @@ READ8_MEMBER( mac_state::mac_sonora_vctl_r )
if (offset == 2)
{
// printf("Sonora: read monitor ID at PC=%x\n", m_maincpu->pc());
return ((m_montype ? m_montype->read() : 6)<<4);
return (m_montype.read_safe(6)<<4);
}
return m_sonora_vctl[offset];
@ -260,7 +260,7 @@ READ8_MEMBER ( mac_state::mac_rbv_r )
if (offset == 0x10)
{
data &= ~0x38;
data |= ((m_montype ? m_montype->read() : 2)<<3);
data |= (m_montype.read_safe(2)<<3);
// printf("rbv_r montype: %02x (PC %x)\n", data, space.cpu->safe_pc());
}

View File

@ -389,12 +389,12 @@ INPUT_PORTS_END
READ8_MEMBER(maxaflex_state::pia_pa_r)
{
return atari_input_disabled() ? 0xff : read_safe(m_joy01, 0);
return atari_input_disabled() ? 0xff : m_joy01.read_safe(0);
}
READ8_MEMBER(maxaflex_state::pia_pb_r)
{
return atari_input_disabled() ? 0xff : read_safe(m_joy23, 0);
return atari_input_disabled() ? 0xff : m_joy23.read_safe(0);
}

View File

@ -559,8 +559,7 @@ WRITE8_MEMBER( maygay1b_state::lamp_data_w )
READ8_MEMBER( maygay1b_state::kbd_r )
{
ioport_port * portnames[] = { m_sw1_port, m_s2_port, m_s3_port, m_s4_port, m_s5_port, m_s6_port, m_s7_port, m_sw2_port};
return (portnames[m_lamp_strobe&0x07])->read();
return (m_kbd_ports[m_lamp_strobe&0x07])->read();
}
WRITE8_MEMBER( maygay1b_state::lamp_data_2_w )

View File

@ -95,7 +95,9 @@ public:
m_vram(*this, "vram"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_palette(*this, "palette") { }
m_palette(*this, "palette"),
m_ports(*this, {"IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7", "IN8"})
{ }
required_device<ide_controller_32_device> m_ide;
required_shared_ptr<UINT32> m_main_ram;
@ -107,6 +109,7 @@ public:
required_device<palette_device> m_palette;
UINT8 m_pal[768];
optional_ioport_array<9> m_ports; // but parallel_pointer takes values 0 -> 23
UINT32 m_disp_ctrl_reg[256/4];
int m_frame_width;
@ -515,25 +518,24 @@ WRITE8_MEMBER(mediagx_state::io20_w)
READ32_MEMBER(mediagx_state::parallel_port_r)
{
UINT32 r = 0;
//static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7", "IN8" }; // but parallel_pointer takes values 0 -> 23
if (ACCESSING_BITS_8_15)
{
UINT8 nibble = m_parallel_latched;//(read_safe(ioport(m_portnames[m_parallel_pointer / 3]), 0) >> (4 * (m_parallel_pointer % 3))) & 15;
UINT8 nibble = m_parallel_latched;
r |= ((~nibble & 0x08) << 12) | ((nibble & 0x07) << 11);
logerror("%08X:parallel_port_r()\n", space.device().safe_pc());
#if 0
if (m_controls_data == 0x18)
{
r |= ioport("IN0")->read() << 8;
r |= m_ports[0]->read() << 8;
}
else if (m_controls_data == 0x60)
{
r |= ioport("IN1")->read() << 8;
r |= m_ports[1]->read() << 8;
}
else if (m_controls_data == 0xff || m_controls_data == 0x50)
{
r |= ioport("IN2")->read() << 8;
r |= m_ports[2]->read() << 8;
}
//r |= m_control_read << 8;
@ -549,8 +551,6 @@ READ32_MEMBER(mediagx_state::parallel_port_r)
WRITE32_MEMBER(mediagx_state::parallel_port_w)
{
static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7", "IN8" }; // but parallel_pointer takes values 0 -> 23
COMBINE_DATA( &m_parport );
if (ACCESSING_BITS_0_7)
@ -572,7 +572,7 @@ WRITE32_MEMBER(mediagx_state::parallel_port_w)
logerror("%08X:", space.device().safe_pc());
m_parallel_latched = (read_safe(ioport(portnames[m_parallel_pointer / 3]), 0) >> (4 * (m_parallel_pointer % 3))) & 15;
m_parallel_latched = (m_ports[m_parallel_pointer / 3].read_safe(0) >> (4 * (m_parallel_pointer % 3))) & 15;
//parallel_pointer++;
//logerror("[%02X] Advance pointer to %d\n", data, parallel_pointer);
switch (data & 0xfc)

View File

@ -356,7 +356,7 @@ MACHINE_RESET_MEMBER(md_cons_state, ms_megadriv)
// same as screen_eof_megadriv but with addition of 32x and SegaCD/MegaCD pieces
void md_cons_state::screen_eof_console(screen_device &screen, bool state)
{
if (m_io_reset && (m_io_reset->read() & 0x01))
if (m_io_reset.read_safe(0) & 0x01)
m_maincpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
// rising edge

View File

@ -303,6 +303,30 @@ static ADDRESS_MAP_START( megasys1B_map, AS_PROGRAM, 16, megasys1_state )
AM_RANGE(0x0e0000, 0x0e0001) AM_READWRITE(ip_select_r,ip_select_w)
ADDRESS_MAP_END
static ADDRESS_MAP_START( megasys1B_edfbl_map, AS_PROGRAM, 16, megasys1_state )
ADDRESS_MAP_GLOBAL_MASK(0xfffff)
AM_RANGE(0xe00002, 0x0e0003) AM_READ_PORT("SYSTEM")
AM_RANGE(0xe00004, 0x0e0005) AM_READ_PORT("P1")
AM_RANGE(0xe00006, 0x0e0007) AM_READ_PORT("P2")
AM_RANGE(0xe00008, 0x0e0009) AM_READ_PORT("DSW1")
AM_RANGE(0xe0000a, 0x0e000b) AM_READ_PORT("DSW2")
AM_IMPORT_FROM(megasys1B_map)
ADDRESS_MAP_END
static ADDRESS_MAP_START( megasys1B_monkelf_map, AS_PROGRAM, 16, megasys1_state )
ADDRESS_MAP_GLOBAL_MASK(0xfffff)
ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x044000, 0x0443ff) AM_WRITE(megasys1_vregs_monkelf_w)
AM_RANGE(0xe00002, 0x0e0003) AM_READ_PORT("P1")
AM_RANGE(0xe00004, 0x0e0005) AM_READ_PORT("P2")
AM_RANGE(0xe00006, 0x0e0007) AM_READ_PORT("DSW1")
AM_RANGE(0xe00008, 0x0e0009) AM_READ_PORT("DSW2")
AM_RANGE(0xe0000a, 0x0e000b) AM_READ_PORT("SYSTEM")
AM_IMPORT_FROM(megasys1B_map)
ADDRESS_MAP_END
/***************************************************************************
[ Main CPU - System C ]
@ -1626,11 +1650,16 @@ static MACHINE_CONFIG_DERIVED( system_B, system_A )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( system_B_monkelf, system_B )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(megasys1B_monkelf_map)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( system_Bbl, megasys1_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, SYS_B_CPU_CLOCK)
MCFG_CPU_PROGRAM_MAP(megasys1B_map)
MCFG_CPU_PROGRAM_MAP(megasys1B_edfbl_map)
MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", megasys1_state, megasys1B_scanline, "screen", 0, 1)
MCFG_MACHINE_RESET_OVERRIDE(megasys1_state,megasys1)
@ -4250,30 +4279,6 @@ DRIVER_INIT_MEMBER(megasys1_state,edfp)
phantasm_rom_decode(machine(), "maincpu");
}
READ16_MEMBER(megasys1_state::edfbl_input_r)
{
ioport_port *in_names[] = { m_io_system, m_io_p1, m_io_p2, m_io_dsw1, m_io_dsw2 };
UINT16 res;
res = 0;
switch(offset)
{
case 0x02/2:
case 0x04/2:
case 0x06/2:
case 0x08/2:
case 0x0a/2: res = in_names[offset-1]->read(); break;
}
return res;
}
DRIVER_INIT_MEMBER(megasys1_state,edfbl)
{
m_maincpu->space(AS_PROGRAM).install_read_handler(0xe0000, 0xe000f, read16_delegate(FUNC(megasys1_state::edfbl_input_r),this));
}
DRIVER_INIT_MEMBER(megasys1_state,hayaosi1)
{
m_ip_select_values[0] = 0x51;
@ -4473,34 +4478,12 @@ DRIVER_INIT_MEMBER(megasys1_state,stdragonb)
stdragona_gfx_unmangle("gfx4");
}
READ16_MEMBER(megasys1_state::monkelf_input_r)
{
ioport_port *in_names[] = { m_io_p1, m_io_p2, m_io_dsw1, m_io_dsw2, m_io_system };
UINT16 res;
res = 0xffff;
switch(offset)
{
case 0x02/2:
case 0x04/2:
case 0x06/2:
case 0x08/2:
case 0x0a/2: res = in_names[offset-1]->read(); break;
}
return res;
}
DRIVER_INIT_MEMBER(megasys1_state,monkelf)
{
DRIVER_INIT_CALL(avspirit);
m_rom_maincpu[0x00744/2] = 0x4e71; // weird check, 0xe000e R is a port-based trap?
m_maincpu->space(AS_PROGRAM).install_read_handler(0xe0000, 0xe000f, read16_delegate(FUNC(megasys1_state::monkelf_input_r),this));
m_maincpu->space(AS_PROGRAM).install_write_handler(0x44000, 0x443ff, write16_delegate(FUNC(megasys1_state::megasys1_vregs_monkelf_w),this));
// convert bootleg priority format to standard
{
int i;
@ -4552,11 +4535,11 @@ GAME( 1992, soldamj, soldam, system_A, soldam, megasys1_state, sol
// Type B
GAME( 1991, avspirit, 0, system_B, avspirit, megasys1_state, avspirit, ROT0, "Jaleco", "Avenging Spirit", 0 )
GAME( 1990, monkelf, avspirit, system_B, avspirit, megasys1_state, monkelf, ROT0, "bootleg","Monky Elf (Korean bootleg of Avenging Spirit)", 0 )
GAME( 1990, monkelf, avspirit, system_B_monkelf, avspirit, megasys1_state, monkelf, ROT0, "bootleg","Monky Elf (Korean bootleg of Avenging Spirit)", 0 )
GAME( 1991, edf, 0, system_B, edf, megasys1_state, edf, ROT0, "Jaleco", "E.D.F. : Earth Defense Force (set 1)", 0 )
GAME( 1991, edfa, edf, system_B, edf, megasys1_state, edf, ROT0, "Jaleco", "E.D.F. : Earth Defense Force (set 2)", 0 )
GAME( 1991, edfu, edf, system_B, edf, megasys1_state, edf, ROT0, "Jaleco", "E.D.F. : Earth Defense Force (North America)", 0 )
GAME( 1991, edfbl, edf, system_Bbl, edf, megasys1_state, edfbl, ROT0, "bootleg","E.D.F. : Earth Defense Force (bootleg)", MACHINE_NO_SOUND )
GAME( 1991, edfbl, edf, system_Bbl, edf, driver_device, 0, ROT0, "bootleg","E.D.F. : Earth Defense Force (bootleg)", MACHINE_NO_SOUND )
GAME( 1993, hayaosi1, 0, system_B_hayaosi1, hayaosi1, megasys1_state, hayaosi1, ROT0, "Jaleco", "Hayaoshi Quiz Ouza Ketteisen - The King Of Quiz", MACHINE_IMPERFECT_GRAPHICS )
// Type C

View File

@ -43,7 +43,8 @@ public:
m_maincpu(*this,"maincpu"),
m_vram(*this, "vram"),
m_heartbeat(*this, "heartbeat"),
m_dac(*this, "dac")
m_dac(*this, "dac"),
m_switches(*this, {"C0", "C1", "C2", "C3"})
{ }
required_device<cpu_device> m_maincpu;
@ -51,6 +52,8 @@ public:
required_device<timer_device> m_heartbeat;
required_device<dac_device> m_dac;
optional_ioport_array<4> m_switches;
UINT8 m_status;
UINT8 m_common;
@ -231,10 +234,10 @@ READ8_MEMBER(meyc8088_state::meyc8088_input_r)
UINT8 ret = 0xff;
// multiplexed switch inputs
if (~m_common & 1) ret &= read_safe(ioport("C0"), 0); // bit switches
if (~m_common & 2) ret &= read_safe(ioport("C1"), 0); // control switches
if (~m_common & 4) ret &= read_safe(ioport("C2"), 0); // light switches
if (~m_common & 8) ret &= read_safe(ioport("C3"), 0); // light switches
if (~m_common & 1) ret &= m_switches[0].read_safe(0); // bit switches
if (~m_common & 2) ret &= m_switches[1].read_safe(0); // control switches
if (~m_common & 4) ret &= m_switches[2].read_safe(0); // light switches
if (~m_common & 8) ret &= m_switches[3].read_safe(0); // light switches
return ret;
}

View File

@ -135,14 +135,13 @@ READ32_MEMBER(midvunit_state::midvunit_adc_r)
WRITE32_MEMBER(midvunit_state::midvunit_adc_w)
{
static const char *const adcnames[] = { "WHEEL", "ACCEL", "BRAKE" };
if (!(m_control_data & 0x20))
{
int which = (data >> m_adc_shift) - 4;
if (which < 0 || which > 2)
logerror("adc_w: unexpected which = %02X\n", which + 4);
m_adc_data = read_safe(ioport(adcnames[which]), 0);
else
m_adc_data = m_adc_ports[which].read_safe(0);
timer_set(attotime::from_msec(1), TIMER_ADC_READY);
}
else

View File

@ -638,11 +638,8 @@ Notes:
READ16_MEMBER(model1_state::io_r)
{
static const char *const analognames[] = { "AN.0", "AN.1", "AN.2", "AN.3", "AN.4", "AN.5", "AN.6", "AN.7" };
static const char *const inputnames[] = { "IN.0", "IN.1", "IN.2" };
if(offset < 0x8)
return read_safe(ioport(analognames[offset]), 0x00);
return m_analog_ports[offset].read_safe(0x00);
if(offset == 0x0f)
return m_lamp_state;
@ -651,7 +648,7 @@ READ16_MEMBER(model1_state::io_r)
{
offset -= 0x8;
if(offset < 3)
return ioport(inputnames[offset])->read();
return m_digital_ports[offset]->read();
return 0xff;
}

View File

@ -520,7 +520,7 @@ WRITE32_MEMBER(model2_state::videoctl_w)
CUSTOM_INPUT_MEMBER(model2_state::_1c00000_r)
{
UINT32 ret = ioport("IN0")->read();
UINT32 ret = m_in0->read();
if(m_ctrlmode == 0)
{
@ -538,8 +538,7 @@ CUSTOM_INPUT_MEMBER(model2_state::_1c0001c_r)
UINT32 iptval = 0x00ff;
if(m_analog_channel < 4)
{
static const char *const ports[] = { "ANA0", "ANA1", "ANA2", "ANA3" };
iptval = read_safe(ioport(ports[m_analog_channel]), 0);
iptval = m_analog_ports[m_analog_channel].read_safe(0);
++m_analog_channel;
}
return iptval;
@ -557,7 +556,7 @@ CUSTOM_INPUT_MEMBER(model2_state::_1c0001c_r)
/* Used specifically by Sega Rally, others might be different */
CUSTOM_INPUT_MEMBER(model2_state::srallyc_gearbox_r)
{
UINT8 res = read_safe(ioport("GEARS"), 0);
UINT8 res = m_gears.read_safe(0);
int i;
const UINT8 gearvalue[5] = { 0, 2, 1, 6, 5 };
@ -1054,21 +1053,20 @@ WRITE32_MEMBER(model2_state::geo_w)
READ32_MEMBER(model2_state::hotd_lightgun_r)
{
static const char *const ports[] = { "P1_Y", "P1_X", "P2_Y", "P2_X" };
UINT16 res = 0xffff;
if(m_lightgun_mux < 8)
res = (read_safe(ioport(ports[m_lightgun_mux >> 1]), 0) >> ((m_lightgun_mux & 1)*8)) & 0xff;
res = (m_lightgun_ports[m_lightgun_mux >> 1].read_safe(0) >> ((m_lightgun_mux & 1)*8)) & 0xff;
else
{
UINT16 p1x,p1y,p2x,p2y;
res = 0xfffc;
p1x = read_safe(ioport("P1_X"), 0);
p1y = read_safe(ioport("P1_Y"), 0);
p2x = read_safe(ioport("P2_X"), 0);
p2y = read_safe(ioport("P2_Y"), 0);
p1x = m_lightgun_ports[1].read_safe(0);
p1y = m_lightgun_ports[0].read_safe(0);
p2x = m_lightgun_ports[3].read_safe(0);
p2y = m_lightgun_ports[2].read_safe(0);
/* TODO: might be better, supposedly user has to calibrate guns in order to make these settings to work ... */
if(p1x <= 0x28 || p1x >= 0x3e0 || p1y <= 0x40 || p1y >= 0x3c0)
@ -1479,10 +1477,9 @@ ADDRESS_MAP_END
READ8_MEMBER(model2_state::virtuacop_lightgun_r)
{
static const char *const ports[] = { "P1_Y", "P1_X", "P2_Y", "P2_X" };
UINT8 res;
res = (read_safe(ioport(ports[offset >> 1]), 0) >> ((offset & 1)*8)) & 0xff;
res = (m_lightgun_ports[offset >> 1].read_safe(0) >> ((offset & 1)*8)) & 0xff;
return res;
}
@ -1493,10 +1490,10 @@ READ8_MEMBER(model2_state::virtuacop_lightgun_offscreen_r)
UINT16 special_res = 0xfffc;
UINT16 p1x,p1y,p2x,p2y;
p1x = read_safe(ioport("P1_X"), 0);
p1y = read_safe(ioport("P1_Y"), 0);
p2x = read_safe(ioport("P2_X"), 0);
p2y = read_safe(ioport("P2_Y"), 0);
p1x = m_lightgun_ports[1].read_safe(0);
p1y = m_lightgun_ports[0].read_safe(0);
p2x = m_lightgun_ports[3].read_safe(0);
p2y = m_lightgun_ports[2].read_safe(0);
/* TODO: might be better, supposedly user has to calibrate guns in order to make these settings to work ... */
if(p1x <= 0x28 || p1x >= 0x3e0 || p1y <= 0x40 || p1y >= 0x3c0)

View File

@ -1431,8 +1431,7 @@ READ64_MEMBER(model3_state::model3_ctrl_r)
case 7:
if (ACCESSING_BITS_24_31) /* ADC Data read */
{
static const char *const adcnames[] = { "AN0", "AN1", "AN2", "AN3", "AN4", "AN5", "AN6", "AN7" };
const UINT8 adc_data = read_safe(ioport(adcnames[m_adc_channel]), 0);
const UINT8 adc_data = m_adc_ports[m_adc_channel].read_safe(0);
m_adc_channel++;
m_adc_channel &= 0x7;
return (UINT64)adc_data << 24;

View File

@ -1255,14 +1255,12 @@ WRITE_LINE_MEMBER(mpu4_state::pia_ic7_cb2_w)
/* IC8, Inputs, TRIACS, alpha clock */
READ8_MEMBER(mpu4_state::pia_ic8_porta_r)
{
ioport_port * portnames[] = { m_orange1_port, m_orange2_port, m_black1_port, m_black2_port, m_orange1_port, m_orange2_port, m_dil1_port, m_dil2_port };
LOG_IC8(("%s: IC8 PIA Read of Port A (MUX input data)\n", machine().describe_context()));
/* The orange inputs are polled twice as often as the black ones, for reasons of efficiency.
This is achieved via connecting every input line to an AND gate, thus allowing two strobes
to represent each orange input bank (strobes are active low). */
m_pia5->cb1_w(m_aux2_port->read() & 0x80);
return (portnames[m_input_strobe])->read();
return (m_port_mux[m_input_strobe])->read();
}

View File

@ -118,10 +118,16 @@ public:
multigam_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_ppu(*this, "ppu") { }
m_ppu(*this, "ppu"),
m_p1(*this, "P1"),
m_p2(*this, "P2"),
m_dsw(*this, "DSW") { }
required_device<cpu_device> m_maincpu;
required_device<ppu2c0x_device> m_ppu;
required_ioport m_p1;
required_ioport m_p2;
optional_ioport m_dsw;
std::unique_ptr<UINT8[]> m_nt_ram;
std::unique_ptr<UINT8[]> m_vram;
@ -313,11 +319,11 @@ WRITE8_MEMBER(multigam_state::multigam_IN0_w)
m_in_0_shift = 0;
m_in_1_shift = 0;
m_in_0 = ioport("P1")->read();
m_in_1 = ioport("P2")->read();
m_in_0 = m_p1->read();
m_in_1 = m_p2->read();
m_in_dsw_shift = 0;
m_in_dsw = read_safe(ioport("DSW"), 0);
m_in_dsw = m_dsw.read_safe(0);
}
READ8_MEMBER(multigam_state::multigam_IN1_r)

View File

@ -55,21 +55,7 @@ public:
m_region_chargen(*this, "chargen"),
m_region_ipl(*this, "ipl"),
m_region_wram(*this, "wram"),
m_io_key0(*this, "KEY0"),
m_io_key1(*this, "KEY1"),
m_io_key2(*this, "KEY2"),
m_io_key3(*this, "KEY3"),
m_io_key4(*this, "KEY4"),
m_io_key5(*this, "KEY5"),
m_io_key6(*this, "KEY6"),
m_io_key7(*this, "KEY7"),
m_io_key8(*this, "KEY8"),
m_io_key9(*this, "KEY9"),
m_io_keya(*this, "KEYA"),
m_io_keyb(*this, "KEYB"),
m_io_keyc(*this, "KEYC"),
m_io_keyd(*this, "KEYD"),
m_io_unused(*this, "UNUSED"),
m_io_keys(*this, {"KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", "KEY8", "KEY9", "KEYA", "KEYB", "KEYC", "KEYD", "UNUSED", "UNUSED"}),
m_io_config(*this, "CONFIG"),
m_palette(*this, "palette") { }
@ -141,21 +127,7 @@ protected:
required_memory_region m_region_chargen;
required_memory_region m_region_ipl;
required_memory_region m_region_wram;
required_ioport m_io_key0;
required_ioport m_io_key1;
required_ioport m_io_key2;
required_ioport m_io_key3;
required_ioport m_io_key4;
required_ioport m_io_key5;
required_ioport m_io_key6;
required_ioport m_io_key7;
required_ioport m_io_key8;
required_ioport m_io_key9;
required_ioport m_io_keya;
required_ioport m_io_keyb;
required_ioport m_io_keyc;
required_ioport m_io_keyd;
required_ioport m_io_unused;
required_ioport_array<16> m_io_keys;
required_ioport m_io_config;
required_device<palette_device> m_palette;
};
@ -760,23 +732,18 @@ WRITE8_MEMBER(mz2000_state::mz2000_pio1_porta_w)
READ8_MEMBER(mz2000_state::mz2000_pio1_portb_r)
{
ioport_port* keynames[] = { m_io_key0, m_io_key1, m_io_key2, m_io_key3,
m_io_key4, m_io_key5, m_io_key6, m_io_key7,
m_io_key8, m_io_key9, m_io_keya, m_io_keyb,
m_io_keyc, m_io_keyd, m_io_unused, m_io_unused };
if(((m_key_mux & 0x10) == 0x00) || ((m_key_mux & 0x0f) == 0x0f)) //status read
{
int res,i;
res = 0xff;
for(i=0;i<0xe;i++)
res &= keynames[i]->read();
res &= m_io_keys[i]->read();
return res;
}
return keynames[m_key_mux & 0xf]->read();
return m_io_keys[m_key_mux & 0xf]->read();
}
READ8_MEMBER(mz2000_state::mz2000_pio1_porta_r)

View File

@ -282,16 +282,16 @@ READ8_MEMBER(namcofl_state::port7_r)
switch (m_mcu_port6 & 0xf0)
{
case 0x00:
return ioport("IN0")->read();
return m_in0->read();
case 0x20:
return ioport("MISC")->read();
return m_misc->read();
case 0x40:
return ioport("IN1")->read();
return m_in1->read();
case 0x60:
return ioport("IN2")->read();
return m_in2->read();
default:
break;
@ -302,17 +302,17 @@ READ8_MEMBER(namcofl_state::port7_r)
READ8_MEMBER(namcofl_state::dac7_r)
{
return read_safe(ioport("ACCEL"), 0xff);
return m_accel.read_safe(0xff);
}
READ8_MEMBER(namcofl_state::dac6_r)
{
return read_safe(ioport("BRAKE"), 0xff);
return m_brake.read_safe(0xff);
}
READ8_MEMBER(namcofl_state::dac5_r)
{
return read_safe(ioport("WHEEL"), 0xff);
return m_wheel.read_safe(0xff);
}
READ8_MEMBER(namcofl_state::dac4_r){ return 0xff; }

View File

@ -639,10 +639,10 @@ READ32_MEMBER(namconb1_state::gunbulet_gun_r)
switch (offset)
{
case 0: case 1: result = (UINT8)(0x0f + ioport("LIGHT1_Y")->read() * 224/255); break; /* Y (p2) */
case 2: case 3: result = (UINT8)(0x26 + ioport("LIGHT1_X")->read() * 288/314); break; /* X (p2) */
case 4: case 5: result = (UINT8)(0x0f + ioport("LIGHT0_Y")->read() * 224/255); break; /* Y (p1) */
case 6: case 7: result = (UINT8)(0x26 + ioport("LIGHT0_X")->read() * 288/314); break; /* X (p1) */
case 0: case 1: result = (UINT8)(0x0f + m_light1_y->read() * 224/255); break; /* Y (p2) */
case 2: case 3: result = (UINT8)(0x26 + m_light1_x->read() * 288/314); break; /* X (p2) */
case 4: case 5: result = (UINT8)(0x0f + m_light0_y->read() * 224/255); break; /* Y (p1) */
case 6: case 7: result = (UINT8)(0x26 + m_light0_x->read() * 288/314); break; /* X (p1) */
}
return result<<24;
} /* gunbulet_gun_r */
@ -757,16 +757,16 @@ READ8_MEMBER(namconb1_state::port7_r)
switch (m_port6 & 0xf0)
{
case 0x00:
return read_safe(ioport("P4"), 0xff);
return m_p4.read_safe(0xff);
case 0x20:
return ioport("MISC")->read();
return m_misc->read();
case 0x40:
return ioport("P1")->read();
return m_p1->read();
case 0x60:
return ioport("P2")->read();
return m_p2->read();
default:
break;
@ -780,42 +780,42 @@ READ8_MEMBER(namconb1_state::port7_r)
// register full scale, so it works...
READ8_MEMBER(namconb1_state::dac7_r)// bit 7
{
return read_safe(ioport("P3"), 0xff)&0x80;
return m_p3.read_safe(0xff)&0x80;
}
READ8_MEMBER(namconb1_state::dac6_r)// bit 3
{
return (read_safe(ioport("P3"), 0xff)<<1)&0x80;
return (m_p3.read_safe(0xff)<<1)&0x80;
}
READ8_MEMBER(namconb1_state::dac5_r)// bit 2
{
return (read_safe(ioport("P3"), 0xff)<<2)&0x80;
return (m_p3.read_safe(0xff)<<2)&0x80;
}
READ8_MEMBER(namconb1_state::dac4_r)// bit 1
{
return (read_safe(ioport("P3"), 0xff)<<3)&0x80;
return (m_p3.read_safe(0xff)<<3)&0x80;
}
READ8_MEMBER(namconb1_state::dac3_r)// bit 0
{
return (read_safe(ioport("P3"), 0xff)<<4)&0x80;
return (m_p3.read_safe(0xff)<<4)&0x80;
}
READ8_MEMBER(namconb1_state::dac2_r)// bit 4
{
return (read_safe(ioport("P3"), 0xff)<<5)&0x80;
return (m_p3.read_safe(0xff)<<5)&0x80;
}
READ8_MEMBER(namconb1_state::dac1_r)// bit 5
{
return (read_safe(ioport("P3"), 0xff)<<6)&0x80;
return (m_p3.read_safe(0xff)<<6)&0x80;
}
READ8_MEMBER(namconb1_state::dac0_r)// bit 6
{
return (read_safe(ioport("P3"), 0xff)<<7)&0x80;
return (m_p3.read_safe(0xff)<<7)&0x80;
}
static ADDRESS_MAP_START( namcoc75_io, AS_IO, 8, namconb1_state )

View File

@ -1686,7 +1686,7 @@ READ16_MEMBER(namcos22_state::namcos22_portbit_r)
WRITE16_MEMBER(namcos22_state::namcos22_portbit_w)
{
m_portbits[offset] = read_safe(ioport((offset == 0) ? "P1" : "P2"), 0xffff);
m_portbits[offset] = ((offset == 0) ? m_p1 : m_p2).read_safe(0xffff);
}
READ16_MEMBER(namcos22_state::namcos22_dipswitch_r)
@ -2760,9 +2760,9 @@ WRITE8_MEMBER(namcos22_state::mcu_port5_w)
READ8_MEMBER(namcos22_state::mcu_port5_r)
{
if (m_p4 & 8)
return read_safe(ioport("MCUP5A"), 0xff);
return m_mcup5a.read_safe(0xff);
else
return read_safe(ioport("MCUP5B"), 0xff);
return m_mcup5b.read_safe(0xff);
}
WRITE8_MEMBER(namcos22_state::mcu_port6_w)
@ -2787,7 +2787,7 @@ READ8_MEMBER(namcos22_state::mcu_port7_r)
READ8_MEMBER(namcos22_state::namcos22s_mcu_adc_r)
{
UINT16 adc = read_safe(m_adc_ports[offset >> 1 & 7], 0) << 2;
UINT16 adc = m_adc_ports[offset >> 1 & 7].read_safe(0) << 2;
return (offset & 1) ? adc >> 8 : adc;
}

View File

@ -3129,7 +3129,7 @@ WRITE16_MEMBER(namcos23_state::iob_p6_w)
READ16_MEMBER(namcos23_state::iob_analog_r)
{
return read_safe(m_adc_ports[offset], 0);
return m_adc_ports[offset].read_safe(0);
}

View File

@ -39,13 +39,7 @@ public:
m_bank1(*this, "bank1"),
m_bank2(*this, "bank2"),
m_bank3(*this, "bank3"),
m_line0(*this, "LINE0"),
m_line1(*this, "LINE1"),
m_line2(*this, "LINE2"),
m_line3(*this, "LINE3"),
m_line4(*this, "LINE4"),
m_line5(*this, "LINE5"),
m_line6(*this, "LINE6"),
m_lines(*this, {"LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6"}),
m_linec(*this, "LINEC")
{ }
@ -84,13 +78,7 @@ protected:
required_memory_bank m_bank1;
required_memory_bank m_bank2;
required_memory_bank m_bank3;
required_ioport m_line0;
required_ioport m_line1;
required_ioport m_line2;
required_ioport m_line3;
required_ioport m_line4;
required_ioport m_line5;
required_ioport m_line6;
required_ioport_array<7> m_lines;
required_ioport m_linec;
UINT8 row_number(UINT8 code);
};
@ -343,8 +331,6 @@ UINT8 nanos_state::row_number(UINT8 code)
TIMER_DEVICE_CALLBACK_MEMBER(nanos_state::keyboard_callback)
{
ioport_port *io_ports[] = { m_line0, m_line1, m_line2, m_line3, m_line4, m_line5, m_line6 };
int i;
UINT8 code;
UINT8 key_code = 0;
@ -353,7 +339,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(nanos_state::keyboard_callback)
m_key_pressed = 0xff;
for(i = 0; i < 7; i++)
{
code = io_ports[i]->read();
code = m_lines[i]->read();
if (code != 0)
{
if (i==0 && shift==0) {

View File

@ -155,9 +155,7 @@ public:
m_io_mode4_dsw(*this, "MODE4_DSW"),
m_io_p1(*this, "P1"),
m_io_p2(*this, "P2"),
m_io_key1(*this, "key1"),
m_io_key2(*this, "key2"),
m_io_key3(*this, "key3"),
m_io_keys(*this, {"key1", "key2", "key3"}),
m_io_key_modifiers(*this, "key_modifiers"),
m_bank1(*this, "bank1"),
m_bank2(*this, "bank2"),
@ -278,9 +276,7 @@ protected:
required_ioport m_io_mode4_dsw;
required_ioport m_io_p1;
required_ioport m_io_p2;
required_ioport m_io_key1;
required_ioport m_io_key2;
required_ioport m_io_key3;
required_ioport_array<3> m_io_keys;
required_ioport m_io_key_modifiers;
required_memory_bank m_bank1;
optional_memory_bank m_bank2;
@ -1903,7 +1899,6 @@ READ8_MEMBER(pc6001_state::pc6001_8255_portc_r)
UINT8 pc6001_state::check_keyboard_press()
{
ioport_port *ports[3] = { m_io_key1, m_io_key2, m_io_key3 };
int i,port_i,scancode;
UINT8 shift_pressed,caps_lock;
scancode = 0;
@ -1915,7 +1910,7 @@ UINT8 pc6001_state::check_keyboard_press()
{
for(i=0;i<32;i++)
{
if((ports[port_i]->read()>>i) & 1)
if((m_io_keys[port_i]->read()>>i) & 1)
{
if((shift_pressed != caps_lock) && scancode >= 0x41 && scancode <= 0x5f)
scancode+=0x20;
@ -1948,7 +1943,7 @@ UINT8 pc6001_state::check_joy_press()
{
UINT8 p1_key = m_io_p1->read() ^ 0xff;
UINT8 shift_key = m_io_key_modifiers->read() & 0x02;
UINT8 space_key = m_io_key2->read() & 0x01;
UINT8 space_key = m_io_keys[1]->read() & 0x01;
UINT8 joy_press;
/*
@ -2027,9 +2022,9 @@ TIMER_DEVICE_CALLBACK_MEMBER(pc6001_state::cassette_callback)
TIMER_DEVICE_CALLBACK_MEMBER(pc6001_state::keyboard_callback)
{
UINT32 key1 = m_io_key1->read();
UINT32 key2 = m_io_key2->read();
UINT32 key3 = m_io_key3->read();
UINT32 key1 = m_io_keys[0]->read();
UINT32 key2 = m_io_keys[1]->read();
UINT32 key3 = m_io_keys[2]->read();
// UINT8 p1_key = m_io_p1->read();
if(m_cas_switch == 0)

View File

@ -227,6 +227,14 @@ public:
m_screen(*this, "screen"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_in0(*this, "IN0"),
m_door(*this, "DOOR"),
m_sensor(*this, "SENSOR"),
m_dbv(*this, "DBV"),
m_bc(*this, "BC"),
m_bp(*this, "BP"),
m_touch_x(*this, "TOUCH_X"),
m_touch_y(*this, "TOUCH_Y"),
m_cmos_ram(*this, "cmos"),
m_program_ram(*this, "prograram"),
m_s3000_ram(*this, "s3000_ram"),
@ -247,6 +255,15 @@ public:
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
optional_ioport m_in0;
optional_ioport m_door;
optional_ioport m_sensor;
optional_ioport m_dbv;
optional_ioport m_bc;
optional_ioport m_bp;
optional_ioport m_touch_x;
optional_ioport m_touch_y;
required_shared_ptr<UINT8> m_cmos_ram;
required_shared_ptr<UINT8> m_program_ram;
required_shared_ptr<UINT8> m_s3000_ram;
@ -406,8 +423,8 @@ void peplus_state::device_timer(emu_timer &timer, device_timer_id id, int param,
void peplus_state::handle_lightpen()
{
int x_val = read_safe(ioport("TOUCH_X"), 0x00);
int y_val = read_safe(ioport("TOUCH_Y"), 0x00);
int x_val = m_touch_x.read_safe(0x00);
int y_val = m_touch_y.read_safe(0x00);
const rectangle &vis_area = m_screen->visible_area();
int xt, yt;
@ -581,14 +598,14 @@ READ8_MEMBER(peplus_state::peplus_input0_r)
UINT64 curr_cycles = m_maincpu->total_cycles();
// Allow Bill Insert if DBV Enabled
if (m_bv_enable_state == 0x01 && ((read_safe(ioport("DBV"), 0xff) & 0x01) == 0x00)) {
if (m_bv_enable_state == 0x01 && ((m_dbv.read_safe(0xff) & 0x01) == 0x00)) {
// If not busy
if (m_bv_busy == 0) {
m_bv_busy = 1;
// Fetch Current Denomination and Protocol
m_bv_denomination = ioport("BC")->read();
m_bv_protocol = ioport("BP")->read();
m_bv_denomination = m_bc->read();
m_bv_protocol = m_bp->read();
if (m_bv_protocol == 0) {
// ID-022
@ -775,9 +792,9 @@ READ8_MEMBER(peplus_state::peplus_input0_r)
}
if (m_bv_pulse == 1) {
return (0x70 || ioport("IN0")->read()); // Add Bill Validator Credit Pulse
return (0x70 || m_in0->read()); // Add Bill Validator Credit Pulse
} else {
return ioport("IN0")->read();
return m_in0->read();
}
}
@ -804,7 +821,7 @@ READ8_MEMBER(peplus_state::peplus_input_bank_a_r)
sda = m_i2cmem->read_sda();
}
if ((read_safe(ioport("SENSOR"), 0x00) & 0x01) == 0x01 && m_coin_state == 0) {
if ((m_sensor.read_safe(0x00) & 0x01) == 0x01 && m_coin_state == 0) {
m_coin_state = 1; // Start Coin Cycle
m_last_cycles = m_maincpu->total_cycles();
} else {
@ -840,7 +857,7 @@ READ8_MEMBER(peplus_state::peplus_input_bank_a_r)
}
if (curr_cycles - m_last_door > door_wait) {
if ((read_safe(ioport("DOOR"), 0xff) & 0x01) == 0x01) {
if ((m_door.read_safe(0xff) & 0x01) == 0x01) {
if (m_doorcycle) {
m_door_open = (m_door_open ^ 0x01) & 0x01;
} else {

View File

@ -177,10 +177,7 @@ READ16_MEMBER( segahang_state::hangon_io_r )
return m_i8255_2->read(space, offset & 3);
case 0x3020/2: // ADC0804 data output
{
static const char *const adcports[] = { "ADC0", "ADC1", "ADC2", "ADC3" };
return read_safe(ioport(adcports[m_adc_select]), 0);
}
return m_adc_ports[m_adc_select].read_safe(0);
}
//logerror("%06X:hangon_io_r - unknown read access to address %04X\n", m_maincpu->pc(), offset * 2);
@ -238,10 +235,7 @@ READ16_MEMBER( segahang_state::sharrier_io_r )
return m_i8255_2->read(space, offset & 3);
case 0x0030/2: // ADC0804 data output
{
static const char *const adcports[] = { "ADC0", "ADC1", "ADC2", "ADC3" };
return read_safe(ioport(adcports[m_adc_select]), 0);
}
return m_adc_ports[m_adc_select].read_safe(0);
}
//logerror("%06X:sharrier_io_r - unknown read access to address %04X\n", m_maincpu->pc(), offset * 2);
@ -391,7 +385,7 @@ void segahang_state::sharrier_i8751_sim()
m_workram[0x0f0/2] = 0;
// read I/O ports
m_workram[0x492/2] = (ioport("ADC0")->read() << 8) | ioport("ADC1")->read();
m_workram[0x492/2] = (m_adc_ports[0]->read() << 8) | m_adc_ports[1]->read();
}

View File

@ -695,7 +695,7 @@ READ16_MEMBER( segaorun_state::outrun_custom_io_r )
case 0x30/2:
{
return read_safe(m_adc_ports[m_adc_select], 0x0010);
return m_adc_ports[m_adc_select].read_safe(0x0010);
}
case 0x60/2:
@ -781,7 +781,7 @@ READ16_MEMBER( segaorun_state::shangon_custom_io_r )
case 0x3020/2:
{
return read_safe(m_adc_ports[m_adc_select], 0x0010);
return m_adc_ports[m_adc_select].read_safe(0x0010);
}
default:

View File

@ -917,19 +917,18 @@ READ16_MEMBER( segas16a_state::sdi_custom_io_r )
READ16_MEMBER( segas16a_state::sjryuko_custom_io_r )
{
static const char *const portname[] = { "MJ0", "MJ1", "MJ2", "MJ3", "MJ4", "MJ5" };
switch (offset & (0x3000/2))
{
case 0x1000/2:
switch (offset & 3)
{
case 1:
if (read_safe(ioport(portname[m_mj_input_num]), 0xff) != 0xff)
if (m_mj_inputs[m_mj_input_num].read_safe(0xff) != 0xff)
return 0xff & ~(1 << m_mj_input_num);
return 0xff;
case 2:
return read_safe(ioport(portname[m_mj_input_num]), 0xff);
return m_mj_inputs[m_mj_input_num].read_safe(0xff);
}
break;
}

View File

@ -1590,14 +1590,30 @@ READ16_MEMBER( segas16b_state::hwchamp_custom_io_r )
WRITE16_MEMBER( segas16b_state::hwchamp_custom_io_w )
{
static const char *const portname[4] = { "MONITOR", "LEFT", "RIGHT", "DUMMY" };
switch (offset & (0x3000/2))
{
case 0x3000/2:
switch (offset & 0x30/2)
{
case 0x20/2:
m_hwc_input_value = read_safe(ioport(portname[offset & 3]), 0xff);
switch (offset & 3)
{
case 0:
m_hwc_input_value = m_hwc_monitor->read();
break;
case 1:
m_hwc_input_value = m_hwc_left->read();
break;
case 2:
m_hwc_input_value = m_hwc_right->read();
break;
default:
m_hwc_input_value = 0xff;
break;
}
break;
case 0x30/2:
@ -1668,20 +1684,18 @@ READ16_MEMBER( segas16b_state::sdi_custom_io_r )
READ16_MEMBER( segas16b_state::sjryuko_custom_io_r )
{
static const char *const portname[] = { "MJ0", "MJ1", "MJ2", "MJ3", "MJ4", "MJ5" };
switch (offset & (0x3000/2))
{
case 0x1000/2:
switch (offset & 3)
{
case 1:
if (read_safe(ioport(portname[m_mj_input_num]), 0xff) != 0xff)
if (m_mj_inputs[m_mj_input_num].read_safe(0xff) != 0xff)
return 0xff & ~(1 << m_mj_input_num);
return 0xff;
case 2:
return read_safe(ioport(portname[m_mj_input_num]), 0xff);
return m_mj_inputs[m_mj_input_num].read_safe(0xff);
}
break;
}

View File

@ -518,19 +518,19 @@ UINT8 segas24_state::hotrod_io_r(UINT8 port)
switch(port)
{
case 0:
return ioport("P1")->read();
return m_p1->read();
case 1:
return ioport("P2")->read();
return m_p2->read();
case 2:
return read_safe(ioport("P3"), 0xff);
return m_p3.read_safe(0xff);
case 3:
return 0xff;
case 4:
return ioport("SERVICE")->read();
return m_service->read();
case 5: // Dip switches
return ioport("COINAGE")->read();
return m_coinage->read();
case 6:
return ioport("DSW")->read();
return m_dsw->read();
case 7: // DAC
return 0xff;
}
@ -544,20 +544,20 @@ UINT8 segas24_state::dcclub_io_r(UINT8 port)
case 0:
{
static const UINT8 pos[16] = { 0, 1, 3, 2, 6, 4, 12, 8, 9 };
return (ioport("P1")->read() & 0xf) | ((~pos[ioport("PADDLE")->read()>>4]<<4) & 0xf0);
return (m_p1->read() & 0xf) | ((~pos[m_paddle->read()>>4]<<4) & 0xf0);
}
case 1:
return ioport("P2")->read();
return m_p2->read();
case 2:
return 0xff;
case 3:
return 0xff;
case 4:
return ioport("SERVICE")->read();
return m_service->read();
case 5: // Dip switches
return ioport("COINAGE")->read();
return m_coinage->read();
case 6:
return ioport("DSW")->read();
return m_dsw->read();
case 7: // DAC
return 0xff;
}
@ -567,8 +567,6 @@ UINT8 segas24_state::dcclub_io_r(UINT8 port)
UINT8 segas24_state::mahmajn_io_r(UINT8 port)
{
static const char *const keynames[] = { "MJ0", "MJ1", "MJ2", "MJ3", "MJ4", "MJ5", "P1", "P2" };
switch(port)
{
case 0:
@ -576,15 +574,15 @@ UINT8 segas24_state::mahmajn_io_r(UINT8 port)
case 1:
return 0xff;
case 2:
return ioport(keynames[cur_input_line])->read();
return m_mj_inputs[cur_input_line].read_safe(0xff);
case 3:
return 0xff;
case 4:
return ioport("SERVICE")->read();
return m_service->read();
case 5: // Dip switches
return ioport("COINAGE")->read();
return m_coinage->read();
case 6:
return ioport("DSW")->read();
return m_dsw->read();
case 7: // DAC
return 0xff;
}
@ -624,12 +622,10 @@ void segas24_state::hotrod_io_w(UINT8 port, UINT8 data)
WRITE16_MEMBER( segas24_state::hotrod3_ctrl_w )
{
static const char *const portnames[] = { "PEDAL1", "PEDAL2", "PEDAL3", "PEDAL4" };
if(ACCESSING_BITS_0_7)
{
data &= 3;
hotrod_ctrl_cur = read_safe(ioport(portnames[data]), 0);
hotrod_ctrl_cur = m_pedals[data].read_safe(0);
}
}
@ -641,21 +637,21 @@ READ16_MEMBER( segas24_state::hotrod3_ctrl_r )
{
// Steering dials
case 0:
return read_safe(ioport("DIAL1"), 0) & 0xff;
return m_dials[0].read_safe(0) & 0xff;
case 1:
return read_safe(ioport("DIAL1"), 0) >> 8;
return m_dials[0].read_safe(0) >> 8;
case 2:
return read_safe(ioport("DIAL2"), 0) & 0xff;
return m_dials[1].read_safe(0) & 0xff;
case 3:
return read_safe(ioport("DIAL2"), 0) >> 8;
return m_dials[1].read_safe(0) >> 8;
case 4:
return read_safe(ioport("DIAL3"), 0) & 0xff;
return m_dials[2].read_safe(0) & 0xff;
case 5:
return read_safe(ioport("DIAL3"), 0) >> 8;
return m_dials[2].read_safe(0) >> 8;
case 6:
return read_safe(ioport("DIAL4"), 0) & 0xff;
return m_dials[3].read_safe(0) & 0xff;
case 7:
return read_safe(ioport("DIAL4"), 0) >> 8;
return m_dials[3].read_safe(0) >> 8;
case 8:
{

View File

@ -545,6 +545,11 @@ segas32_state::segas32_state(const machine_config &mconfig, const char *tag, dev
m_system32_videoram(*this,"videoram", 0),
m_system32_spriteram(*this,"spriteram", 0),
m_system32_paletteram(*this,"paletteram", 0) ,
m_ports_a(*this, {"P1_A", "P2_A", "PORTC_A", "PORTD_A", "SERVICE12_A", "SERVICE34_A", "PORTG_A", "PORTH_A"}),
m_ports_b(*this, {"P1_B", "P2_B", "PORTC_B", "PORTD_B", "SERVICE12_B", "SERVICE34_B", "PORTG_B", "PORTH_B"}),
m_analog_ports(*this, {"ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4", "ANALOG5", "ANALOG6", "ANALOG7", "ANALOG8"}),
m_extra_ports(*this, {"EXTRA1", "EXTRA2", "EXTRA3", "EXTRA4"}),
m_track_ports(*this, {"TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3"}),
m_maincpu(*this, "maincpu"),
m_soundcpu(*this, "soundcpu"),
m_multipcm(*this, "sega"),
@ -805,11 +810,6 @@ INTERRUPT_GEN_MEMBER(segas32_state::start_of_vblank_int)
UINT16 segas32_state::common_io_chip_r(address_space &space, int which, offs_t offset, UINT16 mem_mask)
{
static const char *const portnames[2][8] =
{
{ "P1_A", "P2_A", "PORTC_A", "PORTD_A", "SERVICE12_A", "SERVICE34_A", "PORTG_A", "PORTH_A" },
{ "P1_B", "P2_B", "PORTC_B", "PORTD_B", "SERVICE12_B", "SERVICE34_B", "PORTG_B", "PORTH_B" },
};
offset &= 0x1f/2;
switch (offset)
@ -828,7 +828,7 @@ UINT16 segas32_state::common_io_chip_r(address_space &space, int which, offs_t o
return m_misc_io_data[which][offset];
/* otherwise, return an input port */
return read_safe(ioport(portnames[which][offset]), 0xffff);
return (which ? m_ports_b : m_ports_a)[offset].read_safe(0xffff);
/* 'SEGA' protection */
case 0x10/2:
@ -1090,14 +1090,13 @@ READ16_MEMBER(segas32_state::analog_custom_io_r)
WRITE16_MEMBER(segas32_state::analog_custom_io_w)
{
static const char *const names[] = { "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4" };
switch (offset)
{
case 0x10/2:
case 0x12/2:
case 0x14/2:
case 0x16/2:
m_analog_value[offset & 3] = read_safe(ioport(names[offset & 3]), 0);
m_analog_value[offset & 3] = m_analog_ports[offset & 3].read_safe(0);
return;
}
logerror("%06X:unknown analog_custom_io_w(%X) = %04X & %04X\n", space.device().safe_pc(), offset*2, data, mem_mask);
@ -1106,14 +1105,13 @@ WRITE16_MEMBER(segas32_state::analog_custom_io_w)
READ16_MEMBER(segas32_state::extra_custom_io_r)
{
static const char *const names[] = { "EXTRA1", "EXTRA2", "EXTRA3", "EXTRA4" };
switch (offset)
{
case 0x20/2:
case 0x22/2:
case 0x24/2:
case 0x26/2:
return read_safe(ioport(names[offset & 3]), 0xffff);
return m_extra_ports[offset & 3].read_safe(0xffff);
}
logerror("%06X:unknown extra_custom_io_r(%X) & %04X\n", space.device().safe_pc(), offset*2, mem_mask);
@ -1123,14 +1121,13 @@ READ16_MEMBER(segas32_state::extra_custom_io_r)
WRITE16_MEMBER(segas32_state::orunners_custom_io_w)
{
static const char *const names[] = { "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4", "ANALOG5", "ANALOG6", "ANALOG7", "ANALOG8" };
switch (offset)
{
case 0x10/2:
case 0x12/2:
case 0x14/2:
case 0x16/2:
m_analog_value[offset & 3] = read_safe(ioport(names[m_analog_bank * 4 + (offset & 3)]), 0);
m_analog_value[offset & 3] = m_analog_ports[m_analog_bank * 4 + (offset & 3)].read_safe(0);
return;
case 0x20/2:
@ -1143,8 +1140,6 @@ WRITE16_MEMBER(segas32_state::orunners_custom_io_w)
READ16_MEMBER(segas32_state::sonic_custom_io_r)
{
static const char *const names[] = { "TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3" };
switch (offset)
{
case 0x00/2:
@ -1153,7 +1148,7 @@ READ16_MEMBER(segas32_state::sonic_custom_io_r)
case 0x0c/2:
case 0x10/2:
case 0x14/2:
return (UINT8)(ioport(names[offset/2])->read() - m_sonic_last[offset/2]);
return (UINT8)(m_track_ports[offset/2]->read() - m_sonic_last[offset/2]);
}
logerror("%06X:unknown sonic_custom_io_r(%X) & %04X\n", space.device().safe_pc(), offset*2, mem_mask);
@ -1163,15 +1158,13 @@ READ16_MEMBER(segas32_state::sonic_custom_io_r)
WRITE16_MEMBER(segas32_state::sonic_custom_io_w)
{
static const char *const names[] = { "TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3" };
switch (offset)
{
case 0x00/2:
case 0x08/2:
case 0x10/2:
m_sonic_last[offset/2 + 0] = ioport(names[offset/2 + 0])->read();
m_sonic_last[offset/2 + 1] = ioport(names[offset/2 + 1])->read();
m_sonic_last[offset/2 + 0] = m_track_ports[offset/2 + 0]->read();
m_sonic_last[offset/2 + 1] = m_track_ports[offset/2 + 1]->read();
return;
}

View File

@ -293,7 +293,9 @@ segaxbd_state::segaxbd_state(const machine_config &mconfig, const char *tag, dev
m_gprider_hack(false),
m_palette_entries(0),
m_screen(*this, "screen"),
m_palette(*this, "palette")
m_palette(*this, "palette"),
m_adc_ports(*this, {"ADC0", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC7"}),
m_mux_ports(*this, {"MUX0", "MUX1", "MUX2", "MUX3"})
{
memset(m_adc_reverse, 0, sizeof(m_adc_reverse));
memset(m_iochip_regs, 0, sizeof(m_iochip_regs));
@ -462,11 +464,9 @@ void segaxbd_state::sound_data_w(UINT8 data)
READ16_MEMBER( segaxbd_state::adc_r )
{
static const char *const ports[] = { "ADC0", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC7" };
// on the write, latch the selected input port and stash the value
int which = (m_iochip_regs[0][2] >> 2) & 7;
int value = read_safe(ioport(ports[which]), 0x0010);
int value = m_adc_ports[which].read_safe(0x0010);
// reverse some port values
if (m_adc_reverse[which])
@ -926,8 +926,7 @@ void segaxbd_state::smgp_iochip0_motor_w(UINT8 data)
UINT8 segaxbd_state::lastsurv_iochip1_port_r(UINT8 data)
{
static const char * const port_names[] = { "MUX0", "MUX1", "MUX2", "MUX3" };
return read_safe(ioport(port_names[m_lastsurv_mux]), 0xff);
return m_mux_ports[m_lastsurv_mux].read_safe(0xff);
}

View File

@ -106,7 +106,7 @@ READ16_MEMBER( segaybd_state::analog_r )
WRITE16_MEMBER( segaybd_state::analog_w )
{
int selected = ((offset & 3) == 3) ? (3 + (m_misc_io_data[0x08/2] & 3)) : (offset & 3);
m_analog_data[offset & 3] = read_safe(m_adc_ports[selected], 0xff);
m_analog_data[offset & 3] = m_adc_ports[selected].read_safe(0xff);
}

View File

@ -79,7 +79,7 @@ void seicross_state::machine_reset()
READ8_MEMBER(seicross_state::portB_r)
{
return (m_portb & 0x9f) | (read_safe(ioport("DEBUG"), 0) & 0x60);
return (m_portb & 0x9f) | (m_debug_port.read_safe(0) & 0x60);
}
WRITE8_MEMBER(seicross_state::portB_w)

View File

@ -1583,12 +1583,12 @@ READ16_MEMBER(seta_state::seta_dsw_r)
READ8_MEMBER(seta_state::dsw1_r)
{
return (ioport("DSW")->read() >> 8) & 0xff;
return (m_dsw->read() >> 8) & 0xff;
}
READ8_MEMBER(seta_state::dsw2_r)
{
return (ioport("DSW")->read() >> 0) & 0xff;
return (m_dsw->read() >> 0) & 0xff;
}
@ -1683,15 +1683,15 @@ ADDRESS_MAP_END
READ16_MEMBER(seta_state::calibr50_ip_r)
{
int dir1 = ioport("ROT1")->read(); // analog port
int dir2 = ioport("ROT2")->read(); // analog port
int dir1 = m_rot[0]->read(); // analog port
int dir2 = m_rot[1]->read(); // analog port
switch (offset)
{
case 0x00/2: return ioport("P1")->read(); // p1
case 0x02/2: return ioport("P2")->read(); // p2
case 0x00/2: return m_p1->read(); // p1
case 0x02/2: return m_p2->read(); // p2
case 0x08/2: return ioport("COINS")->read(); // Coins
case 0x08/2: return m_coins->read(); // Coins
case 0x10/2: return (dir1 & 0xff); // lower 8 bits of p1 rotation
case 0x12/2: return (dir1 >> 8); // upper 4 bits of p1 rotation
@ -1746,10 +1746,10 @@ READ16_MEMBER(seta_state::usclssic_dsw_r)
{
switch (offset)
{
case 0/2: return (ioport("DSW")->read() >> 8) & 0xf;
case 2/2: return (ioport("DSW")->read() >> 12) & 0xf;
case 4/2: return (ioport("DSW")->read() >> 0) & 0xf;
case 6/2: return (ioport("DSW")->read() >> 4) & 0xf;
case 0/2: return (m_dsw->read() >> 8) & 0xf;
case 2/2: return (m_dsw->read() >> 12) & 0xf;
case 4/2: return (m_dsw->read() >> 0) & 0xf;
case 6/2: return (m_dsw->read() >> 4) & 0xf;
}
return 0;
}
@ -1963,7 +1963,7 @@ WRITE16_MEMBER(seta_state::zombraid_gun_w)
READ16_MEMBER(seta_state::extra_r)
{
return read_safe(ioport("EXTRA"), 0xff);
return m_extra_port.read_safe(0xff);
}
static ADDRESS_MAP_START( wrofaero_map, AS_PROGRAM, 16, seta_state )
@ -2137,7 +2137,7 @@ READ16_MEMBER(seta_state::keroppi_protection_init_r)
READ16_MEMBER(seta_state::keroppi_coin_r)
{
UINT16 result = ioport("COINS")->read();
UINT16 result = m_coins->read();
if (m_keroppi_prize_hop == 2)
{
@ -2548,10 +2548,10 @@ ADDRESS_MAP_END
READ16_MEMBER(seta_state::krzybowl_input_r)
{
// analog ports
int dir1x = ioport("TRACK1_X")->read() & 0xfff;
int dir1y = ioport("TRACK1_Y")->read() & 0xfff;
int dir2x = ioport("TRACK2_X")->read() & 0xfff;
int dir2y = ioport("TRACK2_Y")->read() & 0xfff;
int dir1x = m_track1_x->read() & 0xfff;
int dir1y = m_track1_y->read() & 0xfff;
int dir2x = m_track2_x->read() & 0xfff;
int dir2y = m_track2_y->read() & 0xfff;
switch (offset)
{
@ -2724,7 +2724,7 @@ READ16_MEMBER(seta_state::kiwame_input_r)
{
case 0x00/2: return ioport(keynames[i])->read();
case 0x02/2: return 0xffff;
case 0x04/2: return ioport("COINS")->read();
case 0x04/2: return m_coins->read();
// case 0x06/2:
case 0x08/2: return 0xffff;
@ -2991,20 +2991,20 @@ ADDRESS_MAP_END
READ16_MEMBER(seta_state::inttoote_dsw_r)
{
int shift = offset * 4;
return ((((ioport("DSW1")->read() >> shift) & 0xf)) << 0) |
((((ioport("DSW2_3")->read() >> shift) & 0xf)) << 4) |
((((ioport("DSW2_3")->read() >> (shift+8)) & 0xf)) << 8) ;
return ((((m_dsw1->read() >> shift) & 0xf)) << 0) |
((((m_dsw2_3->read() >> shift) & 0xf)) << 4) |
((((m_dsw2_3->read() >> (shift+8)) & 0xf)) << 8) ;
}
READ16_MEMBER(seta_state::inttoote_key_r)
{
switch( *m_inttoote_key_select )
{
case 0x08: return ioport("BET0")->read();
case 0x10: return ioport("BET1")->read();
case 0x20: return ioport("BET2")->read();
case 0x40: return ioport("BET3")->read();
case 0x80: return ioport("BET4")->read();
case 0x08: return m_bet[0]->read();
case 0x10: return m_bet[1]->read();
case 0x20: return m_bet[2]->read();
case 0x40: return m_bet[3]->read();
case 0x80: return m_bet[4]->read();
}
logerror("%06X: unknown read, select = %04x\n",space.device().safe_pc(), *m_inttoote_key_select);
@ -3055,11 +3055,11 @@ READ16_MEMBER(seta_state::jockeyc_mux_r)
{
switch( m_jockeyc_key_select )
{
case 0x08: return ioport("BET0")->read();
case 0x10: return ioport("BET1")->read();
case 0x20: return ioport("BET2")->read();
case 0x40: return ioport("BET3")->read();
case 0x80: return ioport("BET4")->read();
case 0x08: return m_bet[0]->read();
case 0x10: return m_bet[1]->read();
case 0x20: return m_bet[2]->read();
case 0x40: return m_bet[3]->read();
case 0x80: return m_bet[4]->read();
}
return 0xffff;

View File

@ -70,7 +70,7 @@ READ8_MEMBER(sidearms_state::turtship_ports_r)
{
int res = 0;
for (int i = 0; i < 5;i++)
res |= ((read_safe(m_ports[i], 0) >> offset) & 1) << i;
res |= ((m_ports[i].read_safe(0) >> offset) & 1) << i;
return res;
}

View File

@ -329,11 +329,11 @@ READ8_MEMBER(spectrum_state::spectrum_port_fe_r)
int lines = offset >> 8;
int data = 0xff;
int cs_extra1 = m_io_plus0 ? m_io_plus0->read() & 0x1f : 0x1f;
int cs_extra2 = m_io_plus1 ? m_io_plus1->read() & 0x1f : 0x1f;
int cs_extra3 = m_io_plus2 ? m_io_plus2->read() & 0x1f : 0x1f;
int ss_extra1 = m_io_plus3 ? m_io_plus3->read() & 0x1f : 0x1f;
int ss_extra2 = m_io_plus4 ? m_io_plus4->read() & 0x1f : 0x1f;
int cs_extra1 = m_io_plus0.read_safe(0x1f) & 0x1f;
int cs_extra2 = m_io_plus1.read_safe(0x1f) & 0x1f;
int cs_extra3 = m_io_plus2.read_safe(0x1f) & 0x1f;
int ss_extra1 = m_io_plus3.read_safe(0x1f) & 0x1f;
int ss_extra2 = m_io_plus4.read_safe(0x1f) & 0x1f;
/* Caps - V */
if ((lines & 1) == 0)

View File

@ -444,9 +444,7 @@ ADDRESS_MAP_END
READ16_MEMBER(ssv_state::gdfs_eeprom_r)
{
ioport_port *gun[] = { m_io_gunx1, m_io_guny1, m_io_gunx2, m_io_guny2 };
return (((m_gdfs_lightgun_select & 1) ? 0 : 0xff) ^ gun[m_gdfs_lightgun_select]->read()) | (m_eeprom->do_read() << 8);
return (((m_gdfs_lightgun_select & 1) ? 0 : 0xff) ^ m_io_gun[m_gdfs_lightgun_select]->read()) | (m_eeprom->do_read() << 8);
}
WRITE16_MEMBER(ssv_state::gdfs_eeprom_w)
@ -722,11 +720,7 @@ ADDRESS_MAP_END
READ16_MEMBER(ssv_state::sxyreact_ballswitch_r)
{
if ( m_io_service )
{
return m_io_service->read();
}
return 0;
return m_io_service.read_safe(0);
}
READ16_MEMBER(ssv_state::sxyreact_dial_r)
@ -740,7 +734,7 @@ WRITE16_MEMBER(ssv_state::sxyreact_dial_w)
if (ACCESSING_BITS_0_7)
{
if (data & 0x20)
m_sxyreact_serial = ( m_io_paddle ? m_io_paddle->read() : 0 ) & 0xff;
m_sxyreact_serial = m_io_paddle.read_safe(0) & 0xff;
if ( (m_sxyreact_dial & 0x40) && !(data & 0x40) ) // $40 -> $00
m_sxyreact_serial <<= 1; // shift 1 bit

View File

@ -320,7 +320,7 @@ static const char *const starfire_sample_names[] =
INTERRUPT_GEN_MEMBER(starfire_state::vblank_int)
{
// starfire has a jumper for disabling NMI, used to do a complete RAM test
if (read_safe(ioport("NMI"), 0x01))
if (m_nmi.read_safe(0x01))
device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
}

View File

@ -29,7 +29,7 @@ TIMER_CALLBACK_MEMBER(svision_state::svision_pet_timer)
switch (m_pet.state)
{
case 0:
if ( m_joy2 )
if (m_joy2.found())
{
m_pet.input = m_joy2->read();
}

View File

@ -1104,8 +1104,8 @@ WRITE16_MEMBER(taitoz_state::spacegun_output_bypass_w)
CUSTOM_INPUT_MEMBER(taitoz_state::taitoz_pedal_r)
{
static const UINT8 retval[8] = { 0,1,3,2,6,7,5,4 };
const char *tag = (const char *)param;
return retval[read_safe(ioport(tag), 0) & 7];
ioport_port *port = ioport((const char *)param);
return retval[port != nullptr ? port->read() & 7 : 0];
}
@ -1114,7 +1114,7 @@ READ8_MEMBER(taitoz_state::contcirc_input_bypass_r)
/* Bypass TC0220IOC controller for analog input */
UINT8 port = m_tc0220ioc->port_r(space, 0); /* read port number */
UINT16 steer = 0xff80 + read_safe(ioport("STEER"), 0x80);
UINT16 steer = 0xff80 + m_steer.read_safe(0x80);
switch (port)
{
@ -1135,7 +1135,7 @@ READ8_MEMBER(taitoz_state::chasehq_input_bypass_r)
/* Bypass TC0220IOC controller for extra inputs */
UINT8 port = m_tc0220ioc->port_r(space, 0); /* read port number */
UINT16 steer = 0xff80 + read_safe(ioport("STEER"), 0x80);
UINT16 steer = 0xff80 + m_steer.read_safe(0x80);
switch (port)
{
@ -1222,7 +1222,7 @@ WRITE16_MEMBER(taitoz_state::bshark_stick_w)
READ16_MEMBER(taitoz_state::sci_steer_input_r)
{
UINT16 steer = 0xff80 + read_safe(ioport("STEER"), 0x80);
UINT16 steer = 0xff80 + m_steer.read_safe(0x80);
switch (offset)
{
@ -1293,7 +1293,7 @@ WRITE16_MEMBER(taitoz_state::spacegun_gun_output_w)
READ16_MEMBER(taitoz_state::dblaxle_steer_input_r)
{
UINT16 steer = 0xff80 + read_safe(ioport("STEER"), 0x80);
UINT16 steer = 0xff80 + m_steer.read_safe(0x80);
switch (offset)
{

View File

@ -754,7 +754,7 @@ WRITE8_MEMBER(taitojc_state::hc11_output_w)
READ8_MEMBER(taitojc_state::hc11_analog_r)
{
return read_safe(m_analog_ports[offset], 0);
return m_analog_ports[offset].read_safe(0);
}

View File

@ -634,16 +634,6 @@ void tmc2000_state::machine_start()
m_colorram[addr] = machine().rand() & 0xff;
}
// find keyboard rows
m_key_row[0] = m_y0;
m_key_row[1] = m_y1;
m_key_row[2] = m_y2;
m_key_row[3] = m_y3;
m_key_row[4] = m_y4;
m_key_row[5] = m_y5;
m_key_row[6] = m_y6;
m_key_row[7] = m_y7;
// state saving
save_item(NAME(m_keylatch));
save_item(NAME(m_rac));

View File

@ -258,16 +258,6 @@ WRITE8_MEMBER( tmc2000e_state::dma_w )
void tmc2000e_state::machine_start()
{
// find keyboard rows
m_key_row[0] = m_y0;
m_key_row[1] = m_y1;
m_key_row[2] = m_y2;
m_key_row[3] = m_y3;
m_key_row[4] = m_y4;
m_key_row[5] = m_y5;
m_key_row[6] = m_y6;
m_key_row[7] = m_y7;
/* register for state saving */
save_item(NAME(m_cdp1864_efx));
save_item(NAME(m_keylatch));

View File

@ -236,16 +236,6 @@ void tmc600_state::machine_start()
break;
}
// find keyboard rows
m_key_row[0] = m_y0;
m_key_row[1] = m_y1;
m_key_row[2] = m_y2;
m_key_row[3] = m_y3;
m_key_row[4] = m_y4;
m_key_row[5] = m_y5;
m_key_row[6] = m_y6;
m_key_row[7] = m_y7;
/* register for state saving */
save_item(NAME(m_keylatch));
}

View File

@ -189,7 +189,7 @@ READ8_MEMBER(topspeed_state::input_bypass_r)
{
// Read port number
UINT8 port = m_tc0220ioc->port_r(space, 0);
UINT16 steer = 0xff80 + read_safe(ioport("STEER"), 0);
UINT16 steer = 0xff80 + m_steer.read_safe(0);
switch (port)
{
@ -207,8 +207,8 @@ READ8_MEMBER(topspeed_state::input_bypass_r)
CUSTOM_INPUT_MEMBER(topspeed_state::pedal_r)
{
static const UINT8 retval[8] = { 0,1,3,2,6,7,5,4 };
const char *tag = (const char *)param;
return retval[read_safe(ioport(tag), 0) & 7];
ioport_port *port = ioport((const char *)param);
return retval[port != nullptr ? port->read() & 7 : 0];
}
READ16_MEMBER(topspeed_state::motor_r)

View File

@ -1484,7 +1484,7 @@ WRITE32_MEMBER( vegas_state::analog_port_w )
{
if (data < 8 || data > 15)
logerror("%08X:Unexpected analog port select = %08X\n", safe_pc(), data);
m_pending_analog_read = m_io_analog[data & 7] ? m_io_analog[data & 7]->read() : 0;
m_pending_analog_read = m_io_analog[data & 7].read_safe(0);
}

View File

@ -191,7 +191,7 @@ CUSTOM_INPUT_MEMBER(vicdual_state::get_timer_value)
int vicdual_state::is_cabinet_color()
{
return ((m_color_bw ? m_color_bw->read() : 0) & 1) ? 0 : 1;
return (m_color_bw.read_safe(0) & 1) ? 0 : 1;
}
@ -1303,7 +1303,7 @@ CUSTOM_INPUT_MEMBER(vicdual_state::fake_lives_r)
/* and use d8 for the port */
int port = ((FPTR)param) >> 8 & 1;
return ((m_fake_lives[port] ? m_fake_lives[port]->read() : 0) & bit_mask) ? 0 : 1;
return (m_fake_lives[port].read_safe(0) & bit_mask) ? 0 : 1;
}

View File

@ -158,7 +158,7 @@ READ8_MEMBER(warpwarp_state::geebee_in_r)
int res;
offset &= 3;
res = m_ports[offset] ? m_ports[offset]->read() : 0;
res = m_ports[offset].read_safe(0);
if (offset == 3)
{
res = (flip_screen() & 1) ? m_in2->read() : m_in1->read(); // read player 2 input in cocktail mode

View File

@ -517,12 +517,12 @@ WRITE16_MEMBER(wgp_state::rotate_port_w)
READ16_MEMBER(wgp_state::wgp_adinput_r)
{
int steer = 0x40;
int fake = m_fake ? m_fake->read() : 0;
int fake = m_fake.read_safe(0);
if (!(fake & 0x10)) /* Analogue steer (the real control method) */
{
/* Reduce span to 0x80 */
steer = ((m_steer ? m_steer->read() : 0) * 0x80) / 0x100;
steer = (m_steer.read_safe(0) * 0x80) / 0x100;
}
else /* Digital steer */
{
@ -567,7 +567,7 @@ READ16_MEMBER(wgp_state::wgp_adinput_r)
}
case 0x05:
return m_unknown ? m_unknown->read() : 0; /* unknown */
return m_unknown.read_safe(0); /* unknown */
}
logerror("CPU #0 PC %06x: warning - read unmapped a/d input offset %06x\n",space.device().safe_pc(),offset);

View File

@ -27,7 +27,9 @@ public:
m_eeprom(*this, "eeprom"),
m_sn(*this, "snsnd"),
m_screen(*this, "screen"),
m_palette(*this, "palette")
m_palette(*this, "palette"),
m_gunx(*this, "GUNX"),
m_guny(*this, "GUNY")
{ }
/* devices/memory pointers */
@ -41,6 +43,8 @@ public:
optional_device<palette_device> m_palette;
/* misc game specific */
optional_ioport m_gunx;
optional_ioport m_guny;
UINT8 m_color_map;
UINT8 m_screen_red;
UINT8 m_fleet_step;

View File

@ -347,8 +347,7 @@ public:
m_potgo_port(*this, "potgo"),
m_pot0dat_port(*this, "POT0DAT"),
m_pot1dat_port(*this, "POT1DAT"),
m_p1joy_port(*this, "p1_joy"),
m_p2joy_port(*this, "p2_joy"),
m_joy_ports(*this, {"p1_joy", "p2_joy"}),
m_p1_mouse_x(*this, "p1_mouse_x"),
m_p1_mouse_y(*this, "p1_mouse_y"),
m_p2_mouse_x(*this, "p2_mouse_x"),
@ -576,8 +575,7 @@ protected:
optional_ioport m_potgo_port;
optional_ioport m_pot0dat_port;
optional_ioport m_pot1dat_port;
optional_ioport m_p1joy_port;
optional_ioport m_p2joy_port;
optional_ioport_array<2> m_joy_ports;
optional_ioport m_p1_mouse_x;
optional_ioport m_p1_mouse_y;
optional_ioport m_p2_mouse_x;

View File

@ -17,6 +17,7 @@ public:
m_videoram(*this, "videoram"),
m_astrof_color(*this, "astrof_color"),
m_tomahawk_protection(*this, "tomahawk_prot"),
m_fake_port(*this, "FAKE"),
m_maincpu(*this, "maincpu"),
m_samples(*this, "samples"),
m_sn(*this, "snsnd"),
@ -28,6 +29,7 @@ public:
std::unique_ptr<UINT8[]> m_colorram;
required_shared_ptr<UINT8> m_astrof_color;
optional_shared_ptr<UINT8> m_tomahawk_protection;
optional_ioport m_fake_port;
UINT8 m_astrof_palette_bank;
UINT8 m_red_on;

View File

@ -102,7 +102,8 @@ public:
m_via_system_irq(CLEAR_LINE),
m_via_user_irq(CLEAR_LINE),
m_acia_irq(CLEAR_LINE),
m_palette(*this, "palette")
m_palette(*this, "palette"),
m_bbcconfig(*this, "BBCCONFIG")
{ }
DECLARE_FLOPPY_FORMATS(floppy_formats_bbc);
@ -445,6 +446,7 @@ public: // HACK FOR MC6845
void bbc_update_nmi();
unsigned int calculate_video_address(int ma,int ra);
required_device<palette_device> m_palette;
optional_ioport m_bbcconfig;
};
#endif /* BBC_H_ */

Some files were not shown because too many files have changed in this diff Show More