mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
C++-fiied code that iterates over rom_entry arrays (without usage of rom_[first|next]_*)
This commit is contained in:
parent
38f86f2c05
commit
f5968efcea
@ -924,14 +924,14 @@ void device_interface::interface_debug_setup()
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// rom_region
|
||||
// rom_region_vector
|
||||
//-------------------------------------------------
|
||||
|
||||
const rom_entry *device_t::rom_region() const
|
||||
const std::vector<rom_entry> &device_t::rom_region_vector() const
|
||||
{
|
||||
if (m_rom_entries.empty())
|
||||
{
|
||||
m_rom_entries = rom_build_entries(device_rom_region());
|
||||
}
|
||||
return m_rom_entries.data();
|
||||
return m_rom_entries;
|
||||
}
|
@ -203,7 +203,8 @@ public:
|
||||
UINT32 configured_clock() const { return m_configured_clock; }
|
||||
const machine_config &mconfig() const { return m_machine_config; }
|
||||
const input_device_default *input_ports_defaults() const { return m_input_defaults; }
|
||||
const rom_entry *rom_region() const;
|
||||
const std::vector<rom_entry> &rom_region_vector() const;
|
||||
const rom_entry *rom_region() const { return rom_region_vector().data(); }
|
||||
machine_config_constructor machine_config_additions() const { return device_mconfig_additions(); }
|
||||
ioport_constructor input_ports() const { return device_input_ports(); }
|
||||
UINT8 default_bios() const { return m_default_bios; }
|
||||
|
@ -2548,9 +2548,8 @@ time_t ioport_manager::initialize()
|
||||
m_has_analog = true;
|
||||
}
|
||||
for (device_t &device : device_iterator(machine().root_device()))
|
||||
if (device.rom_region())
|
||||
for (const rom_entry *rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++)
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom)) { m_has_bioses= true; break; }
|
||||
for (const rom_entry &rom : device.rom_region_vector())
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(&rom)) { m_has_bioses= true; break; }
|
||||
}
|
||||
|
||||
// open playback and record files if specified
|
||||
|
@ -268,23 +268,22 @@ int rom_load_manager::set_disk_handle(const char *region, const char *fullpath)
|
||||
void rom_load_manager::determine_bios_rom(device_t &device, const char *specbios)
|
||||
{
|
||||
const char *defaultname = nullptr;
|
||||
const rom_entry *rom;
|
||||
int default_no = 1;
|
||||
int bios_count = 0;
|
||||
|
||||
device.set_system_bios(0);
|
||||
|
||||
/* first determine the default BIOS name */
|
||||
for (rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++)
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(rom))
|
||||
defaultname = ROM_GETNAME(rom);
|
||||
for (const rom_entry &rom : device.rom_region_vector())
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(&rom))
|
||||
defaultname = ROM_GETNAME(&rom);
|
||||
|
||||
/* look for a BIOS with a matching name */
|
||||
for (rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++)
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom))
|
||||
for (const rom_entry &rom : device.rom_region_vector())
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(&rom))
|
||||
{
|
||||
const char *biosname = ROM_GETNAME(rom);
|
||||
int bios_flags = ROM_GETBIOSFLAGS(rom);
|
||||
const char *biosname = ROM_GETNAME(&rom);
|
||||
int bios_flags = ROM_GETBIOSFLAGS(&rom);
|
||||
char bios_number[20];
|
||||
|
||||
/* Allow '-bios n' to still be used */
|
||||
|
@ -519,19 +519,19 @@ void info_xml_creator::output_bios()
|
||||
|
||||
// first determine the default BIOS name
|
||||
std::string defaultname;
|
||||
for (const rom_entry *rom = rom_entries.data(); !ROMENTRY_ISEND(rom); rom++)
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(rom))
|
||||
defaultname = ROM_GETNAME(rom);
|
||||
for (const rom_entry &rom : rom_entries)
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(&rom))
|
||||
defaultname = ROM_GETNAME(&rom);
|
||||
|
||||
// iterate over ROM entries and look for BIOSes
|
||||
for (const rom_entry *rom = rom_entries.data(); !ROMENTRY_ISEND(rom); rom++)
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom))
|
||||
for (const rom_entry &rom : rom_entries)
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(&rom))
|
||||
{
|
||||
// output extracted name and descriptions
|
||||
fprintf(m_output, "\t\t<biosset");
|
||||
fprintf(m_output, " name=\"%s\"", xml_normalize_string(ROM_GETNAME(rom)));
|
||||
fprintf(m_output, " description=\"%s\"", xml_normalize_string(ROM_GETHASHDATA(rom)));
|
||||
if (defaultname == ROM_GETNAME(rom))
|
||||
fprintf(m_output, " name=\"%s\"", xml_normalize_string(ROM_GETNAME(&rom)));
|
||||
fprintf(m_output, " description=\"%s\"", xml_normalize_string(ROM_GETHASHDATA(&rom)));
|
||||
if (defaultname == ROM_GETNAME(&rom))
|
||||
fprintf(m_output, " default=\"yes\"");
|
||||
fprintf(m_output, "/>\n");
|
||||
}
|
||||
|
@ -147,18 +147,18 @@ void menu_device_config::populate()
|
||||
{
|
||||
std::string bios_str;
|
||||
// first loop through roms in search of default bios (shortname)
|
||||
for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++)
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(rom))
|
||||
bios_str.assign(ROM_GETNAME(rom));
|
||||
for (const rom_entry &rom : dev->rom_region_vector())
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(&rom))
|
||||
bios_str.assign(ROM_GETNAME(&rom));
|
||||
|
||||
// then loop again to count bios options and to get the default bios complete name
|
||||
for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++)
|
||||
for (const rom_entry &rom : dev->rom_region_vector())
|
||||
{
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom))
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(&rom))
|
||||
{
|
||||
bios++;
|
||||
if (bios_str.compare(ROM_GETNAME(rom))==0)
|
||||
bios_str.assign(ROM_GETHASHDATA(rom));
|
||||
if (bios_str.compare(ROM_GETNAME(&rom))==0)
|
||||
bios_str.assign(ROM_GETHASHDATA(&rom));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,9 +117,9 @@ void menu_bios_selection::handle()
|
||||
{
|
||||
device_t *dev = (device_t *)menu_event->itemref;
|
||||
int cnt = 0;
|
||||
for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++)
|
||||
for (const rom_entry &rom : dev->rom_region_vector())
|
||||
{
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom)) cnt ++;
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(&rom)) cnt ++;
|
||||
}
|
||||
int val = dev->system_bios() + ((menu_event->iptkey == IPT_UI_LEFT) ? -1 : +1);
|
||||
if (val<1) val=cnt;
|
||||
@ -842,18 +842,18 @@ void menu_machine_configure::setup_bios()
|
||||
|
||||
std::string specbios(m_opts.bios());
|
||||
std::string default_name;
|
||||
for (const rom_entry *rom = entries.data(); !ROMENTRY_ISEND(rom); ++rom)
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(rom))
|
||||
default_name = ROM_GETNAME(rom);
|
||||
for (const rom_entry &rom : entries)
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(&rom))
|
||||
default_name = ROM_GETNAME(&rom);
|
||||
|
||||
std::size_t bios_count = 0;
|
||||
for (const rom_entry *rom = entries.data(); !ROMENTRY_ISEND(rom); ++rom)
|
||||
for (const rom_entry &rom : entries)
|
||||
{
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom))
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(&rom))
|
||||
{
|
||||
std::string name(ROM_GETHASHDATA(rom));
|
||||
std::string biosname(ROM_GETNAME(rom));
|
||||
int bios_flags = ROM_GETBIOSFLAGS(rom);
|
||||
std::string name(ROM_GETHASHDATA(&rom));
|
||||
std::string biosname(ROM_GETNAME(&rom));
|
||||
int bios_flags = ROM_GETBIOSFLAGS(&rom);
|
||||
std::string bios_number = std::to_string(bios_flags - 1);
|
||||
|
||||
// check biosnumber and name
|
||||
|
@ -1113,8 +1113,8 @@ void menu_select_game::build_list(const char *filter_text, int filter, bool bios
|
||||
}
|
||||
break;
|
||||
case FILTER_CHD:
|
||||
for (const rom_entry *rom = entries.data(); !ROMENTRY_ISEND(rom); ++rom)
|
||||
if (ROMENTRY_ISREGION(rom) && ROMREGION_ISDISKDATA(rom))
|
||||
for (const rom_entry &rom : entries)
|
||||
if (ROMENTRY_ISREGION(&rom) && ROMREGION_ISDISKDATA(&rom))
|
||||
{
|
||||
m_displaylist.push_back(s_driver);
|
||||
break;
|
||||
@ -1123,8 +1123,8 @@ void menu_select_game::build_list(const char *filter_text, int filter, bool bios
|
||||
case FILTER_NOCHD:
|
||||
{
|
||||
bool found = false;
|
||||
for (const rom_entry *rom = entries.data(); !ROMENTRY_ISEND(rom); ++rom)
|
||||
if (ROMENTRY_ISREGION(rom) && ROMREGION_ISDISKDATA(rom))
|
||||
for (const rom_entry &rom : entries)
|
||||
if (ROMENTRY_ISREGION(&rom) && ROMREGION_ISDISKDATA(&rom))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
@ -1304,8 +1304,8 @@ void menu_select_game::general_info(const game_driver *driver, std::string &buff
|
||||
util::stream_format(str, _("Screen Orientation: %1$s\n"), ((driver->flags & ORIENTATION_SWAP_XY) ? _("Vertical") : _("Horizontal")));
|
||||
bool found = false;
|
||||
auto entries = rom_build_entries(driver->rom);
|
||||
for (const rom_entry *rom = entries.data(); !ROMENTRY_ISEND(rom); ++rom)
|
||||
if (ROMENTRY_ISREGION(rom) && ROMREGION_ISDISKDATA(rom))
|
||||
for (const rom_entry &rom : entries)
|
||||
if (ROMENTRY_ISREGION(&rom) && ROMREGION_ISDISKDATA(&rom))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
@ -99,17 +99,17 @@ bool has_multiple_bios(const game_driver *driver, s_bios &biosname)
|
||||
auto entries = rom_build_entries(driver->rom);
|
||||
|
||||
std::string default_name;
|
||||
for (const rom_entry *rom = entries.data(); !ROMENTRY_ISEND(rom); ++rom)
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(rom))
|
||||
default_name = ROM_GETNAME(rom);
|
||||
for (const rom_entry &rom : entries)
|
||||
if (ROMENTRY_ISDEFAULT_BIOS(&rom))
|
||||
default_name = ROM_GETNAME(&rom);
|
||||
|
||||
for (const rom_entry *rom = entries.data(); !ROMENTRY_ISEND(rom); ++rom)
|
||||
for (const rom_entry &rom : entries)
|
||||
{
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom))
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(&rom))
|
||||
{
|
||||
std::string name(ROM_GETHASHDATA(rom));
|
||||
std::string bname(ROM_GETNAME(rom));
|
||||
int bios_flags = ROM_GETBIOSFLAGS(rom);
|
||||
std::string name(ROM_GETHASHDATA(&rom));
|
||||
std::string bname(ROM_GETNAME(&rom));
|
||||
int bios_flags = ROM_GETBIOSFLAGS(&rom);
|
||||
|
||||
if (bname == default_name)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user