Removed rom_source abstraction, which was just mapping to devices

anyways. Updated everyone involved to just iterate over devices
directly.
This commit is contained in:
Aaron Giles 2012-02-20 06:06:58 +00:00
parent 3acdb010c5
commit 1db879e232
11 changed files with 261 additions and 306 deletions

View File

@ -77,42 +77,38 @@ media_auditor::summary media_auditor::audit_media(const char *validation)
// all searches // all searches
const char *driverpath = m_enumerator.config().root_device().searchpath(); const char *driverpath = m_enumerator.config().root_device().searchpath();
// iterate over ROM sources and regions
int found = 0; int found = 0;
int required = 0; int required = 0;
int sharedFound = 0; int shared_found = 0;
int sharedRequired = 0; int shared_required = 0;
for (const rom_source *source = rom_first_source(m_enumerator.config()); source != NULL; source = rom_next_source(*source)) // iterate over devices and regions
device_iterator deviter(m_enumerator.config().root_device());
for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
{ {
// 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 = device->searchpath();
// 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(*device); region != NULL; region = rom_next_region(region))
{ {
// temporary hack: add the driver path & region name // temporary hack: add the driver path & region name
astring combinedpath(source->searchpath(), ";", driverpath); astring combinedpath(device->searchpath(), ";", driverpath);
if(source->shortname()) if (device->shortname())
{ combinedpath.cat(";").cat(device->shortname());
combinedpath=combinedpath.cat(";");
combinedpath=combinedpath.cat(source->shortname());
}
m_searchpath = combinedpath; 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));
const rom_source *shared_source = find_shared_source(source, hashes, ROM_GETLENGTH(rom)); device_t *shared_device = find_shared_device(*device, 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_source != NULL) if (shared_device != NULL)
{ shared_required++;
sharedRequired++;
}
} }
// audit a file // audit a file
@ -127,31 +123,27 @@ m_searchpath = combinedpath;
if (record != NULL) if (record != NULL)
{ {
// count the number of files that are found. // 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)) if (record->status() == audit_record::STATUS_GOOD || (record->status() == audit_record::STATUS_FOUND_INVALID && find_shared_device(*device, record->actual_hashes(), record->actual_length()) == NULL))
{ {
found++; found++;
if (shared_source != NULL) if (shared_device != NULL)
{ shared_found++;
sharedFound++;
}
} }
record->set_shared_source(shared_source); record->set_shared_device(shared_device);
} }
} }
} }
} }
// 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 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 == sharedFound && required > 0 && (required != sharedRequired || sharedFound == 0)) if (found == shared_found && required > 0 && (required != shared_required || shared_found == 0))
{ {
m_record_list.reset(); m_record_list.reset();
return NOTFOUND; return NOTFOUND;
} }
else if (found == 0 && m_record_list.count() == 0) else if (found == 0 && m_record_list.count() == 0)
{
return NONE_NEEDED; return NONE_NEEDED;
}
// return a summary // return a summary
return summarize(m_enumerator.driver().name); return summarize(m_enumerator.driver().name);
@ -345,9 +337,11 @@ media_auditor::summary media_auditor::summarize(const char *name, astring *strin
case audit_record::SUBSTATUS_NOT_FOUND: case audit_record::SUBSTATUS_NOT_FOUND:
if (string != NULL) if (string != NULL)
{ {
const rom_source *shared_source = record->shared_source(); device_t *shared_device = record->shared_device();
if (shared_source == NULL) string->catprintf("NOT FOUND\n"); if (shared_device == NULL)
else string->catprintf("NOT FOUND (%s)\n", shared_source->shortname()); string->catprintf("NOT FOUND\n");
else
string->catprintf("NOT FOUND (%s)\n", shared_device->shortname());
} }
break; break;
@ -494,43 +488,48 @@ void media_auditor::compute_status(audit_record &record, const rom_entry *rom, b
//------------------------------------------------- //-------------------------------------------------
// find_shared_source - return the source that // find_shared_device - return the source that
// shares a media entry with the same hashes // shares a media entry with the same hashes
//------------------------------------------------- //-------------------------------------------------
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)) device_t *media_auditor::find_shared_device(device_t &device, const hash_collection &romhashes, UINT64 romlength)
{
// doesn't apply to NO_DUMP items
if (romhashes.flag(hash_collection::FLAG_NO_DUMP))
return NULL;
// special case for non-root devices
device_t *highest_device = NULL;
if (device.owner() != NULL)
{ {
if (dynamic_cast<const driver_device *>(source) == NULL) for (const rom_entry *region = rom_first_region(device); region != NULL; region = rom_next_region(region))
for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
if (ROM_GETLENGTH(rom) == romlength)
{
hash_collection hashes(ROM_GETHASHDATA(rom));
if (hashes == romhashes)
highest_device = &device;
}
}
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_entry *region = rom_first_region(*source); region; region = rom_next_region(region)) device_iterator deviter(m_enumerator.config().root_device());
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) for (device_t *scandevice = deviter.first(); scandevice != NULL; scandevice = deviter.next())
if (ROM_GETLENGTH(rom) == romlength) 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))
hash_collection hashes(ROM_GETHASHDATA(rom)); if (ROM_GETLENGTH(rom) == romlength)
if (hashes == romhashes) {
highest_source = source; hash_collection hashes(ROM_GETHASHDATA(rom));
} if (hashes == romhashes)
} highest_device = scandevice;
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;
}
} }
} }
return highest_source; return highest_device;
} }
@ -546,7 +545,7 @@ audit_record::audit_record(const rom_entry &media, media_type type)
m_name(ROM_GETNAME(&media)), m_name(ROM_GETNAME(&media)),
m_explength(rom_file_size(&media)), m_explength(rom_file_size(&media)),
m_length(0), m_length(0),
m_shared_source(NULL) m_shared_device(NULL)
{ {
m_exphashes.from_internal_string(ROM_GETHASHDATA(&media)); m_exphashes.from_internal_string(ROM_GETHASHDATA(&media));
} }
@ -559,6 +558,6 @@ audit_record::audit_record(const char *name, media_type type)
m_name(name), m_name(name),
m_explength(0), m_explength(0),
m_length(0), m_length(0),
m_shared_source(NULL) m_shared_device(NULL)
{ {
} }

View File

@ -114,7 +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; } device_t *shared_device() const { return m_shared_device; }
// setters // setters
void set_status(audit_status status, audit_substatus substatus) void set_status(audit_status status, audit_substatus substatus)
@ -129,9 +129,9 @@ public:
m_length = length; m_length = length;
} }
void set_shared_source(const rom_source *shared_source) void set_shared_device(device_t *shared_device)
{ {
m_shared_source = shared_source; m_shared_device = shared_device;
} }
private: private:
@ -145,7 +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 */ device_t * m_shared_device; /* device that shares the rom */
}; };
@ -183,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);
const rom_source *find_shared_source(const rom_source *source, const hash_collection &romhashes, UINT64 romlength); device_t *find_shared_device(device_t &device, 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

@ -463,18 +463,18 @@ void cli_frontend::listcrc(const char *gamename)
// iterate through matches, and then through ROMs // iterate through matches, and then through ROMs
while (drivlist.next()) while (drivlist.next())
for (const rom_source *source = rom_first_source(drivlist.config()); source != NULL; source = rom_next_source(*source)) {
{ device_iterator deviter(drivlist.config().root_device());
bool isdriver = (source == rom_first_source(drivlist.config())); for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (const rom_entry *region = rom_first_region(*source); 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))
{ {
// if we have a CRC, display it // if we have a CRC, display it
UINT32 crc; UINT32 crc;
if (hash_collection(ROM_GETHASHDATA(rom)).crc(crc)) if (hash_collection(ROM_GETHASHDATA(rom)).crc(crc))
mame_printf_info("%08x %-16s \t %-8s \t %s\n", crc, ROM_GETNAME(rom), source->shortname(), isdriver ? drivlist.driver().description : source->name()); mame_printf_info("%08x %-16s \t %-8s \t %s\n", crc, ROM_GETNAME(rom), device->shortname(), device->name());
} }
} }
} }
@ -503,8 +503,9 @@ void cli_frontend::listroms(const char *gamename)
"Name Size Checksum\n", drivlist.driver().name); "Name Size Checksum\n", drivlist.driver().name);
// iterate through roms // iterate through roms
for (const rom_source *source = rom_first_source(drivlist.config()); source != NULL; source = rom_next_source(*source)) device_iterator deviter(drivlist.config().root_device());
for (const rom_entry *region = rom_first_region(*source); region; region = rom_next_region(region)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
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
@ -1649,9 +1650,10 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length)
m_drivlist.reset(); m_drivlist.reset();
while (m_drivlist.next()) while (m_drivlist.next())
{ {
// iterate over sources, regions and files within the region */ // iterate over devices, regions and files within the region */
for (const rom_source *source = rom_first_source(m_drivlist.config()); source != NULL; source = rom_next_source(*source)) device_iterator deviter(m_drivlist.config().root_device());
for (const rom_entry *region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region))
for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
{ {
hash_collection romhashes(ROM_GETHASHDATA(rom)); hash_collection romhashes(ROM_GETHASHDATA(rom));

View File

@ -301,11 +301,12 @@ void device_memory_interface::interface_validity_check(validity_checker &valid)
device().siblingtag(entry_region, entry->m_region); device().siblingtag(entry_region, entry->m_region);
// look for the region // look for the region
for (const rom_source *source = rom_first_source(device().mconfig()); source != NULL && !found; source = rom_next_source(*source)) device_iterator deviter(device().mconfig().root_device());
for (const rom_entry *romp = rom_first_region(*source); romp != NULL && !found; romp = rom_next_region(romp)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (const rom_entry *romp = rom_first_region(*device); romp != NULL && !found; romp = rom_next_region(romp))
{ {
astring fulltag; astring fulltag;
rom_region_name(fulltag, &device().mconfig().gamedrv(), source, romp); rom_region_name(fulltag, *device, romp);
if (fulltag == entry_region) if (fulltag == entry_region)
{ {
// verify the address range is within the region's bounds // verify the address range is within the region's bounds

View File

@ -171,13 +171,12 @@ int cartslot_image_device::load_cartridge(const rom_entry *romrgn, const rom_ent
int cartslot_image_device::process_cartridge(bool load) int cartslot_image_device::process_cartridge(bool load)
{ {
const rom_source *source;
const rom_entry *romrgn, *roment; const rom_entry *romrgn, *roment;
int result = 0; int result = 0;
for (source = rom_first_source(device().machine().config()); source != NULL; source = rom_next_source(*source)) device_iterator deviter(device().mconfig().root_device());
{ for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (romrgn = rom_first_region(*source); romrgn != NULL; romrgn = rom_next_region(romrgn)) for (romrgn = rom_first_region(*device); romrgn != NULL; romrgn = rom_next_region(romrgn))
{ {
roment = romrgn + 1; roment = romrgn + 1;
while(!ROMENTRY_ISREGIONEND(roment)) while(!ROMENTRY_ISREGIONEND(roment))
@ -185,9 +184,9 @@ int cartslot_image_device::process_cartridge(bool load)
if (ROMENTRY_GETTYPE(roment) == ROMENTRYTYPE_CARTRIDGE) if (ROMENTRY_GETTYPE(roment) == ROMENTRYTYPE_CARTRIDGE)
{ {
astring regiontag; astring regiontag;
device().siblingtag(regiontag, roment->_hashdata); this->device().siblingtag(regiontag, roment->_hashdata);
if (strcmp(regiontag.cstr(),device().tag())==0) if (strcmp(regiontag.cstr(),this->device().tag())==0)
{ {
result |= load_cartridge(romrgn, roment, load); result |= load_cartridge(romrgn, roment, load);
@ -199,7 +198,6 @@ int cartslot_image_device::process_cartridge(bool load)
roment++; roment++;
} }
} }
}
return IMAGE_INIT_PASS; return IMAGE_INIT_PASS;
} }

View File

@ -239,7 +239,8 @@ void info_xml_creator::output(FILE *out)
CONFIG_VERSION CONFIG_VERSION
); );
m_device_used = global_alloc_array_clear(UINT8, m_device_count); m_device_used.resize(m_device_count);
memset(m_device_used, 0, m_device_count);
// iterate through the drivers, outputting one at a time // iterate through the drivers, outputting one at a time
while (m_drivlist.next()) while (m_drivlist.next())
@ -248,8 +249,6 @@ void info_xml_creator::output(FILE *out)
// iterate through the devices, and output their roms // iterate through the devices, and output their roms
output_devices(); output_devices();
global_free(m_device_used);
// close the top level tag // close the top level tag
fprintf(m_output, "</%s>\n",emulator_info::get_xml_root()); fprintf(m_output, "</%s>\n",emulator_info::get_xml_root());
} }
@ -266,16 +265,19 @@ void info_xml_creator::output_devices()
m_drivlist.next(); m_drivlist.next();
machine_config &config = m_drivlist.config(); machine_config &config = m_drivlist.config();
device_t &owner = config.root_device(); device_t &owner = config.root_device();
// 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() == (m_drivlist.count()+1); bool display_all = (driver_list::total() == m_drivlist.count() + 1);
for(int i=0;i<m_device_count;i++) { for (int devnum = 0; devnum < m_device_count; devnum++)
if (display_all || (m_device_used[i]!=0)) { {
device_type type = *s_devices_sorted[i]; if (display_all || m_device_used[devnum])
{
device_type type = *s_devices_sorted[devnum];
device_t *dev = (*type)(config, "dummy", &owner, 0); device_t *dev = (*type)(config, "dummy", &owner, 0);
dev->config_complete(); dev->config_complete();
// print the header and the game name // print the header and the game name
fprintf(m_output, "\t<%s",emulator_info::get_xml_top()); fprintf(m_output, "\t<%s", emulator_info::get_xml_top());
fprintf(m_output, " name=\"%s\"", xml_normalize_string(dev->shortname())); fprintf(m_output, " name=\"%s\"", xml_normalize_string(dev->shortname()));
fprintf(m_output, " isdevice=\"yes\""); fprintf(m_output, " isdevice=\"yes\"");
fprintf(m_output, " runnable=\"no\""); fprintf(m_output, " runnable=\"no\"");
@ -285,15 +287,16 @@ void info_xml_creator::output_devices()
if (dev->name() != NULL) if (dev->name() != NULL)
fprintf(m_output, "\t\t<description>%s</description>\n", xml_normalize_string(dev->name())); fprintf(m_output, "\t\t<description>%s</description>\n", xml_normalize_string(dev->name()));
output_rom(dev); output_rom(*dev);
// close the topmost tag // close the topmost tag
fprintf(m_output, "\t</%s>\n",emulator_info::get_xml_top()); fprintf(m_output, "\t</%s>\n", emulator_info::get_xml_top());
global_free(dev); global_free(dev);
} }
} }
} }
//------------------------------------------------- //-------------------------------------------------
// output_one - print the XML information // output_one - print the XML information
// for one particular game driver // for one particular game driver
@ -359,7 +362,7 @@ void info_xml_creator::output_one()
// now print various additional information // now print various additional information
output_bios(); output_bios();
output_rom(rom_first_source(m_drivlist.config())); output_rom(m_drivlist.config().root_device());
output_device_roms(); output_device_roms();
output_sample(); output_sample();
output_chips(); output_chips();
@ -379,6 +382,7 @@ void info_xml_creator::output_one()
fprintf(m_output, "\t</%s>\n",emulator_info::get_xml_top()); fprintf(m_output, "\t</%s>\n",emulator_info::get_xml_top());
} }
//------------------------------------------------ //------------------------------------------------
// output_device_roms - print the device // output_device_roms - print the device
// with roms, if appropriate // with roms, if appropriate
@ -386,19 +390,18 @@ void info_xml_creator::output_one()
void info_xml_creator::output_device_roms() void info_xml_creator::output_device_roms()
{ {
int cnt=0; device_iterator deviter(m_drivlist.config().root_device());
for (const rom_source *source = rom_first_source(m_drivlist.config()); source != NULL; source = rom_next_source(*source)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
{ if (device->owner() != NULL)
if (cnt!=0) { {
fprintf(m_output, "\t\t<device_ref name=\"%s\"/>\n", xml_normalize_string(source->shortname())); fprintf(m_output, "\t\t<device_ref name=\"%s\"/>\n", xml_normalize_string(device->shortname()));
for(int i=0;i<m_device_count;i++) { for (int devnum = 0; devnum < m_device_count; devnum++)
if (source->type() == *s_devices_sorted[i]) m_device_used[i] = 1; if (device->type() == *s_devices_sorted[devnum])
} m_device_used[devnum] = 1;
} }
cnt++;
}
} }
//------------------------------------------------ //------------------------------------------------
// output_sampleof - print the 'sampleof' // output_sampleof - print the 'sampleof'
// attribute, if appropriate // attribute, if appropriate
@ -453,98 +456,96 @@ void info_xml_creator::output_bios()
// the XML output // the XML output
//------------------------------------------------- //-------------------------------------------------
void info_xml_creator::output_rom(const rom_source *source) void info_xml_creator::output_rom(device_t &device)
{ {
// iterate over 3 different ROM "types": BIOS, ROMs, DISKs // iterate over 3 different ROM "types": BIOS, ROMs, DISKs
for (int rom_type = 0; rom_type < 3; rom_type++) for (int rom_type = 0; rom_type < 3; rom_type++)
{ for (const rom_entry *region = rom_first_region(device); region != NULL; region = rom_next_region(region))
for (const rom_entry *region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) {
{ bool is_disk = ROMREGION_ISDISKDATA(region);
bool is_disk = ROMREGION_ISDISKDATA(region);
// disk regions only work for disks // disk regions only work for disks
if ((is_disk && rom_type != 2) || (!is_disk && rom_type == 2)) if ((is_disk && rom_type != 2) || (!is_disk && rom_type == 2))
continue;
// iterate through ROM entries
for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
{
bool is_bios = ROM_GETBIOSFLAGS(rom);
const char *name = ROM_GETNAME(rom);
int offset = ROM_GETOFFSET(rom);
const char *merge_name = NULL;
char bios_name[100];
// BIOS ROMs only apply to bioses
if ((is_bios && rom_type != 0) || (!is_bios && rom_type == 0))
continue; continue;
// iterate through ROM entries // if we have a valid ROM and we are a clone, see if we can find the parent ROM
for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) hash_collection hashes(ROM_GETHASHDATA(rom));
if (!hashes.flag(hash_collection::FLAG_NO_DUMP))
merge_name = get_merge_name(hashes);
// scan for a BIOS name
bios_name[0] = 0;
if (!is_disk && is_bios)
{ {
bool is_bios = ROM_GETBIOSFLAGS(rom); // scan backwards through the ROM entries
const char *name = ROM_GETNAME(rom); for (const rom_entry *brom = rom - 1; brom != m_drivlist.driver().rom; brom--)
int offset = ROM_GETOFFSET(rom); if (ROMENTRY_ISSYSTEM_BIOS(brom))
const char *merge_name = NULL; {
char bios_name[100]; strcpy(bios_name, ROM_GETNAME(brom));
break;
// BIOS ROMs only apply to bioses }
if ((is_bios && rom_type != 0) || (!is_bios && rom_type == 0))
continue;
// if we have a valid ROM and we are a clone, see if we can find the parent ROM
hash_collection hashes(ROM_GETHASHDATA(rom));
if (!hashes.flag(hash_collection::FLAG_NO_DUMP))
merge_name = get_merge_name(hashes);
// scan for a BIOS name
bios_name[0] = 0;
if (!is_disk && is_bios)
{
// scan backwards through the ROM entries
for (const rom_entry *brom = rom - 1; brom != m_drivlist.driver().rom; brom--)
if (ROMENTRY_ISSYSTEM_BIOS(brom))
{
strcpy(bios_name, ROM_GETNAME(brom));
break;
}
}
// opening tag
if (!is_disk)
fprintf(m_output, "\t\t<rom");
else
fprintf(m_output, "\t\t<disk");
// add name, merge, bios, and size tags */
if (name != NULL && name[0] != 0)
fprintf(m_output, " name=\"%s\"", xml_normalize_string(name));
if (merge_name != NULL)
fprintf(m_output, " merge=\"%s\"", xml_normalize_string(merge_name));
if (bios_name[0] != 0)
fprintf(m_output, " bios=\"%s\"", xml_normalize_string(bios_name));
if (!is_disk)
fprintf(m_output, " size=\"%d\"", rom_file_size(rom));
// dump checksum information only if there is a known dump
if (!hashes.flag(hash_collection::FLAG_NO_DUMP))
{
// iterate over hash function types and print m_output their values
astring tempstr;
fprintf(m_output, " %s", hashes.attribute_string(tempstr));
}
else
fprintf(m_output, " status=\"nodump\"");
// append a region name
fprintf(m_output, " region=\"%s\"", ROMREGION_GETTAG(region));
// for non-disk entries, print offset
if (!is_disk)
fprintf(m_output, " offset=\"%x\"", offset);
// for disk entries, add the disk index
else
{
fprintf(m_output, " index=\"%x\"", DISK_GETINDEX(rom));
fprintf(m_output, " writable=\"%s\"", DISK_ISREADONLY(rom) ? "no" : "yes");
}
// add optional flag
if ((!is_disk && ROM_ISOPTIONAL(rom)) || (is_disk && DISK_ISOPTIONAL(rom)))
fprintf(m_output, " optional=\"yes\"");
fprintf(m_output, "/>\n");
} }
// opening tag
if (!is_disk)
fprintf(m_output, "\t\t<rom");
else
fprintf(m_output, "\t\t<disk");
// add name, merge, bios, and size tags */
if (name != NULL && name[0] != 0)
fprintf(m_output, " name=\"%s\"", xml_normalize_string(name));
if (merge_name != NULL)
fprintf(m_output, " merge=\"%s\"", xml_normalize_string(merge_name));
if (bios_name[0] != 0)
fprintf(m_output, " bios=\"%s\"", xml_normalize_string(bios_name));
if (!is_disk)
fprintf(m_output, " size=\"%d\"", rom_file_size(rom));
// dump checksum information only if there is a known dump
if (!hashes.flag(hash_collection::FLAG_NO_DUMP))
{
// iterate over hash function types and print m_output their values
astring tempstr;
fprintf(m_output, " %s", hashes.attribute_string(tempstr));
}
else
fprintf(m_output, " status=\"nodump\"");
// append a region name
fprintf(m_output, " region=\"%s\"", ROMREGION_GETTAG(region));
// for non-disk entries, print offset
if (!is_disk)
fprintf(m_output, " offset=\"%x\"", offset);
// for disk entries, add the disk index
else
{
fprintf(m_output, " index=\"%x\"", DISK_GETINDEX(rom));
fprintf(m_output, " writable=\"%s\"", DISK_ISREADONLY(rom) ? "no" : "yes");
}
// add optional flag
if ((!is_disk && ROM_ISOPTIONAL(rom)) || (is_disk && DISK_ISOPTIONAL(rom)))
fprintf(m_output, " optional=\"yes\"");
fprintf(m_output, "/>\n");
} }
} }
} }
@ -1262,13 +1263,14 @@ void info_xml_creator::output_ramoptions()
const char *info_xml_creator::get_merge_name(const hash_collection &romhashes) const char *info_xml_creator::get_merge_name(const hash_collection &romhashes)
{ {
const char *merge_name = NULL;
// walk the parent chain // walk the parent chain
const char *merge_name = NULL;
for (int clone_of = m_drivlist.find(m_drivlist.driver().parent); clone_of != -1; clone_of = m_drivlist.find(m_drivlist.driver(clone_of).parent)) for (int clone_of = m_drivlist.find(m_drivlist.driver().parent); clone_of != -1; clone_of = m_drivlist.find(m_drivlist.driver(clone_of).parent))
{
// look in the parent's ROMs // look in the parent's ROMs
for (const rom_source *psource = rom_first_source(m_drivlist.config(clone_of,m_lookup_options)); psource != NULL; psource = rom_next_source(*psource)) device_iterator deviter(m_drivlist.config(clone_of, m_lookup_options).root_device());
for (const rom_entry *pregion = rom_first_region(*psource); pregion != NULL; pregion = rom_next_region(pregion)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (const rom_entry *pregion = rom_first_region(*device); pregion != NULL; pregion = rom_next_region(pregion))
for (const rom_entry *prom = rom_first_file(pregion); prom != NULL; prom = rom_next_file(prom)) for (const rom_entry *prom = rom_first_file(pregion); prom != NULL; prom = rom_next_file(prom))
{ {
hash_collection phashes(ROM_GETHASHDATA(prom)); hash_collection phashes(ROM_GETHASHDATA(prom));
@ -1279,6 +1281,7 @@ const char *info_xml_creator::get_merge_name(const hash_collection &romhashes)
break; break;
} }
} }
}
return merge_name; return merge_name;
} }

View File

@ -62,7 +62,7 @@ private:
void output_one(); void output_one();
void output_sampleof(); void output_sampleof();
void output_bios(); void output_bios();
void output_rom(const rom_source *source); void output_rom(device_t &device);
void output_device_roms(); void output_device_roms();
void output_sample(); void output_sample();
void output_chips(); void output_chips();
@ -85,7 +85,7 @@ private:
// internal state // internal state
FILE * m_output; FILE * m_output;
driver_enumerator & m_drivlist; driver_enumerator & m_drivlist;
UINT8 * m_device_used; dynamic_array<UINT8> m_device_used;
emu_options m_lookup_options; emu_options m_lookup_options;
static const char s_dtd_string[]; static const char s_dtd_string[];

View File

@ -1084,6 +1084,9 @@ void driver_device::static_set_game(device_t &device, const game_driver &game)
// set the short name to the game's name // set the short name to the game's name
driver.m_shortname = game.name; driver.m_shortname = game.name;
// set the full name to the game's description
driver.m_name = game.description;
// and set the search path to include all parents // and set the search path to include all parents
driver.m_searchpath = game.name; driver.m_searchpath = game.name;
for (int parent = driver_list::clone(game); parent != -1; parent = driver_list::clone(parent)) for (int parent = driver_list::clone(game); parent != -1; parent = driver_list::clone(parent))

View File

@ -164,54 +164,14 @@ int set_disk_handle(running_machine &machine, const char *region, const char *fu
ROM LOADING ROM LOADING
***************************************************************************/ ***************************************************************************/
/*-------------------------------------------------
rom_first_source - return pointer to first ROM
source
-------------------------------------------------*/
const rom_source *rom_first_source(const machine_config &config)
{
/* look through devices */
device_iterator iter(config.root_device());
for (const device_t *device = iter.first(); device != NULL; device = iter.next())
if (device->rom_region() != NULL)
return device;
return NULL;
}
/*-------------------------------------------------
rom_next_source - return pointer to next ROM
source
-------------------------------------------------*/
const rom_source *rom_next_source(const rom_source &previous)
{
/* look for further devices with ROM definitions */
// fixme: this is awful
device_iterator iter(previous.mconfig().root_device());
const device_t *device;
for (device = iter.first(); device != NULL; device = iter.next())
if (device == &previous)
break;
for (device = iter.next(); device != NULL; device = iter.next())
if (device->rom_region() != NULL)
return device;
return NULL;
}
/*------------------------------------------------- /*-------------------------------------------------
rom_first_region - return pointer to first ROM rom_first_region - return pointer to first ROM
region region
-------------------------------------------------*/ -------------------------------------------------*/
const rom_entry *rom_first_region(const rom_source &source) const rom_entry *rom_first_region(const device_t &device)
{ {
const rom_entry *romp = source.rom_region(); const rom_entry *romp = device.rom_region();
return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL; return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL;
} }
@ -263,9 +223,9 @@ const rom_entry *rom_next_file(const rom_entry *romp)
for a rom region for a rom region
-------------------------------------------------*/ -------------------------------------------------*/
astring &rom_region_name(astring &result, const game_driver *drv, const rom_source *source, const rom_entry *romp) astring &rom_region_name(astring &result, const device_t &device, const rom_entry *romp)
{ {
return source->subtag(result, ROM_GETNAME(romp)); return device.subtag(result, ROM_GETNAME(romp));
} }
@ -333,46 +293,45 @@ static void determine_bios_rom(rom_load_data *romdata)
romdata->system_bios = 0; romdata->system_bios = 0;
for (const rom_source *source = rom_first_source(romdata->machine().config()); source != NULL; source = rom_next_source(*source)) device_t &rootdevice = romdata->machine().config().root_device();
{
/* first determine the default BIOS name */
for (rom = source->rom_region(); !ROMENTRY_ISEND(rom); rom++)
if (ROMENTRY_ISDEFAULT_BIOS(rom))
defaultname = ROM_GETNAME(rom);
/* look for a BIOS with a matching name */ /* first determine the default BIOS name */
for (rom = source->rom_region(); !ROMENTRY_ISEND(rom); rom++) for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++)
if (ROMENTRY_ISSYSTEM_BIOS(rom)) if (ROMENTRY_ISDEFAULT_BIOS(rom))
{ defaultname = ROM_GETNAME(rom);
const char *biosname = ROM_GETNAME(rom);
int bios_flags = ROM_GETBIOSFLAGS(rom);
char bios_number[20];
/* Allow '-bios n' to still be used */ /* look for a BIOS with a matching name */
sprintf(bios_number, "%d", bios_flags - 1); for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++)
if (mame_stricmp(bios_number, specbios) == 0 || mame_stricmp(biosname, specbios) == 0) if (ROMENTRY_ISSYSTEM_BIOS(rom))
romdata->system_bios = bios_flags;
if (defaultname != NULL && mame_stricmp(biosname, defaultname) == 0)
default_no = bios_flags;
bios_count++;
}
/* if none found, use the default */
if (romdata->system_bios == 0 && bios_count > 0)
{ {
/* if we got neither an empty string nor 'default' then warn the user */ const char *biosname = ROM_GETNAME(rom);
if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL) int bios_flags = ROM_GETBIOSFLAGS(rom);
{ char bios_number[20];
romdata->errorstring.catprintf("%s: invalid bios\n", specbios);
romdata->warnings++;
}
/* set to default */ /* Allow '-bios n' to still be used */
romdata->system_bios = default_no; sprintf(bios_number, "%d", bios_flags - 1);
if (mame_stricmp(bios_number, specbios) == 0 || mame_stricmp(biosname, specbios) == 0)
romdata->system_bios = bios_flags;
if (defaultname != NULL && mame_stricmp(biosname, defaultname) == 0)
default_no = bios_flags;
bios_count++;
} }
romdata->default_bios = default_no;
LOG(("Using System BIOS: %d\n", romdata->system_bios)); /* if none found, use the default */
if (romdata->system_bios == 0 && bios_count > 0)
{
/* if we got neither an empty string nor 'default' then warn the user */
if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL)
{
romdata->errorstring.catprintf("%s: invalid bios\n", specbios);
romdata->warnings++;
}
/* set to default */
romdata->system_bios = default_no;
} }
romdata->default_bios = default_no;
LOG(("Using System BIOS: %d\n", romdata->system_bios));
} }
@ -384,15 +343,15 @@ static void determine_bios_rom(rom_load_data *romdata)
static void count_roms(rom_load_data *romdata) static void count_roms(rom_load_data *romdata)
{ {
const rom_entry *region, *rom; const rom_entry *region, *rom;
const rom_source *source;
/* start with 0 */ /* start with 0 */
romdata->romstotal = 0; romdata->romstotal = 0;
romdata->romstotalsize = 0; romdata->romstotalsize = 0;
/* loop over regions, then over files */ /* loop over regions, then over files */
for (source = rom_first_source(romdata->machine().config()); source != NULL; source = rom_next_source(*source)) device_iterator deviter(romdata->machine().config().root_device());
for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (region = rom_first_region(*device); region != NULL; region = rom_next_region(region))
for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->system_bios) if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->system_bios)
{ {
@ -1003,7 +962,6 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_
{ {
emu_file image_file(options.media_path(), OPEN_FLAG_READ); emu_file image_file(options.media_path(), OPEN_FLAG_READ);
const rom_entry *region, *rom; const rom_entry *region, *rom;
const rom_source *source;
file_error filerr; file_error filerr;
chd_error err; chd_error err;
@ -1107,8 +1065,9 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_
for (int drv = driver_list::find(*gamedrv); drv != -1; drv = driver_list::clone(drv)) for (int drv = driver_list::find(*gamedrv); drv != -1; drv = driver_list::clone(drv))
{ {
machine_config config(driver_list::driver(drv), options); machine_config config(driver_list::driver(drv), options);
for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) device_iterator deviter(config.root_device());
for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (region = rom_first_region(*device); region != NULL; region = rom_next_region(region))
if (ROMREGION_ISDISKDATA(region)) if (ROMREGION_ISDISKDATA(region))
for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
@ -1430,16 +1389,15 @@ void load_software_part_region(device_t *device, char *swlist, char *swname, rom
static void process_region_list(rom_load_data *romdata) static void process_region_list(rom_load_data *romdata)
{ {
astring regiontag; astring regiontag;
const rom_source *source;
const rom_entry *region;
/* loop until we hit the end */ /* loop until we hit the end */
for (source = rom_first_source(romdata->machine().config()); source != NULL; source = rom_next_source(*source)) device_iterator deviter(romdata->machine().root_device());
for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region))
{ {
UINT32 regionlength = ROMREGION_GETLENGTH(region); UINT32 regionlength = ROMREGION_GETLENGTH(region);
rom_region_name(regiontag, &romdata->machine().system(), source, region); rom_region_name(regiontag, *device, region);
LOG(("Processing region \"%s\" (length=%X)\n", regiontag.cstr(), regionlength)); LOG(("Processing region \"%s\" (length=%X)\n", regiontag.cstr(), regionlength));
/* the first entry must be a region */ /* the first entry must be a region */
@ -1472,16 +1430,17 @@ static void process_region_list(rom_load_data *romdata)
#endif #endif
/* now process the entries in the region */ /* now process the entries in the region */
process_rom_entries(romdata, (source->shortname()!=NULL) ? source->shortname() : NULL, region, region + 1); process_rom_entries(romdata, device->shortname(), region, region + 1);
} }
else if (ROMREGION_ISDISKDATA(region)) else if (ROMREGION_ISDISKDATA(region))
process_disk_entries(romdata, regiontag, region, region + 1, NULL); process_disk_entries(romdata, regiontag, region, region + 1, NULL);
} }
/* now go back and post-process all the regions */ /* now go back and post-process all the regions */
for (source = rom_first_source(romdata->machine().config()); source != NULL; source = rom_next_source(*source)) for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) { for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region))
rom_region_name(regiontag, &romdata->machine().system(), source, region); {
rom_region_name(regiontag, *device, region);
region_post_process(romdata, regiontag, ROMREGION_ISINVERTED(region)); region_post_process(romdata, regiontag, ROMREGION_ISINVERTED(region));
} }
} }

View File

@ -123,8 +123,6 @@ class machine_config;
class emu_options; class emu_options;
class chd_file; class chd_file;
typedef device_t rom_source;
struct rom_entry struct rom_entry
{ {
@ -284,14 +282,8 @@ file_error common_process_file(emu_options &options, const char *location, bool
/* ----- ROM iteration ----- */ /* ----- ROM iteration ----- */
/* return pointer to first ROM source */
const rom_source *rom_first_source(const machine_config &config);
/* return pointer to next ROM source */
const rom_source *rom_next_source(const rom_source &previous);
/* return pointer to the first ROM region within a source */ /* return pointer to the first ROM region within a source */
const rom_entry *rom_first_region(const rom_source &romp); const rom_entry *rom_first_region(const device_t &romp);
/* return pointer to the next ROM region within a source */ /* return pointer to the next ROM region within a source */
const rom_entry *rom_next_region(const rom_entry *romp); const rom_entry *rom_next_region(const rom_entry *romp);
@ -302,14 +294,11 @@ const rom_entry *rom_first_file(const rom_entry *romp);
/* return pointer to the next ROM file within a region */ /* return pointer to the next ROM file within a region */
const rom_entry *rom_next_file(const rom_entry *romp); const rom_entry *rom_next_file(const rom_entry *romp);
/* return TRUE if the given rom_source refers to the game driver itself */
int rom_source_is_gamedrv(const game_driver *drv, const rom_source *source);
/* return the expected size of a file given the ROM description */ /* return the expected size of a file given the ROM description */
UINT32 rom_file_size(const rom_entry *romp); UINT32 rom_file_size(const rom_entry *romp);
/* return the appropriate name for a rom region */ /* return the appropriate name for a rom region */
astring &rom_region_name(astring &result, const game_driver *drv, const rom_source *source, const rom_entry *romp); astring &rom_region_name(astring &result, const device_t &device, const rom_entry *romp);

View File

@ -616,10 +616,11 @@ void validity_checker::validate_driver()
void validity_checker::validate_roms() void validity_checker::validate_roms()
{ {
// iterate, starting with the driver's ROMs and continuing with device ROMs // iterate, starting with the driver's ROMs and continuing with device ROMs
for (const rom_source *source = rom_first_source(*m_current_config); source != NULL; source = rom_next_source(*source)) device_iterator deviter(m_current_config->root_device());
for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
{ {
// for non-root devices, track the current device // for non-root devices, track the current device
m_current_device = (source == &m_current_config->root_device()) ? NULL : source; m_current_device = (device->owner() == NULL) ? NULL : device;
// scan the ROM entries for this device // scan the ROM entries for this device
const char *last_region_name = "???"; const char *last_region_name = "???";
@ -628,7 +629,7 @@ void validity_checker::validate_roms()
int items_since_region = 1; int items_since_region = 1;
int last_bios = 0; int last_bios = 0;
int total_files = 0; int total_files = 0;
for (const rom_entry *romp = rom_first_region(*source); !ROMENTRY_ISEND(romp); romp++) for (const rom_entry *romp = rom_first_region(*device); romp != NULL && !ROMENTRY_ISEND(romp); romp++)
{ {
// if this is a region, make sure it's valid, and record the length // if this is a region, make sure it's valid, and record the length
if (ROMENTRY_ISREGION(romp)) if (ROMENTRY_ISREGION(romp))
@ -654,7 +655,7 @@ void validity_checker::validate_roms()
// generate the full tag // generate the full tag
astring fulltag; astring fulltag;
rom_region_name(fulltag, m_current_driver, source, romp); rom_region_name(fulltag, *device, romp);
// attempt to add it to the map, reporting duplicates as errors // attempt to add it to the map, reporting duplicates as errors
current_length = ROMREGION_GETLENGTH(romp); current_length = ROMREGION_GETLENGTH(romp);