converted z80_sti to devcb2. nw.

This commit is contained in:
Fabio Priuli 2014-04-17 16:23:24 +00:00
parent 697fd6e868
commit 9af5917e56
3 changed files with 96 additions and 107 deletions

View File

@ -468,21 +468,6 @@ WRITE_LINE_MEMBER( grip_device::speaker_w )
m_speaker->level_w(level);
}
static Z80STI_INTERFACE( sti_intf )
{
0, // serial receive clock
0, // serial transmit clock
DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0), // interrupt
DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, grip_device, sti_gpio_r), // GPIO read
DEVCB_NULL, // GPIO write
DEVCB_NULL, // serial output
DEVCB_NULL, // timer A output
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, grip_device, speaker_w), // timer B output
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF, z80sti_device, tc_w), // timer C output
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF, z80sti_device, rc_w) // timer D output
};
//-------------------------------------------------
// z80_daisy_config grip_daisy_chain
//-------------------------------------------------
@ -551,7 +536,12 @@ static MACHINE_CONFIG_FRAGMENT( grip )
MCFG_I8255_IN_PORTB_CB(READ8(grip_device, ppi_pb_r))
MCFG_I8255_OUT_PORTC_CB(WRITE8(grip_device, ppi_pc_w))
MCFG_Z80STI_ADD(Z80STI_TAG, XTAL_16MHz/4, sti_intf)
MCFG_DEVICE_ADD(Z80STI_TAG, Z80STI, XTAL_16MHz/4)
MCFG_Z80STI_OUT_INT_CB(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0))
MCFG_Z80STI_IN_GPIO_CB(READ8(grip_device, sti_gpio_r))
MCFG_Z80STI_OUT_TBO_CB(WRITELINE(grip_device, speaker_w))
MCFG_Z80STI_OUT_TCO_CB(DEVWRITELINE(Z80STI_TAG, z80sti_device, tc_w))
MCFG_Z80STI_OUT_TDO_CB(DEVWRITELINE(Z80STI_TAG, z80sti_device, tc_w))
MCFG_CENTRONICS_ADD(CENTRONICS_TAG, centronics_printers, "printer")
MCFG_CENTRONICS_BUSY_HANDLER(WRITELINE(grip_device, write_centronics_busy))

View File

@ -89,6 +89,16 @@ z80sti_device::z80sti_device(const machine_config &mconfig, const char *tag, dev
: device_t(mconfig, Z80STI, "Mostek MK3801", tag, owner, clock, "z80sti", __FILE__),
device_serial_interface(mconfig, *this),
device_z80daisy_interface(mconfig, *this),
m_out_int_cb(*this),
m_in_gpio_cb(*this),
m_out_gpio_cb(*this),
m_out_so_cb(*this),
m_out_tao_cb(*this),
m_out_tbo_cb(*this),
m_out_tco_cb(*this),
m_out_tdo_cb(*this),
m_rx_clock(0),
m_tx_clock(0),
m_gpip(0),
m_aer(0),
m_ier(0),
@ -103,35 +113,6 @@ z80sti_device::z80sti_device(const machine_config &mconfig, const char *tag, dev
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void z80sti_device::device_config_complete()
{
// inherit a copy of the static data
const z80sti_interface *intf = reinterpret_cast<const z80sti_interface *>(static_config());
if (intf != NULL)
*static_cast<z80sti_interface *>(this) = *intf;
// or initialize to defaults if none provided
else
{
m_rx_clock = m_tx_clock = 0;
memset(&m_out_int_cb, 0, sizeof(m_out_int_cb));
memset(&m_in_gpio_cb, 0, sizeof(m_in_gpio_cb));
memset(&m_out_gpio_cb, 0, sizeof(m_out_gpio_cb));
memset(&m_out_so_cb, 0, sizeof(m_out_so_cb));
memset(&m_out_tao_cb, 0, sizeof(m_out_tao_cb));
memset(&m_out_tbo_cb, 0, sizeof(m_out_tbo_cb));
memset(&m_out_tco_cb, 0, sizeof(m_out_tco_cb));
memset(&m_out_tdo_cb, 0, sizeof(m_out_tdo_cb));
}
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@ -139,14 +120,14 @@ void z80sti_device::device_config_complete()
void z80sti_device::device_start()
{
// resolve callbacks
m_in_gpio_func.resolve(m_in_gpio_cb, *this);
m_out_gpio_func.resolve(m_out_gpio_cb, *this);
m_out_so_func.resolve(m_out_so_cb, *this);
m_out_timer_func[TIMER_A].resolve(m_out_tao_cb, *this);
m_out_timer_func[TIMER_B].resolve(m_out_tbo_cb, *this);
m_out_timer_func[TIMER_C].resolve(m_out_tco_cb, *this);
m_out_timer_func[TIMER_D].resolve(m_out_tdo_cb, *this);
m_out_int_func.resolve(m_out_int_cb, *this);
m_out_int_cb.resolve_safe();
m_in_gpio_cb.resolve_safe(0);
m_out_gpio_cb.resolve_safe();
m_out_so_cb.resolve_safe();
m_out_tao_cb.resolve_safe();
m_out_tbo_cb.resolve_safe();
m_out_tco_cb.resolve_safe();
m_out_tdo_cb.resolve_safe();
// create the counter timers
m_timer[TIMER_A] = timer_alloc(TIMER_A);
@ -219,7 +200,7 @@ void z80sti_device::device_timer(emu_timer &timer, device_timer_id id, int param
void z80sti_device::tra_callback()
{
m_out_so_func(transmit_register_get_data_bit());
m_out_so_cb(transmit_register_get_data_bit());
}
@ -361,11 +342,11 @@ void z80sti_device::check_interrupts()
{
if (m_ipr & m_imr)
{
m_out_int_func(ASSERT_LINE);
m_out_int_cb(ASSERT_LINE);
}
else
{
m_out_int_func(CLEAR_LINE);
m_out_int_cb(CLEAR_LINE);
}
}
@ -410,7 +391,7 @@ READ8_MEMBER( z80sti_device::read )
}
break;
case REGISTER_GPIP: m_gpip = (m_in_gpio_func(0) & ~m_ddr) | (m_gpip & m_ddr); data = m_gpip; break;
case REGISTER_GPIP: m_gpip = (m_in_gpio_cb(0) & ~m_ddr) | (m_gpip & m_ddr); data = m_gpip; break;
case REGISTER_IPRB: data = m_ipr & 0xff; break;
case REGISTER_IPRA: data = m_ipr >> 8; break;
case REGISTER_ISRB: data = m_isr & 0xff; break;
@ -504,7 +485,7 @@ WRITE8_MEMBER( z80sti_device::write )
LOG(("Z80STI '%s' Timer A Reset\n", tag()));
m_to[TIMER_A] = 0;
m_out_timer_func[TIMER_A](m_to[TIMER_A]);
m_out_tao_cb(m_to[TIMER_A]);
}
if (BIT(data, 3))
@ -512,7 +493,7 @@ WRITE8_MEMBER( z80sti_device::write )
LOG(("Z80STI '%s' Timer B Reset\n", tag()));
m_to[TIMER_B] = 0;
m_out_timer_func[TIMER_B](m_to[TIMER_B]);
m_out_tbo_cb(m_to[TIMER_B]);
}
}
break;
@ -522,7 +503,7 @@ WRITE8_MEMBER( z80sti_device::write )
case REGISTER_GPIP:
LOG(("Z80STI '%s' General Purpose I/O Register: %x\n", tag(), data));
m_gpip = data & m_ddr;
m_out_gpio_func(0, m_gpip);
m_out_gpio_cb((offs_t)0, m_gpip);
break;
case REGISTER_IPRB:
@ -653,7 +634,21 @@ void z80sti_device::timer_count(int index)
// toggle timer output signal
m_to[index] = !m_to[index];
m_out_timer_func[index](m_to[index]);
switch (index)
{
case TIMER_A:
m_out_tao_cb(m_to[index]);
break;
case TIMER_B:
m_out_tbo_cb(m_to[index]);
break;
case TIMER_C:
m_out_tco_cb(m_to[index]);
break;
case TIMER_D:
m_out_tdo_cb(m_to[index]);
break;
}
if (m_ier & (1 << INT_LEVEL_TIMER[index]))
{

View File

@ -42,63 +42,62 @@
// DEVICE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_Z80STI_ADD(_tag, _clock, _config) \
MCFG_DEVICE_ADD((_tag), Z80STI, _clock) \
MCFG_DEVICE_CONFIG(_config)
#define MCFG_Z80STI_RXCLOCK(_clock) \
z80sti_device::set_rx_clock(*device, _clock);
#define Z80STI_INTERFACE(name) \
const z80sti_interface (name) =
#define MCFG_Z80STI_TXCLOCK(_clock) \
z80sti_device::set_tx_clock(*device, _clock);
#define MCFG_Z80STI_OUT_INT_CB(_devcb) \
devcb = &z80sti_device::set_out_int_callback(*device, DEVCB2_##_devcb);
#define MCFG_Z80STI_IN_GPIO_CB(_devcb) \
devcb = &z80sti_device::set_in_gpio_callback(*device, DEVCB2_##_devcb);
#define MCFG_Z80STI_OUT_GPIO_CB(_devcb) \
devcb = &z80sti_device::set_out_gpio_callback(*device, DEVCB2_##_devcb);
#define MCFG_Z80STI_OUT_SO_CB(_devcb) \
devcb = &z80sti_device::set_out_so_callback(*device, DEVCB2_##_devcb);
#define MCFG_Z80STI_OUT_TAO_CB(_devcb) \
devcb = &z80sti_device::set_out_tao_callback(*device, DEVCB2_##_devcb);
#define MCFG_Z80STI_OUT_TBO_CB(_devcb) \
devcb = &z80sti_device::set_out_tbo_callback(*device, DEVCB2_##_devcb);
#define MCFG_Z80STI_OUT_TCO_CB(_devcb) \
devcb = &z80sti_device::set_out_tco_callback(*device, DEVCB2_##_devcb);
#define MCFG_Z80STI_OUT_TDO_CB(_devcb) \
devcb = &z80sti_device::set_out_tdo_callback(*device, DEVCB2_##_devcb);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> z80sti_interface
struct z80sti_interface
{
int m_rx_clock; // serial receive clock
int m_tx_clock; // serial transmit clock
// this gets called on each change of the _INT pin (pin 17)
devcb_write_line m_out_int_cb;
// this is called on each read of the GPIO pins
devcb_read8 m_in_gpio_cb;
// this is called on each write of the GPIO pins
devcb_write8 m_out_gpio_cb;
// this gets called for each change of the SO pin (pin 37)
devcb_write_line m_out_so_cb;
// this gets called for each change of the TAO pin (pin 1)
devcb_write_line m_out_tao_cb;
// this gets called for each change of the TBO pin (pin 2)
devcb_write_line m_out_tbo_cb;
// this gets called for each change of the TCO pin (pin 3)
devcb_write_line m_out_tco_cb;
// this gets called for each change of the TDO pin (pin 4)
devcb_write_line m_out_tdo_cb;
};
// ======================> z80sti_device
class z80sti_device : public device_t,
public device_serial_interface,
public device_z80daisy_interface,
public z80sti_interface
public device_z80daisy_interface
{
public:
// construction/destruction
z80sti_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
template<class _Object> static devcb2_base &set_out_int_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_int_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_in_gpio_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_in_gpio_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_gpio_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_gpio_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_so_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_so_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_tao_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tao_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_tbo_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tbo_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_tco_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tco_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_out_tdo_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tdo_cb.set_callback(object); }
static void set_rx_clock(device_t &device, int clock) { downcast<z80sti_device &>(device).m_rx_clock = clock; }
static void set_tx_clock(device_t &device, int clock) { downcast<z80sti_device &>(device).m_tx_clock = clock; }
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
@ -181,7 +180,6 @@ private:
static const int PRESCALER[];
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
@ -203,11 +201,17 @@ private:
void gpip_input(int bit, int state);
// device callbacks
devcb_resolved_read8 m_in_gpio_func;
devcb_resolved_write8 m_out_gpio_func;
devcb_resolved_write_line m_out_so_func;
devcb_resolved_write_line m_out_timer_func[4];
devcb_resolved_write_line m_out_int_func;
devcb2_write_line m_out_int_cb; // this gets called on each change of the _INT pin (pin 17)
devcb2_read8 m_in_gpio_cb; // this is called on each read of the GPIO pins
devcb2_write8 m_out_gpio_cb; // this is called on each write of the GPIO pins
devcb2_write_line m_out_so_cb; // this gets called for each change of the SO pin (pin 37)
devcb2_write_line m_out_tao_cb; // this gets called for each change of the TAO pin (pin 1)
devcb2_write_line m_out_tbo_cb; // this gets called for each change of the TBO pin (pin 2)
devcb2_write_line m_out_tco_cb; // this gets called for each change of the TCO pin (pin 3)
devcb2_write_line m_out_tdo_cb; // this gets called for each change of the TDO pin (pin 4)
int m_rx_clock; // serial receive clock
int m_tx_clock; // serial transmit clock
// I/O state
UINT8 m_gpip; // general purpose I/O register