From abd47e61c3fed92e0c28cb4cd8bb4aafb65ead47 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 9 May 2023 18:13:02 +1000 Subject: frontend/mame/audit.cpp: Work around issues when no ROMs are shared with immediate parent (MT08625). The issue occurred when a system with no ROMs or only bad dumps had an immediate parent with no ROMs in common. This is another thing broken by the attempts to hide "missing" ROM sets from audits. --- src/devices/bus/spectrum/neogs.cpp | 3 ++- src/frontend/mame/audit.cpp | 41 ++++++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/devices/bus/spectrum/neogs.cpp b/src/devices/bus/spectrum/neogs.cpp index 4a9f32950ca..b3028dbc4ef 100644 --- a/src/devices/bus/spectrum/neogs.cpp +++ b/src/devices/bus/spectrum/neogs.cpp @@ -193,7 +193,8 @@ u8 neogs_device::neogs_data_r() return m_data_out; } -void neogs_device::neogs_data_w(u8 data) { +void neogs_device::neogs_data_w(u8 data) +{ m_status |= 0x80; LOGSTATUS("write: DATA & %02X, status: %02X\n", data, m_status); m_data_in = data; diff --git a/src/frontend/mame/audit.cpp b/src/frontend/mame/audit.cpp index 069c524022e..129126bb2ef 100644 --- a/src/frontend/mame/audit.cpp +++ b/src/frontend/mame/audit.cpp @@ -47,8 +47,41 @@ class parent_rom_vector : public std::vector public: using std::vector::vector; - void remove_redundant_parents() + void remove_redundant_parents(device_t const &device) { + // remove parents with no shared ROMs + const_reverse_iterator firstparent(crend()); + for (rom_entry const *region = rom_first_region(device); region && ((crend() == firstparent) || (back().type.get() != firstparent->type.get())); region = rom_next_region(region)) + { + for (rom_entry const *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) + { + util::hash_collection const hashes(rom->hashdata()); + auto const match( + std::find_if( + crbegin(), + firstparent, + [rom, &hashes] (parent_rom const &r) + { + if (r.length != rom_file_size(rom)) + return false; + else if (!hashes.flag(util::hash_collection::FLAG_NO_DUMP)) + return r.hashes == hashes; + else + return r.name == rom->name(); + })); + if (match != firstparent) + { + firstparent = std::find_if( + crbegin(), + match, + [&match] (parent_rom const &r) { return r.type.get() == match->type.get(); }); + if (back().type.get() == match->type.get()) + break; + } + } + } + erase(firstparent.base(), cend()); + while (!empty()) { // find where the next parent starts @@ -203,7 +236,7 @@ media_auditor::summary media_auditor::audit_media(const char *validation) } } } - parentroms.remove_redundant_parents(); + parentroms.remove_redundant_parents(m_enumerator.config()->root_device()); // count ROMs required/found std::size_t found(0); @@ -279,8 +312,8 @@ media_auditor::summary media_auditor::audit_media(const char *validation) LOG("Total required=%u (shared=%u) found=%u (shared=%u parent=%u)\n", required, shared_required, found, shared_found, parent_found); } - // if we only find files that are in the parent & either the set has no unique files or the parent is not found, then assume we don't have the set at all - if ((found == shared_found) && required && ((required != shared_required) || !parent_found)) + // if we only find files that are in the parent and either the set has no unique files or the parent is not found, then assume we don't have the set at all + if ((found == shared_found) && required && (found != required) && ((required != shared_required) || !parent_found)) { m_record_list.clear(); return NOTFOUND; -- cgit v1.2.3