model1io: Improve interface, drive board read/write callbacks

This commit is contained in:
Dirk Best 2018-04-25 21:54:25 +02:00
parent b4c8e7cd4e
commit 39aa80f2a7
2 changed files with 33 additions and 7 deletions

View File

@ -141,6 +141,8 @@ MACHINE_CONFIG_START( model1io_device::device_add_mconfig )
MCFG_315_5338A_IN1_CB(READ8(model1io_device, in1_r))
MCFG_315_5338A_IN2_CB(READ8(model1io_device, in2_r))
MCFG_315_5338A_IN3_CB(READ8(model1io_device, in3_r))
MCFG_315_5338A_IN4_CB(READ8(model1io_device, in4_r))
MCFG_315_5338A_OUT4_CB(WRITE8(model1io_device, out4_w))
MCFG_315_5338A_OUT5_CB(WRITE8(model1io_device, out5_w))
MCFG_315_5338A_IN6_CB(READ8(model1io_device, in6_r))
@ -165,7 +167,8 @@ model1io_device::model1io_device(const machine_config &mconfig, const char *tag,
m_eeprom(*this, "eeprom"),
m_buttons(*this, "buttons"),
m_read_cb(*this), m_write_cb(*this),
m_in_cb{ {*this}, {*this}, {*this}, {*this}, {*this}, {*this} },
m_in_cb{ {*this}, {*this}, {*this}, {*this} },
m_drive_read_cb(*this), m_drive_write_cb(*this),
m_an_cb{ {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this} },
m_output_cb(*this),
m_secondary_controls(false)
@ -182,9 +185,12 @@ void model1io_device::device_start()
m_read_cb.resolve_safe(0xff);
m_write_cb.resolve_safe();
for (unsigned i = 0; i < 6; i++)
for (unsigned i = 0; i < 4; i++)
m_in_cb[i].resolve_safe(0xff);
m_drive_read_cb.resolve_safe(0xff);
m_drive_write_cb.resolve_safe();
for (unsigned i = 0; i < 8; i++)
m_an_cb[i].resolve_safe(0xff);
@ -238,6 +244,16 @@ READ8_MEMBER( model1io_device::in3_r )
return m_secondary_controls ? m_in_cb[5](0) : m_in_cb[2](0);
}
READ8_MEMBER( model1io_device::in4_r )
{
return m_drive_read_cb(0);
}
WRITE8_MEMBER( model1io_device::out4_w )
{
m_drive_write_cb(data);
}
WRITE8_MEMBER( model1io_device::out5_w )
{
m_output_cb(data);

View File

@ -40,11 +40,11 @@
#define MCFG_MODEL1IO_IN3_CB(_devcb) \
devcb = &downcast<model1io_device &>(*device).set_in_callback(DEVCB_##_devcb, 3);
#define MCFG_MODEL1IO_IN4_CB(_devcb) \
devcb = &downcast<model1io_device &>(*device).set_in_callback(DEVCB_##_devcb, 4);
#define MCFG_MODEL1IO_DRIVE_READ_CB(_devcb) \
devcb = &downcast<model1io_device &>(*device).set_drive_read_callback(DEVCB_##_devcb);
#define MCFG_MODEL1IO_IN5_CB(_devcb) \
devcb = &downcast<model1io_device &>(*device).set_in_callback(DEVCB_##_devcb, 5);
#define MCFG_MODEL1IO_DRIVE_WRITE_CB(_devcb) \
devcb = &downcast<model1io_device &>(*device).set_drive_write_callback(DEVCB_##_devcb);
#define MCFG_MODEL1IO_AN0_CB(_devcb) \
devcb = &downcast<model1io_device &>(*device).set_an_callback(DEVCB_##_devcb, 0);
@ -94,6 +94,12 @@ public:
template <class Object> devcb_base &set_in_callback(Object &&cb, int index)
{ return m_in_cb[index].set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_drive_read_callback(Object &&cb)
{ return m_drive_read_cb.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_drive_write_callback(Object &&cb)
{ return m_drive_write_cb.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_an_callback(Object &&cb, int index)
{ return m_an_cb[index].set_callback(std::forward<Object>(cb)); }
@ -120,6 +126,8 @@ private:
DECLARE_READ8_MEMBER(in1_r);
DECLARE_READ8_MEMBER(in2_r);
DECLARE_READ8_MEMBER(in3_r);
DECLARE_READ8_MEMBER(in4_r);
DECLARE_WRITE8_MEMBER(out4_w);
DECLARE_WRITE8_MEMBER(out5_w);
DECLARE_READ8_MEMBER(in6_r);
@ -130,7 +138,9 @@ private:
devcb_read8 m_read_cb;
devcb_write8 m_write_cb;
devcb_read8 m_in_cb[6];
devcb_read8 m_in_cb[4];
devcb_read8 m_drive_read_cb;
devcb_write8 m_drive_write_cb;
devcb_read8 m_an_cb[8];
devcb_write8 m_output_cb;