summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2012-04-30 13:39:32 +0000
committer Miodrag Milanovic <mmicko@gmail.com>2012-04-30 13:39:32 +0000
commit8dbb34e79e119eca5a9aaab306e50808b96b336e (patch)
tree131143d8f63730badaf5cbdc44f2924e3666ce58
parente8829d3ac95576571e6217edbbc8143fe30aaaa4 (diff)
Made UI for BIOS selection where applicable, and moved info about current
system and default bios to device_t class (no whatsnew)
-rw-r--r--src/emu/device.h6
-rw-r--r--src/emu/machine/generic.c4
-rw-r--r--src/emu/romload.c37
-rw-r--r--src/emu/romload.h6
-rw-r--r--src/emu/uimain.c83
-rw-r--r--src/emu/uimain.h10
6 files changed, 109 insertions, 37 deletions
diff --git a/src/emu/device.h b/src/emu/device.h
index ceb2ecbb99d..2ca4343b989 100644
--- a/src/emu/device.h
+++ b/src/emu/device.h
@@ -164,6 +164,8 @@ public:
const rom_entry *rom_region() const { return device_rom_region(); }
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; }
+ UINT8 system_bios() const { return m_system_bios; }
// interface helpers
template<class _DeviceClass> bool interface(_DeviceClass *&intf) { intf = dynamic_cast<_DeviceClass *>(this); return (intf != NULL); }
@@ -229,6 +231,8 @@ public:
// debugging
device_debug *debug() const { return m_debug; }
+ void set_default_bios(UINT8 bios) { m_default_bios = bios; }
+ void set_system_bios(UINT8 bios) { m_system_bios = bios; }
protected:
// internal helper classes (defined below)
class finder_base;
@@ -313,6 +317,8 @@ protected:
const void * m_static_config; // static device configuration
const input_device_default *m_input_defaults; // devices input ports default overrides
+ UINT8 m_system_bios; // the system BIOS we wish to load
+ UINT8 m_default_bios; // the default system BIOS
private:
// private helpers
device_t *add_subdevice(device_type type, const char *tag, UINT32 clock);
diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c
index ccfae1d817f..54e4d93dd38 100644
--- a/src/emu/machine/generic.c
+++ b/src/emu/machine/generic.c
@@ -286,8 +286,8 @@ static astring &nvram_filename(astring &result, device_t &device)
// start with either basename or basename_biosnum
result.cpy(machine.basename());
- if (rom_system_bios(machine) != 0 && rom_default_bios(machine) != rom_system_bios(machine))
- result.catprintf("_%d", rom_system_bios(machine) - 1);
+ if (device.machine().root_device().system_bios() != 0 && device.machine().root_device().default_bios() != device.machine().root_device().system_bios())
+ result.catprintf("_%d", device.machine().root_device().system_bios() - 1);
// device-based NVRAM gets its own name in a subdirectory
if (&device != &device.machine().root_device())
diff --git a/src/emu/romload.c b/src/emu/romload.c
index bd3f966b68b..e63b93e327f 100644
--- a/src/emu/romload.c
+++ b/src/emu/romload.c
@@ -63,8 +63,6 @@ struct _romload_private
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
running_machine *m_machine; /* machine object where needed */
- int system_bios; /* the system BIOS we wish to load */
- int default_bios; /* the default system BIOS */
int warnings; /* warning count during processing */
int knownbad; /* BAD_DUMP/NO_DUMP count during processing */
@@ -292,10 +290,9 @@ static void determine_bios_rom(rom_load_data *romdata)
int default_no = 1;
int bios_count = 0;
- romdata->system_bios = 0;
device_t &rootdevice = romdata->machine().config().root_device();
-
+ rootdevice.set_system_bios(0);
/* first determine the default BIOS name */
for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++)
if (ROMENTRY_ISDEFAULT_BIOS(rom))
@@ -312,14 +309,14 @@ static void determine_bios_rom(rom_load_data *romdata)
/* Allow '-bios n' to still be used */
sprintf(bios_number, "%d", bios_flags - 1);
if (mame_stricmp(bios_number, specbios) == 0 || mame_stricmp(biosname, specbios) == 0)
- romdata->system_bios = bios_flags;
+ rootdevice.set_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 (rootdevice.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)
@@ -329,10 +326,10 @@ static void determine_bios_rom(rom_load_data *romdata)
}
/* set to default */
- romdata->system_bios = default_no;
+ rootdevice.set_system_bios(default_no);
}
- romdata->default_bios = default_no;
- LOG(("Using System BIOS: %d\n", romdata->system_bios));
+ rootdevice.set_default_bios(default_no);
+ LOG(("Using System BIOS: %d\n", rootdevice.system_bios()));
}
@@ -354,7 +351,7 @@ static void count_roms(rom_load_data *romdata)
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))
- if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->system_bios)
+ if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->machine().config().root_device().system_bios())
{
romdata->romstotal++;
romdata->romstotalsize += rom_file_size(rom);
@@ -880,7 +877,7 @@ static void process_rom_entries(rom_load_data *romdata, const char *regiontag, c
/* handle files */
else if (ROMENTRY_ISFILE(romp))
{
- int irrelevantbios = (ROM_GETBIOSFLAGS(romp) != 0 && ROM_GETBIOSFLAGS(romp) != romdata->system_bios);
+ int irrelevantbios = (ROM_GETBIOSFLAGS(romp) != 0 && ROM_GETBIOSFLAGS(romp) != romdata->machine().config().root_device().system_bios());
const rom_entry *baserom = romp;
int explength = 0;
@@ -1503,21 +1500,3 @@ int rom_load_knownbad(running_machine &machine)
return machine.romload_data->knownbad;
}
-
-/*-------------------------------------------------
- rom_system_bios - return id of selected bios
--------------------------------------------------*/
-
-int rom_system_bios(running_machine &machine)
-{
- return machine.romload_data->system_bios;
-}
-
-/*-------------------------------------------------
- rom_default_bios - return id of default bios
--------------------------------------------------*/
-
-int rom_default_bios(running_machine &machine)
-{
- return machine.romload_data->default_bios;
-}
diff --git a/src/emu/romload.h b/src/emu/romload.h
index 2dfdffe214b..1c7c4d89ee0 100644
--- a/src/emu/romload.h
+++ b/src/emu/romload.h
@@ -268,12 +268,6 @@ int rom_load_warnings(running_machine &machine);
/* return the number of BAD_DUMP/NO_DUMP warnings we generated */
int rom_load_knownbad(running_machine &machine);
-/* return id of selected bios */
-int rom_system_bios(running_machine &machine);
-
-/* return id of default bios */
-int rom_default_bios(running_machine &machine);
-
/* ----- Helpers ----- */
file_error common_process_file(emu_options &options, const char *location, const char *ext, const rom_entry *romp, emu_file **image_file);
diff --git a/src/emu/uimain.c b/src/emu/uimain.c
index c4cfd4e97b5..85af3575eeb 100644
--- a/src/emu/uimain.c
+++ b/src/emu/uimain.c
@@ -114,6 +114,7 @@ void ui_menu_main::populate()
int has_configs = false;
int has_analog = false;
int has_dips = false;
+ int has_bioses = false;
astring menu_text;
/* scan the input port array to see what options we need to enable */
for (port = machine().ioport().first_port(); port != NULL; port = port->next())
@@ -126,6 +127,11 @@ void ui_menu_main::populate()
if (input_type_is_analog(field->type))
has_analog = true;
}
+ device_iterator deviter(machine().root_device());
+ for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
+ if (device->rom_region())
+ for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++)
+ if (ROMENTRY_ISSYSTEM_BIOS(rom)) { has_bioses= true; break; }
/* add input menu items */
item_append("Input (general)", NULL, 0, (void *)INPUT_GROUPS);
@@ -168,6 +174,9 @@ void ui_menu_main::populate()
item_append("Bitbanger Control", NULL, 0, (void *)MESS_MENU_BITBANGER_CONTROL);
}
+ if (has_bioses)
+ item_append("Bios Selection", NULL, 0, (void *)BIOS_SELECTION);
+
slot_interface_iterator slotiter(machine().root_device());
if (slotiter.first() != NULL)
{
@@ -307,6 +316,10 @@ void ui_menu_main::handle()
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, 0)));
break;
+ case BIOS_SELECTION:
+ ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_bios_selection(machine(), container)));
+ break;
+
default:
fatalerror("ui_menu_main::handle - unknown reference");
}
@@ -466,6 +479,76 @@ void ui_menu_slot_devices::handle()
}
}
+/*-------------------------------------------------
+ ui_menu_bios_selection - populates the main
+ bios selection menu
+-------------------------------------------------*/
+
+ui_menu_bios_selection::ui_menu_bios_selection(running_machine &machine, render_container *container) : ui_menu(machine, container)
+{
+}
+
+void ui_menu_bios_selection::populate()
+{
+ /* cycle through all devices for this system */
+ device_iterator deviter(machine().root_device());
+ for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
+ {
+ if (device->rom_region()) {
+ const char *val = "default";
+ for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++)
+ {
+ if (ROMENTRY_ISSYSTEM_BIOS(rom) && ROM_GETBIOSFLAGS(rom)==device->system_bios())
+ {
+ val = ROM_GETHASHDATA(rom);
+ }
+ }
+ item_append(strcmp(device->tag(),":")==0 ? "driver" : device->tag()+1, val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)device);
+ }
+ }
+
+ item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
+ item_append("Reset", NULL, 0, NULL);
+}
+
+ui_menu_bios_selection::~ui_menu_bios_selection()
+{
+}
+
+/*-------------------------------------------------
+ ui_menu_bios_selection - menu that
+-------------------------------------------------*/
+
+void ui_menu_bios_selection::handle()
+{
+ /* process the menu */
+ const ui_menu_event *menu_event = process(0);
+
+ if (menu_event != NULL && menu_event->itemref != NULL)
+ {
+ if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) {
+ device_t *dev = (device_t *)menu_event->itemref;
+ int cnt = 0;
+ for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++)
+ {
+ if (ROMENTRY_ISSYSTEM_BIOS(rom)) cnt ++;
+ }
+ int val = dev->system_bios() + ((menu_event->iptkey == IPT_UI_LEFT) ? -1 : +1);
+ if (val<1) val=cnt;
+ if (val>cnt) val=1;
+ dev->set_system_bios(val);
+ if (strcmp(dev->tag(),":")==0) {
+ astring error;
+ machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE, error);
+ assert(!error);
+ }
+ reset(UI_MENU_RESET_REMEMBER_REF);
+ }
+ } else if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) {
+ machine().schedule_hard_reset();
+ }
+}
+
ui_menu_network_devices::ui_menu_network_devices(running_machine &machine, render_container *container) : ui_menu(machine, container)
{
}
diff --git a/src/emu/uimain.h b/src/emu/uimain.h
index 31eb79090a8..355d6dc831a 100644
--- a/src/emu/uimain.h
+++ b/src/emu/uimain.h
@@ -47,6 +47,7 @@ private:
CHEAT,
MEMORY_CARD,
SELECT_GAME,
+ BIOS_SELECTION,
};
};
@@ -364,6 +365,15 @@ private:
void build_driver_list();
};
+class ui_menu_bios_selection : public ui_menu {
+public:
+ ui_menu_bios_selection(running_machine &machine, render_container *container);
+ virtual ~ui_menu_bios_selection();
+ virtual void populate();
+ virtual void handle();
+
+private:
+};
/* force game select menu */
void ui_menu_force_game_select(running_machine &machine, render_container *container);