ins8154_device: converted to devcb2 (nw)

This commit is contained in:
Ivan Vangelista 2014-04-02 17:27:11 +00:00
parent 64716ba840
commit 157f86298c
5 changed files with 56 additions and 100 deletions

View File

@ -44,38 +44,15 @@ const device_type INS8154 = &device_creator<ins8154_device>;
//------------------------------------------------- //-------------------------------------------------
ins8154_device::ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) 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<const ins8154_interface *>(static_config());
if (intf != NULL)
{
*static_cast<ins8154_interface *>(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 // device_start - device-specific startup
//------------------------------------------------- //-------------------------------------------------
@ -83,11 +60,11 @@ void ins8154_device::device_config_complete()
void ins8154_device::device_start() void ins8154_device::device_start()
{ {
/* resolve callbacks */ /* resolve callbacks */
m_in_a_func.resolve(m_in_a_cb, *this); m_in_a_cb.resolve();
m_out_a_func.resolve(m_out_a_cb, *this); m_out_a_cb.resolve_safe();
m_in_b_func.resolve(m_in_b_cb, *this); m_in_b_cb.resolve();
m_out_b_func.resolve(m_out_b_cb, *this); m_out_b_cb.resolve_safe();
m_out_irq_func.resolve(m_out_irq_cb, *this); m_out_irq_cb.resolve_safe();
/* register for state saving */ /* register for state saving */
save_item(NAME(m_in_a)); save_item(NAME(m_in_a));
@ -132,17 +109,17 @@ READ8_MEMBER(ins8154_device::ins8154_r)
switch (offset) switch (offset)
{ {
case 0x20: 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; m_in_a = val;
break; break;
case 0x21: 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; m_in_b = val;
break; break;
@ -150,17 +127,17 @@ READ8_MEMBER(ins8154_device::ins8154_r)
default: default:
if (offset < 0x08) 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; m_in_a = val;
} }
else 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; m_in_b = val;
} }
@ -177,7 +154,7 @@ WRITE8_MEMBER(ins8154_device::ins8154_porta_w)
/* Test if any pins are set as outputs */ /* Test if any pins are set as outputs */
if (m_odra) 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 */ /* Test if any pins are set as outputs */
if (m_odrb) 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));
} }
} }

View File

@ -44,38 +44,39 @@
DEVICE CONFIGURATION MACROS DEVICE CONFIGURATION MACROS
***************************************************************************/ ***************************************************************************/
#define MCFG_INS8154_ADD(_tag, _intrf) \ #define MCFG_INS8154_IN_A_CB(_devcb) \
MCFG_DEVICE_ADD(_tag, INS8154, 0) \ devcb = &ins8154_device::set_in_a_callback(*device, DEVCB2_##_devcb);
MCFG_DEVICE_CONFIG(_intrf)
#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 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 // ======================> ins8154_device
class ins8154_device : public device_t, class ins8154_device : public device_t
public ins8154_interface
{ {
public: public:
// construction/destruction // construction/destruction
ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
template<class _Object> static devcb2_base &set_in_a_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_in_a_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_a_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_a_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_in_b_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_in_b_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_b_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_b_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_irq_cb.set_callback(object); }
DECLARE_READ8_MEMBER( ins8154_r ); DECLARE_READ8_MEMBER( ins8154_r );
DECLARE_WRITE8_MEMBER( ins8154_w ); DECLARE_WRITE8_MEMBER( ins8154_w );
@ -84,7 +85,6 @@ public:
protected: protected:
// device-level overrides // device-level overrides
virtual void device_config_complete();
virtual void device_start(); virtual void device_start();
virtual void device_reset(); virtual void device_reset();
virtual void device_post_load() { } virtual void device_post_load() { }
@ -93,11 +93,11 @@ protected:
private: private:
/* i/o lines */ /* i/o lines */
devcb_resolved_read8 m_in_a_func; devcb2_read8 m_in_a_cb;
devcb_resolved_write8 m_out_a_func; devcb2_write8 m_out_a_cb;
devcb_resolved_read8 m_in_b_func; devcb2_read8 m_in_b_cb;
devcb_resolved_write8 m_out_b_func; devcb2_write8 m_out_b_cb;
devcb_resolved_write_line m_out_irq_func; devcb2_write_line m_out_irq_cb;
/* registers */ /* registers */
UINT8 m_in_a; /* Input Latch Port A */ UINT8 m_in_a; /* Input Latch Port A */

View File

@ -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 = static const ay8910_interface ay8910_inf =
{ {
AY8910_LEGACY_OUTPUT, AY8910_LEGACY_OUTPUT,
@ -843,7 +833,11 @@ static MACHINE_CONFIG_START( vega, vega_state )
MCFG_I8255A_ADD( "ppi8255", ppi8255_intf ) 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 */ /* video hardware */
MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_ADD("screen", RASTER)

View File

@ -233,15 +233,6 @@ INPUT_PORTS_END
MACHINE DRIVERS 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 ) static MACHINE_CONFIG_START( acrnsys1, acrnsys1_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, 1008000) /* 1.008 MHz */ 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) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
/* devices */ /* 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_DEVICE_ADD("ic8_7445", TTL74145, 0)
MCFG_CASSETTE_ADD( "cassette", default_cassette_interface ) MCFG_CASSETTE_ADD( "cassette", default_cassette_interface )
MCFG_TIMER_DRIVER_ADD_PERIODIC("acrnsys1_c", acrnsys1_state, acrnsys1_c, attotime::from_hz(4800)) MCFG_TIMER_DRIVER_ADD_PERIODIC("acrnsys1_c", acrnsys1_state, acrnsys1_c, attotime::from_hz(4800))

View File

@ -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 ) static MACHINE_CONFIG_START( mk14, mk14_state )
/* basic machine hardware */ /* basic machine hardware */
// IC1 1SP-8A/600 (8060) SC/MP Microprocessor // IC1 1SP-8A/600 (8060) SC/MP Microprocessor
@ -154,7 +145,7 @@ static MACHINE_CONFIG_START( mk14, mk14_state )
MCFG_DEFAULT_LAYOUT(layout_mk14) MCFG_DEFAULT_LAYOUT(layout_mk14)
/* devices */ /* devices */
MCFG_INS8154_ADD("ic8", mk14_ins8154) MCFG_DEVICE_ADD("ic8", INS8154, 0)
MACHINE_CONFIG_END MACHINE_CONFIG_END
/* ROM definition */ /* ROM definition */