src/emu/uimain.c
| r15071 | r15072 | |
| 114 | 114 | int has_configs = false; |
| 115 | 115 | int has_analog = false; |
| 116 | 116 | int has_dips = false; |
| 117 | int has_bioses = false; |
| 117 | 118 | astring menu_text; |
| 118 | 119 | /* scan the input port array to see what options we need to enable */ |
| 119 | 120 | for (port = machine().ioport().first_port(); port != NULL; port = port->next()) |
| r15071 | r15072 | |
| 126 | 127 | if (input_type_is_analog(field->type)) |
| 127 | 128 | has_analog = true; |
| 128 | 129 | } |
| 130 | device_iterator deviter(machine().root_device()); |
| 131 | for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) |
| 132 | if (device->rom_region()) |
| 133 | for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) |
| 134 | if (ROMENTRY_ISSYSTEM_BIOS(rom)) { has_bioses= true; break; } |
| 129 | 135 | |
| 130 | 136 | /* add input menu items */ |
| 131 | 137 | item_append("Input (general)", NULL, 0, (void *)INPUT_GROUPS); |
| r15071 | r15072 | |
| 168 | 174 | item_append("Bitbanger Control", NULL, 0, (void *)MESS_MENU_BITBANGER_CONTROL); |
| 169 | 175 | } |
| 170 | 176 | |
| 177 | if (has_bioses) |
| 178 | item_append("Bios Selection", NULL, 0, (void *)BIOS_SELECTION); |
| 179 | |
| 171 | 180 | slot_interface_iterator slotiter(machine().root_device()); |
| 172 | 181 | if (slotiter.first() != NULL) |
| 173 | 182 | { |
| r15071 | r15072 | |
| 307 | 316 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, 0))); |
| 308 | 317 | break; |
| 309 | 318 | |
| 319 | case BIOS_SELECTION: |
| 320 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_bios_selection(machine(), container))); |
| 321 | break; |
| 322 | |
| 310 | 323 | default: |
| 311 | 324 | fatalerror("ui_menu_main::handle - unknown reference"); |
| 312 | 325 | } |
| r15071 | r15072 | |
| 466 | 479 | } |
| 467 | 480 | } |
| 468 | 481 | |
| 482 | /*------------------------------------------------- |
| 483 | ui_menu_bios_selection - populates the main |
| 484 | bios selection menu |
| 485 | -------------------------------------------------*/ |
| 486 | |
| 487 | ui_menu_bios_selection::ui_menu_bios_selection(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 488 | { |
| 489 | } |
| 490 | |
| 491 | void ui_menu_bios_selection::populate() |
| 492 | { |
| 493 | /* cycle through all devices for this system */ |
| 494 | device_iterator deviter(machine().root_device()); |
| 495 | for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) |
| 496 | { |
| 497 | if (device->rom_region()) { |
| 498 | const char *val = "default"; |
| 499 | for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) |
| 500 | { |
| 501 | if (ROMENTRY_ISSYSTEM_BIOS(rom) && ROM_GETBIOSFLAGS(rom)==device->system_bios()) |
| 502 | { |
| 503 | val = ROM_GETHASHDATA(rom); |
| 504 | } |
| 505 | } |
| 506 | item_append(strcmp(device->tag(),":")==0 ? "driver" : device->tag()+1, val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)device); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 511 | item_append("Reset", NULL, 0, NULL); |
| 512 | } |
| 513 | |
| 514 | ui_menu_bios_selection::~ui_menu_bios_selection() |
| 515 | { |
| 516 | } |
| 517 | |
| 518 | /*------------------------------------------------- |
| 519 | ui_menu_bios_selection - menu that |
| 520 | -------------------------------------------------*/ |
| 521 | |
| 522 | void ui_menu_bios_selection::handle() |
| 523 | { |
| 524 | /* process the menu */ |
| 525 | const ui_menu_event *menu_event = process(0); |
| 526 | |
| 527 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 528 | { |
| 529 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { |
| 530 | device_t *dev = (device_t *)menu_event->itemref; |
| 531 | int cnt = 0; |
| 532 | for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++) |
| 533 | { |
| 534 | if (ROMENTRY_ISSYSTEM_BIOS(rom)) cnt ++; |
| 535 | } |
| 536 | int val = dev->system_bios() + ((menu_event->iptkey == IPT_UI_LEFT) ? -1 : +1); |
| 537 | if (val<1) val=cnt; |
| 538 | if (val>cnt) val=1; |
| 539 | dev->set_system_bios(val); |
| 540 | if (strcmp(dev->tag(),":")==0) { |
| 541 | astring error; |
| 542 | machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE, error); |
| 543 | assert(!error); |
| 544 | } |
| 545 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 546 | } |
| 547 | } else if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) { |
| 548 | machine().schedule_hard_reset(); |
| 549 | } |
| 550 | } |
| 551 | |
| 469 | 552 | ui_menu_network_devices::ui_menu_network_devices(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 470 | 553 | { |
| 471 | 554 | } |
src/emu/romload.c
| r15071 | r15072 | |
| 63 | 63 | running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } |
| 64 | 64 | |
| 65 | 65 | running_machine *m_machine; /* machine object where needed */ |
| 66 | | int system_bios; /* the system BIOS we wish to load */ |
| 67 | | int default_bios; /* the default system BIOS */ |
| 68 | 66 | |
| 69 | 67 | int warnings; /* warning count during processing */ |
| 70 | 68 | int knownbad; /* BAD_DUMP/NO_DUMP count during processing */ |
| r15071 | r15072 | |
| 292 | 290 | int default_no = 1; |
| 293 | 291 | int bios_count = 0; |
| 294 | 292 | |
| 295 | | romdata->system_bios = 0; |
| 296 | 293 | |
| 297 | 294 | device_t &rootdevice = romdata->machine().config().root_device(); |
| 298 | | |
| 295 | rootdevice.set_system_bios(0); |
| 299 | 296 | /* first determine the default BIOS name */ |
| 300 | 297 | for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++) |
| 301 | 298 | if (ROMENTRY_ISDEFAULT_BIOS(rom)) |
| r15071 | r15072 | |
| 312 | 309 | /* Allow '-bios n' to still be used */ |
| 313 | 310 | sprintf(bios_number, "%d", bios_flags - 1); |
| 314 | 311 | if (mame_stricmp(bios_number, specbios) == 0 || mame_stricmp(biosname, specbios) == 0) |
| 315 | | romdata->system_bios = bios_flags; |
| 312 | rootdevice.set_system_bios(bios_flags); |
| 316 | 313 | if (defaultname != NULL && mame_stricmp(biosname, defaultname) == 0) |
| 317 | 314 | default_no = bios_flags; |
| 318 | 315 | bios_count++; |
| 319 | 316 | } |
| 320 | 317 | |
| 321 | 318 | /* if none found, use the default */ |
| 322 | | if (romdata->system_bios == 0 && bios_count > 0) |
| 319 | if (rootdevice.system_bios() == 0 && bios_count > 0) |
| 323 | 320 | { |
| 324 | 321 | /* if we got neither an empty string nor 'default' then warn the user */ |
| 325 | 322 | if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL) |
| r15071 | r15072 | |
| 329 | 326 | } |
| 330 | 327 | |
| 331 | 328 | /* set to default */ |
| 332 | | romdata->system_bios = default_no; |
| 329 | rootdevice.set_system_bios(default_no); |
| 333 | 330 | } |
| 334 | | romdata->default_bios = default_no; |
| 335 | | LOG(("Using System BIOS: %d\n", romdata->system_bios)); |
| 331 | rootdevice.set_default_bios(default_no); |
| 332 | LOG(("Using System BIOS: %d\n", rootdevice.system_bios())); |
| 336 | 333 | } |
| 337 | 334 | |
| 338 | 335 | |
| r15071 | r15072 | |
| 354 | 351 | for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) |
| 355 | 352 | for (region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) |
| 356 | 353 | for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) |
| 357 | | if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->system_bios) |
| 354 | if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->machine().config().root_device().system_bios()) |
| 358 | 355 | { |
| 359 | 356 | romdata->romstotal++; |
| 360 | 357 | romdata->romstotalsize += rom_file_size(rom); |
| r15071 | r15072 | |
| 880 | 877 | /* handle files */ |
| 881 | 878 | else if (ROMENTRY_ISFILE(romp)) |
| 882 | 879 | { |
| 883 | | int irrelevantbios = (ROM_GETBIOSFLAGS(romp) != 0 && ROM_GETBIOSFLAGS(romp) != romdata->system_bios); |
| 880 | int irrelevantbios = (ROM_GETBIOSFLAGS(romp) != 0 && ROM_GETBIOSFLAGS(romp) != romdata->machine().config().root_device().system_bios()); |
| 884 | 881 | const rom_entry *baserom = romp; |
| 885 | 882 | int explength = 0; |
| 886 | 883 | |
| r15071 | r15072 | |
| 1503 | 1500 | return machine.romload_data->knownbad; |
| 1504 | 1501 | } |
| 1505 | 1502 | |
| 1506 | | |
| 1507 | | /*------------------------------------------------- |
| 1508 | | rom_system_bios - return id of selected bios |
| 1509 | | -------------------------------------------------*/ |
| 1510 | | |
| 1511 | | int rom_system_bios(running_machine &machine) |
| 1512 | | { |
| 1513 | | return machine.romload_data->system_bios; |
| 1514 | | } |
| 1515 | | |
| 1516 | | /*------------------------------------------------- |
| 1517 | | rom_default_bios - return id of default bios |
| 1518 | | -------------------------------------------------*/ |
| 1519 | | |
| 1520 | | int rom_default_bios(running_machine &machine) |
| 1521 | | { |
| 1522 | | return machine.romload_data->default_bios; |
| 1523 | | } |
src/emu/device.h
| r15071 | r15072 | |
| 164 | 164 | const rom_entry *rom_region() const { return device_rom_region(); } |
| 165 | 165 | machine_config_constructor machine_config_additions() const { return device_mconfig_additions(); } |
| 166 | 166 | ioport_constructor input_ports() const { return device_input_ports(); } |
| 167 | UINT8 default_bios() const { return m_default_bios; } |
| 168 | UINT8 system_bios() const { return m_system_bios; } |
| 167 | 169 | |
| 168 | 170 | // interface helpers |
| 169 | 171 | template<class _DeviceClass> bool interface(_DeviceClass *&intf) { intf = dynamic_cast<_DeviceClass *>(this); return (intf != NULL); } |
| r15071 | r15072 | |
| 229 | 231 | // debugging |
| 230 | 232 | device_debug *debug() const { return m_debug; } |
| 231 | 233 | |
| 234 | void set_default_bios(UINT8 bios) { m_default_bios = bios; } |
| 235 | void set_system_bios(UINT8 bios) { m_system_bios = bios; } |
| 232 | 236 | protected: |
| 233 | 237 | // internal helper classes (defined below) |
| 234 | 238 | class finder_base; |
| r15071 | r15072 | |
| 313 | 317 | const void * m_static_config; // static device configuration |
| 314 | 318 | const input_device_default *m_input_defaults; // devices input ports default overrides |
| 315 | 319 | |
| 320 | UINT8 m_system_bios; // the system BIOS we wish to load |
| 321 | UINT8 m_default_bios; // the default system BIOS |
| 316 | 322 | private: |
| 317 | 323 | // private helpers |
| 318 | 324 | device_t *add_subdevice(device_type type, const char *tag, UINT32 clock); |