namco_c148: Eliminate machine().device (nw)

This commit is contained in:
AJR 2018-06-30 22:31:49 -04:00
parent 8e6155337f
commit ee3116f4e2
2 changed files with 9 additions and 35 deletions

View File

@ -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<cpu_device>(m_hostcpu_tag);
m_linked_c148 = machine().device<namco_c148_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 : "<nullptr>");
else if (!dynamic_cast<cpu_device *>(hostcpu))
osd_printf_error("Host CPU device %s is not an instance of cpu_device\n", m_hostcpu_tag ? m_hostcpu_tag : "<nullptr>");
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 : "<nullptr>");
else if (linked_c148 && !dynamic_cast<namco_c148_device *>(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 : "<nullptr>");
}
//**************************************************************************
// IRQ section
//**************************************************************************

View File

@ -45,13 +45,13 @@ public:
void map(address_map &map);
void configure_device(const char *tag, bool is_master)
template <class T> void configure_device(T &&tag, bool is_master)
{
m_hostcpu_tag = tag;
m_hostcpu.set_tag(std::forward<T>(tag));
m_hostcpu_master = is_master;
}
void link_c148_device(const char *tag) { m_linked_c148_tag = tag; }
template <class T> void link_c148_device(T &&tag) { m_linked_c148.set_tag(std::forward<T>(tag)); }
template <class Object> devcb_base &set_out_ext1_callback(Object &&cb) { return m_out_ext1_cb.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_out_ext2_callback(Object &&cb) { return m_out_ext2_cb.set_callback(std::forward<Object>(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<cpu_device> m_hostcpu; // reference to the host cpu
optional_device<namco_c148_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;