summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-09-06 23:41:35 +1000
committer Vas Crabb <vas@vastheman.com>2021-09-06 23:41:35 +1000
commitfa9c035c8024e0f78fde882fb3e8437485ec91ae (patch)
tree4fb29b5714ac6c7fbde0aff8a60f0ee690a324bb /src/emu
parentf474673bc58555910852bae062f030283407c448 (diff)
Allow devices to specify a parent for the purpose of searching for ROMs.
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/device.cpp2
-rw-r--r--src/emu/device.h14
-rw-r--r--src/emu/validity.cpp27
3 files changed, 37 insertions, 6 deletions
diff --git a/src/emu/device.cpp b/src/emu/device.cpp
index 51088b02d4a..8e80fe3c809 100644
--- a/src/emu/device.cpp
+++ b/src/emu/device.cpp
@@ -136,6 +136,8 @@ std::vector<std::string> device_t::searchpath() const
system = system->owner();
if (system)
result = system->searchpath();
+ if (type().parent_rom_device_type())
+ result.emplace(result.begin(), type().parent_rom_device_type()->shortname());
result.emplace(result.begin(), shortname());
return result;
}
diff --git a/src/emu/device.h b/src/emu/device.h
index d5fe81dd305..04d1df34b7a 100644
--- a/src/emu/device.h
+++ b/src/emu/device.h
@@ -220,6 +220,7 @@ private:
char const *const m_source;
device_feature::type const m_unemulated_features;
device_feature::type const m_imperfect_features;
+ device_type_impl_base const *const m_parent_rom;
device_type_impl_base *m_next;
@@ -234,6 +235,7 @@ public:
, m_source(nullptr)
, m_unemulated_features(device_feature::NONE)
, m_imperfect_features(device_feature::NONE)
+ , m_parent_rom(nullptr)
, m_next(nullptr)
{
}
@@ -247,6 +249,7 @@ public:
, m_source(Source)
, m_unemulated_features(DeviceClass::unemulated_features())
, m_imperfect_features(DeviceClass::imperfect_features())
+ , m_parent_rom(DeviceClass::parent_rom_device_type())
, m_next(device_registrar::register_device(*this))
{
}
@@ -260,6 +263,7 @@ public:
, m_source(Source)
, m_unemulated_features(DriverClass::unemulated_features() | Unemulated)
, m_imperfect_features((DriverClass::imperfect_features() & ~Unemulated) | Imperfect)
+ , m_parent_rom(DriverClass::parent_rom_device_type())
, m_next(nullptr)
{
}
@@ -270,6 +274,7 @@ public:
char const *source() const { return m_source; }
device_feature::type unemulated_features() const { return m_unemulated_features; }
device_feature::type imperfect_features() const { return m_imperfect_features; }
+ device_type_impl_base const *parent_rom_device_type() const { return m_parent_rom; }
std::unique_ptr<device_t> create(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock) const
{
@@ -517,6 +522,15 @@ public:
/// \sa unemulated_features
static constexpr feature_type imperfect_features() { return feature::NONE; }
+ /// \brief Get parent device type for ROM search
+ ///
+ /// Impement this member in a derived class to declare the parent
+ /// device type for the purpose of searching for ROMs. Only one
+ /// level is allowed. It is an error the parent device type itself
+ /// declares a parent device type.
+ /// \return Pointer to parent device type, or nullptr.
+ static auto parent_rom_device_type() { return nullptr; }
+
virtual ~device_t();
// getters
diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp
index 9bd9edb1ff0..fd8b8d4464b 100644
--- a/src/emu/validity.cpp
+++ b/src/emu/validity.cpp
@@ -1493,6 +1493,10 @@ void validity_checker::validate_driver(device_t &root)
if (clone_of != -1 && (clone_of = driver_list::non_bios_clone(clone_of)) != -1)
osd_printf_error("Driver is a clone of a clone\n");
+ // look for drivers specifying a parent ROM device type
+ if (root.type().parent_rom_device_type())
+ osd_printf_error("Driver has parent ROM device type '%s'\n", root.type().parent_rom_device_type()->shortname());
+
// make sure the driver name is not too long
if (!is_clone && strlen(m_current_driver->name) > 16)
osd_printf_error("Parent driver name must be 16 characters or less\n");
@@ -1548,11 +1552,11 @@ void validity_checker::validate_driver(device_t &root)
// catch invalid flag combinations
if (unemulated & ~device_t::feature::ALL)
- osd_printf_error("Driver has invalid unemulated feature flags (0x%08lX)\n", static_cast<unsigned long>(unemulated & ~device_t::feature::ALL));
+ osd_printf_error("Driver has invalid unemulated feature flags (0x%08X)\n", util::underlying_value(unemulated & ~device_t::feature::ALL));
if (imperfect & ~device_t::feature::ALL)
- osd_printf_error("Driver has invalid imperfect feature flags (0x%08lX)\n", static_cast<unsigned long>(imperfect & ~device_t::feature::ALL));
+ osd_printf_error("Driver has invalid imperfect feature flags (0x%08X)\n", util::underlying_value(imperfect & ~device_t::feature::ALL));
if (unemulated & imperfect)
- osd_printf_error("Driver cannot have features that are both unemulated and imperfect (0x%08lX)\n", static_cast<unsigned long>(unemulated & imperfect));
+ osd_printf_error("Driver cannot have features that are both unemulated and imperfect (0x%08X)\n", util::underlying_value(unemulated & imperfect));
if ((m_current_driver->flags & machine_flags::NO_SOUND_HW) && ((unemulated | imperfect) & device_t::feature::SOUND))
osd_printf_error("Machine without sound hardware cannot have unemulated/imperfect sound\n");
}
@@ -2203,11 +2207,22 @@ void validity_checker::validate_device_types()
device_t::feature_type const unemulated(dev->type().unemulated_features());
device_t::feature_type const imperfect(dev->type().imperfect_features());
if (unemulated & ~device_t::feature::ALL)
- osd_printf_error("Device has invalid unemulated feature flags (0x%08lX)\n", static_cast<unsigned long>(unemulated & ~device_t::feature::ALL));
+ osd_printf_error("Device has invalid unemulated feature flags (0x%08X)\n", util::underlying_value(unemulated & ~device_t::feature::ALL));
if (imperfect & ~device_t::feature::ALL)
- osd_printf_error("Device has invalid imperfect feature flags (0x%08lX)\n", static_cast<unsigned long>(imperfect & ~device_t::feature::ALL));
+ osd_printf_error("Device has invalid imperfect feature flags (0x%08X)\n", util::underlying_value(imperfect & ~device_t::feature::ALL));
if (unemulated & imperfect)
- osd_printf_error("Device cannot have features that are both unemulated and imperfect (0x%08lX)\n", static_cast<unsigned long>(unemulated & imperfect));
+ osd_printf_error("Device cannot have features that are both unemulated and imperfect (0x%08X)\n", util::underlying_value(unemulated & imperfect));
+
+ // check that parents are only ever one generation deep
+ auto const parent(dev->type().parent_rom_device_type());
+ if (parent)
+ {
+ auto const grandparent(parent->parent_rom_device_type());
+ if ((dev->type() == *parent) || !strcmp(parent->shortname(), name))
+ osd_printf_error("Device has parent ROM set that identical to its type\n");
+ if (grandparent)
+ osd_printf_error("Device has parent ROM set '%s' which has parent ROM set '%s'\n", parent->shortname(), grandparent->shortname());
+ }
// give devices some of the same scrutiny that drivers get - necessary for cards not default for any slots
validate_roms(*dev);