From 95863464389feba1cb8bf3e6a2c1057d72e33344 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 30 Oct 2018 01:02:09 +1100 Subject: hp_hil: Removing MCFG macros doesn't just mean blindly expanding them (nw) * The validation and slot registration still needs modernising, but the client code is prettier at least --- src/devices/bus/hp_dio/human_interface.cpp | 11 ++--------- src/devices/bus/hp_hil/hp_hil.cpp | 8 ++++---- src/devices/bus/hp_hil/hp_hil.h | 29 +++++++++++++++-------------- src/mame/drivers/hp16500.cpp | 5 +---- src/mame/drivers/hp_ipc.cpp | 12 +++--------- 5 files changed, 25 insertions(+), 40 deletions(-) diff --git a/src/devices/bus/hp_dio/human_interface.cpp b/src/devices/bus/hp_dio/human_interface.cpp index ae796d136b9..75f7f1c1296 100644 --- a/src/devices/bus/hp_dio/human_interface.cpp +++ b/src/devices/bus/hp_dio/human_interface.cpp @@ -36,15 +36,8 @@ void human_interface_device::device_add_mconfig(machine_config &config) iocpu.t1_in_cb().set_constant(1); HP_HIL_MLC(config, m_mlc, XTAL(8'000'000)); - hp_hil_slot_device &keyboard(HP_HIL_SLOT(config, "hil1", 0)); - hp_hil_devices(keyboard); - keyboard.set_default_option("hp_46021a"); - keyboard.set_hp_hil_slot(this, "mlc"); - - hp_hil_slot_device &mouse(HP_HIL_SLOT(config, "hil2", 0)); - hp_hil_devices(mouse); - mouse.set_default_option("hp_46060b"); - mouse.set_hp_hil_slot(this, "mlc"); + HP_HIL_SLOT(config, "hil1", m_mlc, hp_hil_devices, "hp_46021a"); + HP_HIL_SLOT(config, "hil2", m_mlc, hp_hil_devices, "hp_46060b"); SPEAKER(config, "mono").front_center(); sn76494_device &sound(SN76494(config, "sn76494", 333333)); diff --git a/src/devices/bus/hp_hil/hp_hil.cpp b/src/devices/bus/hp_hil/hp_hil.cpp index 02dbf69b61c..2e8a904c97b 100644 --- a/src/devices/bus/hp_hil/hp_hil.cpp +++ b/src/devices/bus/hp_hil/hp_hil.cpp @@ -28,6 +28,7 @@ DEFINE_DEVICE_TYPE(HP_HIL_SLOT, hp_hil_slot_device, "hp_hil_slot", "HP-HIL Slot" hp_hil_slot_device::hp_hil_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, HP_HIL_SLOT, tag, owner, clock) , device_slot_interface(mconfig, *this) + , m_mlc(*this, finder_base::DUMMY_TAG) { } @@ -39,8 +40,8 @@ hp_hil_slot_device::hp_hil_slot_device(const machine_config &mconfig, const char void hp_hil_slot_device::device_start() { device_hp_hil_interface *dev = dynamic_cast(get_card_device()); - - if (dev) dev->set_hp_hil_mlc(m_owner->subdevice(m_mlc_tag)); + if (dev) + dev->set_hp_hil_mlc(*m_mlc); } @@ -243,7 +244,6 @@ WRITE_LINE_MEMBER(hp_hil_mlc_device::ap_w) device_hp_hil_interface::device_hp_hil_interface(const machine_config &mconfig, device_t &device) : device_slot_card_interface(mconfig, device) , m_hp_hil_mlc(nullptr) - , m_hp_hil_mlc_dev(nullptr) , m_next(nullptr) { } @@ -259,6 +259,6 @@ device_hp_hil_interface::~device_hp_hil_interface() void device_hp_hil_interface::set_hp_hil_mlc_device() { - m_hp_hil_mlc = dynamic_cast(m_hp_hil_mlc_dev); + assert(m_hp_hil_mlc); m_hp_hil_mlc->add_hp_hil_device(this); } diff --git a/src/devices/bus/hp_hil/hp_hil.h b/src/devices/bus/hp_hil/hp_hil.h index 4ee8984cdc9..7ec8335a8fb 100644 --- a/src/devices/bus/hp_hil/hp_hil.h +++ b/src/devices/bus/hp_hil/hp_hil.h @@ -75,31 +75,35 @@ * */ -//************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - //************************************************************************** // TYPE DEFINITIONS //************************************************************************** +class hp_hil_mlc_device; + class hp_hil_slot_device : public device_t, public device_slot_interface { public: // construction/destruction + template + hp_hil_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&mlc_tag, U &&opts, const char *dflt) + : hp_hil_slot_device(mconfig, tag, owner, 0) + { + m_mlc.set_tag(std::forward(mlc_tag)); + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } hp_hil_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +protected: // device-level overrides virtual void device_start() override; - // inline configuration - void set_hp_hil_slot(device_t *owner, const char *mlc_tag) { m_owner = owner; m_mlc_tag = mlc_tag; } - -protected: // configuration - device_t *m_owner; - const char *m_mlc_tag; + required_device m_mlc; }; @@ -116,8 +120,6 @@ public: hp_hil_mlc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); ~hp_hil_mlc_device() { m_device_list.detach_all(); } - template devcb_base &set_int_callback(Object &&cb) { return int_cb.set_callback(std::forward(cb)); } - template devcb_base &set_nmi_callback(Object &&cb) { return nmi_cb.set_callback(std::forward(cb)); } auto int_callback() { return int_cb.bind(); } auto nmi_callback() { return nmi_cb.bind(); } @@ -165,7 +167,7 @@ public: void set_hp_hil_mlc_device(); // inline configuration - void set_hp_hil_mlc(device_t *mlc_device) { m_hp_hil_mlc_dev = mlc_device; } + void set_hp_hil_mlc(hp_hil_mlc_device &mlc_device) { m_hp_hil_mlc = &mlc_device; } virtual bool hil_write(uint16_t *data) { return true; }; int device_id() { return m_device_id; }; @@ -176,7 +178,6 @@ protected: virtual void device_reset() { } hp_hil_mlc_device *m_hp_hil_mlc; - device_t *m_hp_hil_mlc_dev; hp_hil_slot_device *m_slot; diff --git a/src/mame/drivers/hp16500.cpp b/src/mame/drivers/hp16500.cpp index a816ef21a55..7db8c658a0f 100644 --- a/src/mame/drivers/hp16500.cpp +++ b/src/mame/drivers/hp16500.cpp @@ -493,10 +493,7 @@ MACHINE_CONFIG_START(hp16500_state::hp16500) // TODO: for now hook up the ipc hil keyboard - this might be replaced // later with a 16500b specific keyboard implementation - hp_hil_slot_device &keyboard(HP_HIL_SLOT(config, "hil1", 0)); - hp_hil_devices(keyboard); - keyboard.set_default_option("hp_ipc_kbd"); - keyboard.set_hp_hil_slot(this, "mlc"); + HP_HIL_SLOT(config, "hil1", "mlc", hp_hil_devices, "hp_ipc_kbd"); SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); diff --git a/src/mame/drivers/hp_ipc.cpp b/src/mame/drivers/hp_ipc.cpp index 1f67ed30a59..2a6aa4b067f 100644 --- a/src/mame/drivers/hp_ipc.cpp +++ b/src/mame/drivers/hp_ipc.cpp @@ -757,15 +757,9 @@ MACHINE_CONFIG_START(hp_ipc_state::hp_ipc_base) hp_hil_mlc_device &mlc(HP_HIL_MLC(config, "mlc", XTAL(15'920'000)/2)); mlc.int_callback().set(FUNC(hp_ipc_state::irq_2)); mlc.nmi_callback().set(FUNC(hp_ipc_state::irq_7)); - hp_hil_slot_device &keyboard(HP_HIL_SLOT(config, "hil1", 0)); - hp_hil_devices(keyboard); - keyboard.set_default_option("hp_ipc_kbd"); - keyboard.set_hp_hil_slot(this, "mlc"); - - hp_hil_slot_device &mouse(HP_HIL_SLOT(config, "hil2", 0)); - hp_hil_devices(mouse); - mouse.set_default_option("hp_46060b"); - mouse.set_hp_hil_slot(this, "mlc"); + + HP_HIL_SLOT(config, "hil1", "mlc", hp_hil_devices, "hp_ipc_kbd"); + HP_HIL_SLOT(config, "hil2", "mlc", hp_hil_devices, "hp_46060b"); tms9914_device &hpib(TMS9914(config, "hpib", 4_MHz_XTAL)); hpib.int_write_cb().set(FUNC(hp_ipc_state::irq_3)); -- cgit v1.2.3