Allow machine configuration to specify BIOS easily, move default BIOS selection into device configuration complete
This commit is contained in:
parent
44a1d8ba14
commit
503be5cbdb
@ -231,7 +231,56 @@ void device_t::set_clock(u32 clock)
|
|||||||
|
|
||||||
void device_t::config_complete()
|
void device_t::config_complete()
|
||||||
{
|
{
|
||||||
// first notify the interfaces
|
// resolve default BIOS
|
||||||
|
tiny_rom_entry const *const roms(rom_region());
|
||||||
|
if (roms)
|
||||||
|
{
|
||||||
|
// first pass: try to find default BIOS from ROM region or machine configuration
|
||||||
|
char const *defbios(m_default_bios_tag.empty() ? nullptr : m_default_bios_tag.c_str());
|
||||||
|
bool twopass(false), havebios(false);
|
||||||
|
u8 firstbios(0);
|
||||||
|
for (const tiny_rom_entry *rom = roms; !m_default_bios && !ROMENTRY_ISEND(rom); ++rom)
|
||||||
|
{
|
||||||
|
if (ROMENTRY_ISSYSTEM_BIOS(rom))
|
||||||
|
{
|
||||||
|
if (!havebios)
|
||||||
|
{
|
||||||
|
havebios = true;
|
||||||
|
firstbios = ROM_GETBIOSFLAGS(rom);
|
||||||
|
}
|
||||||
|
if (!defbios)
|
||||||
|
twopass = true;
|
||||||
|
else if (!std::strcmp(rom->name, defbios))
|
||||||
|
m_default_bios = ROM_GETBIOSFLAGS(rom);
|
||||||
|
}
|
||||||
|
else if (!defbios && ROMENTRY_ISDEFAULT_BIOS(rom))
|
||||||
|
{
|
||||||
|
defbios = rom->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// second pass is needed if default BIOS came after one or more system BIOSes
|
||||||
|
if (havebios && !m_default_bios)
|
||||||
|
{
|
||||||
|
if (defbios && twopass)
|
||||||
|
{
|
||||||
|
for (const tiny_rom_entry *rom = roms; !m_default_bios && !ROMENTRY_ISEND(rom); ++rom)
|
||||||
|
{
|
||||||
|
if (ROMENTRY_ISSYSTEM_BIOS(rom) && !std::strcmp(rom->name, defbios))
|
||||||
|
m_default_bios = ROM_GETBIOSFLAGS(rom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no default BIOS declared but at least one system BIOS declared
|
||||||
|
if (!m_default_bios)
|
||||||
|
m_default_bios = firstbios;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set system BIOS to the default unless something overrides it
|
||||||
|
set_system_bios(m_default_bios);
|
||||||
|
}
|
||||||
|
|
||||||
|
// notify the interfaces
|
||||||
for (device_interface &intf : interfaces())
|
for (device_interface &intf : interfaces())
|
||||||
intf.interface_config_complete();
|
intf.interface_config_complete();
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
device->set_clock(_clock);
|
device->set_clock(_clock);
|
||||||
#define MCFG_DEVICE_INPUT_DEFAULTS(_config) \
|
#define MCFG_DEVICE_INPUT_DEFAULTS(_config) \
|
||||||
device->set_input_default(DEVICE_INPUT_DEFAULTS_NAME(_config));
|
device->set_input_default(DEVICE_INPUT_DEFAULTS_NAME(_config));
|
||||||
|
#define MCFG_DEVICE_BIOS(...) \
|
||||||
|
device->set_default_bios_tag(__VA_ARGS__);
|
||||||
|
|
||||||
#define DECLARE_READ_LINE_MEMBER(name) int name()
|
#define DECLARE_READ_LINE_MEMBER(name) int name()
|
||||||
#define READ_LINE_MEMBER(name) int name()
|
#define READ_LINE_MEMBER(name) int name()
|
||||||
@ -455,9 +457,9 @@ public:
|
|||||||
const std::vector<rom_entry> &rom_region_vector() const;
|
const std::vector<rom_entry> &rom_region_vector() const;
|
||||||
const tiny_rom_entry *rom_region() const { return device_rom_region(); }
|
const tiny_rom_entry *rom_region() const { return device_rom_region(); }
|
||||||
ioport_constructor input_ports() const { return device_input_ports(); }
|
ioport_constructor input_ports() const { return device_input_ports(); }
|
||||||
u8 default_bios() const { return m_default_bios; }
|
std::string const &get_default_bios_tag() const { return m_default_bios_tag; }
|
||||||
|
u8 default_bios() const { assert(configured()); return m_default_bios; }
|
||||||
u8 system_bios() const { return m_system_bios; }
|
u8 system_bios() const { return m_system_bios; }
|
||||||
const std::string &default_bios_tag() const { return m_default_bios_tag; }
|
|
||||||
|
|
||||||
// interface helpers
|
// interface helpers
|
||||||
interface_list &interfaces() { return m_interfaces; }
|
interface_list &interfaces() { return m_interfaces; }
|
||||||
@ -500,7 +502,7 @@ public:
|
|||||||
void set_clock(u32 clock);
|
void set_clock(u32 clock);
|
||||||
void set_clock(const XTAL &xtal) { set_clock(xtal.value()); }
|
void set_clock(const XTAL &xtal) { set_clock(xtal.value()); }
|
||||||
void set_input_default(const input_device_default *config) { m_input_defaults = config; }
|
void set_input_default(const input_device_default *config) { m_input_defaults = config; }
|
||||||
void set_default_bios_tag(const char *tag) { m_default_bios_tag = tag; }
|
template <typename... Params> void set_default_bios_tag(Params &&... args) { assert(!configured()); m_default_bios_tag.assign(std::forward<Params>(args)...); }
|
||||||
|
|
||||||
// state helpers
|
// state helpers
|
||||||
void config_complete();
|
void config_complete();
|
||||||
@ -536,7 +538,6 @@ public:
|
|||||||
offs_t safe_pc() const;
|
offs_t safe_pc() const;
|
||||||
offs_t safe_pcbase() const;
|
offs_t safe_pcbase() const;
|
||||||
|
|
||||||
void set_default_bios(u8 bios) { m_default_bios = bios; }
|
|
||||||
void set_system_bios(u8 bios) { m_system_bios = bios; }
|
void set_system_bios(u8 bios) { m_system_bios = bios; }
|
||||||
bool findit(bool pre_map, bool isvalidation) const;
|
bool findit(bool pre_map, bool isvalidation) const;
|
||||||
|
|
||||||
|
@ -265,53 +265,34 @@ 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)
|
void rom_load_manager::determine_bios_rom(device_t &device, const char *specbios)
|
||||||
{
|
{
|
||||||
device.set_system_bios(0);
|
// default is applied by the device at config complete time
|
||||||
|
if (specbios && *specbios && core_stricmp(specbios, "default"))
|
||||||
/* first determine the default BIOS name */
|
|
||||||
char const *defaultname(nullptr);
|
|
||||||
for (const rom_entry &rom : device.rom_region_vector())
|
|
||||||
{
|
{
|
||||||
if (ROMENTRY_ISDEFAULT_BIOS(&rom))
|
bool found(false);
|
||||||
|
for (const rom_entry &rom : device.rom_region_vector())
|
||||||
{
|
{
|
||||||
defaultname = ROM_GETNAME(&rom);
|
if (ROMENTRY_ISSYSTEM_BIOS(&rom))
|
||||||
break;
|
{
|
||||||
}
|
char const *const biosname = ROM_GETNAME(&rom);
|
||||||
}
|
int const bios_flags = ROM_GETBIOSFLAGS(&rom);
|
||||||
|
char bios_number[20];
|
||||||
|
|
||||||
/* look for a BIOS with a matching name */
|
// Allow '-bios n' to still be used
|
||||||
int bios_count = 0, default_no = 1;
|
sprintf(bios_number, "%d", bios_flags - 1);
|
||||||
for (const rom_entry &rom : device.rom_region_vector())
|
if (!core_stricmp(bios_number, specbios) || !core_stricmp(biosname, specbios))
|
||||||
{
|
{
|
||||||
if (ROMENTRY_ISSYSTEM_BIOS(&rom))
|
found = true;
|
||||||
{
|
device.set_system_bios(bios_flags);
|
||||||
char const *const biosname = ROM_GETNAME(&rom);
|
break;
|
||||||
int const bios_flags = ROM_GETBIOSFLAGS(&rom);
|
}
|
||||||
char bios_number[20];
|
}
|
||||||
|
|
||||||
/* Allow '-bios n' to still be used */
|
|
||||||
sprintf(bios_number, "%d", bios_flags - 1);
|
|
||||||
if (!core_stricmp(bios_number, specbios) || !core_stricmp(biosname, specbios))
|
|
||||||
device.set_system_bios(bios_flags);
|
|
||||||
if (defaultname && !core_stricmp(biosname, defaultname))
|
|
||||||
default_no = bios_flags;
|
|
||||||
bios_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if none found, use the default */
|
|
||||||
if (device.system_bios() == 0 && bios_count > 0)
|
|
||||||
{
|
|
||||||
/* if we got neither an empty string nor 'default' then warn the user */
|
|
||||||
if (specbios[0] && !core_stricmp(specbios, "default"))
|
|
||||||
{
|
|
||||||
m_errorstring.append(string_format("%s: invalid bios, reverting to default\n", specbios));
|
|
||||||
m_warnings++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set to default */
|
// if we got neither an empty string nor 'default' then warn the user
|
||||||
device.set_system_bios(default_no);
|
m_errorstring.append(util::string_format("%s: invalid BIOS \"%s\", reverting to default\n", device.tag(), specbios));
|
||||||
}
|
}
|
||||||
device.set_default_bios(default_no);
|
|
||||||
|
// log final result
|
||||||
LOG("For \"%s\" using System BIOS: %d\n", device.tag(), device.system_bios());
|
LOG("For \"%s\" using System BIOS: %d\n", device.tag(), device.system_bios());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1490,7 +1471,7 @@ void rom_load_manager::process_region_list()
|
|||||||
rom_load_manager::rom_load_manager(running_machine &machine)
|
rom_load_manager::rom_load_manager(running_machine &machine)
|
||||||
: m_machine(machine)
|
: m_machine(machine)
|
||||||
{
|
{
|
||||||
/* figure out which BIOS we are using */
|
// figure out which BIOS we are using
|
||||||
std::map<std::string, std::string> card_bios;
|
std::map<std::string, std::string> card_bios;
|
||||||
for (device_t &device : device_iterator(machine.config().root_device()))
|
for (device_t &device : device_iterator(machine.config().root_device()))
|
||||||
{
|
{
|
||||||
@ -1523,16 +1504,16 @@ rom_load_manager::rom_load_manager(running_machine &machine)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count the total number of ROMs */
|
// count the total number of ROMs
|
||||||
count_roms();
|
count_roms();
|
||||||
|
|
||||||
/* reset the disk list */
|
// reset the disk list
|
||||||
m_chd_list.clear();
|
m_chd_list.clear();
|
||||||
|
|
||||||
/* process the ROM entries we were passed */
|
// process the ROM entries we were passed
|
||||||
process_region_list();
|
process_region_list();
|
||||||
|
|
||||||
/* display the results and exit */
|
// display the results and exit
|
||||||
display_rom_load_results(false);
|
display_rom_load_results(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1620,6 +1620,8 @@ void validity_checker::validate_roms(device_t &root)
|
|||||||
// check that default BIOS exists
|
// check that default BIOS exists
|
||||||
if (defbios && (bios_names.find(defbios) == bios_names.end()))
|
if (defbios && (bios_names.find(defbios) == bios_names.end()))
|
||||||
osd_printf_error("Default BIOS '%s' not found\n", defbios);
|
osd_printf_error("Default BIOS '%s' not found\n", defbios);
|
||||||
|
if (!device.get_default_bios_tag().empty() && (bios_names.find(device.get_default_bios_tag()) == bios_names.end()))
|
||||||
|
osd_printf_error("Configured BIOS '%s' not found\n", device.get_default_bios_tag().c_str());
|
||||||
|
|
||||||
// final check for empty regions
|
// final check for empty regions
|
||||||
if (items_since_region == 0)
|
if (items_since_region == 0)
|
||||||
|
@ -1660,7 +1660,7 @@ MACHINE_CONFIG_START(model1_state::wingwar)
|
|||||||
MCFG_CPU_PROGRAM_MAP(model1_comm_mem)
|
MCFG_CPU_PROGRAM_MAP(model1_comm_mem)
|
||||||
|
|
||||||
MCFG_M1COMM_ADD(M1COMM_TAG)
|
MCFG_M1COMM_ADD(M1COMM_TAG)
|
||||||
// use EPR-15112
|
MCFG_DEVICE_BIOS("epr15112");
|
||||||
MACHINE_CONFIG_END
|
MACHINE_CONFIG_END
|
||||||
|
|
||||||
MACHINE_CONFIG_START(model1_state::swa)
|
MACHINE_CONFIG_START(model1_state::swa)
|
||||||
@ -1738,14 +1738,14 @@ MACHINE_CONFIG_START(model1_state::vr)
|
|||||||
model1_vr(config);
|
model1_vr(config);
|
||||||
|
|
||||||
MCFG_M1COMM_ADD(M1COMM_TAG)
|
MCFG_M1COMM_ADD(M1COMM_TAG)
|
||||||
// use EPR-15112
|
MCFG_DEVICE_BIOS("epr15112");
|
||||||
MACHINE_CONFIG_END
|
MACHINE_CONFIG_END
|
||||||
|
|
||||||
MACHINE_CONFIG_START(model1_state::vformula)
|
MACHINE_CONFIG_START(model1_state::vformula)
|
||||||
model1_vr(config);
|
model1_vr(config);
|
||||||
|
|
||||||
MCFG_M1COMM_ADD(M1COMM_TAG)
|
MCFG_M1COMM_ADD(M1COMM_TAG)
|
||||||
// use EPR-15624
|
MCFG_DEVICE_BIOS("epr15624");
|
||||||
MACHINE_CONFIG_END
|
MACHINE_CONFIG_END
|
||||||
|
|
||||||
DRIVER_INIT_MEMBER(model1_state,wingwar360)
|
DRIVER_INIT_MEMBER(model1_state,wingwar360)
|
||||||
|
@ -83,14 +83,14 @@ void m1comm_device::m1comm_io(address_map &map)
|
|||||||
|
|
||||||
ROM_START( m1comm )
|
ROM_START( m1comm )
|
||||||
ROM_REGION( 0x20000, Z80_TAG, ROMREGION_ERASEFF )
|
ROM_REGION( 0x20000, Z80_TAG, ROMREGION_ERASEFF )
|
||||||
ROM_DEFAULT_BIOS("epr-15112")
|
ROM_DEFAULT_BIOS("epr15112")
|
||||||
|
|
||||||
// found on Virtua Racing and WingWar
|
// found on Virtua Racing and WingWar
|
||||||
ROM_SYSTEM_BIOS( 0, "epr-15112", "EPR-15112" )
|
ROM_SYSTEM_BIOS( 0, "epr15112", "EPR-15112" )
|
||||||
ROMX_LOAD( "epr-15112.17", 0x0000, 0x20000, CRC(4950e771) SHA1(99014124e0324dd114cb22f55159d18b597a155a), ROM_BIOS(1) )
|
ROMX_LOAD( "epr-15112.17", 0x0000, 0x20000, CRC(4950e771) SHA1(99014124e0324dd114cb22f55159d18b597a155a), ROM_BIOS(1) )
|
||||||
|
|
||||||
// found on Virtua Formula
|
// found on Virtua Formula
|
||||||
ROM_SYSTEM_BIOS( 1, "epr-15624", "EPR-15624" )
|
ROM_SYSTEM_BIOS( 1, "epr15624", "EPR-15624" )
|
||||||
ROMX_LOAD( "epr-15624.17", 0x0000, 0x20000, CRC(9b3ba315) SHA1(0cd0983cc8b2f2d6b41617d0d0a24cc6c188e62a), ROM_BIOS(2) )
|
ROMX_LOAD( "epr-15624.17", 0x0000, 0x20000, CRC(9b3ba315) SHA1(0cd0983cc8b2f2d6b41617d0d0a24cc6c188e62a), ROM_BIOS(2) )
|
||||||
ROM_END
|
ROM_END
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user