diff --git a/src/emu/machine/ins8154.c b/src/emu/machine/ins8154.c index 45ca7143f9e..1e4124e7f3f 100644 --- a/src/emu/machine/ins8154.c +++ b/src/emu/machine/ins8154.c @@ -44,38 +44,15 @@ const device_type INS8154 = &device_creator; //------------------------------------------------- ins8154_device::ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, INS8154, "INS8154", tag, owner, clock, "ins8154", __FILE__) + : device_t(mconfig, INS8154, "INS8154", tag, owner, clock, "ins8154", __FILE__), + m_in_a_cb(*this), + m_out_a_cb(*this), + m_in_b_cb(*this), + m_out_b_cb(*this), + m_out_irq_cb(*this) { } - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void ins8154_device::device_config_complete() -{ - // inherit a copy of the static data - const ins8154_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - { - *static_cast(this) = *intf; - } - - // or initialize to defaults if none provided - else - { - memset(&m_in_a_cb, 0, sizeof(m_in_a_cb)); - memset(&m_in_b_cb, 0, sizeof(m_in_b_cb)); - memset(&m_out_a_cb, 0, sizeof(m_out_a_cb)); - memset(&m_out_b_cb, 0, sizeof(m_out_b_cb)); - memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb)); - } -} - - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -83,11 +60,11 @@ void ins8154_device::device_config_complete() void ins8154_device::device_start() { /* resolve callbacks */ - m_in_a_func.resolve(m_in_a_cb, *this); - m_out_a_func.resolve(m_out_a_cb, *this); - m_in_b_func.resolve(m_in_b_cb, *this); - m_out_b_func.resolve(m_out_b_cb, *this); - m_out_irq_func.resolve(m_out_irq_cb, *this); + m_in_a_cb.resolve(); + m_out_a_cb.resolve_safe(); + m_in_b_cb.resolve(); + m_out_b_cb.resolve_safe(); + m_out_irq_cb.resolve_safe(); /* register for state saving */ save_item(NAME(m_in_a)); @@ -132,17 +109,17 @@ READ8_MEMBER(ins8154_device::ins8154_r) switch (offset) { case 0x20: - if(!m_in_a_func.isnull()) + if(!m_in_a_cb.isnull()) { - val = m_in_a_func(0); + val = m_in_a_cb(0); } m_in_a = val; break; case 0x21: - if(!m_in_b_func.isnull()) + if(!m_in_b_cb.isnull()) { - val = m_in_b_func(0); + val = m_in_b_cb(0); } m_in_b = val; break; @@ -150,17 +127,17 @@ READ8_MEMBER(ins8154_device::ins8154_r) default: if (offset < 0x08) { - if(!m_in_a_func.isnull()) + if(!m_in_a_cb.isnull()) { - val = (m_in_a_func(0) << (8 - offset)) & 0x80; + val = (m_in_a_cb(0) << (8 - offset)) & 0x80; } m_in_a = val; } else { - if(!m_in_b_func.isnull()) + if(!m_in_b_cb.isnull()) { - val = (m_in_b_func(0) << (8 - (offset >> 4))) & 0x80; + val = (m_in_b_cb(0) << (8 - (offset >> 4))) & 0x80; } m_in_b = val; } @@ -177,7 +154,7 @@ WRITE8_MEMBER(ins8154_device::ins8154_porta_w) /* Test if any pins are set as outputs */ if (m_odra) { - m_out_a_func(0, (data & m_odra) | (m_odra ^ 0xff)); + m_out_a_cb((offs_t)0, (data & m_odra) | (m_odra ^ 0xff)); } } @@ -188,7 +165,7 @@ WRITE8_MEMBER(ins8154_device::ins8154_portb_w) /* Test if any pins are set as outputs */ if (m_odrb) { - m_out_b_func(0, (data & m_odrb) | (m_odrb ^ 0xff)); + m_out_b_cb((offs_t)0, (data & m_odrb) | (m_odrb ^ 0xff)); } } diff --git a/src/emu/machine/ins8154.h b/src/emu/machine/ins8154.h index eef4aebffe9..4c836c9e6c6 100644 --- a/src/emu/machine/ins8154.h +++ b/src/emu/machine/ins8154.h @@ -44,38 +44,39 @@ DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MCFG_INS8154_ADD(_tag, _intrf) \ - MCFG_DEVICE_ADD(_tag, INS8154, 0) \ - MCFG_DEVICE_CONFIG(_intrf) +#define MCFG_INS8154_IN_A_CB(_devcb) \ + devcb = &ins8154_device::set_in_a_callback(*device, DEVCB2_##_devcb); + +#define MCFG_INS8154_OUT_A_CB(_devcb) \ + devcb = &ins8154_device::set_out_a_callback(*device, DEVCB2_##_devcb); + +#define MCFG_INS8154_IN_B_CB(_devcb) \ + devcb = &ins8154_device::set_in_b_callback(*device, DEVCB2_##_devcb); + +#define MCFG_INS8154_OUT_B_CB(_devcb) \ + devcb = &ins8154_device::set_out_b_callback(*device, DEVCB2_##_devcb); +#define MCFG_INS8154_OUT_IRQ_CB(_devcb) \ + devcb = &ins8154_device::set_out_irq_callback(*device, DEVCB2_##_devcb); //currently unused /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ - -// ======================> ins8154_interface - -struct ins8154_interface -{ - devcb_read8 m_in_a_cb; - devcb_write8 m_out_a_cb; - devcb_read8 m_in_b_cb; - devcb_write8 m_out_b_cb; - devcb_write_line m_out_irq_cb; -}; - - - // ======================> ins8154_device -class ins8154_device : public device_t, - public ins8154_interface +class ins8154_device : public device_t { public: // construction/destruction ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + template static devcb2_base &set_in_a_callback(device_t &device, _Object object) { return downcast(device).m_in_a_cb.set_callback(object); } + template static devcb2_base &set_out_a_callback(device_t &device, _Object object) { return downcast(device).m_out_a_cb.set_callback(object); } + template static devcb2_base &set_in_b_callback(device_t &device, _Object object) { return downcast(device).m_in_b_cb.set_callback(object); } + template static devcb2_base &set_out_b_callback(device_t &device, _Object object) { return downcast(device).m_out_b_cb.set_callback(object); } + template static devcb2_base &set_out_irq_callback(device_t &device, _Object object) { return downcast(device).m_out_irq_cb.set_callback(object); } + DECLARE_READ8_MEMBER( ins8154_r ); DECLARE_WRITE8_MEMBER( ins8154_w ); @@ -84,7 +85,6 @@ public: protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); virtual void device_post_load() { } @@ -93,11 +93,11 @@ protected: private: /* i/o lines */ - devcb_resolved_read8 m_in_a_func; - devcb_resolved_write8 m_out_a_func; - devcb_resolved_read8 m_in_b_func; - devcb_resolved_write8 m_out_b_func; - devcb_resolved_write_line m_out_irq_func; + devcb2_read8 m_in_a_cb; + devcb2_write8 m_out_a_cb; + devcb2_read8 m_in_b_cb; + devcb2_write8 m_out_b_cb; + devcb2_write_line m_out_irq_cb; /* registers */ UINT8 m_in_a; /* Input Latch Port A */ diff --git a/src/mame/drivers/vega.c b/src/mame/drivers/vega.c index 6826911c973..32eb06d18ad 100644 --- a/src/mame/drivers/vega.c +++ b/src/mame/drivers/vega.c @@ -807,16 +807,6 @@ static I8255A_INTERFACE( ppi8255_intf ) }; -static const ins8154_interface ins8154_intf = -{ - DEVCB_DRIVER_MEMBER(vega_state, ins8154_pa_r), - DEVCB_DRIVER_MEMBER(vega_state, ins8154_pa_w), - DEVCB_DRIVER_MEMBER(vega_state, ins8154_pb_r), - DEVCB_DRIVER_MEMBER(vega_state, ins8154_pb_w), - DEVCB_NULL -}; - - static const ay8910_interface ay8910_inf = { AY8910_LEGACY_OUTPUT, @@ -843,7 +833,11 @@ static MACHINE_CONFIG_START( vega, vega_state ) MCFG_I8255A_ADD( "ppi8255", ppi8255_intf ) - MCFG_INS8154_ADD( "ins8154", ins8154_intf) + MCFG_DEVICE_ADD( "ins8154", INS8154, 0 ) + MCFG_INS8154_IN_A_CB(READ8(vega_state, ins8154_pa_r)) + MCFG_INS8154_OUT_A_CB(WRITE8(vega_state, ins8154_pa_w)) + MCFG_INS8154_IN_B_CB(READ8(vega_state, ins8154_pb_r)) + MCFG_INS8154_OUT_B_CB(WRITE8(vega_state, ins8154_pb_w)) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) diff --git a/src/mess/drivers/acrnsys1.c b/src/mess/drivers/acrnsys1.c index dfc09ba8ef3..3bf65b72396 100644 --- a/src/mess/drivers/acrnsys1.c +++ b/src/mess/drivers/acrnsys1.c @@ -233,15 +233,6 @@ INPUT_PORTS_END MACHINE DRIVERS ***************************************************************************/ -static const ins8154_interface ins8154_b1 = -{ - DEVCB_DRIVER_MEMBER(acrnsys1_state, ins8154_b1_port_a_r), - DEVCB_DRIVER_MEMBER(acrnsys1_state, ins8154_b1_port_a_w), - DEVCB_NULL, - DEVCB_DRIVER_MEMBER(acrnsys1_state, acrnsys1_led_segment_w), - DEVCB_NULL -}; - static MACHINE_CONFIG_START( acrnsys1, acrnsys1_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M6502, 1008000) /* 1.008 MHz */ @@ -255,7 +246,10 @@ static MACHINE_CONFIG_START( acrnsys1, acrnsys1_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) /* devices */ - MCFG_INS8154_ADD("b1", ins8154_b1) + MCFG_DEVICE_ADD("b1", INS8154, 0) + MCFG_INS8154_IN_A_CB(READ8(acrnsys1_state, ins8154_b1_port_a_r)) + MCFG_INS8154_OUT_A_CB(WRITE8(acrnsys1_state, ins8154_b1_port_a_w)) + MCFG_INS8154_OUT_B_CB(WRITE8(acrnsys1_state, acrnsys1_led_segment_w)) MCFG_DEVICE_ADD("ic8_7445", TTL74145, 0) MCFG_CASSETTE_ADD( "cassette", default_cassette_interface ) MCFG_TIMER_DRIVER_ADD_PERIODIC("acrnsys1_c", acrnsys1_state, acrnsys1_c, attotime::from_hz(4800)) diff --git a/src/mess/drivers/mk14.c b/src/mess/drivers/mk14.c index b386b8169ec..9927ef7e070 100644 --- a/src/mess/drivers/mk14.c +++ b/src/mess/drivers/mk14.c @@ -134,15 +134,6 @@ void mk14_state::machine_reset() { } -static const ins8154_interface mk14_ins8154 = -{ - DEVCB_NULL, - DEVCB_NULL, - DEVCB_NULL, - DEVCB_NULL, - DEVCB_NULL -}; - static MACHINE_CONFIG_START( mk14, mk14_state ) /* basic machine hardware */ // IC1 1SP-8A/600 (8060) SC/MP Microprocessor @@ -154,7 +145,7 @@ static MACHINE_CONFIG_START( mk14, mk14_state ) MCFG_DEFAULT_LAYOUT(layout_mk14) /* devices */ - MCFG_INS8154_ADD("ic8", mk14_ins8154) + MCFG_DEVICE_ADD("ic8", INS8154, 0) MACHINE_CONFIG_END /* ROM definition */