From 5a0d918e8f21cee908d50ddf81cc9fe6c95c2d6e Mon Sep 17 00:00:00 2001 From: smf- Date: Sat, 20 Aug 2011 20:33:18 +0000 Subject: [PATCH] lists the rom source short name for shared roms & individual devices are only verified if they match the "game name". also doesn't display the "approximately matches" just because roms aren't found. --- src/emu/audit.c | 101 +++++++++++++++++++++-------------------- src/emu/audit.h | 11 +++-- src/emu/clifront.c | 111 ++++++++++++++++++++++++--------------------- 3 files changed, 118 insertions(+), 105 deletions(-) diff --git a/src/emu/audit.c b/src/emu/audit.c index 3ccbe964b94..a68004f60fe 100644 --- a/src/emu/audit.c +++ b/src/emu/audit.c @@ -89,9 +89,6 @@ const char *driverpath = m_enumerator.config().devicelist().find("root")->search // determine the search path for this source and iterate through the regions m_searchpath = source->searchpath(); - // also determine if this is the driver's specific ROMs or not - bool source_is_gamedrv = (dynamic_cast(source) != NULL); - // now iterate over regions and ROMs within for (const rom_entry *region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) { @@ -107,13 +104,13 @@ m_searchpath = combinedpath; for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { hash_collection hashes(ROM_GETHASHDATA(rom)); - bool shared = !source_is_gamedrv || also_used_by_parent(hashes, ROM_GETLENGTH(rom)) >= 0; + const rom_source *shared_source = find_shared_source(source, hashes, ROM_GETLENGTH(rom)); // count the number of files with hashes if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom)) { required++; - if (shared) + if (shared_source != NULL) { sharedRequired++; } @@ -128,14 +125,19 @@ m_searchpath = combinedpath; else if (ROMREGION_ISDISKDATA(region)) record = audit_one_disk(rom); - // count the number of files that are found. - if (record != NULL && (record->status() == audit_record::STATUS_GOOD || (record->status() == audit_record::STATUS_FOUND_INVALID && also_used_by_parent(record->actual_hashes(), record->actual_length()) < 0))) + if (record != NULL) { - found++; - if (shared) + // count the number of files that are found. + if (record->status() == audit_record::STATUS_GOOD || (record->status() == audit_record::STATUS_FOUND_INVALID && find_shared_source(source,record->actual_hashes(), record->actual_length()) != NULL)) { - sharedFound++; + found++; + if (shared_source != NULL) + { + sharedFound++; + } } + + record->set_shared_source(shared_source); } } } @@ -323,7 +325,12 @@ media_auditor::summary media_auditor::summarize(const char *name, astring *strin break; case audit_record::SUBSTATUS_NOT_FOUND: - if (string != NULL) string->catprintf("NOT FOUND\n"); + if (string != NULL) + { + const rom_source *shared_source = record->shared_source(); + if (shared_source == NULL) string->catprintf("NOT FOUND\n"); + else string->catprintf("NOT FOUND (%s)\n", shared_source->shortname()); + } break; case audit_record::SUBSTATUS_NOT_FOUND_NODUMP: @@ -336,14 +343,6 @@ media_auditor::summary media_auditor::summarize(const char *name, astring *strin best_new_status = BEST_AVAILABLE; break; - case audit_record::SUBSTATUS_NOT_FOUND_PARENT: - if (string != NULL) string->catprintf("NOT FOUND (shared with parent)\n"); - break; - - case audit_record::SUBSTATUS_NOT_FOUND_BIOS: - if (string != NULL) string->catprintf("NOT FOUND (BIOS)\n"); - break; - default: assert(false); } @@ -444,8 +443,6 @@ void media_auditor::compute_status(audit_record &record, const rom_entry *rom, b // if not found, provide more details if (!found) { - int parent; - // no good dump if (record.expected_hashes().flag(hash_collection::FLAG_NO_DUMP)) record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND_NODUMP); @@ -454,15 +451,6 @@ void media_auditor::compute_status(audit_record &record, const rom_entry *rom, b else if (ROM_ISOPTIONAL(rom)) record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND_OPTIONAL); - // not found and used by parent - else if ((parent = also_used_by_parent(record.expected_hashes(), record.expected_length())) != -1) - { - if (m_enumerator.driver(parent).flags & GAME_IS_BIOS_ROOT) - record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND_BIOS); - else - record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND_PARENT); - } - // just plain old not found else record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND); @@ -495,30 +483,43 @@ void media_auditor::compute_status(audit_record &record, const rom_entry *rom, b //------------------------------------------------- -// also_used_by_parent - return the index in the -// enumerator of the parent who also owns a media -// entry with the same hashes +// find_shared_source - return the source that +// shares a media entry with the same hashes //------------------------------------------------- - -int media_auditor::also_used_by_parent(const hash_collection &romhashes, UINT64 romlength) +const rom_source *media_auditor::find_shared_source(const rom_source *source, const hash_collection &romhashes, UINT64 romlength) { + const rom_source *highest_source = NULL; + if (!romhashes.flag(hash_collection::FLAG_NO_DUMP)) - // iterate up the parent chain - for (int drvindex = m_enumerator.find(m_enumerator.driver().parent); drvindex != -1; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent)) + { + if (dynamic_cast(source) == NULL) + { + for (const rom_entry *region = rom_first_region(*source); region; region = rom_next_region(region)) + for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) + if (ROM_GETLENGTH(rom) == romlength) + { + hash_collection hashes(ROM_GETHASHDATA(rom)); + if (hashes == romhashes) + highest_source = source; + } + } + else + { + // iterate up the parent chain + for (int drvindex = m_enumerator.find(m_enumerator.driver().parent); drvindex != -1; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent)) + for (const rom_source *source = rom_first_source(m_enumerator.config(drvindex)); source != NULL; source = rom_next_source(*source)) + for (const rom_entry *region = rom_first_region(*source); region; region = rom_next_region(region)) + for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) + if (ROM_GETLENGTH(rom) == romlength) + { + hash_collection hashes(ROM_GETHASHDATA(rom)); + if (hashes == romhashes) + highest_source = source; + } + } + } - // see if the parent has the same ROM or not - for (const rom_source *source = rom_first_source(m_enumerator.config(drvindex)); source != NULL; source = rom_next_source(*source)) - for (const rom_entry *region = rom_first_region(*source); region; region = rom_next_region(region)) - for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) - if (ROM_GETLENGTH(rom) == romlength) - { - hash_collection hashes(ROM_GETHASHDATA(rom)); - if (hashes == romhashes) - return drvindex; - } - - // nope, return -1 - return -1; + return highest_source; } diff --git a/src/emu/audit.h b/src/emu/audit.h index 4e743dd180d..44190f19557 100644 --- a/src/emu/audit.h +++ b/src/emu/audit.h @@ -97,8 +97,6 @@ public: SUBSTATUS_NOT_FOUND, SUBSTATUS_NOT_FOUND_NODUMP, SUBSTATUS_NOT_FOUND_OPTIONAL, - SUBSTATUS_NOT_FOUND_PARENT, - SUBSTATUS_NOT_FOUND_BIOS, SUBSTATUS_ERROR = 100 }; @@ -116,6 +114,7 @@ public: UINT64 actual_length() const { return m_length; } const hash_collection &expected_hashes() const { return m_exphashes; } const hash_collection &actual_hashes() const { return m_hashes; } + const rom_source *shared_source() const { return m_shared_source; } // setters void set_status(audit_status status, audit_substatus substatus) @@ -130,6 +129,11 @@ public: m_length = length; } + void set_shared_source(const rom_source *shared_source) + { + m_shared_source = shared_source; + } + private: // internal state audit_record * m_next; @@ -141,6 +145,7 @@ private: UINT64 m_length; /* actual length of item */ hash_collection m_exphashes; /* expected hash data */ hash_collection m_hashes; /* actual hash information */ + const rom_source * m_shared_source; /* rom_source that shares the rom */ }; @@ -178,7 +183,7 @@ private: audit_record *audit_one_rom(const rom_entry *rom); audit_record *audit_one_disk(const rom_entry *rom); void compute_status(audit_record &record, const rom_entry *rom, bool found); - int also_used_by_parent(const hash_collection &romhashes, UINT64 romlength); + const rom_source *find_shared_source(const rom_source *source, const hash_collection &romhashes, UINT64 romlength); // internal state simple_list m_record_list; diff --git a/src/emu/clifront.c b/src/emu/clifront.c index bc2ba104eb1..090ce57fac0 100644 --- a/src/emu/clifront.c +++ b/src/emu/clifront.c @@ -739,34 +739,23 @@ extern const device_type *s_devices_sorted[]; void cli_frontend::verifyroms(const char *gamename) { - // determine which drivers to output; return an error if none found + // determine which drivers to output; driver_enumerator drivlist(m_options, gamename); - if (drivlist.count() == 0) - throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "No matching games found for '%s'", gamename); int correct = 0; int incorrect = 0; int notfound = 0; + int matched = 0; // iterate over drivers media_auditor auditor(drivlist); - UINT8* device_used = global_alloc_array_clear(UINT8, m_device_count); while (drivlist.next()) { + matched++; + // audit the ROMs in this set media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST); - // output the summary of the audit - astring summary_string; - auditor.summarize(drivlist.driver().name,&summary_string); - mame_printf_info("%s", summary_string.cstr()); - for (const rom_source *source = rom_first_source(drivlist.config()); source != NULL; source = rom_next_source(*source)) - { - for(int i=0;itype() == *s_devices_sorted[i]) device_used[i] = 1; - } - } - // if not found, count that and leave it at that if (summary == media_auditor::NOTFOUND) notfound++; @@ -774,6 +763,11 @@ void cli_frontend::verifyroms(const char *gamename) // else display information about what we discovered else { + // output the summary of the audit + astring summary_string; + auditor.summarize(drivlist.driver().name,&summary_string); + mame_printf_info("%s", summary_string.cstr()); + // output the name of the driver and its clone mame_printf_info("romset %s ", drivlist.driver().name); int clone_of = drivlist.clone(); @@ -803,68 +797,81 @@ void cli_frontend::verifyroms(const char *gamename) } } } - - drivlist.reset(); - drivlist.next(); - machine_config &config = drivlist.config(); + + driver_enumerator dummy_drivlist(m_options); + dummy_drivlist.next(); + machine_config &config = dummy_drivlist.config(); device_t *owner = config.devicelist().first(); // check if all are listed, note that empty one is included - bool display_all = driver_list::total() == (drivlist.count()+1); - for(int i=0;iconfig_complete(); + for (int i=0;iconfig_complete(); + if (mame_strwildcmp(gamename, dev->shortname()) == 0) + { + matched++; + // audit the ROMs in this set media_auditor::summary summary = auditor.audit_device(dev, AUDIT_VALIDATE_FAST); - // output the summary of the audit - astring summary_string; - auditor.summarize(dev->shortname(),&summary_string); - mame_printf_info("%s", summary_string.cstr()); + // if not found, count that and leave it at that + if (summary == media_auditor::NOTFOUND) + notfound++; - // display information about what we discovered - mame_printf_info("romset %s ", dev->shortname()); - - // switch off of the result - switch (summary) + // else display information about what we discovered + else { - case media_auditor::INCORRECT: - mame_printf_info("is bad\n"); - incorrect++; - break; + // output the summary of the audit + astring summary_string; + auditor.summarize(dev->shortname(),&summary_string); + mame_printf_info("%s", summary_string.cstr()); - case media_auditor::CORRECT: - mame_printf_info("is good\n"); - correct++; - break; + // display information about what we discovered + mame_printf_info("romset %s ", dev->shortname()); - case media_auditor::BEST_AVAILABLE: - mame_printf_info("is best available\n"); - correct++; - break; + // switch off of the result + switch (summary) + { + case media_auditor::INCORRECT: + mame_printf_info("is bad\n"); + incorrect++; + break; - default: - break; + case media_auditor::CORRECT: + mame_printf_info("is good\n"); + correct++; + break; + + case media_auditor::BEST_AVAILABLE: + mame_printf_info("is best available\n"); + correct++; + break; + + default: + break; + } } global_free(dev); } } - global_free(device_used); - // clear out any cached files zip_file_cache_clear(); + // return an error if none found + if (matched==0) + throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "No matching games found for '%s'", gamename); + // if we didn't get anything at all, display a generic end message if (correct + incorrect == 0) { if (notfound > 0) - throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "romset \"%s\" not found!\n", gamename); + throw emu_fatalerror(MAMERR_MISSING_FILES, "romset \"%s\" not found!\n", gamename); else - throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "romset \"%s\" not supported!\n", gamename); + throw emu_fatalerror(MAMERR_MISSING_FILES, "romset \"%s\" not supported!\n", gamename); } // otherwise, print a summary