mirror of
https://github.com/holub/mame
synced 2025-04-21 16:01:56 +03:00
sbus: Eliminate tag hacking (nw)
This commit is contained in:
parent
84b924a1f7
commit
b630126137
@ -44,11 +44,15 @@ sbus_slot_device::sbus_slot_device(const machine_config &mconfig, device_type ty
|
||||
: device_t(mconfig, type, tag, owner, clock)
|
||||
, device_slot_interface(mconfig, *this)
|
||||
, m_sbus(*this, finder_base::DUMMY_TAG)
|
||||
, m_slot(-1)
|
||||
{
|
||||
}
|
||||
|
||||
void sbus_slot_device::device_validity_check(validity_checker &valid) const
|
||||
{
|
||||
if (m_slot < 0 || m_slot > 2)
|
||||
osd_printf_error("Slot %d out of range for Sun SBus\n", m_slot);
|
||||
|
||||
device_t *const card(get_card_device());
|
||||
if (card && !dynamic_cast<device_sbus_card_interface *>(card))
|
||||
osd_printf_error("Card device %s (%s) does not implement device_sbus_card_interface\n", card->tag(), card->name());
|
||||
@ -58,7 +62,7 @@ void sbus_slot_device::device_resolve_objects()
|
||||
{
|
||||
device_sbus_card_interface *const sbus_card(dynamic_cast<device_sbus_card_interface *>(get_card_device()));
|
||||
if (sbus_card)
|
||||
sbus_card->set_sbus(m_sbus, tag());
|
||||
sbus_card->set_sbus(m_sbus, m_slot);
|
||||
}
|
||||
|
||||
void sbus_slot_device::device_start()
|
||||
@ -169,7 +173,6 @@ device_sbus_card_interface::device_sbus_card_interface(const machine_config &mco
|
||||
: device_slot_card_interface(mconfig, device)
|
||||
, m_sbus_finder(device, finder_base::DUMMY_TAG)
|
||||
, m_sbus(nullptr)
|
||||
, m_sbus_slottag(nullptr)
|
||||
, m_slot(-1)
|
||||
, m_base(0)
|
||||
{
|
||||
@ -201,20 +204,13 @@ void device_sbus_card_interface::interface_pre_start()
|
||||
if (!m_sbus->started())
|
||||
throw device_missing_dependencies();
|
||||
|
||||
// extract the slot number from the last digit of the slot tag
|
||||
size_t const tlen = strlen(m_sbus_slottag);
|
||||
|
||||
m_slot = (m_sbus_slottag[tlen - 1] - '1');
|
||||
if (m_slot < 0 || m_slot > 2)
|
||||
fatalerror("Slot %x out of range for Sun SBus\n", m_slot);
|
||||
|
||||
m_base = m_slot << 25;
|
||||
m_sbus->add_sbus_card(m_slot, this);
|
||||
}
|
||||
}
|
||||
|
||||
void device_sbus_card_interface::set_sbus(sbus_device *sbus, const char *slottag)
|
||||
void device_sbus_card_interface::set_sbus(sbus_device *sbus, int slot)
|
||||
{
|
||||
m_sbus = sbus;
|
||||
m_sbus_slottag = slottag;
|
||||
m_slot = slot;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class sbus_slot_device : public device_t, public device_slot_interface
|
||||
public:
|
||||
// construction/destruction
|
||||
template <typename T, typename U>
|
||||
sbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&sbus_tag, U &&opts, const char *dflt, bool fixed = false)
|
||||
sbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&sbus_tag, int slot, U &&opts, const char *dflt, bool fixed = false)
|
||||
: sbus_slot_device(mconfig, tag, owner, clock)
|
||||
{
|
||||
option_reset();
|
||||
@ -29,6 +29,7 @@ public:
|
||||
set_default_option(dflt);
|
||||
set_fixed(fixed);
|
||||
m_sbus.set_tag(std::forward<T>(sbus_tag));
|
||||
m_slot = slot;
|
||||
}
|
||||
sbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
@ -42,6 +43,7 @@ protected:
|
||||
|
||||
// configuration
|
||||
required_device<sbus_device> m_sbus;
|
||||
int m_slot;
|
||||
|
||||
DECLARE_READ32_MEMBER(timeout_r);
|
||||
DECLARE_WRITE32_MEMBER(timeout_w);
|
||||
@ -131,8 +133,8 @@ public:
|
||||
virtual ~device_sbus_card_interface();
|
||||
|
||||
// inline configuration
|
||||
void set_sbus(sbus_device *sbus, const char *slottag);
|
||||
template <typename T> void set_onboard(T &&sbus) { m_sbus_finder.set_tag(std::forward<T>(sbus)); m_sbus_slottag = device().tag(); }
|
||||
void set_sbus(sbus_device *sbus, int slot);
|
||||
template <typename T> void set_onboard(T &&sbus, int slot) { m_sbus_finder.set_tag(std::forward<T>(sbus)); m_slot = slot; }
|
||||
|
||||
virtual void mem_map(address_map &map) = 0;
|
||||
|
||||
|
@ -2017,9 +2017,9 @@ void sun4_state::sun4c(machine_config &config)
|
||||
|
||||
// SBus
|
||||
SBUS(config, m_sbus, 20'000'000, "maincpu", "type1");
|
||||
SBUS_SLOT(config, m_sbus_slot[0], 20'000'000, m_sbus, sbus_cards, nullptr);
|
||||
SBUS_SLOT(config, m_sbus_slot[1], 20'000'000, m_sbus, sbus_cards, nullptr);
|
||||
SBUS_SLOT(config, m_sbus_slot[2], 20'000'000, m_sbus, sbus_cards, nullptr);
|
||||
SBUS_SLOT(config, m_sbus_slot[0], 20'000'000, m_sbus, 0, sbus_cards, nullptr);
|
||||
SBUS_SLOT(config, m_sbus_slot[1], 20'000'000, m_sbus, 1, sbus_cards, nullptr);
|
||||
SBUS_SLOT(config, m_sbus_slot[2], 20'000'000, m_sbus, 2, sbus_cards, nullptr);
|
||||
}
|
||||
|
||||
void sun4_state::sun4_20(machine_config &config)
|
||||
|
Loading…
Reference in New Issue
Block a user