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.

This commit is contained in:
smf- 2011-08-20 20:33:18 +00:00
parent 8ff4603523
commit 5a0d918e8f
3 changed files with 118 additions and 105 deletions

View File

@ -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 // determine the search path for this source and iterate through the regions
m_searchpath = source->searchpath(); m_searchpath = source->searchpath();
// also determine if this is the driver's specific ROMs or not
bool source_is_gamedrv = (dynamic_cast<const driver_device *>(source) != NULL);
// now iterate over regions and ROMs within // now iterate over regions and ROMs within
for (const rom_entry *region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) 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)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{ {
hash_collection hashes(ROM_GETHASHDATA(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 // count the number of files with hashes
if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom)) if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom))
{ {
required++; required++;
if (shared) if (shared_source != NULL)
{ {
sharedRequired++; sharedRequired++;
} }
@ -128,14 +125,19 @@ m_searchpath = combinedpath;
else if (ROMREGION_ISDISKDATA(region)) else if (ROMREGION_ISDISKDATA(region))
record = audit_one_disk(rom); record = audit_one_disk(rom);
// count the number of files that are found. if (record != NULL)
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)))
{ {
found++; // count the number of files that are found.
if (shared) 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; break;
case audit_record::SUBSTATUS_NOT_FOUND: 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; break;
case audit_record::SUBSTATUS_NOT_FOUND_NODUMP: 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; best_new_status = BEST_AVAILABLE;
break; 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: default:
assert(false); 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 not found, provide more details
if (!found) if (!found)
{ {
int parent;
// no good dump // no good dump
if (record.expected_hashes().flag(hash_collection::FLAG_NO_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); 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)) else if (ROM_ISOPTIONAL(rom))
record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND_OPTIONAL); 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 // just plain old not found
else else
record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND); 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 // find_shared_source - return the source that
// enumerator of the parent who also owns a media // shares a media entry with the same hashes
// entry with the same hashes
//------------------------------------------------- //-------------------------------------------------
const rom_source *media_auditor::find_shared_source(const rom_source *source, const hash_collection &romhashes, UINT64 romlength)
int media_auditor::also_used_by_parent(const hash_collection &romhashes, UINT64 romlength)
{ {
const rom_source *highest_source = NULL;
if (!romhashes.flag(hash_collection::FLAG_NO_DUMP)) 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<const driver_device *>(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 return highest_source;
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;
} }

View File

@ -97,8 +97,6 @@ public:
SUBSTATUS_NOT_FOUND, SUBSTATUS_NOT_FOUND,
SUBSTATUS_NOT_FOUND_NODUMP, SUBSTATUS_NOT_FOUND_NODUMP,
SUBSTATUS_NOT_FOUND_OPTIONAL, SUBSTATUS_NOT_FOUND_OPTIONAL,
SUBSTATUS_NOT_FOUND_PARENT,
SUBSTATUS_NOT_FOUND_BIOS,
SUBSTATUS_ERROR = 100 SUBSTATUS_ERROR = 100
}; };
@ -116,6 +114,7 @@ public:
UINT64 actual_length() const { return m_length; } UINT64 actual_length() const { return m_length; }
const hash_collection &expected_hashes() const { return m_exphashes; } const hash_collection &expected_hashes() const { return m_exphashes; }
const hash_collection &actual_hashes() const { return m_hashes; } const hash_collection &actual_hashes() const { return m_hashes; }
const rom_source *shared_source() const { return m_shared_source; }
// setters // setters
void set_status(audit_status status, audit_substatus substatus) void set_status(audit_status status, audit_substatus substatus)
@ -130,6 +129,11 @@ public:
m_length = length; m_length = length;
} }
void set_shared_source(const rom_source *shared_source)
{
m_shared_source = shared_source;
}
private: private:
// internal state // internal state
audit_record * m_next; audit_record * m_next;
@ -141,6 +145,7 @@ private:
UINT64 m_length; /* actual length of item */ UINT64 m_length; /* actual length of item */
hash_collection m_exphashes; /* expected hash data */ hash_collection m_exphashes; /* expected hash data */
hash_collection m_hashes; /* actual hash information */ 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_rom(const rom_entry *rom);
audit_record *audit_one_disk(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); 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 // internal state
simple_list<audit_record> m_record_list; simple_list<audit_record> m_record_list;

View File

@ -739,34 +739,23 @@ extern const device_type *s_devices_sorted[];
void cli_frontend::verifyroms(const char *gamename) 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); 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 correct = 0;
int incorrect = 0; int incorrect = 0;
int notfound = 0; int notfound = 0;
int matched = 0;
// iterate over drivers // iterate over drivers
media_auditor auditor(drivlist); media_auditor auditor(drivlist);
UINT8* device_used = global_alloc_array_clear(UINT8, m_device_count);
while (drivlist.next()) while (drivlist.next())
{ {
matched++;
// audit the ROMs in this set // audit the ROMs in this set
media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST); 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;i<m_device_count;i++) {
if (source->type() == *s_devices_sorted[i]) device_used[i] = 1;
}
}
// if not found, count that and leave it at that // if not found, count that and leave it at that
if (summary == media_auditor::NOTFOUND) if (summary == media_auditor::NOTFOUND)
notfound++; notfound++;
@ -774,6 +763,11 @@ void cli_frontend::verifyroms(const char *gamename)
// else display information about what we discovered // else display information about what we discovered
else 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 // output the name of the driver and its clone
mame_printf_info("romset %s ", drivlist.driver().name); mame_printf_info("romset %s ", drivlist.driver().name);
int clone_of = drivlist.clone(); int clone_of = drivlist.clone();
@ -803,68 +797,81 @@ void cli_frontend::verifyroms(const char *gamename)
} }
} }
} }
drivlist.reset(); driver_enumerator dummy_drivlist(m_options);
drivlist.next(); dummy_drivlist.next();
machine_config &config = drivlist.config(); machine_config &config = dummy_drivlist.config();
device_t *owner = config.devicelist().first(); device_t *owner = config.devicelist().first();
// check if all are listed, note that empty one is included // check if all are listed, note that empty one is included
bool display_all = driver_list::total() == (drivlist.count()+1); for (int i=0;i<m_device_count;i++)
for(int i=0;i<m_device_count;i++) { {
if (display_all || (device_used[i]!=0)) { device_type type = *s_devices_sorted[i];
device_type type = *s_devices_sorted[i]; device_t *dev = (*type)(config, "dummy", owner, 0);
device_t *dev = (*type)(config, "dummy", owner, 0); dev->config_complete();
dev->config_complete();
if (mame_strwildcmp(gamename, dev->shortname()) == 0)
{
matched++;
// audit the ROMs in this set // audit the ROMs in this set
media_auditor::summary summary = auditor.audit_device(dev, AUDIT_VALIDATE_FAST); media_auditor::summary summary = auditor.audit_device(dev, AUDIT_VALIDATE_FAST);
// output the summary of the audit // if not found, count that and leave it at that
astring summary_string; if (summary == media_auditor::NOTFOUND)
auditor.summarize(dev->shortname(),&summary_string); notfound++;
mame_printf_info("%s", summary_string.cstr());
// display information about what we discovered // else display information about what we discovered
mame_printf_info("romset %s ", dev->shortname()); else
// switch off of the result
switch (summary)
{ {
case media_auditor::INCORRECT: // output the summary of the audit
mame_printf_info("is bad\n"); astring summary_string;
incorrect++; auditor.summarize(dev->shortname(),&summary_string);
break; mame_printf_info("%s", summary_string.cstr());
case media_auditor::CORRECT: // display information about what we discovered
mame_printf_info("is good\n"); mame_printf_info("romset %s ", dev->shortname());
correct++;
break;
case media_auditor::BEST_AVAILABLE: // switch off of the result
mame_printf_info("is best available\n"); switch (summary)
correct++; {
break; case media_auditor::INCORRECT:
mame_printf_info("is bad\n");
incorrect++;
break;
default: case media_auditor::CORRECT:
break; 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(dev);
} }
} }
global_free(device_used);
// clear out any cached files // clear out any cached files
zip_file_cache_clear(); 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 we didn't get anything at all, display a generic end message
if (correct + incorrect == 0) if (correct + incorrect == 0)
{ {
if (notfound > 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 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 // otherwise, print a summary