summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-09-22 21:36:37 +1000
committer Vas Crabb <vas@vastheman.com>2017-09-22 21:36:37 +1000
commit165da5efa4d52b550ff224b1f207a8baa0fa1ab6 (patch)
tree9790d420195893fafe6406582ce804ac81d8f698
parentff82930d50611586228dd0bdb093ae5a51348e4a (diff)
Start adding stuff for iterating ROM entries in a more C++ way without needing to allocate everywhere, improve performance of -listxml by another 10% or so
-rw-r--r--src/emu/addrmap.cpp8
-rw-r--r--src/emu/devfind.cpp8
-rw-r--r--src/emu/romload.h289
-rw-r--r--src/emu/validity.cpp22
-rw-r--r--src/frontend/mame/clifront.cpp16
-rw-r--r--src/frontend/mame/info.cpp42
-rw-r--r--src/frontend/mame/media_ident.cpp22
-rw-r--r--src/frontend/mame/media_ident.h2
-rw-r--r--src/frontend/mame/ui/devopt.cpp11
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp46
-rw-r--r--src/frontend/mame/ui/selmenu.cpp25
11 files changed, 384 insertions, 107 deletions
diff --git a/src/emu/addrmap.cpp b/src/emu/addrmap.cpp
index 0616947af03..0d8d7bc4eef 100644
--- a/src/emu/addrmap.cpp
+++ b/src/emu/addrmap.cpp
@@ -708,17 +708,19 @@ void address_map::map_validity_check(validity_checker &valid, int spacenum) cons
// look for the region
for (device_t &dev : device_iterator(m_device->mconfig().root_device()))
- for (const rom_entry *romp = rom_first_region(dev); romp != nullptr && !found; romp = rom_next_region(romp))
+ {
+ for (romload::region const &region : romload::entries(dev.rom_region()).get_regions())
{
- if (rom_region_name(dev, romp) == entry_region)
+ if (dev.subtag(region.get_tag()) == entry_region)
{
// verify the address range is within the region's bounds
- offs_t length = ROMREGION_GETLENGTH(romp);
+ offs_t const length = region.get_length();
if (entry.m_rgnoffs + (byteend - bytestart + 1) > length)
osd_printf_error("%s space memory map entry %X-%X extends beyond region '%s' size (%X)\n", spaceconfig.m_name, entry.m_addrstart, entry.m_addrend, entry.m_region, length);
found = true;
}
}
+ }
// error if not found
if (!found)
diff --git a/src/emu/devfind.cpp b/src/emu/devfind.cpp
index 7eb309bbfd2..81071fa891c 100644
--- a/src/emu/devfind.cpp
+++ b/src/emu/devfind.cpp
@@ -165,13 +165,13 @@ bool finder_base::validate_memregion(size_t bytes, bool required) const
std::string region_fulltag = m_base.subtag(m_tag);
// look for the region
- for (device_t &dev : device_iterator(m_base.mconfig().root_device()))
+ for (device_t const &dev : device_iterator(m_base.mconfig().root_device()))
{
- for (const rom_entry *romp = rom_first_region(dev); romp != nullptr; romp = rom_next_region(romp))
+ for (romload::region const &region : romload::entries(dev.rom_region()).get_regions())
{
- if (rom_region_name(dev, romp) == region_fulltag)
+ if (dev.subtag(region.get_tag()) == region_fulltag)
{
- bytes_found = ROMREGION_GETLENGTH(romp);
+ bytes_found = region.get_length();
break;
}
}
diff --git a/src/emu/romload.h b/src/emu/romload.h
index 3a4756ddb0d..12f8679cb24 100644
--- a/src/emu/romload.h
+++ b/src/emu/romload.h
@@ -87,6 +87,295 @@ template <typename T> inline u32 DISK_GETINDEX(T const &r) { return
template <typename T> inline bool DISK_ISREADONLY(T const &r) { return (ROM_GETFLAGS(r) & DISK_READONLYMASK) == DISK_READONLY; }
+namespace romload {
+
+template <typename T>
+class const_entry_iterator
+{
+protected:
+ tiny_rom_entry const *m_data;
+
+ constexpr const_entry_iterator() noexcept : m_data(nullptr) { }
+ constexpr const_entry_iterator(tiny_rom_entry const *data) noexcept : m_data(data) { }
+ constexpr const_entry_iterator(const_entry_iterator const &) noexcept = default;
+ const_entry_iterator(const_entry_iterator &&) noexcept = default;
+ const_entry_iterator &operator=(const_entry_iterator const &) noexcept = default;
+ const_entry_iterator &operator=(const_entry_iterator &&) noexcept = default;
+
+public:
+ typedef T value_type;
+ typedef value_type const *pointer;
+ typedef value_type const &reference;
+ typedef std::ptrdiff_t difference_type;
+ typedef std::forward_iterator_tag iterator_category;
+
+ reference operator*() const noexcept { return reinterpret_cast<reference>(*m_data); }
+ pointer operator->() const noexcept { return reinterpret_cast<pointer>(m_data); }
+};
+
+
+class file final : tiny_rom_entry
+{
+private:
+ file() = default;
+ file(file const &) = delete;
+ file &operator=(file const &) = delete;
+
+public:
+ // ROM
+ constexpr char const *get_name() const { return name; }
+ constexpr u32 get_offset() const { return offset; }
+ constexpr u32 get_length() const { return length; }
+ constexpr u32 get_flags() const { return flags; }
+ constexpr char const *get_hashdata() const { return hashdata; }
+ constexpr bool is_optional() const { return (flags & ROM_OPTIONALMASK) == ROM_OPTIONAL; }
+ constexpr u32 get_groupsize() const { return ((flags & ROM_GROUPMASK) >> 8) + 1; }
+ constexpr u32 get_skipcount() const { return (flags & ROM_SKIPMASK) >> 12; }
+ constexpr bool is_reversed() const { return (flags & ROM_REVERSEMASK) == ROM_REVERSE; }
+ constexpr u32 get_bitwidth() const { return (flags & ROM_BITWIDTHMASK) ? ((flags & ROM_BITWIDTHMASK) >> 16) : 8; }
+ constexpr u32 get_bitshift() const { return (flags & ROM_BITSHIFTMASK) >> 20; }
+ constexpr bool inherits_flags() const { return (flags & ROM_INHERITFLAGSMASK) == ROM_INHERITFLAGS; }
+ constexpr u32 get_bios_flags() const { return (flags & ROM_BIOSFLAGSMASK) >> 24; }
+
+ // disk
+ constexpr u32 get_index() const { return offset; }
+ constexpr bool is_readonly() const { return (flags & DISK_READONLYMASK) == DISK_READONLY; }
+};
+
+class files
+{
+private:
+ tiny_rom_entry const *m_data;
+
+public:
+ class const_iterator : public const_entry_iterator<file>
+ {
+ private:
+ friend class files;
+
+ constexpr const_iterator(tiny_rom_entry const *data) noexcept : const_entry_iterator<file>(data) { }
+
+ public:
+ constexpr const_iterator() noexcept = default;
+ constexpr const_iterator(const_iterator const &) noexcept = default;
+ const_iterator(const_iterator &&) noexcept = default;
+ const_iterator &operator=(const_iterator const &) noexcept = default;
+ const_iterator &operator=(const_iterator &&) noexcept = default;
+
+ const_iterator &operator++() noexcept
+ {
+ while (m_data)
+ {
+ ++m_data;
+ if (ROMENTRY_ISFILE(m_data))
+ break;
+ else if (ROMENTRY_ISREGIONEND(m_data))
+ m_data = nullptr;
+ }
+ return *this;
+ }
+
+ const_iterator operator++(int) noexcept { const_iterator result(*this); operator++(); return result; }
+
+ constexpr bool operator==(const_iterator const &rhs) const noexcept { return m_data == rhs.m_data; }
+ constexpr bool operator!=(const_iterator const &rhs) const noexcept { return m_data != rhs.m_data; }
+ };
+
+ files(tiny_rom_entry const *data) : m_data(data)
+ {
+ while (m_data && !ROMENTRY_ISFILE(m_data))
+ {
+ if (ROMENTRY_ISREGIONEND(m_data))
+ m_data = nullptr;
+ else
+ ++m_data;
+ }
+ }
+
+ const_iterator begin() const { return const_iterator(m_data); }
+ const_iterator cbegin() const { return const_iterator(m_data); }
+ const_iterator end() const { return const_iterator(nullptr); }
+ const_iterator cend() const { return const_iterator(nullptr); }
+};
+
+
+class region final : tiny_rom_entry
+{
+private:
+ region() = default;
+ region(region const &) = delete;
+ region &operator=(region const &) = delete;
+
+public:
+ constexpr char const *get_tag() const { return name; }
+ constexpr u32 get_length() const { return length; }
+ constexpr u32 get_width() const { return 8 << ((flags & ROMREGION_WIDTHMASK) >> 8); }
+ constexpr bool is_littleendian() const { return (flags & ROMREGION_ENDIANMASK) == ROMREGION_LE; }
+ constexpr bool is_bigendian() const { return (flags & ROMREGION_ENDIANMASK) == ROMREGION_BE; }
+ constexpr bool is_inverted() const { return (flags & ROMREGION_INVERTMASK) == ROMREGION_INVERT; }
+ constexpr bool is_erase() const { return (flags & ROMREGION_ERASEMASK) == ROMREGION_ERASE; }
+ constexpr u32 get_eraseval() const { return (flags & ROMREGION_ERASEVALMASK) >> 16; }
+ constexpr u32 get_datatype() const { return flags & ROMREGION_DATATYPEMASK; }
+ constexpr bool is_romdata() const { return get_datatype() == ROMREGION_DATATYPEROM; }
+ constexpr bool is_diskdata() const { return get_datatype() == ROMREGION_DATATYPEDISK; }
+
+ files get_files() const { return files(static_cast<tiny_rom_entry const *>(this) + 1); }
+};
+
+class regions
+{
+private:
+ tiny_rom_entry const *m_data;
+
+public:
+ class const_iterator : public const_entry_iterator<region>
+ {
+ private:
+ friend class regions;
+
+ constexpr const_iterator(tiny_rom_entry const *data) noexcept : const_entry_iterator<region>(data) { }
+
+ public:
+ constexpr const_iterator() noexcept = default;
+ constexpr const_iterator(const_iterator const &) noexcept = default;
+ const_iterator(const_iterator &&) noexcept = default;
+ const_iterator &operator=(const_iterator const &) noexcept = default;
+ const_iterator &operator=(const_iterator &&) noexcept = default;
+
+ const_iterator &operator++() noexcept
+ {
+ while (m_data)
+ {
+ ++m_data;
+ if (ROMENTRY_ISREGION(m_data))
+ break;
+ else if (ROMENTRY_ISEND(m_data))
+ m_data = nullptr;
+ }
+ return *this;
+ }
+
+ const_iterator operator++(int) noexcept { const_iterator result(*this); operator++(); return result; }
+
+ constexpr bool operator==(const_iterator const &rhs) const noexcept { return m_data == rhs.m_data; }
+ constexpr bool operator!=(const_iterator const &rhs) const noexcept { return m_data != rhs.m_data; }
+ };
+
+ regions(tiny_rom_entry const *data) : m_data(data)
+ {
+ while (m_data && !ROMENTRY_ISREGION(m_data))
+ {
+ if (ROMENTRY_ISEND(m_data))
+ m_data = nullptr;
+ else
+ ++m_data;
+ }
+ }
+
+ const_iterator begin() const { return const_iterator(m_data); }
+ const_iterator cbegin() const { return const_iterator(m_data); }
+ const_iterator end() const { return const_iterator(nullptr); }
+ const_iterator cend() const { return const_iterator(nullptr); }
+};
+
+
+class system_bios final : tiny_rom_entry
+{
+private:
+ system_bios() = default;
+ system_bios(system_bios const &) = delete;
+ system_bios &operator=(system_bios const &) = delete;
+
+public:
+ constexpr u32 get_value() const { return (flags & ROM_BIOSFLAGSMASK) >> 24; }
+ constexpr char const *get_name() const { return name; }
+ constexpr char const *get_description() const { return hashdata; }
+};
+
+class system_bioses
+{
+private:
+ tiny_rom_entry const *m_data;
+
+public:
+ class const_iterator : public const_entry_iterator<system_bios>
+ {
+ private:
+ friend class system_bioses;
+
+ constexpr const_iterator(tiny_rom_entry const *data) noexcept : const_entry_iterator<system_bios>(data) { }
+
+ public:
+ constexpr const_iterator() noexcept = default;
+ constexpr const_iterator(const_iterator const &) noexcept = default;
+ const_iterator(const_iterator &&) noexcept = default;
+ const_iterator &operator=(const_iterator const &) noexcept = default;
+ const_iterator &operator=(const_iterator &&) noexcept = default;
+
+ const_iterator &operator++() noexcept
+ {
+ while (m_data)
+ {
+ ++m_data;
+ if (ROMENTRY_ISSYSTEM_BIOS(m_data))
+ break;
+ else if (ROMENTRY_ISEND(m_data))
+ m_data = nullptr;
+ }
+ return *this;
+ }
+
+ const_iterator operator++(int) noexcept { const_iterator result(*this); operator++(); return result; }
+
+ constexpr bool operator==(const_iterator const &rhs) const noexcept { return m_data == rhs.m_data; }
+ constexpr bool operator!=(const_iterator const &rhs) const noexcept { return m_data != rhs.m_data; }
+ };
+
+ system_bioses(tiny_rom_entry const *data) : m_data(data)
+ {
+ while (m_data && !ROMENTRY_ISSYSTEM_BIOS(m_data))
+ {
+ if (ROMENTRY_ISEND(m_data))
+ m_data = nullptr;
+ else
+ ++m_data;
+ }
+ }
+
+ const_iterator begin() const { return const_iterator(m_data); }
+ const_iterator cbegin() const { return const_iterator(m_data); }
+ const_iterator end() const { return const_iterator(nullptr); }
+ const_iterator cend() const { return const_iterator(nullptr); }
+};
+
+
+class default_bios final : tiny_rom_entry
+{
+private:
+ default_bios() = default;
+ default_bios(default_bios const &) = delete;
+ default_bios &operator=(default_bios const &) = delete;
+
+public:
+ constexpr char const *get_name() const { return name; }
+};
+
+
+class entries
+{
+private:
+ tiny_rom_entry const *m_data;
+
+public:
+ constexpr entries(tiny_rom_entry const *data) : m_data(data) { }
+
+ regions get_regions() const { return regions(m_data); }
+ system_bioses get_system_bioses() const { return system_bioses(m_data); }
+};
+
+} // namespace romload
+
+
/* ----- start/stop macros ----- */
#define ROM_NAME(name) rom_##name
#define ROM_START(name) static const tiny_rom_entry ROM_NAME(name)[] = {
diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp
index f5f139c38b7..618214970c2 100644
--- a/src/emu/validity.cpp
+++ b/src/emu/validity.cpp
@@ -1475,7 +1475,7 @@ void validity_checker::validate_roms(device_t &root)
std::unordered_map<std::string, int> bios_names;
std::unordered_map<std::string, std::string> bios_descs;
char const *defbios = nullptr;
- for (const rom_entry *romp = rom_first_region(device); romp && !ROMENTRY_ISEND(romp); romp++)
+ for (tiny_rom_entry const *romp = device.rom_region(); romp && !ROMENTRY_ISEND(romp); ++romp)
{
if (ROMENTRY_ISREGION(romp)) // if this is a region, make sure it's valid, and record the length
{
@@ -1484,12 +1484,12 @@ void validity_checker::validate_roms(device_t &root)
osd_printf_warning("Empty ROM region '%s' (warning)\n", last_region_name);
// reset our region tracking states
- const char *basetag = ROMREGION_GETTAG(romp);
+ char const *const basetag = romp->name;
items_since_region = (ROMREGION_ISERASE(romp) || ROMREGION_ISDISKDATA(romp)) ? 1 : 0;
last_region_name = basetag;
// check for a valid tag
- if (basetag == nullptr)
+ if (!basetag)
{
osd_printf_error("ROM_REGION tag with nullptr name\n");
continue;
@@ -1499,7 +1499,7 @@ void validity_checker::validate_roms(device_t &root)
validate_tag(basetag);
// generate the full tag
- std::string fulltag = rom_region_name(device, romp);
+ std::string const fulltag = device.subtag(romp->name);
// attempt to add it to the map, reporting duplicates as errors
current_length = ROMREGION_GETLENGTH(romp);
@@ -1509,7 +1509,7 @@ void validity_checker::validate_roms(device_t &root)
else if (ROMENTRY_ISSYSTEM_BIOS(romp)) // If this is a system bios, make sure it is using the next available bios number
{
int const bios_flags = ROM_GETBIOSFLAGS(romp);
- char const *const biosname = ROM_GETNAME(romp);
+ char const *const biosname = romp->name;
if (bios_flags != last_bios + 1)
osd_printf_error("Non-sequential BIOS %s (specified as %d, expected to be %d)\n", biosname, bios_flags, last_bios + 1);
last_bios = bios_flags;
@@ -1530,24 +1530,24 @@ void validity_checker::validate_roms(device_t &root)
auto const nameins = bios_names.emplace(biosname, bios_flags);
if (!nameins.second)
osd_printf_error("Duplicate BIOS name %s specified (%d and %d)\n", biosname, nameins.first->second, bios_flags);
- auto const descins = bios_descs.emplace(ROM_GETHASHDATA(romp), biosname);
+ auto const descins = bios_descs.emplace(romp->hashdata, biosname);
if (!descins.second)
- osd_printf_error("BIOS %s has duplicate description '%s' (was %s)\n", biosname, ROM_GETHASHDATA(romp), descins.first->second.c_str());
+ osd_printf_error("BIOS %s has duplicate description '%s' (was %s)\n", biosname, romp->hashdata, descins.first->second.c_str());
}
else if (ROMENTRY_ISDEFAULT_BIOS(romp)) // if this is a default BIOS setting, remember it so it to check at the end
{
- defbios = ROM_GETNAME(romp);
+ defbios = romp->name;
}
else if (ROMENTRY_ISFILE(romp)) // if this is a file, make sure it is properly formatted
{
// track the last filename we found
- last_name = ROM_GETNAME(romp);
+ last_name = romp->name;
total_files++;
// make sure the hash is valid
util::hash_collection hashes;
- if (!hashes.from_internal_string(ROM_GETHASHDATA(romp)))
- osd_printf_error("ROM '%s' has an invalid hash string '%s'\n", last_name, ROM_GETHASHDATA(romp));
+ if (!hashes.from_internal_string(romp->hashdata))
+ osd_printf_error("ROM '%s' has an invalid hash string '%s'\n", last_name, romp->hashdata);
}
// for any non-region ending entries, make sure they don't extend past the end
diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp
index c2007cae06c..91a4df81b3c 100644
--- a/src/frontend/mame/clifront.cpp
+++ b/src/frontend/mame/clifront.cpp
@@ -498,15 +498,19 @@ void cli_frontend::listcrc(const std::vector<std::string> &args)
// iterate through matches, and then through ROMs
while (drivlist.next())
{
- for (device_t &device : device_iterator(drivlist.config()->root_device()))
- for (const rom_entry *region = rom_first_region(device); region; region = rom_next_region(region))
- for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
+ for (device_t const &device : device_iterator(drivlist.config()->root_device()))
+ {
+ for (tiny_rom_entry const *rom = device.rom_region(); rom && !ROMENTRY_ISEND(rom); ++rom)
+ {
+ if (ROMENTRY_ISFILE(rom))
{
// if we have a CRC, display it
uint32_t crc;
- if (util::hash_collection(ROM_GETHASHDATA(rom)).crc(crc))
- osd_printf_info("%08x %-32s\t%-16s\t%s\n", crc, ROM_GETNAME(rom), device.shortname(), device.name());
+ if (util::hash_collection(rom->hashdata).crc(crc))
+ osd_printf_info("%08x %-32s\t%-16s\t%s\n", crc, rom->name, device.shortname(), device.name());
}
+ }
+ }
}
}
@@ -549,7 +553,7 @@ void cli_frontend::listroms(const std::vector<std::string> &args)
// iterate through roms
bool hasroms = false;
- for (device_t &device : device_iterator(root))
+ for (device_t const &device : device_iterator(root))
{
for (const rom_entry *region = rom_first_region(device); region; region = rom_next_region(region))
{
diff --git a/src/frontend/mame/info.cpp b/src/frontend/mame/info.cpp
index fb61543c875..6d1712e6ca4 100644
--- a/src/frontend/mame/info.cpp
+++ b/src/frontend/mame/info.cpp
@@ -658,18 +658,15 @@ void info_xml_creator::output_bios(device_t const &device)
}
// iterate over ROM entries and look for BIOSes
- for (tiny_rom_entry const *rom = device.rom_region(); rom && !ROMENTRY_ISEND(rom); ++rom)
+ for (romload::system_bios const &bios : romload::entries(device.rom_region()).get_system_bioses())
{
- if (ROMENTRY_ISSYSTEM_BIOS(rom))
- {
- // output extracted name and descriptions
- fprintf(m_output, "\t\t<biosset");
- fprintf(m_output, " name=\"%s\"", util::xml::normalize_string(rom->name));
- fprintf(m_output, " description=\"%s\"", util::xml::normalize_string(rom->hashdata));
- if (defaultname && !std::strcmp(defaultname, rom->name))
- fprintf(m_output, " default=\"yes\"");
- fprintf(m_output, "/>\n");
- }
+ // output extracted name and descriptions
+ fprintf(m_output, "\t\t<biosset");
+ fprintf(m_output, " name=\"%s\"", util::xml::normalize_string(bios.get_name()));
+ fprintf(m_output, " description=\"%s\"", util::xml::normalize_string(bios.get_description()));
+ if (defaultname && !std::strcmp(defaultname, bios.get_name()))
+ fprintf(m_output, " default=\"yes\"");
+ fprintf(m_output, "/>\n");
}
}
@@ -1847,23 +1844,20 @@ void info_xml_creator::output_ramoptions(device_t &root)
const char *info_xml_creator::get_merge_name(driver_enumerator &drivlist, util::hash_collection const &romhashes)
{
// walk the parent chain
- const char *merge_name = nullptr;
- for (int clone_of = drivlist.find(drivlist.driver().parent); clone_of != -1; clone_of = drivlist.find(drivlist.driver(clone_of).parent))
+ for (int clone_of = drivlist.find(drivlist.driver().parent); 0 <= clone_of; clone_of = drivlist.find(drivlist.driver(clone_of).parent))
{
// look in the parent's ROMs
- device_t *device = &drivlist.config(clone_of, m_lookup_options)->root_device();
- for (const rom_entry *pregion = rom_first_region(*device); pregion != nullptr; pregion = rom_next_region(pregion))
- for (const rom_entry *prom = rom_first_file(pregion); prom != nullptr; prom = rom_next_file(prom))
+ for (romload::region const &pregion : romload::entries(drivlist.driver(clone_of).rom).get_regions())
+ {
+ for (romload::file const &prom : pregion.get_files())
{
- util::hash_collection phashes(ROM_GETHASHDATA(prom));
- if (!phashes.flag(util::hash_collection::FLAG_NO_DUMP) && romhashes == phashes)
- {
- // stop when we find a match
- merge_name = ROM_GETNAME(prom);
- break;
- }
+ // stop when we find a match
+ util::hash_collection const phashes(prom.get_hashdata());
+ if (!phashes.flag(util::hash_collection::FLAG_NO_DUMP) && (romhashes == phashes))
+ return prom.get_name();
}
+ }
}
- return merge_name;
+ return nullptr;
}
diff --git a/src/frontend/mame/media_ident.cpp b/src/frontend/mame/media_ident.cpp
index 3e1ee54048a..277ef2bc959 100644
--- a/src/frontend/mame/media_ident.cpp
+++ b/src/frontend/mame/media_ident.cpp
@@ -22,7 +22,7 @@
void media_identifier::file_info::match(
device_t const &device,
- rom_entry const &rom,
+ romload::file const &rom,
util::hash_collection const &hashes)
{
if (hashes == m_hashes)
@@ -30,7 +30,7 @@ void media_identifier::file_info::match(
m_matches.emplace_back(
device.shortname(),
device.name(),
- ROM_GETNAME(&rom),
+ rom.get_name(),
hashes.flag(util::hash_collection::FLAG_BAD_DUMP),
device.owner());
}
@@ -340,21 +340,21 @@ void media_identifier::match_hashes(std::vector<file_info> &info)
{
// iterate over regions and files within the region
device_t &device = m_drivlist.config()->root_device();
- for (rom_entry const *region = rom_first_region(device); region; region = rom_next_region(region))
+ for (romload::region const &region : romload::entries(device.rom_region()).get_regions())
{
- for (rom_entry const *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
+ for (romload::file const &rom : region.get_files())
{
- util::hash_collection romhashes(ROM_GETHASHDATA(rom));
+ util::hash_collection const romhashes(rom.get_hashdata());
if (!romhashes.flag(util::hash_collection::FLAG_NO_DUMP))
{
for (file_info &file : info)
- file.match(device, *rom, romhashes);
+ file.match(device, rom, romhashes);
}
}
}
// next iterate over softlists
- for (software_list_device &swlistdev : software_list_device_iterator(m_drivlist.config()->root_device()))
+ for (software_list_device &swlistdev : software_list_device_iterator(device))
{
if (listnames.insert(swlistdev.list_name()).second)
{
@@ -386,15 +386,15 @@ void media_identifier::match_hashes(std::vector<file_info> &info)
{
// iterate over regions and files within the region
device_t *const device = config.device_add(&config.root_device(), "_tmp", type, 0);
- for (rom_entry const *region = rom_first_region(*device); region; region = rom_next_region(region))
+ for (romload::region const &region : romload::entries(device->rom_region()).get_regions())
{
- for (rom_entry const *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
+ for (romload::file const &rom : region.get_files())
{
- util::hash_collection romhashes(ROM_GETHASHDATA(rom));
+ util::hash_collection const romhashes(rom.get_hashdata());
if (!romhashes.flag(util::hash_collection::FLAG_NO_DUMP))
{
for (file_info &file : info)
- file.match(*device, *rom, romhashes);
+ file.match(*device, rom, romhashes);
}
}
}
diff --git a/src/frontend/mame/media_ident.h b/src/frontend/mame/media_ident.h
index b7da0dde350..ac919dd8611 100644
--- a/src/frontend/mame/media_ident.h
+++ b/src/frontend/mame/media_ident.h
@@ -102,7 +102,7 @@ private:
file_flavour flavour() const { return m_flavour; }
std::vector<match_data> const &matches() const { return m_matches; }
- void match(device_t const &device, rom_entry const &rom, util::hash_collection const &hashes);
+ void match(device_t const &device, romload::file const &rom, util::hash_collection const &hashes);
void match(std::string const &list, software_info const &software, rom_entry const &rom, util::hash_collection const &hashes);
private:
diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp
index 1b683b4418b..71ccb6d9a40 100644
--- a/src/frontend/mame/ui/devopt.cpp
+++ b/src/frontend/mame/ui/devopt.cpp
@@ -155,14 +155,11 @@ void menu_device_config::populate(float &customtop, float &custombottom)
// then loop again to count bios options and to get the default bios complete name
char const *bios_desc(nullptr);
- for (const tiny_rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); ++rom)
+ for (romload::system_bios const &rom : romload::entries(dev->rom_region()).get_system_bioses())
{
- if (ROMENTRY_ISSYSTEM_BIOS(rom))
- {
- bios++;
- if (bios_str && !std::strcmp(bios_str, rom->name))
- bios_desc = rom->hashdata;
- }
+ bios++;
+ if (bios_str && !std::strcmp(bios_str, rom.get_name()))
+ bios_desc = rom.get_description();
}
if (bios)
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index 89a86760851..f681895b084 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -116,15 +116,12 @@ void menu_bios_selection::handle()
else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
{
device_t *dev = (device_t *)menu_event->itemref;
- int cnt = 0;
- for (const tiny_rom_entry *rom = dev->rom_region(); rom && !ROMENTRY_ISEND(rom); ++rom)
- {
- if (ROMENTRY_ISSYSTEM_BIOS(rom))
- ++cnt;
- }
+ int const cnt = ([bioses = romload::entries(dev->rom_region()).get_system_bioses()] () { return std::distance(bioses.begin(), bioses.end()); })();
int val = dev->system_bios() + ((menu_event->iptkey == IPT_UI_LEFT) ? -1 : +1);
- if (val < 1) val = cnt;
- if (val > cnt) val = 1;
+ if (val < 1)
+ val = cnt;
+ if (val > cnt)
+ val = 1;
dev->set_system_bios(val);
if (strcmp(dev->tag(),":")==0) {
machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE);
@@ -813,28 +810,25 @@ void menu_machine_configure::setup_bios()
}
std::size_t bios_count = 0;
- for (tiny_rom_entry const *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom)
+ for (romload::system_bios const &bios : romload::entries(m_drv->rom).get_system_bioses())
{
- if (ROMENTRY_ISSYSTEM_BIOS(rom))
- {
- std::string name(rom->hashdata);
- u32 const bios_flags(ROM_GETBIOSFLAGS(rom));
- std::string const bios_number(std::to_string(bios_flags - 1));
+ std::string name(bios.get_description());
+ u32 const bios_flags(bios.get_value());
+ std::string const bios_number(std::to_string(bios_flags - 1));
- // check biosnumber and name
- if ((bios_number == specbios) || (specbios == rom->name))
- m_curbios = bios_count;
+ // check biosnumber and name
+ if ((bios_number == specbios) || (specbios == bios.get_name()))
+ m_curbios = bios_count;
- if (default_name && !std::strcmp(rom->name, default_name))
- {
- name.append(_(" (default)"));
- if (specbios == "default")
- m_curbios = bios_count;
- }
-
- m_bios.emplace_back(std::move(name), bios_flags - 1);
- bios_count++;
+ if (default_name && !std::strcmp(bios.get_name(), default_name))
+ {
+ name.append(_(" (default)"));
+ if (specbios == "default")
+ m_curbios = bios_count;
}
+
+ m_bios.emplace_back(std::move(name), bios_flags - 1);
+ bios_count++;
}
}
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index 00ccd64548a..a7372c4133b 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -2391,22 +2391,19 @@ bool menu_select_launch::has_multiple_bios(game_driver const &driver, s_bios &bi
default_name = rom->name;
}
- for (tiny_rom_entry const *rom = driver.rom; !ROMENTRY_ISEND(rom); ++rom)
+ for (romload::system_bios const &bios : romload::entries(driver.rom).get_system_bioses())
{
- if (ROMENTRY_ISSYSTEM_BIOS(rom))
- {
- std::string name(rom->hashdata);
- u32 const bios_flags(ROM_GETBIOSFLAGS(rom));
+ std::string name(bios.get_description());
+ u32 const bios_flags(bios.get_value());
- if (default_name && !std::strcmp(rom->name, default_name))
- {
- name.append(_(" (default)"));
- biosname.emplace(biosname.begin(), std::move(name), bios_flags - 1);
- }
- else
- {
- biosname.emplace_back(std::move(name), bios_flags - 1);
- }
+ if (default_name && !std::strcmp(bios.get_name(), default_name))
+ {
+ name.append(_(" (default)"));
+ biosname.emplace(biosname.begin(), std::move(name), bios_flags - 1);
+ }
+ else
+ {
+ biosname.emplace_back(std::move(name), bios_flags - 1);
}
}
return biosname.size() > 1U;