mirror of
https://github.com/holub/mame
synced 2025-05-25 23:35:26 +03:00
lh5810_device: converted to devcb2 (nw)
This commit is contained in:
parent
880613a70a
commit
a19ec24775
@ -19,33 +19,6 @@
|
||||
|
||||
const device_type LH5810 = &device_creator<lh5810_device>;
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void lh5810_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const lh5810_interface *intf = reinterpret_cast<const lh5810_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<lh5810_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_porta_r_cb, 0, sizeof(m_porta_r_cb));
|
||||
memset(&m_porta_w_cb, 0, sizeof(m_porta_w_cb));
|
||||
memset(&m_portb_r_cb, 0, sizeof(m_portb_r_cb));
|
||||
memset(&m_portb_w_cb, 0, sizeof(m_portb_w_cb));
|
||||
memset(&m_portc_w_cb, 0, sizeof(m_portc_w_cb));
|
||||
memset(&m_out_int_cb, 0, sizeof(m_out_int_cb));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
@ -55,7 +28,13 @@ void lh5810_device::device_config_complete()
|
||||
//-------------------------------------------------
|
||||
|
||||
lh5810_device::lh5810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, LH5810, "LH5810", tag, owner, clock, "lh5810", __FILE__)
|
||||
: device_t(mconfig, LH5810, "LH5810", tag, owner, clock, "lh5810", __FILE__),
|
||||
m_porta_r_cb(*this),
|
||||
m_porta_w_cb(*this),
|
||||
m_portb_r_cb(*this),
|
||||
m_portb_w_cb(*this),
|
||||
m_portc_w_cb(*this),
|
||||
m_out_int_cb(*this)
|
||||
{
|
||||
}
|
||||
|
||||
@ -67,12 +46,12 @@ lh5810_device::lh5810_device(const machine_config &mconfig, const char *tag, dev
|
||||
void lh5810_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
m_porta_r_func.resolve(m_porta_r_cb, *this);
|
||||
m_porta_w_func.resolve(m_porta_w_cb, *this);
|
||||
m_portb_r_func.resolve(m_portb_r_cb, *this);
|
||||
m_portb_w_func.resolve(m_portb_w_cb, *this);
|
||||
m_portc_w_func.resolve(m_portc_w_cb, *this);
|
||||
m_out_int_func.resolve(m_out_int_cb, *this);
|
||||
m_porta_r_cb.resolve_safe(0);
|
||||
m_porta_w_cb.resolve_safe();
|
||||
m_portb_r_cb.resolve_safe(0);
|
||||
m_portb_w_cb.resolve_safe();
|
||||
m_portc_w_cb.resolve_safe();
|
||||
m_out_int_cb.resolve_safe();
|
||||
|
||||
// register for state saving
|
||||
save_item(NAME(m_irq));
|
||||
@ -109,7 +88,7 @@ READ8_MEMBER( lh5810_device::data_r )
|
||||
return m_reg[offset];
|
||||
|
||||
case LH5810_IF:
|
||||
if (BIT(m_portb_r_func(0) & ~m_reg[LH5810_DDB], 7))
|
||||
if (BIT(m_portb_r_cb(0) & ~m_reg[LH5810_DDB], 7))
|
||||
m_reg[offset] |= 2;
|
||||
else
|
||||
m_reg[offset] &= 0xfd;
|
||||
@ -120,12 +99,12 @@ READ8_MEMBER( lh5810_device::data_r )
|
||||
return (m_reg[offset]&0x0f) | (m_irq<<4) | (BIT(m_reg[LH5810_OPB],7)<<5);
|
||||
|
||||
case LH5810_OPA:
|
||||
m_reg[offset] = (m_reg[offset] & m_reg[LH5810_DDA]) | (m_porta_r_func(0) & ~m_reg[LH5810_DDA]);
|
||||
m_reg[offset] = (m_reg[offset] & m_reg[LH5810_DDA]) | (m_porta_r_cb(0) & ~m_reg[LH5810_DDA]);
|
||||
return m_reg[offset];
|
||||
|
||||
case LH5810_OPB:
|
||||
m_reg[offset] = (m_reg[offset] & m_reg[LH5810_DDB]) | (m_portb_r_func(0) & ~m_reg[LH5810_DDB]);
|
||||
m_out_int_func((m_reg[offset] & 0x80 && m_reg[LH5810_MSK] & 0x02) ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_reg[offset] = (m_reg[offset] & m_reg[LH5810_DDB]) | (m_portb_r_cb(0) & ~m_reg[LH5810_DDB]);
|
||||
m_out_int_cb((m_reg[offset] & 0x80 && m_reg[LH5810_MSK] & 0x02) ? ASSERT_LINE : CLEAR_LINE);
|
||||
return m_reg[offset];
|
||||
|
||||
default:
|
||||
@ -175,18 +154,18 @@ WRITE8_MEMBER( lh5810_device::data_w )
|
||||
|
||||
case LH5810_OPA:
|
||||
m_reg[offset] = (data & m_reg[LH5810_DDA]) | (m_reg[offset] & ~m_reg[LH5810_DDA]);
|
||||
m_porta_w_func(0, m_reg[offset]);
|
||||
m_porta_w_cb((offs_t)0, m_reg[offset]);
|
||||
break;
|
||||
|
||||
case LH5810_OPB:
|
||||
m_reg[offset] = (data & m_reg[LH5810_DDB]) | (m_reg[offset] & ~m_reg[LH5810_DDB]);
|
||||
m_portb_w_func(0, m_reg[offset]);
|
||||
m_out_int_func((m_reg[offset] & 0x80 && m_reg[LH5810_MSK] & 0x02) ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_portb_w_cb((offs_t)0, m_reg[offset]);
|
||||
m_out_int_cb((m_reg[offset] & 0x80 && m_reg[LH5810_MSK] & 0x02) ? ASSERT_LINE : CLEAR_LINE);
|
||||
break;
|
||||
|
||||
case LH5810_OPC:
|
||||
m_reg[offset] = data;
|
||||
m_portc_w_func(0, m_reg[offset]);
|
||||
m_portc_w_cb((offs_t)0, m_reg[offset]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +38,23 @@ enum
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//*************************************************************************
|
||||
|
||||
#define MCFG_LH5810_ADD(_tag, _config) \
|
||||
MCFG_DEVICE_ADD((_tag), LH5810, 0) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
#define MCFG_LH5810_PORTA_R_CB(_devcb) \
|
||||
devcb = &lh5810_device::set_porta_r_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_LH5810_PORTA_W_CB(_devcb) \
|
||||
devcb = &lh5810_device::set_porta_w_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_LH5810_PORTB_R_CB(_devcb) \
|
||||
devcb = &lh5810_device::set_portb_r_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_LH5810_PORTB_W_CB(_devcb) \
|
||||
devcb = &lh5810_device::set_portb_w_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_LH5810_PORTC_W_CB(_devcb) \
|
||||
devcb = &lh5810_device::set_portc_w_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_LH5810_OUT_INT_CB(_devcb) \
|
||||
devcb = &lh5810_device::set_out_int_callback(*device, DEVCB2_##_devcb); //currently unused
|
||||
|
||||
|
||||
|
||||
@ -48,28 +62,21 @@ enum
|
||||
// TYPE DEFINITIONS
|
||||
//*************************************************************************
|
||||
|
||||
// ======================> lh5810_interface
|
||||
|
||||
struct lh5810_interface
|
||||
{
|
||||
devcb_read8 m_porta_r_cb; //port A read
|
||||
devcb_write8 m_porta_w_cb; //port A write
|
||||
devcb_read8 m_portb_r_cb; //port B read
|
||||
devcb_write8 m_portb_w_cb; //port B write
|
||||
devcb_write8 m_portc_w_cb; //port C write
|
||||
|
||||
devcb_write_line m_out_int_cb; //IRQ callback
|
||||
};
|
||||
|
||||
// ======================> lh5810_device
|
||||
|
||||
class lh5810_device : public device_t,
|
||||
public lh5810_interface
|
||||
class lh5810_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
lh5810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
template<class _Object> static devcb2_base &set_porta_r_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_porta_r_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_porta_w_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_porta_w_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_portb_r_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_portb_r_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_portb_w_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_portb_w_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_portc_w_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_portc_w_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_out_int_callback(device_t &device, _Object object) { return downcast<lh5810_device &>(device).m_out_int_cb.set_callback(object); }
|
||||
|
||||
DECLARE_READ8_MEMBER( data_r );
|
||||
DECLARE_WRITE8_MEMBER( data_w );
|
||||
|
||||
@ -77,16 +84,16 @@ protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_config_complete();
|
||||
|
||||
private:
|
||||
|
||||
devcb_resolved_read8 m_porta_r_func;
|
||||
devcb_resolved_write8 m_porta_w_func;
|
||||
devcb_resolved_read8 m_portb_r_func;
|
||||
devcb_resolved_write8 m_portb_w_func;
|
||||
devcb_resolved_write8 m_portc_w_func;
|
||||
devcb_resolved_write_line m_out_int_func;
|
||||
devcb2_read8 m_porta_r_cb; //port A read
|
||||
devcb2_write8 m_porta_w_cb; //port A write
|
||||
devcb2_read8 m_portb_r_cb; //port B read
|
||||
devcb2_write8 m_portb_w_cb; //port B write
|
||||
devcb2_write8 m_portc_w_cb; //port C write
|
||||
|
||||
devcb2_write_line m_out_int_cb; //IRQ callback
|
||||
|
||||
UINT8 m_reg[0x10];
|
||||
UINT8 m_irq;
|
||||
|
@ -264,16 +264,6 @@ PALETTE_INIT_MEMBER(pc1500_state, pc1500)
|
||||
palette.set_pen_color(1, rgb_t(92, 83, 88));
|
||||
}
|
||||
|
||||
static const lh5810_interface lh5810_pc1500_config =
|
||||
{
|
||||
DEVCB_DRIVER_MEMBER(pc1500_state, port_a_r), //port A read
|
||||
DEVCB_DRIVER_MEMBER(pc1500_state, kb_matrix_w), //port A write
|
||||
DEVCB_DRIVER_MEMBER(pc1500_state, port_b_r), //port B read
|
||||
DEVCB_NULL, //port B write
|
||||
DEVCB_DRIVER_MEMBER(pc1500_state, port_c_w), //port C write
|
||||
DEVCB_CPU_INPUT_LINE("maincpu", LH5801_LINE_MI) //IRQ callback
|
||||
};
|
||||
|
||||
static MACHINE_CONFIG_START( pc1500, pc1500_state )
|
||||
MCFG_CPU_ADD("maincpu", LH5801, 1300000) //1.3 MHz
|
||||
MCFG_CPU_PROGRAM_MAP( pc1500_mem )
|
||||
@ -292,7 +282,12 @@ static MACHINE_CONFIG_START( pc1500, pc1500_state )
|
||||
MCFG_PALETTE_ADD("palette", 2)
|
||||
MCFG_PALETTE_INIT_OWNER(pc1500_state, pc1500)
|
||||
|
||||
MCFG_LH5810_ADD("lh5810", lh5810_pc1500_config)
|
||||
MCFG_DEVICE_ADD("lh5810", LH5810, 0)
|
||||
MCFG_LH5810_PORTA_R_CB(READ8(pc1500_state, port_a_r))
|
||||
MCFG_LH5810_PORTA_W_CB(WRITE8(pc1500_state, kb_matrix_w))
|
||||
MCFG_LH5810_PORTB_R_CB(READ8(pc1500_state, port_b_r))
|
||||
MCFG_LH5810_PORTC_W_CB(WRITE8(pc1500_state, port_c_w))
|
||||
MCFG_LH5810_OUT_INT_CB(INPUTLINE("maincpu", LH5801_LINE_MI))
|
||||
|
||||
MCFG_UPD1990A_ADD("upd1990a", XTAL_32_768kHz, NULL, NULL)
|
||||
MACHINE_CONFIG_END
|
||||
|
Loading…
Reference in New Issue
Block a user