diff options
author | 2019-11-01 00:47:41 +1100 | |
---|---|---|
committer | 2019-11-01 00:47:41 +1100 | |
commit | 6f4c1f6e5b2525ac8b700b3a0754f5e99c4223e1 (patch) | |
tree | 4b0e0ac5cf1c3a7fd518a7d8f4d12f39291b2629 /src/devices/bus/wangpc | |
parent | 0be348c7fbc8c0478f724ba098dabeb9eb3aab8c (diff) |
Spring cleaning:
* Changed emu_fatalerror to use util::string_format semantics
* Fixed some incorrectly marked up stuff in build scripts
* Make internal layout compression type a scoped enum (only zlib is supported still, but at least the values aren't magic numbers now)
* Fixed memory leaks in Xbox USB
* There can only be one "perfect quantum" device - enforce that only the root machine can set it, as allowing subdevices to will cause weird issues with slot cards overiding it
* Allow multiple devices to set maximum quantum and use the most restrictive one (it's maximum quantum, it would be minimum interleave)
* Got rid of device_slot_card_interface as it wasn't providing value
* Added a helper template to reduce certain kinds of boilerplate in slots/buses
* Cleaned up some particularly bad slot code (plenty more of that to do), and made some slots more idiomatic
Diffstat (limited to 'src/devices/bus/wangpc')
-rw-r--r-- | src/devices/bus/wangpc/wangpc.cpp | 27 | ||||
-rw-r--r-- | src/devices/bus/wangpc/wangpc.h | 34 |
2 files changed, 32 insertions, 29 deletions
diff --git a/src/devices/bus/wangpc/wangpc.cpp b/src/devices/bus/wangpc/wangpc.cpp index 540ed94c1b3..7f209465d2d 100644 --- a/src/devices/bus/wangpc/wangpc.cpp +++ b/src/devices/bus/wangpc/wangpc.cpp @@ -29,8 +29,8 @@ DEFINE_DEVICE_TYPE(WANGPC_BUS_SLOT, wangpcbus_slot_device, "wangpcbus_slot", "Wa wangpcbus_slot_device::wangpcbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, WANGPC_BUS_SLOT, tag, owner, clock), - device_slot_interface(mconfig, *this), - m_bus(nullptr), + device_single_card_slot_interface<device_wangpcbus_card_interface>(mconfig, *this), + m_bus(*this, finder_base::DUMMY_TAG), m_sid(0) { } @@ -41,9 +41,9 @@ wangpcbus_slot_device::wangpcbus_slot_device(const machine_config &mconfig, cons void wangpcbus_slot_device::device_start() { - m_bus = machine().device<wangpcbus_device>(WANGPC_BUS_TAG); - device_wangpcbus_card_interface *dev = dynamic_cast<device_wangpcbus_card_interface *>(get_card_device()); - if (dev) m_bus->add_card(dev, m_sid); + device_wangpcbus_card_interface *dev = get_card_device(); + if (dev) + m_bus->add_card(*dev, m_sid); } @@ -91,12 +91,12 @@ void wangpcbus_device::device_start() // add_card - add card //------------------------------------------------- -void wangpcbus_device::add_card(device_wangpcbus_card_interface *card, int sid) +void wangpcbus_device::add_card(device_wangpcbus_card_interface &card, int sid) { - m_device_list.append(*card); + m_device_list.append(card); - card->m_bus = this; - card->m_sid = sid; + card.m_bus = this; + card.m_sid = sid; } @@ -242,12 +242,19 @@ WRITE_LINE_MEMBER( wangpcbus_device::tc_w ) //------------------------------------------------- device_wangpcbus_card_interface::device_wangpcbus_card_interface(const machine_config &mconfig, device_t &device) : - device_slot_card_interface(mconfig, device), m_bus(nullptr), m_sid(0), m_next(nullptr) + device_interface(device, "wangpcbus"), m_bus(nullptr), m_sid(0), m_next(nullptr) { m_slot = dynamic_cast<wangpcbus_slot_device *>(device.owner()); } +void device_wangpcbus_card_interface::interface_pre_start() +{ + if (!m_bus) + throw device_missing_dependencies(); +} + + //------------------------------------------------- // SLOT_INTERFACE( wangpc_cards ) //------------------------------------------------- diff --git a/src/devices/bus/wangpc/wangpc.h b/src/devices/bus/wangpc/wangpc.h index bb8c7a3c4ac..05ca1908f75 100644 --- a/src/devices/bus/wangpc/wangpc.h +++ b/src/devices/bus/wangpc/wangpc.h @@ -18,38 +18,35 @@ //************************************************************************** -// CONSTANTS +// TYPE DEFINITIONS //************************************************************************** -#define WANGPC_BUS_TAG "wangpcbus" - +class device_wangpcbus_card_interface; +class wangpcbus_device; -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** // ======================> wangpcbus_slot_device -class wangpcbus_device; - -class wangpcbus_slot_device : public device_t, public device_slot_interface +class wangpcbus_slot_device : public device_t, public device_single_card_slot_interface<device_wangpcbus_card_interface> { public: // construction/destruction - template <typename T> - wangpcbus_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt, int sid) + template <typename T, typename U> + wangpcbus_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&bus, U &&opts, char const *dflt, int sid) : wangpcbus_slot_device(mconfig, tag, owner, 0) { option_reset(); opts(*this); set_default_option(dflt); set_fixed(false); - set_wangpcbus_slot(sid); + set_bus(std::forward<T>(bus)); + set_bus_slot(sid); } wangpcbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); // inline configuration - void set_wangpcbus_slot(int sid) { m_sid = sid; } + template <typename T> void set_bus(T &&tag) { m_bus.set_tag(std::forward<T>(tag)); } + void set_bus_slot(int sid) { m_sid = sid; } protected: // device-level overrides @@ -57,7 +54,7 @@ protected: private: // configuration - wangpcbus_device *m_bus; + required_device<wangpcbus_device> m_bus; int m_sid; }; @@ -66,9 +63,6 @@ private: DECLARE_DEVICE_TYPE(WANGPC_BUS_SLOT, wangpcbus_slot_device) -class device_wangpcbus_card_interface; - - // ======================> wangpcbus_device class wangpcbus_device : public device_t @@ -89,7 +83,7 @@ public: auto drq3_wr_callback() { return m_write_drq3.bind(); } auto ioerror_wr_callback() { return m_write_ioerror.bind(); } - void add_card(device_wangpcbus_card_interface *card, int sid); + void add_card(device_wangpcbus_card_interface &card, int sid); // computer interface uint16_t mrdc_r(offs_t offset, uint16_t mem_mask = 0xffff); @@ -151,7 +145,7 @@ DECLARE_DEVICE_TYPE(WANGPC_BUS, wangpcbus_device) // ======================> device_wangpcbus_card_interface // class representing interface-specific live wangpcbus card -class device_wangpcbus_card_interface : public device_slot_card_interface +class device_wangpcbus_card_interface : public device_interface { friend class wangpcbus_device; template <class ElementType> friend class simple_list; @@ -178,6 +172,8 @@ protected: // construction/destruction device_wangpcbus_card_interface(const machine_config &mconfig, device_t &device); + virtual void interface_pre_start() override; + wangpcbus_device *m_bus; wangpcbus_slot_device *m_slot; |