mirror of
https://github.com/holub/mame
synced 2025-04-24 17:30:55 +03:00
(MESS) cbm2: devcb2. (nw)
This commit is contained in:
parent
228463f3ac
commit
46a1b9e491
@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
const device_type CBM2_USER_PORT = &device_creator<cbm2_user_port_device>;
|
||||
@ -29,22 +29,13 @@ const device_type CBM2_USER_PORT = &device_creator<cbm2_user_port_device>;
|
||||
// device_cbm2_user_port_interface - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
device_cbm2_user_port_interface::device_cbm2_user_port_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_slot_card_interface(mconfig,device)
|
||||
device_cbm2_user_port_interface::device_cbm2_user_port_interface(const machine_config &mconfig, device_t &device) :
|
||||
device_slot_card_interface(mconfig,device)
|
||||
{
|
||||
m_slot = dynamic_cast<cbm2_user_port_device *>(device.owner());
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// ~device_cbm2_user_port_interface - destructor
|
||||
//-------------------------------------------------
|
||||
|
||||
device_cbm2_user_port_interface::~device_cbm2_user_port_interface()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
@ -55,47 +46,16 @@ device_cbm2_user_port_interface::~device_cbm2_user_port_interface()
|
||||
//-------------------------------------------------
|
||||
|
||||
cbm2_user_port_device::cbm2_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, CBM2_USER_PORT, "CBM2 user port", tag, owner, clock, "cbm2_user_port", __FILE__),
|
||||
device_slot_interface(mconfig, *this)
|
||||
device_t(mconfig, CBM2_USER_PORT, "CBM2 user port", tag, owner, clock, "cbm2_user_port", __FILE__),
|
||||
device_slot_interface(mconfig, *this),
|
||||
m_write_irq(*this),
|
||||
m_write_sp(*this),
|
||||
m_write_cnt(*this),
|
||||
m_write_flag(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// cbm2_user_port_device - destructor
|
||||
//-------------------------------------------------
|
||||
|
||||
cbm2_user_port_device::~cbm2_user_port_device()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void cbm2_user_port_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const cbm2_user_port_interface *intf = reinterpret_cast<const cbm2_user_port_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
{
|
||||
*static_cast<cbm2_user_port_interface *>(this) = *intf;
|
||||
}
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
|
||||
memset(&m_out_sp_cb, 0, sizeof(m_out_sp_cb));
|
||||
memset(&m_out_cnt_cb, 0, sizeof(m_out_cnt_cb));
|
||||
memset(&m_out_flag_cb, 0, sizeof(m_out_flag_cb));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
@ -105,26 +65,13 @@ void cbm2_user_port_device::device_start()
|
||||
m_card = dynamic_cast<device_cbm2_user_port_interface *>(get_card_device());
|
||||
|
||||
// resolve callbacks
|
||||
m_out_irq_func.resolve(m_out_irq_cb, *this);
|
||||
m_out_sp_func.resolve(m_out_sp_cb, *this);
|
||||
m_out_cnt_func.resolve(m_out_cnt_cb, *this);
|
||||
m_out_flag_func.resolve(m_out_flag_cb, *this);
|
||||
m_write_irq.resolve_safe();
|
||||
m_write_sp.resolve_safe();
|
||||
m_write_cnt.resolve_safe();
|
||||
m_write_flag.resolve_safe();
|
||||
}
|
||||
|
||||
|
||||
READ8_MEMBER( cbm2_user_port_device::d1_r ) { UINT8 data = 0xff; if (m_card != NULL) data = m_card->cbm2_d1_r(space, offset); return data; }
|
||||
WRITE8_MEMBER( cbm2_user_port_device::d1_w ) { if (m_card != NULL) m_card->cbm2_d1_w(space, offset, data); }
|
||||
READ8_MEMBER( cbm2_user_port_device::d2_r ) { UINT8 data = 0xff; if (m_card != NULL) data = m_card->cbm2_d2_r(space, offset); return data; }
|
||||
WRITE8_MEMBER( cbm2_user_port_device::d2_w ) { if (m_card != NULL) m_card->cbm2_d2_w(space, offset, data); }
|
||||
READ_LINE_MEMBER( cbm2_user_port_device::pb2_r ) { return m_card ? m_card->cbm2_pb2_r() : 1; }
|
||||
WRITE_LINE_MEMBER( cbm2_user_port_device::pb2_w ) { if (m_card != NULL) m_card->cbm2_pb2_w(state); }
|
||||
READ_LINE_MEMBER( cbm2_user_port_device::pb3_r ) { return m_card ? m_card->cbm2_pb3_r() : 1; }
|
||||
WRITE_LINE_MEMBER( cbm2_user_port_device::pb3_w ) { if (m_card != NULL) m_card->cbm2_pb3_w(state); }
|
||||
WRITE_LINE_MEMBER( cbm2_user_port_device::pc_w ) { if (m_card != NULL) m_card->cbm2_pc_w(state); }
|
||||
WRITE_LINE_MEMBER( cbm2_user_port_device::cnt_w ) { if (m_card != NULL) m_card->cbm2_cnt_w(state); }
|
||||
WRITE_LINE_MEMBER( cbm2_user_port_device::sp_w ) { if (m_card != NULL) m_card->cbm2_sp_w(state); }
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// SLOT_INTERFACE( cbm2_user_port_cards )
|
||||
//-------------------------------------------------
|
||||
|
@ -46,77 +46,30 @@
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define CBM2_USER_PORT_INTERFACE(_name) \
|
||||
const cbm2_user_port_interface (_name) =
|
||||
|
||||
|
||||
#define MCFG_CBM2_USER_PORT_ADD(_tag, _config, _slot_intf, _def_slot) \
|
||||
#define MCFG_CBM2_USER_PORT_ADD(_tag, _slot_intf, _def_slot) \
|
||||
MCFG_DEVICE_ADD(_tag, CBM2_USER_PORT, 0) \
|
||||
MCFG_DEVICE_CONFIG(_config) \
|
||||
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
|
||||
|
||||
|
||||
#define MCFG_CBM2_USER_PORT_IRQ_CALLBACK(_write) \
|
||||
devcb = &cbm2_user_port_device::set_irq_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define MCFG_CBM2_USER_PORT_SP_CALLBACK(_write) \
|
||||
devcb = &cbm2_user_port_device::set_sp_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define MCFG_CBM2_USER_PORT_CNT_CALLBACK(_write) \
|
||||
devcb = &cbm2_user_port_device::set_cnt_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define MCFG_CBM2_USER_PORT_FLAG_CALLBACK(_write) \
|
||||
devcb = &cbm2_user_port_device::set_flag_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> cbm2_user_port_interface
|
||||
|
||||
struct cbm2_user_port_interface
|
||||
{
|
||||
devcb_write_line m_out_irq_cb;
|
||||
devcb_write_line m_out_sp_cb;
|
||||
devcb_write_line m_out_cnt_cb;
|
||||
devcb_write_line m_out_flag_cb;
|
||||
};
|
||||
|
||||
|
||||
// ======================> cbm2_user_port_device
|
||||
|
||||
class device_cbm2_user_port_interface;
|
||||
|
||||
class cbm2_user_port_device : public device_t,
|
||||
public cbm2_user_port_interface,
|
||||
public device_slot_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
cbm2_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~cbm2_user_port_device();
|
||||
|
||||
// computer interface
|
||||
DECLARE_READ8_MEMBER( d1_r );
|
||||
DECLARE_WRITE8_MEMBER( d1_w );
|
||||
DECLARE_READ8_MEMBER( d2_r );
|
||||
DECLARE_WRITE8_MEMBER( d2_w );
|
||||
DECLARE_READ_LINE_MEMBER( pb2_r );
|
||||
DECLARE_WRITE_LINE_MEMBER( pb2_w );
|
||||
DECLARE_READ_LINE_MEMBER( pb3_r );
|
||||
DECLARE_WRITE_LINE_MEMBER( pb3_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( pc_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( cnt_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( sp_w );
|
||||
|
||||
// cartridge interface
|
||||
DECLARE_WRITE_LINE_MEMBER( irq_w ) { m_out_irq_func(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( cia_sp_w ) { m_out_sp_func(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( cia_cnt_w ) { m_out_cnt_func(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( flag_w ) { m_out_flag_func(state); }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
|
||||
devcb_resolved_write_line m_out_irq_func;
|
||||
devcb_resolved_write_line m_out_sp_func;
|
||||
devcb_resolved_write_line m_out_cnt_func;
|
||||
devcb_resolved_write_line m_out_flag_func;
|
||||
|
||||
device_cbm2_user_port_interface *m_card;
|
||||
};
|
||||
|
||||
class cbm2_user_port_device;
|
||||
|
||||
// ======================> device_cbm2_user_port_interface
|
||||
|
||||
@ -126,7 +79,7 @@ class device_cbm2_user_port_interface : public device_slot_card_interface
|
||||
public:
|
||||
// construction/destruction
|
||||
device_cbm2_user_port_interface(const machine_config &mconfig, device_t &device);
|
||||
virtual ~device_cbm2_user_port_interface();
|
||||
virtual ~device_cbm2_user_port_interface() { }
|
||||
|
||||
virtual UINT8 cbm2_d1_r(address_space &space, offs_t offset) { return 0xff; };
|
||||
virtual void cbm2_d1_w(address_space &space, offs_t offset, UINT8 data) { };
|
||||
@ -148,6 +101,53 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
// ======================> cbm2_user_port_device
|
||||
|
||||
class cbm2_user_port_device : public device_t,
|
||||
public device_slot_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
cbm2_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~cbm2_user_port_device() { }
|
||||
|
||||
template<class _Object> static devcb2_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<cbm2_user_port_device &>(device).m_write_irq.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_sp_wr_callback(device_t &device, _Object object) { return downcast<cbm2_user_port_device &>(device).m_write_sp.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_cnt_wr_callback(device_t &device, _Object object) { return downcast<cbm2_user_port_device &>(device).m_write_cnt.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_flag_wr_callback(device_t &device, _Object object) { return downcast<cbm2_user_port_device &>(device).m_write_flag.set_callback(object); }
|
||||
|
||||
// computer interface
|
||||
DECLARE_READ8_MEMBER( d1_r ) { UINT8 data = 0xff; if (m_card != NULL) data = m_card->cbm2_d1_r(space, offset); return data; }
|
||||
DECLARE_WRITE8_MEMBER( d1_w ) { if (m_card != NULL) m_card->cbm2_d1_w(space, offset, data); }
|
||||
DECLARE_READ8_MEMBER( d2_r ) { UINT8 data = 0xff; if (m_card != NULL) data = m_card->cbm2_d2_r(space, offset); return data; }
|
||||
DECLARE_WRITE8_MEMBER( d2_w ) { if (m_card != NULL) m_card->cbm2_d2_w(space, offset, data); }
|
||||
DECLARE_READ_LINE_MEMBER( pb2_r ) { return m_card ? m_card->cbm2_pb2_r() : 1; }
|
||||
DECLARE_WRITE_LINE_MEMBER( pb2_w ) { if (m_card != NULL) m_card->cbm2_pb2_w(state); }
|
||||
DECLARE_READ_LINE_MEMBER( pb3_r ) { return m_card ? m_card->cbm2_pb3_r() : 1; }
|
||||
DECLARE_WRITE_LINE_MEMBER( pb3_w ) { if (m_card != NULL) m_card->cbm2_pb3_w(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( pc_w ) { if (m_card != NULL) m_card->cbm2_pc_w(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( cnt_w ) { if (m_card != NULL) m_card->cbm2_cnt_w(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( sp_w ) { if (m_card != NULL) m_card->cbm2_sp_w(state); }
|
||||
|
||||
// cartridge interface
|
||||
DECLARE_WRITE_LINE_MEMBER( irq_w ) { m_write_irq(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( cia_sp_w ) { m_write_sp(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( cia_cnt_w ) { m_write_cnt(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( flag_w ) { m_write_flag(state); }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
|
||||
devcb2_write_line m_write_irq;
|
||||
devcb2_write_line m_write_sp;
|
||||
devcb2_write_line m_write_cnt;
|
||||
devcb2_write_line m_write_flag;
|
||||
|
||||
device_cbm2_user_port_interface *m_card;
|
||||
};
|
||||
|
||||
|
||||
// device type definition
|
||||
extern const device_type CBM2_USER_PORT;
|
||||
|
||||
|
@ -1872,14 +1872,6 @@ WRITE_LINE_MEMBER( cbm2_state::user_irq_w )
|
||||
m_maincpu->set_input_line(INPUT_LINE_IRQ0, m_tpi1_irq || m_user_irq);
|
||||
}
|
||||
|
||||
static CBM2_USER_PORT_INTERFACE( user_intf )
|
||||
{
|
||||
DEVCB_DRIVER_LINE_MEMBER(cbm2_state, user_irq_w),
|
||||
DEVCB_DEVICE_LINE_MEMBER(MOS6526_TAG, mos6526_device, sp_w),
|
||||
DEVCB_DEVICE_LINE_MEMBER(MOS6526_TAG, mos6526_device, cnt_w),
|
||||
DEVCB_DEVICE_LINE_MEMBER(MOS6526_TAG, mos6526_device, flag_w)
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// CBM2_USER_PORT_INTERFACE( p500_user_intf )
|
||||
@ -1892,14 +1884,6 @@ WRITE_LINE_MEMBER( p500_state::user_irq_w )
|
||||
m_maincpu->set_input_line(INPUT_LINE_IRQ0, m_vic_irq || m_tpi1_irq || m_user_irq);
|
||||
}
|
||||
|
||||
static CBM2_USER_PORT_INTERFACE( p500_user_intf )
|
||||
{
|
||||
DEVCB_DRIVER_LINE_MEMBER(p500_state, user_irq_w),
|
||||
DEVCB_DEVICE_LINE_MEMBER(MOS6526_TAG, mos6526_device, sp_w),
|
||||
DEVCB_DEVICE_LINE_MEMBER(MOS6526_TAG, mos6526_device, cnt_w),
|
||||
DEVCB_DEVICE_LINE_MEMBER(MOS6526_TAG, mos6526_device, flag_w)
|
||||
};
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
@ -2176,7 +2160,11 @@ static MACHINE_CONFIG_START( p500_ntsc, p500_state )
|
||||
MCFG_VCS_CONTROL_PORT_TRIGGER_CALLBACK(DEVWRITELINE(MOS6567_TAG, mos6567_device, lp_w))
|
||||
MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL)
|
||||
MCFG_CBM2_EXPANSION_SLOT_ADD(CBM2_EXPANSION_SLOT_TAG, VIC6567_CLOCK, cbm2_expansion_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_ADD(CBM2_USER_PORT_TAG, p500_user_intf, cbm2_user_port_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_ADD(CBM2_USER_PORT_TAG, cbm2_user_port_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_IRQ_CALLBACK(WRITELINE(p500_state, user_irq_w))
|
||||
MCFG_CBM2_USER_PORT_SP_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, sp_w))
|
||||
MCFG_CBM2_USER_PORT_CNT_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, cnt_w))
|
||||
MCFG_CBM2_USER_PORT_FLAG_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, flag_w))
|
||||
|
||||
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
|
||||
MCFG_RS232_RXD_HANDLER(DEVWRITELINE(MOS6551A_TAG, mos6551_device, rxd_w))
|
||||
@ -2258,7 +2246,11 @@ static MACHINE_CONFIG_START( p500_pal, p500_state )
|
||||
MCFG_VCS_CONTROL_PORT_TRIGGER_CALLBACK(DEVWRITELINE(MOS6569_TAG, mos6569_device, lp_w))
|
||||
MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL)
|
||||
MCFG_CBM2_EXPANSION_SLOT_ADD(CBM2_EXPANSION_SLOT_TAG, VIC6569_CLOCK, cbm2_expansion_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_ADD(CBM2_USER_PORT_TAG, p500_user_intf, cbm2_user_port_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_ADD(CBM2_USER_PORT_TAG, cbm2_user_port_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_IRQ_CALLBACK(WRITELINE(p500_state, user_irq_w))
|
||||
MCFG_CBM2_USER_PORT_SP_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, sp_w))
|
||||
MCFG_CBM2_USER_PORT_CNT_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, cnt_w))
|
||||
MCFG_CBM2_USER_PORT_FLAG_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, flag_w))
|
||||
|
||||
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
|
||||
MCFG_RS232_RXD_HANDLER(DEVWRITELINE(MOS6551A_TAG, mos6551_device, rxd_w))
|
||||
@ -2348,7 +2340,11 @@ static MACHINE_CONFIG_START( cbm2lp_ntsc, cbm2_state )
|
||||
MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL)
|
||||
MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL)
|
||||
MCFG_CBM2_EXPANSION_SLOT_ADD(CBM2_EXPANSION_SLOT_TAG, XTAL_18MHz/9, cbm2_expansion_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_ADD(CBM2_USER_PORT_TAG, user_intf, cbm2_user_port_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_ADD(CBM2_USER_PORT_TAG, cbm2_user_port_cards, NULL)
|
||||
MCFG_CBM2_USER_PORT_IRQ_CALLBACK(WRITELINE(cbm2_state, user_irq_w))
|
||||
MCFG_CBM2_USER_PORT_SP_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, sp_w))
|
||||
MCFG_CBM2_USER_PORT_CNT_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, cnt_w))
|
||||
MCFG_CBM2_USER_PORT_FLAG_CALLBACK(DEVWRITELINE(MOS6526_TAG, mos6526_device, flag_w))
|
||||
|
||||
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
|
||||
MCFG_RS232_RXD_HANDLER(DEVWRITELINE(MOS6551A_TAG, mos6551_device, rxd_w))
|
||||
|
Loading…
Reference in New Issue
Block a user