From ee3116f4e27e65af0b0ba2d94576ece8ef9d0b91 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 30 Jun 2018 22:31:49 -0400 Subject: namco_c148: Eliminate machine().device (nw) --- src/mame/machine/namco_c148.cpp | 27 ++------------------------- src/mame/machine/namco_c148.h | 17 +++++++---------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/src/mame/machine/namco_c148.cpp b/src/mame/machine/namco_c148.cpp index a9492710cb9..262ced95964 100644 --- a/src/mame/machine/namco_c148.cpp +++ b/src/mame/machine/namco_c148.cpp @@ -69,8 +69,8 @@ namco_c148_device::namco_c148_device(const machine_config &mconfig, const char * : device_t(mconfig, NAMCO_C148, tag, owner, clock), m_out_ext1_cb(*this), m_out_ext2_cb(*this), - m_hostcpu_tag(nullptr), - m_linked_c148_tag(finder_base::DUMMY_TAG) + m_hostcpu(*this, finder_base::DUMMY_TAG), + m_linked_c148(*this, finder_base::DUMMY_TAG) { } @@ -104,10 +104,6 @@ void namco_c148_device::map(address_map &map) void namco_c148_device::device_start() { - m_hostcpu = machine().device(m_hostcpu_tag); - m_linked_c148 = machine().device(m_linked_c148_tag); - assert(m_hostcpu != nullptr); - m_out_ext1_cb.resolve_safe(); m_out_ext2_cb.resolve_safe(); @@ -136,25 +132,6 @@ void namco_c148_device::device_reset() m_irqlevel.cpu = 0; } -//------------------------------------------------- -// device_validity_check - device-specific checks -//------------------------------------------------- - -void namco_c148_device::device_validity_check(validity_checker &valid) const -{ - device_t *const hostcpu = mconfig().root_device().subdevice(m_hostcpu_tag); - if (!hostcpu) - osd_printf_error("Host CPU device %s not found\n", m_hostcpu_tag ? m_hostcpu_tag : ""); - else if (!dynamic_cast(hostcpu)) - osd_printf_error("Host CPU device %s is not an instance of cpu_device\n", m_hostcpu_tag ? m_hostcpu_tag : ""); - - device_t *const linked_c148 = mconfig().root_device().subdevice(m_linked_c148_tag); - if ((finder_base::DUMMY_TAG != m_linked_c148_tag) && !linked_c148) - osd_printf_error("Linked C148 device %s not found\n", m_linked_c148_tag ? m_linked_c148_tag : ""); - else if (linked_c148 && !dynamic_cast(linked_c148)) - osd_printf_error("Linked C148 device %s is not an instance of c148_device\n", m_linked_c148_tag ? m_linked_c148_tag : ""); -} - //************************************************************************** // IRQ section //************************************************************************** diff --git a/src/mame/machine/namco_c148.h b/src/mame/machine/namco_c148.h index e168dda66de..c2e2cab4e50 100644 --- a/src/mame/machine/namco_c148.h +++ b/src/mame/machine/namco_c148.h @@ -45,13 +45,13 @@ public: void map(address_map &map); - void configure_device(const char *tag, bool is_master) + template void configure_device(T &&tag, bool is_master) { - m_hostcpu_tag = tag; + m_hostcpu.set_tag(std::forward(tag)); m_hostcpu_master = is_master; } - void link_c148_device(const char *tag) { m_linked_c148_tag = tag; } + template void link_c148_device(T &&tag) { m_linked_c148.set_tag(std::forward(tag)); } template devcb_base &set_out_ext1_callback(Object &&cb) { return m_out_ext1_cb.set_callback(std::forward(cb)); } template devcb_base &set_out_ext2_callback(Object &&cb) { return m_out_ext2_cb.set_callback(std::forward(cb)); } @@ -103,16 +103,13 @@ public: protected: void cpu_irq_trigger(); // device-level overrides -// virtual void device_validity_check(validity_checker &valid) const; virtual void device_start() override; virtual void device_reset() override; - virtual void device_validity_check(validity_checker &valid) const override; private: - cpu_device *m_hostcpu; /**< reference to the host cpu */ - namco_c148_device *m_linked_c148; /**< reference to linked master/slave c148 */ - const char *m_hostcpu_tag; /**< host cpu tag name */ - const char *m_linked_c148_tag; /**< other c148 tag name */ - bool m_hostcpu_master; /**< define if host cpu is master */ + required_device m_hostcpu; // reference to the host cpu + optional_device m_linked_c148; // reference to linked master/slave c148 + bool m_hostcpu_master; // define if host cpu is master + struct{ uint8_t cpu; uint8_t ex; -- cgit v1.2.3