Previous 199869 Revisions Next

r17654 Wednesday 5th September, 2012 at 10:30:30 UTC by Miodrag Milanović
Made core able to use bios selection per slot device [Miodrag Milanovic]

Sample of usage :
 mess kc85_4 -exp d004gide,bios=v31

Will need to cleanup handling of sub options to make it more robust and able to validate
[src/emu]dislot.c emuopts.c emuopts.h mconfig.c romload.c uimain.c

trunk/src/emu/emuopts.c
r17653r17654
565565
566566   return result;
567567}
568
569
570const char *emu_options::main_value(astring &buffer, const char *name) const
571{   
572   buffer = value(name);
573   int pos = buffer.chr(0,',');
574   if (pos!=-1) {
575      buffer = buffer.substr(0,pos);
576   }
577   return buffer.cstr();
578}
579
580const char *emu_options::sub_value(astring &buffer, const char *name, const char *subname) const
581{   
582   astring tmp = ",";
583   tmp.cat(subname);
584   tmp.cat("=");
585   buffer = value(name);
586   int pos = buffer.find(0,tmp);
587   if (pos!=-1) {
588      int endpos = buffer.chr(pos+1,',');
589      if(endpos==-1) endpos = buffer.len();
590      buffer = buffer.substr(pos+tmp.len(),endpos-pos-tmp.len());
591   } else {
592      buffer ="";
593   }
594   return buffer.cstr();
595}
trunk/src/emu/emuopts.h
r17653r17654
357357   const char *device_option(device_image_interface &image);
358358
359359   void remove_device_options();
360
361   const char *main_value(astring &buffer, const char *option) const;
362   const char *sub_value(astring &buffer, const char *name, const char *subname) const;
360363private:
361364   // device-specific option handling
362365   void add_device_options(bool isfirst);
trunk/src/emu/uimain.c
r17653r17654
367367-------------------------------------------------*/
368368int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot)
369369{
370   const char *current = machine().options().value(slot->device().tag()+1);
370   astring temp;
371   const char *current = machine().options().main_value(temp,slot->device().tag()+1);
371372   const slot_interface* intf = slot->get_slot_interfaces();
372373   int val = -1;
373374   for (int i = 0; intf[i].name != NULL; i++) {
r17653r17654
421422-------------------------------------------------*/
422423const char *ui_menu_slot_devices::get_slot_device(device_slot_interface *slot)
423424{
424   return machine().options().value(slot->device().tag()+1);
425   astring temp;
426   return machine().options().main_value(temp,slot->device().tag()+1);
425427}
426428
427429
r17653r17654
551553            astring error;
552554            machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE, error);
553555            assert(!error);
556         } else {
557            astring error;
558            astring value;
559            astring temp;
560            value.printf("%s,bios=%d",machine().options().main_value(temp,dev->owner()->tag()+1),val-1);
561            machine().options().set_value(dev->owner()->tag()+1, value.cstr(), OPTION_PRIORITY_CMDLINE, error);
562            assert(!error);
554563         }
555564         reset(UI_MENU_RESET_REMEMBER_REF);
556565      }
trunk/src/emu/romload.c
r17653r17654
283283    from SystemBios structure and OPTION_BIOS
284284-------------------------------------------------*/
285285
286static void determine_bios_rom(rom_load_data *romdata)
286static void determine_bios_rom(rom_load_data *romdata, device_t *device,const char *specbios)
287287{
288   const char *specbios = romdata->machine().options().bios();
289288   const char *defaultname = NULL;
290289   const rom_entry *rom;
291290   int default_no = 1;
292291   int bios_count = 0;
293292
294293
295   device_t &rootdevice = romdata->machine().config().root_device();
296   rootdevice.set_system_bios(0);
294   device->set_system_bios(0);
297295   /* first determine the default BIOS name */
298   for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++)
296   for (rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++)
299297      if (ROMENTRY_ISDEFAULT_BIOS(rom))
300298         defaultname = ROM_GETNAME(rom);
301299
302300   /* look for a BIOS with a matching name */
303   for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++)
301   for (rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++)
304302      if (ROMENTRY_ISSYSTEM_BIOS(rom))
305303      {
306304         const char *biosname = ROM_GETNAME(rom);
r17653r17654
310308         /* Allow '-bios n' to still be used */
311309         sprintf(bios_number, "%d", bios_flags - 1);
312310         if (mame_stricmp(bios_number, specbios) == 0 || mame_stricmp(biosname, specbios) == 0)
313            rootdevice.set_system_bios(bios_flags);
311            device->set_system_bios(bios_flags);
314312         if (defaultname != NULL && mame_stricmp(biosname, defaultname) == 0)
315313            default_no = bios_flags;
316314         bios_count++;
317315      }
318316
319317   /* if none found, use the default */
320   if (rootdevice.system_bios() == 0 && bios_count > 0)
318   if (device->system_bios() == 0 && bios_count > 0)
321319   {
322320      /* if we got neither an empty string nor 'default' then warn the user */
323321      if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL)
r17653r17654
327325      }
328326
329327      /* set to default */
330      rootdevice.set_system_bios(default_no);
328      device->set_system_bios(default_no);
331329   }
332   rootdevice.set_default_bios(default_no);
333   LOG(("Using System BIOS: %d\n", rootdevice.system_bios()));
330   device->set_default_bios(default_no);
331   LOG(("For \"%s\" using System BIOS: %d\n", device->tag(), device->system_bios()));
334332}
335333
336334
r17653r17654
352350   for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
353351      for (region = rom_first_region(*device); region != NULL; region = rom_next_region(region))
354352         for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
355            if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->machine().config().root_device().system_bios())
353            if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == device->system_bios())
356354            {
357355               romdata->romstotal++;
358356               romdata->romstotalsize += rom_file_size(rom);
r17653r17654
848846    for a region
849847-------------------------------------------------*/
850848
851static void process_rom_entries(rom_load_data *romdata, const char *regiontag, const rom_entry *parent_region, const rom_entry *romp)
849static void process_rom_entries(rom_load_data *romdata, const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, device_t *device)
852850{
853851   UINT32 lastflags = 0;
854852
r17653r17654
878876      /* handle files */
879877      else if (ROMENTRY_ISFILE(romp))
880878      {
881         int irrelevantbios = (ROM_GETBIOSFLAGS(romp) != 0 && ROM_GETBIOSFLAGS(romp) != romdata->machine().config().root_device().system_bios());
879         int irrelevantbios = (ROM_GETBIOSFLAGS(romp) != 0 && ROM_GETBIOSFLAGS(romp) != device->system_bios());
882880         const rom_entry *baserom = romp;
883881         int explength = 0;
884882
r17653r17654
13571355
13581356      /* now process the entries in the region */
13591357      if (ROMREGION_ISROMDATA(region))
1360         process_rom_entries(romdata, locationtag, region, region + 1);
1358         process_rom_entries(romdata, locationtag, region, region + 1, device);
13611359      else if (ROMREGION_ISDISKDATA(region))
13621360         process_disk_entries(romdata, core_strdup(regiontag.cstr()), region, region + 1, locationtag);
13631361   }
r17653r17654
14211419#endif
14221420
14231421            /* now process the entries in the region */
1424            process_rom_entries(romdata, device->shortname(), region, region + 1);
1422            process_rom_entries(romdata, device->shortname(), region, region + 1, device);
14251423         }
14261424         else if (ROMREGION_ISDISKDATA(region))
14271425            process_disk_entries(romdata, regiontag, region, region + 1, NULL);
r17653r17654
14561454   romdata->m_machine = &machine;
14571455
14581456   /* figure out which BIOS we are using */
1459   determine_bios_rom(romdata);
1457   device_iterator deviter(romdata->machine().config().root_device());
1458   for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) {   
1459      if (device->rom_region()) {
1460         const char *specbios;
1461         astring temp;
1462         if (strcmp(device->tag(),":")==0) {
1463            specbios = romdata->machine().options().bios();
1464         } else {
1465            specbios = romdata->machine().options().sub_value(temp,device->owner()->tag()+1,"bios");           
1466         }
1467         determine_bios_rom(romdata, device, specbios);
1468      }
1469   }
14601470
14611471   /* count the total number of ROMs */
14621472   count_roms(romdata);
trunk/src/emu/dislot.c
r17653r17654
3838{
3939   const char *subtag;
4040   device_t *dev = NULL;
41   astring temp;
4142   if (!device().mconfig().options().exists(device().tag()+1)) {
4243      subtag = m_default_card;
4344   } else {
44      subtag = device().mconfig().options().value(device().tag()+1);
45      subtag = device().mconfig().options().main_value(temp,device().tag()+1);
4546   }
4647   if (subtag && *subtag != 0) {
4748      device_slot_card_interface *intf = NULL;
trunk/src/emu/mconfig.c
r17653r17654
7676      if (intf != NULL)
7777      {
7878         device_t &owner = slot->device();
79         const char *selval = options.value(owner.tag()+1);
79         astring temp;
80         const char *selval = options.main_value(temp, owner.tag()+1);
8081         bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT);
8182         if (!is_selected_driver || !options.exists(owner.tag()+1))
8283            selval = slot->get_default_card();

Previous 199869 Revisions Next


© 1997-2024 The MAME Team