mirror of
https://github.com/holub/mame
synced 2025-06-06 04:43:45 +03:00
z80sio: devcb2'd so we can get rid of devcb1, refactoring dlair.c to use z80dart is not trivial. (nw)
This commit is contained in:
parent
c1b7ad0ae5
commit
2ae868588b
@ -1,5 +1,9 @@
|
||||
/***************************************************************************
|
||||
|
||||
!!! DEPRECATED DO NOT USE !!!
|
||||
|
||||
WILL BE DELETED WHEN src/mame/drivers/dlair.c USES z80dart.h
|
||||
|
||||
Z80 SIO (Z8440) implementation
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
@ -118,7 +122,7 @@ const int SIO_WR5_DTR = 0x80; // D7 = DTR
|
||||
//const int SIO_WR5_TX_DATABITS_7 = 0x20; // 01 = Tx 7 bits/character
|
||||
//const int SIO_WR5_TX_DATABITS_6 = 0x40; // 10 = Tx 6 bits/character
|
||||
//const int SIO_WR5_TX_DATABITS_8 = 0x60; // 11 = Tx 8 bits/character
|
||||
const int SIO_WR5_SEND_BREAK = 0x10; // D4 = Send break
|
||||
//const int SIO_WR5_SEND_BREAK = 0x10; // D4 = Send break
|
||||
const int SIO_WR5_TX_ENABLE = 0x08; // D3 = Tx Enable
|
||||
//const int SIO_WR5_CRC16_SDLC = 0x04; // D2 = CRC-16/SDLC
|
||||
const int SIO_WR5_RTS = 0x02; // D1 = RTS
|
||||
@ -299,40 +303,31 @@ inline attotime z80sio_device::sio_channel::compute_time_per_character()
|
||||
|
||||
z80sio_device::z80sio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, Z80SIO, "Z80 SIO", tag, owner, clock, "z80sio", __FILE__),
|
||||
device_z80daisy_interface(mconfig, *this)
|
||||
device_z80daisy_interface(mconfig, *this),
|
||||
m_irq(*this),
|
||||
m_dtr_changed(*this),
|
||||
m_rts_changed(*this),
|
||||
m_break_changed(*this),
|
||||
m_transmit(*this),
|
||||
m_received_poll(*this)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
m_int_state[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void z80sio_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const z80sio_interface *intf = reinterpret_cast<const z80sio_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<z80sio_interface *>(this) = *intf;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void z80sio_device::device_start()
|
||||
{
|
||||
m_irq.resolve(m_irq_cb, *this);
|
||||
m_dtr_changed.resolve(m_dtr_changed_cb, *this);
|
||||
m_rts_changed.resolve(m_rts_changed_cb, *this);
|
||||
m_break_changed.resolve(m_break_changed_cb, *this);
|
||||
m_transmit.resolve(m_transmit_cb, *this);
|
||||
m_received_poll.resolve(m_received_poll_cb, *this);
|
||||
m_irq.resolve_safe();
|
||||
m_dtr_changed.resolve_safe();
|
||||
m_rts_changed.resolve_safe();
|
||||
m_break_changed.resolve_safe();
|
||||
m_transmit.resolve_safe();
|
||||
m_received_poll.resolve_safe(0);
|
||||
|
||||
m_channel[0].start(this, 0);
|
||||
m_channel[1].start(this, 1);
|
||||
@ -517,7 +512,7 @@ void z80sio_device::sio_channel::control_write(UINT8 data)
|
||||
VPRINTF(("%s:sio_reg_w(%c,%d) = %02X\n", m_device->machine().describe_context(), 'A' + m_index, regnum, data));
|
||||
|
||||
// write a new value to the selected register
|
||||
UINT8 old = m_regs[regnum];
|
||||
//UINT8 old = m_regs[regnum];
|
||||
m_regs[regnum] = data;
|
||||
|
||||
// clear the register number for the next write
|
||||
@ -562,12 +557,14 @@ void z80sio_device::sio_channel::control_write(UINT8 data)
|
||||
|
||||
// SIO write register 5
|
||||
case 5:
|
||||
/*
|
||||
if (((old ^ data) & SIO_WR5_DTR) && !m_device->m_dtr_changed.isnull())
|
||||
m_device->m_dtr_changed(m_index, (data & SIO_WR5_DTR) != 0);
|
||||
if (((old ^ data) & SIO_WR5_SEND_BREAK) && !m_device->m_break_changed.isnull())
|
||||
m_device->m_break_changed(m_index, (data & SIO_WR5_SEND_BREAK) != 0);
|
||||
if (((old ^ data) & SIO_WR5_RTS) && !m_device->m_rts_changed.isnull())
|
||||
m_device->m_rts_changed(m_index, (data & SIO_WR5_RTS) != 0);
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
/***************************************************************************
|
||||
|
||||
!!! DEPRECATED DO NOT USE !!!
|
||||
|
||||
WILL BE DELETED WHEN src/mame/drivers/dlair.c USES z80dart.h
|
||||
|
||||
Z80 SIO (Z8440) implementation
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
@ -17,9 +21,14 @@
|
||||
// DEVICE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_Z80SIO_ADD(_tag, _clock, _intrf) \
|
||||
MCFG_DEVICE_ADD(_tag, Z80SIO, _clock) \
|
||||
MCFG_DEVICE_CONFIG(_intrf)
|
||||
#define MCFG_Z80SIO_INT_CALLBACK(_write) \
|
||||
devcb = &z80sio_device::set_int_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define MCFG_Z80SIO_TRANSMIT_CALLBACK(_write) \
|
||||
devcb = &z80sio_device::set_transmit_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define MCFG_Z80SIO_RECEIVE_CALLBACK(_read) \
|
||||
devcb = &z80sio_device::set_receive_callback(*device, DEVCB2_##_read);
|
||||
|
||||
|
||||
|
||||
@ -27,31 +36,19 @@
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
|
||||
// ======================> z80sio_interface
|
||||
|
||||
struct z80sio_interface
|
||||
{
|
||||
devcb_write_line m_irq_cb;
|
||||
devcb_write8 m_dtr_changed_cb;
|
||||
devcb_write8 m_rts_changed_cb;
|
||||
devcb_write8 m_break_changed_cb;
|
||||
devcb_write16 m_transmit_cb;
|
||||
devcb_read16 m_received_poll_cb;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ======================> z80sio_device
|
||||
|
||||
class z80sio_device : public device_t,
|
||||
public device_z80daisy_interface,
|
||||
public z80sio_interface
|
||||
public device_z80daisy_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
z80sio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
template<class _Object> static devcb2_base &set_int_callback(device_t &device, _Object object) { return downcast<z80sio_device &>(device).m_irq.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_transmit_callback(device_t &device, _Object object) { return downcast<z80sio_device &>(device).m_transmit.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_receive_callback(device_t &device, _Object object) { return downcast<z80sio_device &>(device).m_received_poll.set_callback(object); }
|
||||
|
||||
// control register I/O
|
||||
UINT8 control_read(int ch) { return m_channel[ch].control_read(); }
|
||||
void control_write(int ch, UINT8 data) { m_channel[ch].control_write(data); }
|
||||
@ -77,7 +74,6 @@ public:
|
||||
|
||||
private:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
@ -141,12 +137,12 @@ private:
|
||||
UINT8 m_int_state[8]; // interrupt states
|
||||
|
||||
// callbacks
|
||||
devcb_resolved_write_line m_irq;
|
||||
devcb_resolved_write8 m_dtr_changed;
|
||||
devcb_resolved_write8 m_rts_changed;
|
||||
devcb_resolved_write8 m_break_changed;
|
||||
devcb_resolved_write16 m_transmit;
|
||||
devcb_resolved_read16 m_received_poll;
|
||||
devcb2_write_line m_irq;
|
||||
devcb2_write8 m_dtr_changed;
|
||||
devcb2_write8 m_rts_changed;
|
||||
devcb2_write8 m_break_changed;
|
||||
devcb2_write16 m_transmit;
|
||||
devcb2_read16 m_received_poll;
|
||||
|
||||
static const UINT8 k_int_priority[];
|
||||
};
|
||||
|
@ -194,17 +194,6 @@ WRITE_LINE_MEMBER(dlair_state::write_speaker)
|
||||
}
|
||||
|
||||
|
||||
static const z80sio_interface sio_intf =
|
||||
{
|
||||
DEVCB_DRIVER_LINE_MEMBER(dlair_state, dleuro_interrupt), /* interrupt handler */
|
||||
DEVCB_NULL, /* DTR changed handler */
|
||||
DEVCB_NULL, /* RTS changed handler */
|
||||
DEVCB_NULL, /* BREAK changed handler */
|
||||
DEVCB_DRIVER_MEMBER16(dlair_state,serial_transmit), /* transmit handler */
|
||||
DEVCB_DRIVER_MEMBER16(dlair_state,serial_receive) /* receive handler */
|
||||
};
|
||||
|
||||
|
||||
static const z80_daisy_config dleuro_daisy_chain[] =
|
||||
{
|
||||
{ "sio" },
|
||||
@ -741,7 +730,10 @@ static MACHINE_CONFIG_START( dleuro, dlair_state )
|
||||
MCFG_Z80CTC_INTR_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0))
|
||||
MCFG_Z80CTC_ZC0_CB(WRITELINE(dlair_state, write_speaker))
|
||||
|
||||
MCFG_Z80SIO_ADD("sio", MASTER_CLOCK_EURO/4 /* same as "maincpu" */, sio_intf)
|
||||
MCFG_DEVICE_ADD("sio", Z80SIO, MASTER_CLOCK_EURO/4 /* same as "maincpu" */)
|
||||
MCFG_Z80SIO_INT_CALLBACK(WRITELINE(dlair_state, dleuro_interrupt))
|
||||
MCFG_Z80SIO_TRANSMIT_CALLBACK(WRITE16(dlair_state,serial_transmit))
|
||||
MCFG_Z80SIO_RECEIVE_CALLBACK(READ16(dlair_state,serial_receive))
|
||||
|
||||
MCFG_WATCHDOG_TIME_INIT(attotime::from_hz(MASTER_CLOCK_EURO/(16*16*16*16*16*8)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user