(MESS) ecbbus: devcb2. (nw)

This commit is contained in:
Curt Coder 2014-03-15 20:23:46 +00:00
parent 997b4e8a6f
commit b7c2ea9c60
3 changed files with 21 additions and 123 deletions

View File

@ -56,49 +56,18 @@ void ecbbus_slot_device::device_start()
{ {
m_bus = machine().device<ecbbus_device>(m_bus_tag); m_bus = machine().device<ecbbus_device>(m_bus_tag);
device_ecbbus_card_interface *dev = dynamic_cast<device_ecbbus_card_interface *>(get_card_device()); device_ecbbus_card_interface *dev = dynamic_cast<device_ecbbus_card_interface *>(get_card_device());
if (dev) m_bus->add_ecbbus_card(dev, m_bus_num); if (dev) m_bus->add_card(dev, m_bus_num);
} }
//************************************************************************** //**************************************************************************
// GLOBAL VARIABLES // DEVICE DEFINITIONS
//************************************************************************** //**************************************************************************
const device_type ECBBUS = &device_creator<ecbbus_device>; const device_type ECBBUS = &device_creator<ecbbus_device>;
void ecbbus_device::static_set_cputag(device_t &device, const char *tag)
{
ecbbus_device &ecbbus = downcast<ecbbus_device &>(device);
ecbbus.m_cputag = tag;
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void ecbbus_device::device_config_complete()
{
// inherit a copy of the static data
const ecbbus_interface *intf = reinterpret_cast<const ecbbus_interface *>(static_config());
if (intf != NULL)
{
*static_cast<ecbbus_interface *>(this) = *intf;
}
// or initialize to defaults if none provided
else
{
memset(&m_out_int_cb, 0, sizeof(m_out_int_cb));
memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb));
}
}
//************************************************************************** //**************************************************************************
// DEVICE ECBBUS CARD INTERFACE // DEVICE ECBBUS CARD INTERFACE
@ -108,22 +77,13 @@ void ecbbus_device::device_config_complete()
// device_ecbbus_card_interface - constructor // device_ecbbus_card_interface - constructor
//------------------------------------------------- //-------------------------------------------------
device_ecbbus_card_interface::device_ecbbus_card_interface(const machine_config &mconfig, device_t &device) device_ecbbus_card_interface::device_ecbbus_card_interface(const machine_config &mconfig, device_t &device) :
: device_slot_card_interface(mconfig, device) device_slot_card_interface(mconfig, device)
{ {
m_slot = dynamic_cast<ecbbus_slot_device *>(device.owner()); m_slot = dynamic_cast<ecbbus_slot_device *>(device.owner());
} }
//-------------------------------------------------
// ~device_ecbbus_card_interface - destructor
//-------------------------------------------------
device_ecbbus_card_interface::~device_ecbbus_card_interface()
{
}
//************************************************************************** //**************************************************************************
// LIVE DEVICE // LIVE DEVICE
@ -134,7 +94,9 @@ device_ecbbus_card_interface::~device_ecbbus_card_interface()
//------------------------------------------------- //-------------------------------------------------
ecbbus_device::ecbbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : ecbbus_device::ecbbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, ECBBUS, "ECB bus", tag, owner, clock, "ecbbus", __FILE__) device_t(mconfig, ECBBUS, "ECB bus", tag, owner, clock, "ecbbus", __FILE__),
m_write_irq(*this),
m_write_nmi(*this)
{ {
for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) for (int i = 0; i < MAX_ECBBUS_SLOTS; i++)
m_ecbbus_device[i] = NULL; m_ecbbus_device[i] = NULL;
@ -147,28 +109,17 @@ ecbbus_device::ecbbus_device(const machine_config &mconfig, const char *tag, dev
void ecbbus_device::device_start() void ecbbus_device::device_start()
{ {
m_maincpu = machine().device<cpu_device>(m_cputag);
// resolve callbacks // resolve callbacks
m_out_int_func.resolve(m_out_int_cb, *this); m_write_irq.resolve_safe();
m_out_nmi_func.resolve(m_out_nmi_cb, *this); m_write_nmi.resolve_safe();
} }
//------------------------------------------------- //-------------------------------------------------
// device_reset - device-specific reset // add_card - add ECB bus card
//------------------------------------------------- //-------------------------------------------------
void ecbbus_device::device_reset() void ecbbus_device::add_card(device_ecbbus_card_interface *card, int pos)
{
}
//-------------------------------------------------
// add_ecbbus_card - add ECB bus card
//-------------------------------------------------
void ecbbus_device::add_ecbbus_card(device_ecbbus_card_interface *card, int pos)
{ {
m_ecbbus_device[pos] = card; m_ecbbus_device[pos] = card;
} }
@ -246,26 +197,6 @@ WRITE8_MEMBER( ecbbus_device::io_w )
} }
//-------------------------------------------------
// int_w -
//-------------------------------------------------
WRITE_LINE_MEMBER( ecbbus_device::int_w )
{
m_out_int_func(state);
}
//-------------------------------------------------
// nmi_w -
//-------------------------------------------------
WRITE_LINE_MEMBER( ecbbus_device::nmi_w )
{
m_out_nmi_func(state);
}
//------------------------------------------------- //-------------------------------------------------
// SLOT_INTERFACE( ecbbus_cards ) // SLOT_INTERFACE( ecbbus_cards )
//------------------------------------------------- //-------------------------------------------------

View File

@ -68,15 +68,8 @@
// INTERFACE CONFIGURATION MACROS // INTERFACE CONFIGURATION MACROS
//************************************************************************** //**************************************************************************
#define MCFG_ECBBUS_ADD(_cpu_tag, _config) \ #define MCFG_ECBBUS_ADD() \
MCFG_DEVICE_ADD(ECBBUS_TAG, ECBBUS, 0) \ MCFG_DEVICE_ADD(ECBBUS_TAG, ECBBUS, 0) \
MCFG_DEVICE_CONFIG(_config) \
ecbbus_device::static_set_cputag(*device, _cpu_tag);
#define ECBBUS_INTERFACE(_name) \
const ecbbus_interface (_name) =
#define MCFG_ECBBUS_SLOT_ADD(_num, _tag, _slot_intf, _def_slot) \ #define MCFG_ECBBUS_SLOT_ADD(_num, _tag, _slot_intf, _def_slot) \
MCFG_DEVICE_ADD(_tag, ECBBUS_SLOT, 0) \ MCFG_DEVICE_ADD(_tag, ECBBUS_SLOT, 0) \
@ -94,7 +87,7 @@
class ecbbus_device; class ecbbus_device;
class ecbbus_slot_device : public device_t, class ecbbus_slot_device : public device_t,
public device_slot_interface public device_slot_interface
{ {
public: public:
// construction/destruction // construction/destruction
@ -120,27 +113,18 @@ extern const device_type ECBBUS_SLOT;
// ======================> ecbbus_interface // ======================> ecbbus_interface
struct ecbbus_interface
{
devcb_write_line m_out_int_cb;
devcb_write_line m_out_nmi_cb;
};
class device_ecbbus_card_interface; class device_ecbbus_card_interface;
// ======================> ecbbus_device // ======================> ecbbus_device
class ecbbus_device : public device_t, class ecbbus_device : public device_t
public ecbbus_interface
{ {
public: public:
// construction/destruction // construction/destruction
ecbbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ecbbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// inline configuration
static void static_set_cputag(device_t &device, const char *tag);
void add_ecbbus_card(device_ecbbus_card_interface *card, int pos); void add_card(device_ecbbus_card_interface *card, int pos);
DECLARE_READ8_MEMBER( mem_r ); DECLARE_READ8_MEMBER( mem_r );
DECLARE_WRITE8_MEMBER( mem_w ); DECLARE_WRITE8_MEMBER( mem_w );
@ -148,24 +132,18 @@ public:
DECLARE_READ8_MEMBER( io_r ); DECLARE_READ8_MEMBER( io_r );
DECLARE_WRITE8_MEMBER( io_w ); DECLARE_WRITE8_MEMBER( io_w );
DECLARE_WRITE_LINE_MEMBER( int_w ); DECLARE_WRITE_LINE_MEMBER( irq_w ) { m_write_irq(state); }
DECLARE_WRITE_LINE_MEMBER( nmi_w ); DECLARE_WRITE_LINE_MEMBER( nmi_w ) { m_write_nmi(state); }
protected: protected:
// device-level overrides // device-level overrides
virtual void device_start(); virtual void device_start();
virtual void device_reset();
virtual void device_config_complete();
private: private:
// internal state devcb2_write_line m_write_irq;
cpu_device *m_maincpu; devcb2_write_line m_write_nmi;
devcb_resolved_write_line m_out_int_func;
devcb_resolved_write_line m_out_nmi_func;
device_ecbbus_card_interface *m_ecbbus_device[MAX_ECBBUS_SLOTS]; device_ecbbus_card_interface *m_ecbbus_device[MAX_ECBBUS_SLOTS];
const char *m_cputag;
}; };
@ -183,7 +161,7 @@ class device_ecbbus_card_interface : public device_slot_card_interface
public: public:
// construction/destruction // construction/destruction
device_ecbbus_card_interface(const machine_config &mconfig, device_t &device); device_ecbbus_card_interface(const machine_config &mconfig, device_t &device);
virtual ~device_ecbbus_card_interface(); virtual ~device_ecbbus_card_interface() { }
// optional operation overrides // optional operation overrides
virtual UINT8 ecbbus_mem_r(offs_t offset) { return 0; }; virtual UINT8 ecbbus_mem_r(offs_t offset) { return 0; };

View File

@ -440,17 +440,6 @@ static SLOT_INTERFACE_START( prof80_floppies )
SLOT_INTERFACE_END SLOT_INTERFACE_END
//-------------------------------------------------
// ECB_BUS_INTERFACE( ecb_intf )
//-------------------------------------------------
static ECBBUS_INTERFACE( ecb_intf )
{
DEVCB_NULL,
DEVCB_NULL
};
//************************************************************************** //**************************************************************************
// MACHINE INITIALIZATION // MACHINE INITIALIZATION
@ -527,7 +516,7 @@ static MACHINE_CONFIG_START( prof80, prof80_state )
MCFG_FLOPPY_DRIVE_ADD(UPD765_TAG ":3", prof80_floppies, NULL, floppy_image_device::default_floppy_formats) MCFG_FLOPPY_DRIVE_ADD(UPD765_TAG ":3", prof80_floppies, NULL, floppy_image_device::default_floppy_formats)
// ECB bus // ECB bus
MCFG_ECBBUS_ADD(Z80_TAG, ecb_intf) MCFG_ECBBUS_ADD()
MCFG_ECBBUS_SLOT_ADD(1, "ecb_1", ecbbus_cards, "grip21") MCFG_ECBBUS_SLOT_ADD(1, "ecb_1", ecbbus_cards, "grip21")
MCFG_ECBBUS_SLOT_ADD(2, "ecb_2", ecbbus_cards, NULL) MCFG_ECBBUS_SLOT_ADD(2, "ecb_2", ecbbus_cards, NULL)
MCFG_ECBBUS_SLOT_ADD(3, "ecb_3", ecbbus_cards, NULL) MCFG_ECBBUS_SLOT_ADD(3, "ecb_3", ecbbus_cards, NULL)