frontend/mame/audit.cpp: Fix failure to recognise device ROMs that use continue/ignore load commands (see GitHub #7314).

This commit is contained in:
Vas Crabb 2020-10-03 23:36:39 +10:00
parent 0c6d1a7b51
commit 0f6a1cec4a
2 changed files with 36 additions and 43 deletions

View File

@ -72,10 +72,11 @@ media_auditor::summary media_auditor::audit_media(const char *validation)
char const *const name(ROM_GETNAME(rom));
util::hash_collection const hashes(ROM_GETHASHDATA(rom));
device_t *const shared_device(find_shared_device(device, name, hashes, ROM_GETLENGTH(rom)));
bool const dumped = !hashes.flag(util::hash_collection::FLAG_NO_DUMP);
std::add_pointer_t<device_type> const shared_device(find_shared_device(device, name, hashes, rom_file_size(rom)));
// count the number of files with hashes
if (!hashes.flag(util::hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom))
if (dumped && !ROM_ISOPTIONAL(rom))
{
required++;
if (shared_device)
@ -340,7 +341,7 @@ media_auditor::summary media_auditor::summarize(const char *name, std::ostream *
case audit_substatus::NOT_FOUND:
if (output)
{
device_t *const shared_device = record.shared_device();
std::add_pointer_t<device_type> const shared_device = record.shared_device();
if (shared_device)
util::stream_format(*output, "NOT FOUND (%s)\n", shared_device->shortname());
else
@ -503,15 +504,14 @@ void media_auditor::compute_status(audit_record &record, const rom_entry *rom, b
// shares a media entry with the same hashes
//-------------------------------------------------
device_t *media_auditor::find_shared_device(device_t &device, const char *name, const util::hash_collection &romhashes, uint64_t romlength)
std::add_pointer_t<device_type> media_auditor::find_shared_device(device_t &device, const char *name, const util::hash_collection &romhashes, uint64_t romlength)
{
bool const dumped = !romhashes.flag(util::hash_collection::FLAG_NO_DUMP);
// special case for non-root devices
device_t *highest_device = nullptr;
if (device.owner())
auto const scan =
[dumped, name, &romhashes, romlength, &highest_device] (device_t &curdev)
{
for (const rom_entry *region = rom_first_region(device); region; region = rom_next_region(region))
for (const rom_entry *region = rom_first_region(curdev); region; region = rom_next_region(region))
{
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{
@ -519,10 +519,16 @@ device_t *media_auditor::find_shared_device(device_t &device, const char *name,
{
util::hash_collection hashes(ROM_GETHASHDATA(rom));
if ((dumped && hashes == romhashes) || (!dumped && ROM_GETNAME(rom) == name))
highest_device = &device;
highest_device = &curdev;
}
}
}
};
if (device.owner())
{
// special case for non-root devices
scan(device);
}
else
{
@ -530,24 +536,11 @@ device_t *media_auditor::find_shared_device(device_t &device, const char *name,
for (auto drvindex = m_enumerator.find(m_enumerator.driver().parent); drvindex >= 0; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent))
{
for (device_t &scandevice : device_iterator(m_enumerator.config(drvindex)->root_device()))
{
for (const rom_entry *region = rom_first_region(scandevice); region; region = rom_next_region(region))
{
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{
if (rom_file_size(rom) == romlength)
{
util::hash_collection hashes(ROM_GETHASHDATA(rom));
if ((dumped && hashes == romhashes) || (!dumped && ROM_GETNAME(rom) == name))
highest_device = &scandevice;
}
}
}
}
scan(scandevice);
}
}
return highest_device;
return highest_device ? &highest_device->type() : nullptr;
}

View File

@ -107,7 +107,7 @@ public:
uint64_t actual_length() const { return m_length; }
const util::hash_collection &expected_hashes() const { return m_exphashes; }
const util::hash_collection &actual_hashes() const { return m_hashes; }
device_t *shared_device() const { return m_shared_device; }
std::add_pointer_t<device_type> shared_device() const { return m_shared_device; }
// setters
void set_status(audit_status status, audit_substatus substatus)
@ -128,7 +128,7 @@ public:
m_length = length;
}
void set_shared_device(device_t *shared_device)
void set_shared_device(std::add_pointer_t<device_type> shared_device)
{
m_shared_device = shared_device;
}
@ -143,7 +143,7 @@ public:
uint64_t m_length; // actual length of item
util::hash_collection m_exphashes; // expected hash data
util::hash_collection m_hashes; // actual hash information
device_t * m_shared_device; // device that shares the rom
std::add_pointer_t<device_type> m_shared_device; // device that shares the ROM
};
using record_list = std::list<audit_record>;
@ -166,7 +166,7 @@ private:
audit_record &audit_one_rom(const std::vector<std::string> &searchpath, const rom_entry *rom);
template <typename... T> audit_record &audit_one_disk(const rom_entry *rom, T &&... args);
void compute_status(audit_record &record, const rom_entry *rom, bool found);
device_t *find_shared_device(device_t &device, const char *name, const util::hash_collection &romhashes, uint64_t romlength);
std::add_pointer_t<device_type> find_shared_device(device_t &device, const char *name, const util::hash_collection &romhashes, uint64_t romlength);
// internal state
record_list m_record_list;