Previous 15994 Revisions Next

r15072 Monday 30th April, 2012 at 13:44:16 UTC by Miodrag Milanović
Made UI for BIOS selection where applicable, and moved info about current
system and default bios to device_t class (no whatsnew)

clean build needed
[src/emu]device.h romload.c romload.h uimain.c uimain.h
[src/emu/machine]generic.c

src/emu/uimain.c
r15071r15072
114114   int has_configs = false;
115115   int has_analog = false;
116116   int has_dips = false;
117   int has_bioses = false;
117118   astring menu_text;
118119   /* scan the input port array to see what options we need to enable */
119120   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
r15071r15072
126127         if (input_type_is_analog(field->type))
127128            has_analog = true;
128129      }
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; }
129135
130136   /* add input menu items */
131137   item_append("Input (general)", NULL, 0, (void *)INPUT_GROUPS);
r15071r15072
168174         item_append("Bitbanger Control", NULL, 0, (void *)MESS_MENU_BITBANGER_CONTROL);
169175   }
170176
177   if (has_bioses)
178      item_append("Bios Selection", NULL, 0, (void *)BIOS_SELECTION);
179
171180   slot_interface_iterator slotiter(machine().root_device());
172181   if (slotiter.first() != NULL)
173182   {
r15071r15072
307316         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, 0)));
308317         break;
309318
319      case BIOS_SELECTION:
320         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_bios_selection(machine(), container)));
321         break;
322         
310323      default:
311324         fatalerror("ui_menu_main::handle - unknown reference");
312325      }
r15071r15072
466479   }
467480}
468481
482/*-------------------------------------------------
483    ui_menu_bios_selection - populates the main
484    bios selection menu
485-------------------------------------------------*/
486
487ui_menu_bios_selection::ui_menu_bios_selection(running_machine &machine, render_container *container) : ui_menu(machine, container)
488{
489}
490
491void 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
514ui_menu_bios_selection::~ui_menu_bios_selection()
515{
516}
517
518/*-------------------------------------------------
519    ui_menu_bios_selection - menu that
520-------------------------------------------------*/
521
522void 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
469552ui_menu_network_devices::ui_menu_network_devices(running_machine &machine, render_container *container) : ui_menu(machine, container)
470553{
471554}
src/emu/uimain.h
r15071r15072
4747      CHEAT,
4848      MEMORY_CARD,
4949      SELECT_GAME,
50      BIOS_SELECTION,
5051   };
5152};
5253
r15071r15072
364365   void build_driver_list();
365366};
366367
368class ui_menu_bios_selection : public ui_menu {
369public:
370   ui_menu_bios_selection(running_machine &machine, render_container *container);
371   virtual ~ui_menu_bios_selection();
372   virtual void populate();
373   virtual void handle();
374
375private:
376};
367377/* force game select menu */
368378void ui_menu_force_game_select(running_machine &machine, render_container *container);
369379
src/emu/romload.c
r15071r15072
6363   running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
6464
6565   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 */
6866
6967   int            warnings;         /* warning count during processing */
7068   int            knownbad;         /* BAD_DUMP/NO_DUMP count during processing */
r15071r15072
292290   int default_no = 1;
293291   int bios_count = 0;
294292
295   romdata->system_bios = 0;
296293
297294   device_t &rootdevice = romdata->machine().config().root_device();
298
295   rootdevice.set_system_bios(0);
299296   /* first determine the default BIOS name */
300297   for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++)
301298      if (ROMENTRY_ISDEFAULT_BIOS(rom))
r15071r15072
312309         /* Allow '-bios n' to still be used */
313310         sprintf(bios_number, "%d", bios_flags - 1);
314311         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);
316313         if (defaultname != NULL && mame_stricmp(biosname, defaultname) == 0)
317314            default_no = bios_flags;
318315         bios_count++;
319316      }
320317
321318   /* if none found, use the default */
322   if (romdata->system_bios == 0 && bios_count > 0)
319   if (rootdevice.system_bios() == 0 && bios_count > 0)
323320   {
324321      /* if we got neither an empty string nor 'default' then warn the user */
325322      if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL)
r15071r15072
329326      }
330327
331328      /* set to default */
332      romdata->system_bios = default_no;
329      rootdevice.set_system_bios(default_no);
333330   }
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()));
336333}
337334
338335
r15071r15072
354351   for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
355352      for (region = rom_first_region(*device); region != NULL; region = rom_next_region(region))
356353         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())
358355            {
359356               romdata->romstotal++;
360357               romdata->romstotalsize += rom_file_size(rom);
r15071r15072
880877      /* handle files */
881878      else if (ROMENTRY_ISFILE(romp))
882879      {
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());
884881         const rom_entry *baserom = romp;
885882         int explength = 0;
886883
r15071r15072
15031500   return machine.romload_data->knownbad;
15041501}
15051502
1506
1507/*-------------------------------------------------
1508    rom_system_bios - return id of selected bios
1509-------------------------------------------------*/
1510
1511int 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
1520int rom_default_bios(running_machine &machine)
1521{
1522   return machine.romload_data->default_bios;
1523}
src/emu/romload.h
r15071r15072
268268/* return the number of BAD_DUMP/NO_DUMP warnings we generated */
269269int rom_load_knownbad(running_machine &machine);
270270
271/* return id of selected bios */
272int rom_system_bios(running_machine &machine);
273
274/* return id of default bios */
275int rom_default_bios(running_machine &machine);
276
277271/* ----- Helpers ----- */
278272
279273file_error common_process_file(emu_options &options, const char *location, const char *ext, const rom_entry *romp, emu_file **image_file);
src/emu/device.h
r15071r15072
164164   const rom_entry *rom_region() const { return device_rom_region(); }
165165   machine_config_constructor machine_config_additions() const { return device_mconfig_additions(); }
166166   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; }
167169
168170   // interface helpers
169171   template<class _DeviceClass> bool interface(_DeviceClass *&intf) { intf = dynamic_cast<_DeviceClass *>(this); return (intf != NULL); }
r15071r15072
229231   // debugging
230232   device_debug *debug() const { return m_debug; }
231233
234   void set_default_bios(UINT8 bios) { m_default_bios = bios; }
235   void set_system_bios(UINT8 bios) { m_system_bios = bios; }
232236protected:
233237   // internal helper classes (defined below)
234238   class finder_base;
r15071r15072
313317   const void *         m_static_config;      // static device configuration
314318   const input_device_default *m_input_defaults;   // devices input ports default overrides
315319
320   UINT8               m_system_bios;         // the system BIOS we wish to load
321   UINT8               m_default_bios;         // the default system BIOS
316322private:
317323   // private helpers
318324   device_t *add_subdevice(device_type type, const char *tag, UINT32 clock);
src/emu/machine/generic.c
r15071r15072
286286
287287   // start with either basename or basename_biosnum
288288   result.cpy(machine.basename());
289   if (rom_system_bios(machine) != 0 && rom_default_bios(machine) != rom_system_bios(machine))
290      result.catprintf("_%d", rom_system_bios(machine) - 1);
289   if (device.machine().root_device().system_bios() != 0 && device.machine().root_device().default_bios() != device.machine().root_device().system_bios())
290      result.catprintf("_%d", device.machine().root_device().system_bios() - 1);
291291
292292   // device-based NVRAM gets its own name in a subdirectory
293293   if (&device != &device.machine().root_device())

Previous 15994 Revisions Next


© 1998-2018 The MESS Team