mirror of
https://github.com/holub/mame
synced 2025-06-22 04:06:39 +03:00
Support -listroms for devices (e.g. mpu401 or m68705p3)
* Also ~67% improvement of device walk in -verifyroms
This commit is contained in:
parent
a8c908b05e
commit
75dfd32e71
@ -508,26 +508,23 @@ void cli_frontend::listcrc(const std::vector<std::string> &args)
|
|||||||
void cli_frontend::listroms(const std::vector<std::string> &args)
|
void cli_frontend::listroms(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
const char *gamename = args.empty() ? nullptr : args[0].c_str();
|
const char *gamename = args.empty() ? nullptr : args[0].c_str();
|
||||||
|
|
||||||
// determine which drivers to output; return an error if none found
|
|
||||||
driver_enumerator drivlist(m_options, gamename);
|
|
||||||
if (drivlist.count() == 0)
|
|
||||||
throw emu_fatalerror(EMU_ERR_NO_SUCH_GAME, "No matching games found for '%s'", gamename);
|
|
||||||
|
|
||||||
// iterate through matches
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (drivlist.next())
|
auto const list_system_roms = [&first] (device_t &root, char const *type)
|
||||||
{
|
{
|
||||||
// print a header
|
// print a header
|
||||||
if (!first)
|
if (!first)
|
||||||
osd_printf_info("\n");
|
osd_printf_info("\n");
|
||||||
first = false;
|
first = false;
|
||||||
osd_printf_info("ROMs required for driver \"%s\".\n"
|
osd_printf_info(
|
||||||
"%-32s %10s %s\n",drivlist.driver().name, "Name", "Size", "Checksum");
|
"ROMs required for %s \"%s\".\n"
|
||||||
|
"%-32s %10s %s\n",
|
||||||
|
type, root.shortname(), "Name", "Size", "Checksum");
|
||||||
|
|
||||||
// iterate through roms
|
// iterate through roms
|
||||||
for (device_t &device : device_iterator(drivlist.config()->root_device()))
|
for (device_t &device : device_iterator(root))
|
||||||
|
{
|
||||||
for (const rom_entry *region = rom_first_region(device); region; region = rom_next_region(region))
|
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 (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
|
||||||
{
|
{
|
||||||
// accumulate the total length of all chunks
|
// accumulate the total length of all chunks
|
||||||
@ -561,6 +558,38 @@ void cli_frontend::listroms(const std::vector<std::string> &args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// determine which drivers to output
|
||||||
|
driver_enumerator drivlist(m_options, gamename);
|
||||||
|
|
||||||
|
// iterate through matches
|
||||||
|
while (drivlist.next())
|
||||||
|
list_system_roms(drivlist.config()->root_device(), "driver");
|
||||||
|
|
||||||
|
bool const iswild(!gamename || core_iswildstr(gamename));
|
||||||
|
if (iswild || first)
|
||||||
|
{
|
||||||
|
machine_config config(GAME_NAME(___empty), m_options);
|
||||||
|
for (device_type type : registered_device_types)
|
||||||
|
{
|
||||||
|
if (!gamename || !core_strwildcmp(gamename, type.shortname()))
|
||||||
|
{
|
||||||
|
device_t *const dev = config.device_add(&config.root_device(), "_tmp", type, 0);
|
||||||
|
list_system_roms(*dev, "device");
|
||||||
|
config.device_remove(&config.root_device(), "_tmp");
|
||||||
|
|
||||||
|
// if it wasn't a wildcard, there can only be one
|
||||||
|
if (!iswild)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return an error if none found
|
||||||
|
if (first)
|
||||||
|
throw emu_fatalerror(EMU_ERR_NO_SUCH_GAME, "No matching systems found for '%s'", gamename);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -829,15 +858,18 @@ void cli_frontend::verifyroms(const std::vector<std::string> &args)
|
|||||||
summary_string);
|
summary_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool const iswild(!gamename || core_iswildstr(gamename));
|
||||||
|
if (iswild || !matched)
|
||||||
|
{
|
||||||
machine_config config(GAME_NAME(___empty), m_options);
|
machine_config config(GAME_NAME(___empty), m_options);
|
||||||
for (device_type type : registered_device_types)
|
for (device_type type : registered_device_types)
|
||||||
{
|
{
|
||||||
device_t *const dev = config.device_add(&config.root_device(), "_tmp", type, 0);
|
if (!gamename || !core_strwildcmp(gamename, type.shortname()))
|
||||||
if (!gamename || !core_strwildcmp(gamename, dev->shortname()))
|
|
||||||
{
|
{
|
||||||
matched++;
|
matched++;
|
||||||
|
|
||||||
// audit the ROMs in this set
|
// audit the ROMs in this set
|
||||||
|
device_t *const dev = config.device_add(&config.root_device(), "_tmp", type, 0);
|
||||||
media_auditor::summary summary = auditor.audit_device(*dev, AUDIT_VALIDATE_FAST);
|
media_auditor::summary summary = auditor.audit_device(*dev, AUDIT_VALIDATE_FAST);
|
||||||
|
|
||||||
print_summary(
|
print_summary(
|
||||||
@ -845,8 +877,13 @@ void cli_frontend::verifyroms(const std::vector<std::string> &args)
|
|||||||
"rom", dev->shortname(), nullptr,
|
"rom", dev->shortname(), nullptr,
|
||||||
correct, incorrect, notfound,
|
correct, incorrect, notfound,
|
||||||
summary_string);
|
summary_string);
|
||||||
}
|
|
||||||
config.device_remove(&config.root_device(), "_tmp");
|
config.device_remove(&config.root_device(), "_tmp");
|
||||||
|
|
||||||
|
// if it wasn't a wildcard, there can only be one
|
||||||
|
if (!iswild)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear out any cached files
|
// clear out any cached files
|
||||||
@ -854,7 +891,7 @@ void cli_frontend::verifyroms(const std::vector<std::string> &args)
|
|||||||
|
|
||||||
// return an error if none found
|
// return an error if none found
|
||||||
if (matched == 0)
|
if (matched == 0)
|
||||||
throw emu_fatalerror(EMU_ERR_NO_SUCH_GAME, "No matching games found for '%s'", gamename ? gamename : "");
|
throw emu_fatalerror(EMU_ERR_NO_SUCH_GAME, "No matching systems found for '%s'", gamename ? 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 (matched > 0 && correct == 0 && incorrect == 0)
|
if (matched > 0 && correct == 0 && incorrect == 0)
|
||||||
|
@ -107,6 +107,16 @@ int core_strwildcmp(const char *sp1, const char *sp2)
|
|||||||
return core_stricmp(s1, s2);
|
return core_stricmp(s1, s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool core_iswildstr(const char *sp)
|
||||||
|
{
|
||||||
|
for ( ; sp && *sp; sp++)
|
||||||
|
{
|
||||||
|
if (('?' == *sp) || ('*' == *sp))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
core_strdup - string duplication via malloc
|
core_strdup - string duplication via malloc
|
||||||
|
@ -59,6 +59,7 @@ char *core_strdup(const char *str);
|
|||||||
|
|
||||||
/* additional string compare helper (up to 16 characters at the moment) */
|
/* additional string compare helper (up to 16 characters at the moment) */
|
||||||
int core_strwildcmp(const char *sp1, const char *sp2);
|
int core_strwildcmp(const char *sp1, const char *sp2);
|
||||||
|
bool core_iswildstr(const char *sp);
|
||||||
|
|
||||||
|
|
||||||
int strcatvprintf(std::string &str, const char *format, va_list args);
|
int strcatvprintf(std::string &str, const char *format, va_list args);
|
||||||
|
Loading…
Reference in New Issue
Block a user