mirror of
https://github.com/holub/mame
synced 2025-04-23 08:49:55 +03:00
i8212: devcb2. (nw)
This commit is contained in:
parent
84ecd31bfa
commit
73dc290a50
@ -33,37 +33,17 @@ const device_type I8212 = &device_creator<i8212_device>;
|
||||
// i8212_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
i8212_device::i8212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, I8212, "Intel 8212", tag, owner, clock, "i8212", __FILE__),
|
||||
m_md(I8212_MODE_INPUT),
|
||||
m_stb(0)
|
||||
i8212_device::i8212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, I8212, "I8212", tag, owner, clock, "i8212", __FILE__),
|
||||
m_write_irq(*this),
|
||||
m_read_di(*this),
|
||||
m_write_do(*this),
|
||||
m_md(I8212_MODE_INPUT),
|
||||
m_stb(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void i8212_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const i8212_interface *intf = reinterpret_cast<const i8212_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<i8212_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_out_int_cb, 0, sizeof(m_out_int_cb));
|
||||
memset(&m_in_di_cb, 0, sizeof(m_in_di_cb));
|
||||
memset(&m_out_do_cb, 0, sizeof(m_out_do_cb));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
@ -71,9 +51,9 @@ void i8212_device::device_config_complete()
|
||||
void i8212_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
m_out_int_func.resolve(m_out_int_cb, *this);
|
||||
m_in_di_func.resolve(m_in_di_cb, *this);
|
||||
m_out_do_func.resolve(m_out_do_cb, *this);
|
||||
m_write_irq.resolve_safe();
|
||||
m_read_di.resolve_safe(0);
|
||||
m_write_do.resolve_safe();
|
||||
|
||||
// register for state saving
|
||||
save_item(NAME(m_md));
|
||||
@ -93,19 +73,19 @@ void i8212_device::device_reset()
|
||||
if (m_md == I8212_MODE_OUTPUT)
|
||||
{
|
||||
// output data
|
||||
m_out_do_func(0, m_data);
|
||||
m_write_do((offs_t)0, m_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// data_r - data latch read
|
||||
// read - data latch read
|
||||
//-------------------------------------------------
|
||||
|
||||
READ8_MEMBER( i8212_device::data_r )
|
||||
READ8_MEMBER( i8212_device::read )
|
||||
{
|
||||
// clear interrupt line
|
||||
m_out_int_func(CLEAR_LINE);
|
||||
m_write_irq(CLEAR_LINE);
|
||||
|
||||
if (LOG) logerror("I8212 '%s' INT: %u\n", tag(), CLEAR_LINE);
|
||||
|
||||
@ -114,16 +94,16 @@ READ8_MEMBER( i8212_device::data_r )
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// data_w - data latch write
|
||||
// write - data latch write
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER( i8212_device::data_w )
|
||||
WRITE8_MEMBER( i8212_device::write )
|
||||
{
|
||||
// latch data
|
||||
m_data = data;
|
||||
|
||||
// output data
|
||||
m_out_do_func(0, m_data);
|
||||
m_write_do((offs_t)0, m_data);
|
||||
}
|
||||
|
||||
|
||||
@ -152,10 +132,10 @@ WRITE_LINE_MEMBER( i8212_device::stb_w )
|
||||
if (m_stb && !state)
|
||||
{
|
||||
// input data
|
||||
m_data = m_in_di_func(0);
|
||||
m_data = m_read_di(0);
|
||||
|
||||
// assert interrupt line
|
||||
m_out_int_func(ASSERT_LINE);
|
||||
m_write_irq(ASSERT_LINE);
|
||||
|
||||
if (LOG) logerror("I8212 '%s' INT: %u\n", tag(), ASSERT_LINE);
|
||||
}
|
||||
|
@ -49,12 +49,14 @@ enum
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
///*************************************************************************
|
||||
|
||||
#define MCFG_I8212_ADD(_tag, _config) \
|
||||
MCFG_DEVICE_ADD((_tag), I8212, 0) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
#define MCFG_I8212_IRQ_CALLBACK(_write) \
|
||||
devcb = &i8212_device::set_irq_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define I8212_INTERFACE(name) \
|
||||
const i8212_interface (name) =
|
||||
#define MCFG_I8212_DI_CALLBACK(_read) \
|
||||
devcb = &i8212_device::set_di_rd_callback(*device, DEVCB2_##_read);
|
||||
|
||||
#define MCFG_I8212_DO_CALLBACK(_write) \
|
||||
devcb = &i8212_device::set_do_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
|
||||
|
||||
@ -62,42 +64,33 @@ enum
|
||||
// TYPE DEFINITIONS
|
||||
///*************************************************************************
|
||||
|
||||
// ======================> i8212_interface
|
||||
|
||||
struct i8212_interface
|
||||
{
|
||||
devcb_write_line m_out_int_cb;
|
||||
|
||||
devcb_read8 m_in_di_cb;
|
||||
devcb_write8 m_out_do_cb;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ======================> i8212_device
|
||||
|
||||
class i8212_device : public device_t, public i8212_interface
|
||||
class i8212_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
i8212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
DECLARE_READ8_MEMBER( data_r );
|
||||
DECLARE_WRITE8_MEMBER( data_w );
|
||||
template<class _Object> static devcb2_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<i8212_device &>(device).m_write_irq.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_di_rd_callback(device_t &device, _Object object) { return downcast<i8212_device &>(device).m_read_di.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_do_wr_callback(device_t &device, _Object object) { return downcast<i8212_device &>(device).m_write_do.set_callback(object); }
|
||||
|
||||
DECLARE_READ8_MEMBER( read );
|
||||
DECLARE_WRITE8_MEMBER( write );
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER( md_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( stb_w );
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
private:
|
||||
devcb_resolved_write_line m_out_int_func;
|
||||
devcb_resolved_read8 m_in_di_func;
|
||||
devcb_resolved_write8 m_out_do_func;
|
||||
devcb2_write_line m_write_irq;
|
||||
devcb2_read8 m_read_di;
|
||||
devcb2_write8 m_write_do;
|
||||
|
||||
int m_md; // mode
|
||||
int m_stb; // strobe
|
||||
|
@ -105,7 +105,7 @@ READ8_MEMBER( mm1_state::read )
|
||||
break;
|
||||
|
||||
case 4:
|
||||
data = m_iop->data_r(space, 0);
|
||||
data = m_iop->read(space, 0);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
@ -174,7 +174,7 @@ WRITE8_MEMBER( mm1_state::write )
|
||||
break;
|
||||
|
||||
case 4:
|
||||
m_iop->data_w(space, 0, data);
|
||||
m_iop->write(space, 0, data);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
@ -485,13 +485,6 @@ READ8_MEMBER( mm1_state::kb_r )
|
||||
return m_keydata;
|
||||
}
|
||||
|
||||
static I8212_INTERFACE( iop_intf )
|
||||
{
|
||||
DEVCB_CPU_INPUT_LINE(I8085A_TAG, I8085_RST65_LINE),
|
||||
DEVCB_DRIVER_MEMBER(mm1_state, kb_r),
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// I8237_INTERFACE( dmac_intf )
|
||||
@ -709,7 +702,10 @@ static MACHINE_CONFIG_START( mm1, mm1_state )
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
||||
|
||||
// peripheral hardware
|
||||
MCFG_I8212_ADD(I8212_TAG, iop_intf)
|
||||
MCFG_DEVICE_ADD(I8212_TAG, I8212, 0)
|
||||
MCFG_I8212_IRQ_CALLBACK(INPUTLINE(I8085A_TAG, I8085_RST65_LINE))
|
||||
MCFG_I8212_DI_CALLBACK(READ8(mm1_state, kb_r))
|
||||
|
||||
MCFG_I8237_ADD(I8237_TAG, XTAL_6_144MHz/2, dmac_intf)
|
||||
|
||||
MCFG_DEVICE_ADD(I8253_TAG, PIT8253, 0)
|
||||
|
Loading…
Reference in New Issue
Block a user