Previous 15994 Revisions Next

r9024 Friday 3rd September, 2010 at 12:30:39 UTC by Miodrag Milanović
Sync with MAME and MAMEUI updates in order to make this all work
[src/emu]audit.c clifront.c dimemory.c emuopts.c info.c machine.c machine.h mame.c mconfig.c mconfig.h romload.c romload.h validity.c validity.h
[src/mess]mess.c mess.h
[src/mess/devices]cartslot.c
[src/mess/osd/winui]messui.c msuiutil.c propertiesms.c swconfig.c
[src/osd/winui]mui_opts.c mui_util.c properties.c treeview.c winui.c

src/osd/winui/mui_opts.c
r9023r9024
27392739
27402740      astring *basename;
27412741      astring *srcname;
2742      machine_config *config = global_alloc(machine_config(driver->machine_config));
2742      machine_config config(*driver);
27432743
27442744      /* parse "vector.ini" for vector games */
2745      if (isDriverVector(config))
2745      if (isDriverVector(&config))
27462746      {
27472747         ui_parse_ini_file(opts, "vector");
27482748      }
r9023r9024
27682768      {
27692769         return opts;
27702770      }
2771      global_free(config);
27722771
27732772
27742773      /* then parse "<sourcefile>.ini" */
src/osd/winui/mui_util.c
r9023r9024
361361         const game_driver *gamedrv = drivers[ndriver];
362362         struct DriversInfo *gameinfo = &drivers_info[ndriver];
363363         const rom_entry *region, *rom;
364         machine_config *config;
364         machine_config config(*gamedrv);
365365         const rom_source *source;
366366         int num_speakers;
367367
368         /* Allocate machine config */
369         config = global_alloc(machine_config(gamedrv->machine_config));
370
371368         gameinfo->isClone = (GetParentRomSetIndex(gamedrv) != -1);
372369         gameinfo->isBroken = ((gamedrv->flags & GAME_NOT_WORKING) != 0);
373370         gameinfo->supportsSaveState = ((gamedrv->flags & GAME_SUPPORTS_SAVE) != 0);
374371         gameinfo->isHarddisk = FALSE;
375372         gameinfo->isVertical = (gamedrv->flags & ORIENTATION_SWAP_XY) ? TRUE : FALSE;
376         for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source))
373         for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
377374         {
378            for (region = rom_first_region(gamedrv, source); region; region = rom_next_region(region))
375            for (region = rom_first_region(*source); region; region = rom_next_region(region))
379376            {
380377               if (ROMREGION_ISDISKDATA(region))
381378                  gameinfo->isHarddisk = TRUE;
r9023r9024
394391            }
395392         }
396393
397         num_speakers = numberOfSpeakers(config);
394         num_speakers = numberOfSpeakers(&config);
398395
399396         gameinfo->isStereo = (num_speakers > 1);
400         gameinfo->screenCount = numberOfScreens(config);
401         gameinfo->isVector = isDriverVector(config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0);
397         gameinfo->screenCount = numberOfScreens(&config);
398         gameinfo->isVector = isDriverVector(&config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0);
402399         gameinfo->usesRoms = FALSE;
403         for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source))
400         for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
404401         {
405            for (region = rom_first_region(gamedrv, source); region; region = rom_next_region(region))
402            for (region = rom_first_region(*source); region; region = rom_next_region(region))
406403            {
407404               for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
408405               {
r9023r9024
416413         {
417414            const device_config_sound_interface *sound = NULL;
418415            const char * const * samplenames = NULL;
419            for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) {
416            for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound)) {
420417               if (sound->devconfig().type() == SAMPLES)
421418               {
422419                  const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config();
r9023r9024
430427               }           
431428            }
432429         }
433         /* Free the structure */
434         global_free(config);
435430
436431         gameinfo->usesTrackball = FALSE;
437432         gameinfo->usesLightGun = FALSE;
src/osd/winui/treeview.c
r9023r9024
924924   int i, j, device_folder_count = 0;
925925   LPTREEFOLDER device_folders[512];
926926   LPTREEFOLDER folder;
927   machine_config *config = NULL;
928   machine_config_constructor last_tokens = NULL;
929927   const device_config_execute_interface *device;
930928   int nFolder = numFolders;
931929
932930   for (i = 0; drivers[i] != NULL; i++)
933931   {
934      // instantiate this device config (if it is different than the previous)
935      if (last_tokens != drivers[i]->machine_config)
936      {
937         if (config != NULL)
938            global_free(config);
939         config = global_alloc(machine_config(drivers[i]->machine_config));
940         last_tokens = drivers[i]->machine_config;
941      }
932      machine_config config(*drivers[i]);
942933
943934      // enumerate through all devices
944      for (bool gotone = config->m_devicelist.first(device); gotone; gotone = device->next(device))
935      for (bool gotone = config.m_devicelist.first(device); gotone; gotone = device->next(device))
945936      {
946937     
947938         // get the name
r9023r9024
986977      }
987978   }
988979
989   // free the config that we're still holding on to
990   if (config != NULL)
991      global_free(config);   
992980}
993981
994982void CreateSoundFolders(int parent_index)
r9023r9024
996984   int i, j, device_folder_count = 0;
997985   LPTREEFOLDER device_folders[512];
998986   LPTREEFOLDER folder;
999   machine_config *config = NULL;
1000   machine_config_constructor last_tokens = NULL;
1001987   const device_config_sound_interface *device;
1002988   int nFolder = numFolders;
1003989
1004990   for (i = 0; drivers[i] != NULL; i++)
1005991   {
1006      // instantiate this device config (if it is different than the previous)
1007      if (last_tokens != drivers[i]->machine_config)
1008      {
1009         if (config != NULL)
1010            global_free(config);
1011         config = global_alloc(machine_config(drivers[i]->machine_config));
1012         last_tokens = drivers[i]->machine_config;
1013      }
992      machine_config config(*drivers[i]);
1014993
1015994      // enumerate through all devices
1016995     
1017      for (bool gotone = config->m_devicelist.first(device); gotone; gotone = device->next(device))
996      for (bool gotone = config.m_devicelist.first(device); gotone; gotone = device->next(device))
1018997      {
1019998         // get the name
1020999         const char *dev_name = device->devconfig().name();
r9023r9024
10571036         AddGame(folder, i);
10581037      }
10591038   }
1060
1061   // free the config that we're still holding on to
1062   if (config != NULL)
1063      global_free(config);   
10641039}
10651040
10661041void CreateDeficiencyFolders(int parent_index)
r9023r9024
12221197   LPTREEFOLDER lpFolder = treeFolders[parent_index];
12231198   const rom_entry *region, *rom;
12241199   //const char *name;
1225   const game_driver *gamedrv;
1226   machine_config *config;
1200   const game_driver *gamedrv;   
12271201
12281202   // create our two subfolders
12291203   LPTREEFOLDER lpBad, lpNo;
r9023r9024
12651239      bBadDump = FALSE;
12661240      bNoDump = FALSE;
12671241      /* Allocate machine config */
1268      config = global_alloc(machine_config(gamedrv->machine_config));
1269      for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source))
1242      machine_config config(*gamedrv);
1243     
1244      for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
12701245      {
1271         for (region = rom_first_region(gamedrv,source); region; region = rom_next_region(region))
1246         for (region = rom_first_region(*source); region; region = rom_next_region(region))
12721247         {
12731248            for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
12741249            {
r9023r9024
12831258            }
12841259         }
12851260      }
1286      /* Free the structure */
1287      global_free(config);
12881261      if (bBadDump)
12891262      {
12901263         AddGame(lpBad,jj);
src/osd/winui/winui.c
r9023r9024
48694869
48704870      case COLUMN_TYPE:
48714871         {
4872            machine_config *config = global_alloc(machine_config(drivers[nItem]->machine_config));
4872            machine_config config(*drivers[nItem]);
48734873            /* Vector/Raster */
4874            if (isDriverVector(config))
4874            if (isDriverVector(&config))
48754875               s = TEXT("Vector");
48764876            else
48774877               s = TEXT("Raster");
48784878
4879            global_free(config);
48804879         }
48814880         break;
48824881
r9023r9024
53585357
53595358   case COLUMN_TYPE:
53605359      {
5361         machine_config *config1 = global_alloc(machine_config(drivers[index1]->machine_config));
5362         machine_config *config2 = global_alloc(machine_config(drivers[index2]->machine_config));
5363
5364         value = isDriverVector(config1) - isDriverVector(config2);
5365
5366         global_free(config1);
5367         global_free(config2);
5360         machine_config config1(*drivers[index1]);
5361         machine_config config2(*drivers[index2]);
5362         
5363         value = isDriverVector(&config1) - isDriverVector(&config2);
53685364      }
53695365      break;
53705366
src/osd/winui/properties.c
r9023r9024
392392   {
393393      if ((gamedrv != NULL) || g_propSheets[i].bOnDefaultPage)
394394      {
395         machine_config *config = NULL;
396
397         /* Allocate machine config */
398         if (gamedrv != NULL)
395         machine_config config(*gamedrv);
396         
397         if (!gamedrv || !g_propSheets[i].pfnFilterProc || g_propSheets[i].pfnFilterProc(&config, gamedrv))
399398         {
400            config = global_alloc(machine_config(gamedrv->machine_config));
401         }
402         if (!gamedrv || !g_propSheets[i].pfnFilterProc || g_propSheets[i].pfnFilterProc(config, gamedrv))
403         {
404399            pspages[maxPropSheets].dwSize      = sizeof(PROPSHEETPAGE);
405400            pspages[maxPropSheets].dwFlags     = 0;
406401            pspages[maxPropSheets].hInstance   = hInst;
r9023r9024
410405            pspages[maxPropSheets].pfnDlgProc  = g_propSheets[i].pfnDlgProc;
411406            maxPropSheets++;
412407         }
413         if (config != NULL)
414         {
415            /* Free the structure */
416            global_free(config);
417         }
418408      }
419409   }
420410   
r9023r9024
602592static char *GameInfoCPU(UINT nIndex)
603593{
604594   static char buf[1024];
605   machine_config *config = global_alloc(machine_config(drivers[nIndex]->machine_config));
595   machine_config config(*drivers[nIndex]);
606596   const device_config_execute_interface *cpu;
607597
608598   ZeroMemory(buf, sizeof(buf));
609599
610   bool gotone = config->m_devicelist.first(cpu);
600   bool gotone = config.m_devicelist.first(cpu);
611601   while (gotone)
612602   {
613603      if (cpu->devconfig().clock() >= 1000000)
r9023r9024
629619
630620      gotone = cpu->next(cpu);
631621    }
632
633   /* Free the structure */
634   global_free(config);
635
622   
636623   return buf;
637624}
638625
r9023r9024
643630
644631   buf[0] = 0;
645632   
646   machine_config *config = global_alloc(machine_config(drivers[nIndex]->machine_config));
633   machine_config config(*drivers[nIndex]);
647634   
648635   /* iterate over sound chips */
649636   const device_config_sound_interface *sound = NULL;
650   bool gotone = config->m_devicelist.first(sound);
637   bool gotone = config.m_devicelist.first(sound);
651638   while(gotone)
652639   {
653640      int clock,count;
r9023r9024
695682
696683      strcat(buf,"\n");
697684   }
698   /* Free the structure */
699   global_free(config);
700
701685   return buf;
702686}
703687
r9023r9024
705689static char *GameInfoScreen(UINT nIndex)
706690{
707691   static char buf[1024];
708   machine_config *config = global_alloc(machine_config(drivers[nIndex]->machine_config));
692   machine_config config(*drivers[nIndex]);
709693   memset(buf, '\0', 1024);
710694
711   if (isDriverVector(config))
695   if (isDriverVector(&config))
712696   {
713697      strcpy(buf, "Vector Game");
714698   }
715699   else
716700   {
717      const screen_device_config *screen = screen_first(*config);
701      const screen_device_config *screen = screen_first(config);
718702      if (screen == NULL) {
719703         strcpy(buf, "Screenless Game");
720704      }
r9023r9024
739723         }
740724      }
741725   }
742   /* Free the structure */
743   global_free(config);
744
745726   return buf;
746727}
747728
r9023r9024
749730static char *GameInfoColors(UINT nIndex)
750731{
751732   static char buf[1024];
752   machine_config *config = global_alloc(machine_config(drivers[nIndex]->machine_config));
733   machine_config config(*drivers[nIndex]);
753734
754735   ZeroMemory(buf, sizeof(buf));
755   sprintf(buf, "%d colors ", config->m_total_colors);
756   global_free(config);
736   sprintf(buf, "%d colors ", config.m_total_colors);
757737
758738   return buf;
759739}
r9023r9024
25862566
25872567static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled)
25882568{
2589   machine_config *config = NULL;
25902569   BOOL enabled = FALSE;
25912570   HWND hCtrl;
25922571
25932572   hCtrl = GetDlgItem(hWnd, IDC_SAMPLES);
25942573
2595   if ( nIndex > -1 ) {
2596      config = global_alloc(machine_config(drivers[nIndex]->machine_config));
2597   }
25982574   
25992575   if (hCtrl)
26002576   {     
26012577      const device_config_sound_interface *sound;
2602      if (config != NULL)
2603      {
2604         for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
2578      if ( nIndex > -1 ) {
2579         machine_config config(*drivers[nIndex]);
2580     
2581         for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound))
26052582         {
26062583            if (sound->devconfig().type() == SAMPLES ||
26072584               sound->devconfig().type() == VLM5030) {
r9023r9024
26092586            }
26102587         }
26112588      }
2612
26132589      enabled = enabled && bSoundEnabled;
26142590      EnableWindow(hCtrl, enabled);
26152591   }
2616   if (config != NULL)
2617   {
2618      global_free(config);
2619   }
26202592}
26212593
26222594/* Moved here cause it's called in a few places */
src/emu/emuopts.c
r9023r9024
232232void image_add_device_options(core_options *opts, const game_driver *driver)
233233{
234234   int index = 0;
235   machine_config *config;
236235   const device_config_image_interface *image = NULL;
237236
238237   /* create the configuration */
239   config = global_alloc(machine_config(driver->machine_config));
238   machine_config config(*driver);
240239
241240   /* enumerate our callback for every device */
242241   /* loop on each device instance */
243   for (bool gotone = config->m_devicelist.first(image); gotone; gotone = image->next(image))
242   for (bool gotone = config.m_devicelist.first(image); gotone; gotone = image->next(image))
244243   {
245244      options_entry entry[2];
246245      astring dev_full_name;
r9023r9024
267266
268267   /* record that we've added device options */
269268   options_set_bool(opts, OPTION_ADDED_DEVICE_OPTIONS, TRUE, OPTION_PRIORITY_CMDLINE);
270
271   /* free the configuration */
272   global_free(config);
273269}
274270
275271/*-------------------------------------------------
src/emu/machine.c
r9023r9024
138138//  running_machine - constructor
139139//-------------------------------------------------
140140
141running_machine::running_machine(const game_driver &driver, const machine_config &_config, core_options &options, bool exit_to_game_select)
141running_machine::running_machine(const machine_config &_config, core_options &options, bool exit_to_game_select)
142142   : m_regionlist(m_respool),
143143     m_devicelist(m_respool),
144144     config(&_config),
145145     m_config(_config),
146146     firstcpu(NULL),
147     gamedrv(&driver),
148     m_game(driver),
147     gamedrv(&_config.gamedrv()),
148     m_game(_config.gamedrv()),
149149     primary_screen(NULL),
150150     palette(NULL),
151151     pens(NULL),
r9023r9024
177177     m_logerror_list(NULL),
178178     m_scheduler(*this),
179179     m_options(options),
180     m_basename(driver.name),
180     m_basename(_config.gamedrv().name),
181181     m_current_phase(MACHINE_PHASE_PREINIT),
182182     m_paused(false),
183183     m_hard_reset_pending(false),
r9023r9024
190190     m_saveload_schedule_time(attotime_zero),
191191     m_saveload_searchpath(NULL),
192192     m_rand_seed(0x9d14abd7),
193     m_driver_data(NULL)
193     m_driver_device(NULL)
194194{
195195   memset(gfx, 0, sizeof(gfx));
196196   memset(&generic, 0, sizeof(generic));
r9023r9024
201201   device_config *config = m_config.m_devicelist.find("root");
202202   if (config == NULL)
203203      throw emu_fatalerror("Machine configuration missing driver_device");
204   driver_device_config_base::static_set_game(config, &driver);
205204
206205   // attach this machine to all the devices in the configuration
207206   m_devicelist.import_config_list(m_config.m_devicelist, *this);
208   m_driver_data = device<driver_device>("root");
209   assert(m_driver_data != NULL);
207   m_driver_device = device<driver_device>("root");
208   assert(m_driver_device != NULL);
210209
211210   // find devices
212211   primary_screen = screen_first(*this);
r9023r9024
10131012}
10141013
10151014
1015//-------------------------------------------------
1016//  rom_region - return a pointer to the ROM
1017//  regions specified for the current game
1018//-------------------------------------------------
10161019
1020const rom_entry *driver_device_config_base::rom_region() const
1021{
1022   return m_game->rom;
1023}
1024
1025
1026
10171027//**************************************************************************
10181028//  DRIVER DEVICE
10191029//**************************************************************************
src/emu/machine.h
r9023r9024
338338
339339public:
340340   // construction/destruction
341   running_machine(const game_driver &driver, const machine_config &config, core_options &options, bool exit_to_game_select = false);
341   running_machine(const machine_config &config, core_options &options, bool exit_to_game_select = false);
342342   ~running_machine();
343343
344344   // fetch items by name
r9023r9024
456456   debug_view_manager *   m_debug_view;      // internal data from debugvw.c
457457
458458   // driver-specific information
459   driver_device *driver_data() const { return m_driver_device; }
460
459461   template<class T>
460   T *driver_data() const { return downcast<T *>(m_driver_data); }
462   T *driver_data() const { return downcast<T *>(m_driver_device); }
461463
462464private:
463465   void start();
r9023r9024
521523   // base time
522524   time_t               m_base_time;
523525
524   driver_device *         m_driver_data;      // drivers can hang data off of here instead of using globals
526   driver_device *         m_driver_device;
525527};
526528
527529
r9023r9024
558560   static void static_set_video_update(device_config *device, video_update_func callback);
559561
560562protected:
563   // optional information overrides
564   virtual const rom_entry *rom_region() const;
565
561566   // internal state
562567   const game_driver *      m_game;                  // pointer to the game driver
563568
src/emu/clifront.c
r9023r9024
508508   for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
509509      if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
510510      {
511         machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config));
511         machine_config config(*drivers[drvindex]);
512512         const rom_entry *region, *rom;
513513         const rom_source *source;
514514
515515         /* iterate over sources, regions, and then ROMs within the region */
516         for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
517            for (region = rom_first_region(drivers[drvindex], source); region; region = rom_next_region(region))
516         for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
517            for (region = rom_first_region(*source); region; region = rom_next_region(region))
518518               for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
519519               {
520520                  char hashbuf[HASH_BUF_SIZE];
r9023r9024
525525               }
526526
527527         count++;
528         global_free(config);
529528      }
530529
531530   /* return an error if none found */
r9023r9024
546545   for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
547546      if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
548547      {
549         machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config));
548         machine_config config(*drivers[drvindex]);
550549         const rom_entry *region, *rom;
551550         const rom_source *source;
552551
r9023r9024
557556               "Name            Size Checksum\n", drivers[drvindex]->name);
558557
559558         /* iterate over sources, regions and then ROMs within the region */
560         for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
561            for (region = rom_first_region(drivers[drvindex], source); region != NULL; region = rom_next_region(region))
559         for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
560            for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
562561               for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
563562               {
564563                  const char *name = ROM_GETNAME(rom);
r9023r9024
596595               }
597596
598597         count++;
599         global_free(config);
600598      }
601599
602600   return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
r9023r9024
617615   for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
618616      if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
619617      {
620         machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config));
618         machine_config config(*drivers[drvindex]);
621619         const device_config_sound_interface *sound = NULL;
622620
623621         /* find samples interfaces */
624         for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
622         for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound))
625623            if (sound->devconfig().type() == SAMPLES)
626624            {
627625               const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames;
r9023r9024
634632            }
635633
636634         count++;
637         global_free(config);
638635      }
639636
640637   return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
r9023r9024
656653   for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
657654      if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
658655      {
659         machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config));
656         machine_config config(*drivers[drvindex]);
660657         const device_config *devconfig;
661658
662659         if (count != 0)
r9023r9024
664661         printf("Driver %s (%s):\n", drivers[drvindex]->name, drivers[drvindex]->description);
665662
666663         /* iterate through devices */
667         for (devconfig = config->m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
664         for (devconfig = config.m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
668665         {
669666            printf("   %s ('%s')", devconfig->name(), devconfig->tag());
670667
r9023r9024
682679         }
683680
684681         count++;
685         global_free(config);
686682      }
687683
688684   return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
r9023r9024
794790      if ( mame_strwildcmp( gamename, drivers[drvindex]->name ) == 0 )
795791      {
796792         /* allocate the machine config */
797         machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config));
793         machine_config config(*drivers[drvindex]);
798794
799         for (const device_config *dev = config->m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
795         for (const device_config *dev = config.m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
800796         {
801797            software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config();
802798
r9023r9024
806802                  nr_lists++;
807803            }
808804         }
809
810         /* free the machine config */
811         global_free(config);
812805      }
813806   }
814807
r9023r9024
855848      if ( mame_strwildcmp( gamename, drivers[drvindex]->name ) == 0 )
856849      {
857850         /* allocate the machine config */
858         machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config));
851         machine_config config(*drivers[drvindex]);
859852
860         for (const device_config *dev = config->m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
853         for (const device_config *dev = config.m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
861854         {
862855            software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config();
863856
r9023r9024
964957               }
965958            }
966959         }
967
968         global_free(config);
969960      }
970961   }
971962
r9023r9024
988979   /* iterate over drivers */
989980   for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
990981   {
991      machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config));
982      machine_config config(*drivers[drvindex]);
992983
993      for (const device_config *dev = config->m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
984      for (const device_config *dev = config.m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
994985      {
995986         software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config();
996987
r9023r9024
10271018            }
10281019         }
10291020      }
1030
1031      global_free(config);
10321021   }
10331022}
10341023
r9023r9024
10421031{
10431032   int count = 0, devcount;
10441033   int drvindex;
1045   machine_config *config;
10461034   const device_config_image_interface *dev = NULL;
10471035   const char *src;
10481036   const char *driver_name;
r9023r9024
10581046      if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
10591047      {
10601048         /* allocate the machine config */
1061         config = global_alloc(machine_config(drivers[drvindex]->machine_config));
1049         machine_config config(*drivers[drvindex]);
10621050
10631051         driver_name = drivers[drvindex]->name;
10641052
10651053         devcount = 0;
10661054
1067         for (bool gotone = config->m_devicelist.first(dev); gotone; gotone = dev->next(dev))
1055         for (bool gotone = config.m_devicelist.first(dev); gotone; gotone = dev->next(dev))
10681056         {
10691057            src = downcast<const legacy_image_device_config_base *>(dev)->file_extensions();
10701058            name = downcast<const legacy_image_device_config_base *>(dev)->instance_name();
r9023r9024
10891077            printf("%-13s(none)\n",driver_name);
10901078
10911079         count++;
1092         global_free(config);
10931080      }
10941081
10951082   if (!count)
r9023r9024
14471434   /* iterate over drivers */
14481435   for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
14491436   {
1450      machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config));
1437      machine_config config(*drivers[drvindex]);
14511438      const rom_entry *region, *rom;
14521439      const rom_source *source;
14531440
14541441      /* iterate over sources, regions and files within the region */
1455      for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
1456         for (region = rom_first_region(drivers[drvindex], source); region; region = rom_next_region(region))
1442      for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
1443         for (region = rom_first_region(*source); region; region = rom_next_region(region))
14571444            for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
14581445               if (hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0))
14591446               {
r9023r9024
14651452                  mame_printf_info("= %s%-20s  %-10s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), drivers[drvindex]->name, drivers[drvindex]->description);
14661453                  (*found)++;
14671454               }
1468
1469      global_free(config);
14701455   }
14711456
14721457   softlist_match_roms( options, hash, length, found );
src/emu/validity.c
r9023r9024
8686    meets the general requirements
8787-------------------------------------------------*/
8888
89bool validate_tag(const game_driver *driver, const char *object, const char *tag)
89bool validate_tag(const game_driver &driver, const char *object, const char *tag)
9090{
9191   const char *validchars = "abcdefghijklmnopqrstuvwxyz0123456789_.:";
9292   const char *begin = strrchr(tag, ':');
r9023r9024
100100      strcmp(tag, "left") == 0 ||
101101      strcmp(tag, "right") == 0)
102102   {
103      mame_printf_error("%s: %s has invalid generic tag '%s'\n", driver->source_file, driver->name, tag);
103      mame_printf_error("%s: %s has invalid generic tag '%s'\n", driver.source_file, driver.name, tag);
104104      error = true;
105105   }
106106
r9023r9024
108108   {
109109      if (*p != tolower((UINT8)*p))
110110      {
111         mame_printf_error("%s: %s has %s with tag '%s' containing upper-case characters\n", driver->source_file, driver->name, object, tag);
111         mame_printf_error("%s: %s has %s with tag '%s' containing upper-case characters\n", driver.source_file, driver.name, object, tag);
112112         error = true;
113113         break;
114114      }
115115      if (*p == ' ')
116116      {
117         mame_printf_error("%s: %s has %s with tag '%s' containing spaces\n", driver->source_file, driver->name, object, tag);
117         mame_printf_error("%s: %s has %s with tag '%s' containing spaces\n", driver.source_file, driver.name, object, tag);
118118         error = true;
119119         break;
120120      }
121121      if (strchr(validchars, *p) == NULL)
122122      {
123         mame_printf_error("%s: %s has %s with tag '%s' containing invalid character '%c'\n", driver->source_file, driver->name, object, tag, *p);
123         mame_printf_error("%s: %s has %s with tag '%s' containing invalid character '%c'\n", driver.source_file, driver.name, object, tag, *p);
124124         error = true;
125125         break;
126126      }
r9023r9024
133133
134134   if (strlen(begin) == 0)
135135   {
136      mame_printf_error("%s: %s has %s with 0-length tag\n", driver->source_file, driver->name, object);
136      mame_printf_error("%s: %s has %s with 0-length tag\n", driver.source_file, driver.name, object);
137137      error = true;
138138   }
139139   if (strlen(begin) < MIN_TAG_LENGTH)
140140   {
141      mame_printf_error("%s: %s has %s with tag '%s' < %d characters\n", driver->source_file, driver->name, object, tag, MIN_TAG_LENGTH);
141      mame_printf_error("%s: %s has %s with tag '%s' < %d characters\n", driver.source_file, driver.name, object, tag, MIN_TAG_LENGTH);
142142      error = true;
143143   }
144144   if (strlen(begin) > MAX_TAG_LENGTH)
145145   {
146      mame_printf_error("%s: %s has %s with tag '%s' > %d characters\n", driver->source_file, driver->name, object, tag, MAX_TAG_LENGTH);
146      mame_printf_error("%s: %s has %s with tag '%s' > %d characters\n", driver.source_file, driver.name, object, tag, MAX_TAG_LENGTH);
147147      error = true;
148148   }
149149
r9023r9024
314314    information
315315-------------------------------------------------*/
316316
317static bool validate_driver(int drivnum, const machine_config *config, game_driver_map &names, game_driver_map &descriptions)
317static bool validate_driver(const machine_config &config, game_driver_map &names, game_driver_map &descriptions)
318318{
319   const game_driver *driver = drivers[drivnum];
319   const game_driver &driver = config.gamedrv();
320320   const game_driver *clone_of;
321321   const char *compatible_with;
322322   const game_driver *other_drv;
r9023r9024
326326   enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 };
327327
328328   /* check for duplicate names */
329   if (names.add(driver->name, driver, FALSE) == TMERR_DUPLICATE)
329   if (names.add(driver.name, &driver, FALSE) == TMERR_DUPLICATE)
330330   {
331      const game_driver *match = names.find(driver->name);
332      mame_printf_error("%s: %s is a duplicate name (%s, %s)\n", driver->source_file, driver->name, match->source_file, match->name);
331      const game_driver *match = names.find(driver.name);
332      mame_printf_error("%s: %s is a duplicate name (%s, %s)\n", driver.source_file, driver.name, match->source_file, match->name);
333333      error = true;
334334   }
335335
336336   /* check for duplicate descriptions */
337   if (descriptions.add(driver->description, driver, FALSE) == TMERR_DUPLICATE)
337   if (descriptions.add(driver.description, &driver, FALSE) == TMERR_DUPLICATE)
338338   {
339      const game_driver *match = descriptions.find(driver->description);
340      mame_printf_error("%s: %s is a duplicate description (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->description);
339      const game_driver *match = descriptions.find(driver.description);
340      mame_printf_error("%s: %s is a duplicate description (%s, %s)\n", driver.source_file, driver.description, match->source_file, match->description);
341341      error = true;
342342   }
343343
344344   /* determine the clone */
345   is_clone = (strcmp(driver->parent, "0") != 0);
346   clone_of = driver_get_clone(driver);
345   is_clone = (strcmp(driver.parent, "0") != 0);
346   clone_of = driver_get_clone(&driver);
347347   if (clone_of && (clone_of->flags & GAME_IS_BIOS_ROOT))
348348      is_clone = false;
349349
r9023r9024
351351   /* (100 is arbitrary, but tries to avoid tiny.mak dependencies) */
352352   if (driver_list_get_count(drivers) > 100 && !clone_of && is_clone)
353353   {
354      mame_printf_error("%s: %s is a non-existant clone\n", driver->source_file, driver->parent);
354      mame_printf_error("%s: %s is a non-existant clone\n", driver.source_file, driver.parent);
355355      error = true;
356356   }
357357
358358   /* look for recursive cloning */
359   if (clone_of == driver)
359   if (clone_of == &driver)
360360   {
361      mame_printf_error("%s: %s is set as a clone of itself\n", driver->source_file, driver->name);
361      mame_printf_error("%s: %s is set as a clone of itself\n", driver.source_file, driver.name);
362362      error = true;
363363   }
364364
365365   /* look for clones that are too deep */
366366   if (clone_of != NULL && (clone_of = driver_get_clone(clone_of)) != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0)
367367   {
368      mame_printf_error("%s: %s is a clone of a clone\n", driver->source_file, driver->name);
368      mame_printf_error("%s: %s is a clone of a clone\n", driver.source_file, driver.name);
369369      error = true;
370370   }
371371
372372   /* make sure the driver name is 8 chars or less */
373   if ((is_clone && strlen(driver->name) > NAME_LEN_CLONE) || ((!is_clone) && strlen(driver->name) > NAME_LEN_PARENT))
373   if ((is_clone && strlen(driver.name) > NAME_LEN_CLONE) || ((!is_clone) && strlen(driver.name) > NAME_LEN_PARENT))
374374   {
375      mame_printf_error("%s: %s %s driver name must be %d characters or less\n", driver->source_file, driver->name,
375      mame_printf_error("%s: %s %s driver name must be %d characters or less\n", driver.source_file, driver.name,
376376                    is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT);
377377      error = true;
378378   }
379379
380380   /* make sure the year is only digits, '?' or '+' */
381   for (s = driver->year; *s; s++)
381   for (s = driver.year; *s; s++)
382382      if (!isdigit((UINT8)*s) && *s != '?' && *s != '+')
383383      {
384         mame_printf_error("%s: %s has an invalid year '%s'\n", driver->source_file, driver->name, driver->year);
384         mame_printf_error("%s: %s has an invalid year '%s'\n", driver.source_file, driver.name, driver.year);
385385         error = true;
386386         break;
387387      }
388388
389389   /* normalize driver->compatible_with */
390   compatible_with = driver->compatible_with;
390   compatible_with = driver.compatible_with;
391391   if ((compatible_with != NULL) && !strcmp(compatible_with, "0"))
392392      compatible_with = NULL;
393393
394394   /* check for this driver being compatible with a non-existant driver */
395   if ((compatible_with != NULL) && (driver_get_name(driver->compatible_with) == NULL))
395   if ((compatible_with != NULL) && (driver_get_name(driver.compatible_with) == NULL))
396396   {
397      mame_printf_error("%s: is compatible with %s, which is not in drivers[]\n", driver->name, driver->compatible_with);
397      mame_printf_error("%s: is compatible with %s, which is not in drivers[]\n", driver.name, driver.compatible_with);
398398      error = true;
399399   }
400400
401401   /* check for clone_of and compatible_with being specified at the same time */
402   if ((driver_get_clone(driver) != NULL) && (compatible_with != NULL))
402   if ((driver_get_clone(&driver) != NULL) && (compatible_with != NULL))
403403   {
404      mame_printf_error("%s: both compatible_with and clone_of are specified\n", driver->name);
404      mame_printf_error("%s: both compatible_with and clone_of are specified\n", driver.name);
405405      error = true;
406406   }
407407
408408   /* find any recursive dependencies on the current driver */
409   for (other_drv = driver_get_compatible(driver); other_drv != NULL; other_drv = driver_get_compatible(other_drv))
409   for (other_drv = driver_get_compatible(&driver); other_drv != NULL; other_drv = driver_get_compatible(other_drv))
410410   {
411      if (driver == other_drv)
411      if (&driver == other_drv)
412412      {
413         mame_printf_error("%s: recursive compatibility\n", driver->name);
413         mame_printf_error("%s: recursive compatibility\n", driver.name);
414414         error = true;
415415         break;
416416      }
r9023r9024
418418
419419   /* make sure sound-less drivers are flagged */
420420   const device_config_sound_interface *sound;
421   if ((driver->flags & GAME_IS_BIOS_ROOT) == 0 && !config->m_devicelist.first(sound) && (driver->flags & GAME_NO_SOUND) == 0 && (driver->flags & GAME_NO_SOUND_HW) == 0)
421   if ((driver.flags & GAME_IS_BIOS_ROOT) == 0 && !config.m_devicelist.first(sound) && (driver.flags & GAME_NO_SOUND) == 0 && (driver.flags & GAME_NO_SOUND_HW) == 0)
422422   {
423      mame_printf_error("%s: %s missing GAME_NO_SOUND flag\n", driver->source_file, driver->name);
423      mame_printf_error("%s: %s missing GAME_NO_SOUND flag\n", driver.source_file, driver.name);
424424      error = true;
425425   }
426426
r9023r9024
432432    validate_roms - validate ROM definitions
433433-------------------------------------------------*/
434434
435static bool validate_roms(int drivnum, const machine_config *config, region_array *rgninfo, game_driver_map &roms)
435static bool validate_roms(const machine_config &config, region_array *rgninfo, game_driver_map &roms)
436436{
437   const game_driver *driver = drivers[drivnum];
437   const game_driver &driver = config.gamedrv();
438438   int bios_flags = 0, last_bios = 0;
439439   const char *last_rgnname = "???";
440440   const char *last_name = "???";
r9023r9024
442442   int items_since_region = 1;
443443   bool error = false;
444444
445   /* check for duplicate ROM entries */
446/*
447    if (driver->rom != NULL && (driver->flags & GAME_NO_STANDALONE) == 0)
448    {
449        char romaddr[20];
450        sprintf(romaddr, "%p", driver->rom);
451        if (roms.add(romaddr, driver, FALSE) == TMERR_DUPLICATE)
452        {
453            const game_driver *match = roms.find(romaddr);
454            mame_printf_error("%s: %s uses the same ROM set as (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->name);
455            error = true;
456        }
457    }
458*/
459445   /* iterate, starting with the driver's ROMs and continuing with device ROMs */
460   for (const rom_source *source = rom_first_source(driver, config); source != NULL; source = rom_next_source(driver, config, source))
446   for (const rom_source *source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
461447   {
462448      /* scan the ROM entries */
463      for (const rom_entry *romp = rom_first_region(driver, source); !ROMENTRY_ISEND(romp); romp++)
449      for (const rom_entry *romp = rom_first_region(*source); !ROMENTRY_ISEND(romp); romp++)
464450      {
465451         /* if this is a region, make sure it's valid, and record the length */
466452         if (ROMENTRY_ISREGION(romp))
r9023r9024
469455
470456            /* if we haven't seen any items since the last region, print a warning */
471457            if (items_since_region == 0)
472               mame_printf_warning("%s: %s has empty ROM region '%s' (warning)\n", driver->source_file, driver->name, last_rgnname);
458               mame_printf_warning("%s: %s has empty ROM region '%s' (warning)\n", driver.source_file, driver.name, last_rgnname);
473459            items_since_region = (ROMREGION_ISERASE(romp) || ROMREGION_ISDISKDATA(romp)) ? 1 : 0;
474460            currgn = NULL;
475461            last_rgnname = regiontag;
r9023r9024
477463            /* check for a valid tag */
478464            if (regiontag == NULL)
479465            {
480               mame_printf_error("%s: %s has NULL ROM_REGION tag\n", driver->source_file, driver->name);
466               mame_printf_error("%s: %s has NULL ROM_REGION tag\n", driver.source_file, driver.name);
481467               error = true;
482468            }
483469
484470            /* load by name entries must be 8 characters or less */
485471            else if (ROMREGION_ISLOADBYNAME(romp) && strlen(regiontag) > 8)
486472            {
487               mame_printf_error("%s: %s has load-by-name region '%s' with name >8 characters\n", driver->source_file, driver->name, regiontag);
473               mame_printf_error("%s: %s has load-by-name region '%s' with name >8 characters\n", driver.source_file, driver.name, regiontag);
488474               error = true;
489475            }
490476
r9023r9024
494480               astring fulltag;
495481
496482               /* iterate over all regions found so far */
497               rom_region_name(fulltag, driver, source, romp);
483               rom_region_name(fulltag, &driver, source, romp);
498484               for (int rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++)
499485               {
500486                  /* stop when we hit an empty */
r9023r9024
509495                  /* fail if we hit a duplicate */
510496                  if (fulltag == rgninfo->entries[rgnnum].tag)
511497                  {
512                     mame_printf_error("%s: %s has duplicate ROM_REGION tag '%s'\n", driver->source_file, driver->name, fulltag.cstr());
498                     mame_printf_error("%s: %s has duplicate ROM_REGION tag '%s'\n", driver.source_file, driver.name, fulltag.cstr());
513499                     error = true;
514500                     break;
515501                  }
r9023r9024
528514            if (last_bios+1 != bios_flags)
529515            {
530516               const char *name = ROM_GETNAME(romp);
531               mame_printf_error("%s: %s has non-sequential bios %s\n", driver->source_file, driver->name, name);
517               mame_printf_error("%s: %s has non-sequential bios %s\n", driver.source_file, driver.name, name);
532518               error = true;
533519            }
534520            last_bios = bios_flags;
r9023r9024
549535            for (s = last_name; *s; s++)
550536               if (tolower((UINT8)*s) != *s)
551537               {
552                  mame_printf_error("%s: %s has upper case ROM name %s\n", driver->source_file, driver->name, last_name);
538                  mame_printf_error("%s: %s has upper case ROM name %s\n", driver.source_file, driver.name, last_name);
553539                  error = true;
554540                  break;
555541               }
r9023r9024
558544            hash = ROM_GETHASHDATA(romp);
559545            if (!hash_verify_string(hash))
560546            {
561               mame_printf_error("%s: rom '%s' has an invalid hash string '%s'\n", driver->name, last_name, hash);
547               mame_printf_error("%s: rom '%s' has an invalid hash string '%s'\n", driver.name, last_name, hash);
562548               error = true;
563549            }
564550         }
r9023r9024
574560
575561            if (ROM_GETOFFSET(romp) + ROM_GETLENGTH(romp) > currgn->length)
576562            {
577               mame_printf_error("%s: %s has ROM %s extending past the defined memory region\n", driver->source_file, driver->name, last_name);
563               mame_printf_error("%s: %s has ROM %s extending past the defined memory region\n", driver.source_file, driver.name, last_name);
578564               error = true;
579565            }
580566         }
r9023r9024
582568
583569      /* final check for empty regions */
584570      if (items_since_region == 0)
585         mame_printf_warning("%s: %s has empty ROM region (warning)\n", driver->source_file, driver->name);
571         mame_printf_warning("%s: %s has empty ROM region (warning)\n", driver.source_file, driver.name);
586572   }
587573
588574   return error;
r9023r9024
594580    configurations
595581-------------------------------------------------*/
596582
597static bool validate_display(int drivnum, const machine_config *config)
583static bool validate_display(const machine_config &config)
598584{
599   const game_driver *driver = drivers[drivnum];
585   const game_driver &driver = config.gamedrv();
600586   bool palette_modes = false;
601587   bool error = false;
602588
603   for (const screen_device_config *scrconfig = screen_first(*config); scrconfig != NULL; scrconfig = screen_next(scrconfig))
589   for (const screen_device_config *scrconfig = screen_first(config); scrconfig != NULL; scrconfig = screen_next(scrconfig))
604590      if (scrconfig->format() == BITMAP_FORMAT_INDEXED16)
605591         palette_modes = true;
606592
607593   /* check for empty palette */
608   if (palette_modes && config->m_total_colors == 0)
594   if (palette_modes && config.m_total_colors == 0)
609595   {
610      mame_printf_error("%s: %s has zero palette entries\n", driver->source_file, driver->name);
596      mame_printf_error("%s: %s has zero palette entries\n", driver.source_file, driver.name);
611597      error = true;
612598   }
613599
r9023r9024
620606    configuration
621607-------------------------------------------------*/
622608
623static bool validate_gfx(int drivnum, const machine_config *config, region_array *rgninfo)
609static bool validate_gfx(const machine_config &config, region_array *rgninfo)
624610{
625   const game_driver *driver = drivers[drivnum];
611   const game_driver &driver = config.gamedrv();
626612   bool error = false;
627613   int gfxnum;
628614
629615   /* bail if no gfx */
630   if (!config->m_gfxdecodeinfo)
616   if (!config.m_gfxdecodeinfo)
631617      return false;
632618
633619   /* iterate over graphics decoding entries */
634   for (gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && config->m_gfxdecodeinfo[gfxnum].gfxlayout != NULL; gfxnum++)
620   for (gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && config.m_gfxdecodeinfo[gfxnum].gfxlayout != NULL; gfxnum++)
635621   {
636      const gfx_decode_entry *gfx = &config->m_gfxdecodeinfo[gfxnum];
622      const gfx_decode_entry *gfx = &config.m_gfxdecodeinfo[gfxnum];
637623      const char *region = gfx->memory_region;
638      int xscale = (config->m_gfxdecodeinfo[gfxnum].xscale == 0) ? 1 : config->m_gfxdecodeinfo[gfxnum].xscale;
639      int yscale = (config->m_gfxdecodeinfo[gfxnum].yscale == 0) ? 1 : config->m_gfxdecodeinfo[gfxnum].yscale;
624      int xscale = (config.m_gfxdecodeinfo[gfxnum].xscale == 0) ? 1 : config.m_gfxdecodeinfo[gfxnum].xscale;
625      int yscale = (config.m_gfxdecodeinfo[gfxnum].yscale == 0) ? 1 : config.m_gfxdecodeinfo[gfxnum].yscale;
640626      const gfx_layout *gl = gfx->gfxlayout;
641627      int israw = (gl->planeoffset[0] == GFX_RAW);
642628      int planes = gl->planes;
r9023r9024
655641            /* stop if we hit an empty */
656642            if (!rgninfo->entries[rgnnum].tag)
657643            {
658               mame_printf_error("%s: %s has gfx[%d] referencing non-existent region '%s'\n", driver->source_file, driver->name, gfxnum, region);
644               mame_printf_error("%s: %s has gfx[%d] referencing non-existent region '%s'\n", driver.source_file, driver.name, gfxnum, region);
659645               error = true;
660646               break;
661647            }
r9023r9024
686672                  /* if not, this is an error */
687673                  if ((start + len) / 8 > avail)
688674                  {
689                     mame_printf_error("%s: %s has gfx[%d] extending past allocated memory of region '%s'\n", driver->source_file, driver->name, gfxnum, region);
675                     mame_printf_error("%s: %s has gfx[%d] extending past allocated memory of region '%s'\n", driver.source_file, driver.name, gfxnum, region);
690676                     error = true;
691677                  }
692678               }
r9023r9024
699685      {
700686         if (total != RGN_FRAC(1,1))
701687         {
702            mame_printf_error("%s: %s has gfx[%d] with unsupported layout total\n", driver->source_file, driver->name, gfxnum);
688            mame_printf_error("%s: %s has gfx[%d] with unsupported layout total\n", driver.source_file, driver.name, gfxnum);
703689            error = true;
704690         }
705691
706692         if (xscale != 1 || yscale != 1)
707693         {
708            mame_printf_error("%s: %s has gfx[%d] with unsupported xscale/yscale\n", driver->source_file, driver->name, gfxnum);
694            mame_printf_error("%s: %s has gfx[%d] with unsupported xscale/yscale\n", driver.source_file, driver.name, gfxnum);
709695            error = true;
710696         }
711697      }
r9023r9024
713699      {
714700         if (planes > MAX_GFX_PLANES)
715701         {
716            mame_printf_error("%s: %s has gfx[%d] with invalid planes\n", driver->source_file, driver->name, gfxnum);
702            mame_printf_error("%s: %s has gfx[%d] with invalid planes\n", driver.source_file, driver.name, gfxnum);
717703            error = true;
718704         }
719705
720706         if (xscale * width > MAX_ABS_GFX_SIZE || yscale * height > MAX_ABS_GFX_SIZE)
721707         {
722            mame_printf_error("%s: %s has gfx[%d] with invalid xscale/yscale\n", driver->source_file, driver->name, gfxnum);
708            mame_printf_error("%s: %s has gfx[%d] with invalid xscale/yscale\n", driver.source_file, driver.name, gfxnum);
723709            error = true;
724710         }
725711      }
r9023r9024
735721    strings
736722-------------------------------------------------*/
737723
738static int get_defstr_index(int_map &defstr_map, const char *name, const game_driver *driver, bool *error)
724static int get_defstr_index(int_map &defstr_map, const char *name, const game_driver &driver, bool *error)
739725{
740726   /* check for strings that should be DEF_STR */
741727   int strindex = defstr_map.find(name);
742728   if (strindex != 0 && name != input_port_string_from_index(strindex) && error != NULL)
743729   {
744      mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, name);
730      mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver.source_file, driver.name, name);
745731      *error = true;
746732   }
747733
r9023r9024
754740    analog input field
755741-------------------------------------------------*/
756742
757static void validate_analog_input_field(const input_field_config *field, const game_driver *driver, bool *error)
743static void validate_analog_input_field(const input_field_config *field, const game_driver &driver, bool *error)
758744{
759745   INT32 analog_max = field->max;
760746   INT32 analog_min = field->min;
r9023r9024
769755      /* positional port size must fit in bits used */
770756      if (((field->mask >> shift) + 1) < field->max)
771757      {
772         mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver->source_file, driver->name);
758         mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver.source_file, driver.name);
773759         *error = true;
774760      }
775761   }
r9023r9024
778764      /* only positional controls use PORT_WRAPS */
779765      if (field->flags & ANALOG_FLAG_WRAPS)
780766      {
781         mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver->source_file, driver->name);
767         mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver.source_file, driver.name);
782768         *error = true;
783769      }
784770   }
r9023r9024
786772   /* analog ports must have a valid sensitivity */
787773   if (field->sensitivity == 0)
788774   {
789      mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver->source_file, driver->name);
775      mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver.source_file, driver.name);
790776      *error = true;
791777   }
792778
793779   /* check that the default falls in the bitmask range */
794780   if (field->defvalue & ~field->mask)
795781   {
796      mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver->source_file, driver->name);
782      mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver.source_file, driver.name);
797783      *error = true;
798784   }
799785
r9023r9024
813799      /* check that the default falls in the MINMAX range */
814800      if (default_value < analog_min || default_value > analog_max)
815801      {
816         mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver->source_file, driver->name);
802         mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver.source_file, driver.name);
817803         *error = true;
818804      }
819805
r9023r9024
821807      /* we use the unadjusted min for testing */
822808      if (field->min & ~field->mask || analog_max & ~field->mask)
823809      {
824         mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver->source_file, driver->name);
810         mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver.source_file, driver.name);
825811         *error = true;
826812      }
827813
828814      /* absolute analog ports do not use PORT_RESET */
829815      if (field->flags & ANALOG_FLAG_RESET)
830816      {
831         mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver->source_file, driver->name);
817         mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver.source_file, driver.name);
832818         *error = true;
833819      }
834820   }
r9023r9024
842828         /* relative devices do not use PORT_MINMAX */
843829         if (field->min != 0 || field->max != field->mask)
844830         {
845            mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver->source_file, driver->name);
831            mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver.source_file, driver.name);
846832            *error = true;
847833         }
848834
r9023r9024
850836         /* the counter is at 0 on power up */
851837         if (field->defvalue != 0)
852838         {
853            mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver->source_file, driver->name);
839            mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver.source_file, driver.name);
854840            *error = true;
855841         }
856842      }
r9023r9024
863849    setting
864850-------------------------------------------------*/
865851
866static void validate_dip_settings(const input_field_config *field, const game_driver *driver, int_map &defstr_map, bool *error)
852static void validate_dip_settings(const input_field_config *field, const game_driver &driver, int_map &defstr_map, bool *error)
867853{
868854   const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds);
869855   const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen);
r9023r9024
883869      /* make sure demo sounds default to on */
884870      if (field->name == demo_sounds && strindex == INPUT_STRING_On && field->defvalue != setting->value)
885871      {
886         mame_printf_error("%s: %s Demo Sounds must default to On\n", driver->source_file, driver->name);
872         mame_printf_error("%s: %s Demo Sounds must default to On\n", driver.source_file, driver.name);
887873         *error = true;
888874      }
889875
890876      /* check for bad demo sounds options */
891877      if (field->name == demo_sounds && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No))
892878      {
893         mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name);
879         mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver.source_file, driver.name, setting->name);
894880         *error = true;
895881      }
896882
897883      /* check for bad flip screen options */
898884      if (field->name == flipscreen && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No))
899885      {
900         mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name);
886         mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver.source_file, driver.name, setting->name);
901887         *error = true;
902888      }
903889
r9023r9024
909895         /* check for inverted off/on dispswitch order */
910896         if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off)
911897         {
912            mame_printf_error("%s: %s has inverted Off/On dipswitch order\n", driver->source_file, driver->name);
898            mame_printf_error("%s: %s has inverted Off/On dipswitch order\n", driver.source_file, driver.name);
913899            *error = true;
914900         }
915901
916902         /* check for inverted yes/no dispswitch order */
917903         else if (strindex == INPUT_STRING_Yes && next_strindex == INPUT_STRING_No)
918904         {
919            mame_printf_error("%s: %s has inverted No/Yes dipswitch order\n", driver->source_file, driver->name);
905            mame_printf_error("%s: %s has inverted No/Yes dipswitch order\n", driver.source_file, driver.name);
920906            *error = true;
921907         }
922908
923909         /* check for inverted upright/cocktail dispswitch order */
924910         else if (strindex == INPUT_STRING_Cocktail && next_strindex == INPUT_STRING_Upright)
925911         {
926            mame_printf_error("%s: %s has inverted Upright/Cocktail dipswitch order\n", driver->source_file, driver->name);
912            mame_printf_error("%s: %s has inverted Upright/Cocktail dipswitch order\n", driver.source_file, driver.name);
927913            *error = true;
928914         }
929915
r9023r9024
931917         else if (strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C && next_strindex >= INPUT_STRING_9C_1C && next_strindex <= INPUT_STRING_1C_9C &&
932918                strindex >= next_strindex && memcmp(&setting->condition, &setting->next->condition, sizeof(setting->condition)) == 0)
933919         {
934            mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver->source_file, driver->name, setting->name, setting->next->name);
920            mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver.source_file, driver.name, setting->name, setting->next->name);
935921            coin_error = *error = true;
936922         }
937923      }
r9023r9024
942928   {
943929      int entry;
944930
945      mame_printf_error("%s: %s proper coin sort order should be:\n", driver->source_file, driver->name);
931      mame_printf_error("%s: %s proper coin sort order should be:\n", driver.source_file, driver.name);
946932      for (entry = 0; entry < ARRAY_LENGTH(coin_list); entry++)
947933         if (coin_list[entry])
948934            mame_printf_error("%s\n", input_port_string_from_index(INPUT_STRING_9C_1C + entry));
r9023r9024
954940    validate_inputs - validate input configuration
955941-------------------------------------------------*/
956942
957static bool validate_inputs(int drivnum, const machine_config *config, int_map &defstr_map, ioport_list &portlist)
943static bool validate_inputs(const machine_config &config, int_map &defstr_map, ioport_list &portlist)
958944{
959945   const input_port_config *scanport;
960946   const input_port_config *port;
961947   const input_field_config *field;
962   const game_driver *driver = drivers[drivnum];
948   const game_driver &driver = config.gamedrv();
963949   int empty_string_found = FALSE;
964950   char errorbuf[1024];
965951   bool error = false;
966952
967953   /* skip if no ports */
968   if (driver->ipt == NULL)
954   if (driver.ipt == NULL)
969955      return FALSE;
970956
971957   /* allocate the input ports */
972   input_port_list_init(portlist, driver->ipt, errorbuf, sizeof(errorbuf), FALSE);
958   input_port_list_init(portlist, driver.ipt, errorbuf, sizeof(errorbuf), FALSE);
973959   if (errorbuf[0] != 0)
974960   {
975      mame_printf_error("%s: %s has input port errors:\n%s\n", driver->source_file, driver->name, errorbuf);
961      mame_printf_error("%s: %s has input port errors:\n%s\n", driver.source_file, driver.name, errorbuf);
976962      error = true;
977963   }
978964
r9023r9024
982968         for (scanport = port->next(); scanport != NULL; scanport = scanport->next())
983969            if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0)
984970            {
985               mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver->source_file, driver->name, port->tag);
971               mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver.source_file, driver.name, port->tag);
986972               error = true;
987973            }
988974
r9023r9024
1003989            /* dip switch fields must have a name */
1004990            if (field->name == NULL)
1005991            {
1006               mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver->source_file, driver->name);
992               mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver.source_file, driver.name);
1007993               error = true;
1008994            }
1009995
r9023r9024
10141000         /* look for invalid (0) types which should be mapped to IPT_OTHER */
10151001         if (field->type == IPT_INVALID)
10161002         {
1017            mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver->source_file, driver->name);
1003            mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver.source_file, driver.name);
10181004            error = true;
10191005         }
10201006
r9023r9024
10241010            /* check for empty string */
10251011            if (field->name[0] == 0 && !empty_string_found)
10261012            {
1027               mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name);
1013               mame_printf_error("%s: %s has an input with an empty string\n", driver.source_file, driver.name);
10281014               empty_string_found = error = true;
10291015            }
10301016
10311017            /* check for trailing spaces */
10321018            if (field->name[0] != 0 && field->name[strlen(field->name) - 1] == ' ')
10331019            {
1034               mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, field->name);
1020               mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver.source_file, driver.name, field->name);
10351021               error = true;
10361022            }
10371023
10381024            /* check for invalid UTF-8 */
10391025            if (!utf8_is_valid_string(field->name))
10401026            {
1041               mame_printf_error("%s: %s input '%s' has invalid characters\n", driver->source_file, driver->name, field->name);
1027               mame_printf_error("%s: %s input '%s' has invalid characters\n", driver.source_file, driver.name, field->name);
10421028               error = true;
10431029            }
10441030
r9023r9024
10571043            /* if none, error */
10581044            if (scanport == NULL)
10591045            {
1060               mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver->source_file, driver->name, field->condition.tag);
1046               mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver.source_file, driver.name, field->condition.tag);
10611047               error = true;
10621048            }
10631049         }
r9023r9024
10741060               /* if none, error */
10751061               if (scanport == NULL)
10761062               {
1077                  mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver->source_file, driver->name, setting->condition.tag);
1063                  mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver.source_file, driver.name, setting->condition.tag);
10781064                  error = true;
10791065               }
10801066            }
r9023r9024
10821068
10831069   error = error || validate_natural_keyboard_statics();
10841070
1085   /* free the config */
10861071   return error;
10871072}
10881073
r9023r9024
10921077    checks
10931078-------------------------------------------------*/
10941079
1095static bool validate_devices(int drivnum, const machine_config *config, const ioport_list &portlist, region_array *rgninfo)
1080static bool validate_devices(const machine_config &config, const ioport_list &portlist, region_array *rgninfo)
10961081{
10971082   bool error = false;
1098   const game_driver *driver = drivers[drivnum];
1083   const game_driver &driver = config.gamedrv();
10991084
1100   for (const device_config *devconfig = config->m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
1085   for (const device_config *devconfig = config.m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
11011086   {
11021087      /* validate the device tag */
11031088      if (!validate_tag(driver, devconfig->name(), devconfig->tag()))
11041089         error = true;
11051090
11061091      /* look for duplicates */
1107      for (const device_config *scanconfig = config->m_devicelist.first(); scanconfig != devconfig; scanconfig = scanconfig->next())
1092      for (const device_config *scanconfig = config.m_devicelist.first(); scanconfig != devconfig; scanconfig = scanconfig->next())
11081093         if (strcmp(scanconfig->tag(), devconfig->tag()) == 0)
11091094         {
1110            mame_printf_warning("%s: %s has multiple devices with the tag '%s'\n", driver->source_file, driver->name, devconfig->tag());
1095            mame_printf_warning("%s: %s has multiple devices with the tag '%s'\n", driver.source_file, driver.name, devconfig->tag());
11111096            break;
11121097         }
11131098
11141099      /* check for device-specific validity check */
1115      if (devconfig->validity_check(*driver))
1100      if (devconfig->validity_check(driver))
11161101         error = true;
11171102
11181103   }
r9023r9024
11351120   osd_ticks_t input_checks = 0;
11361121   osd_ticks_t device_checks = 0;
11371122
1138   int drivnum, strnum;
1123   int strnum;
11391124   bool error = false;
11401125   UINT16 lsbtest;
11411126   UINT8 a, b;
r9023r9024
11871172   prep += get_profile_ticks();
11881173
11891174   /* iterate over all drivers */
1190   for (drivnum = 0; drivers[drivnum]; drivnum++)
1175   for (int drivnum = 0; drivers[drivnum]; drivnum++)
11911176   {
1192      const game_driver *driver = drivers[drivnum];
1193      machine_config *config = NULL;
1177      const game_driver &driver = *drivers[drivnum];
11941178      ioport_list portlist;
11951179      region_array rgninfo;
11961180
11971181      /* non-debug builds only care about games in the same driver */
1198      if (curdriver != NULL && strcmp(curdriver->source_file, driver->source_file) != 0)
1182      if (curdriver != NULL && strcmp(curdriver->source_file, driver.source_file) != 0)
11991183         continue;
12001184
12011185      try
12021186      {
12031187         /* expand the machine driver */
12041188         expansion -= get_profile_ticks();
1205         config = global_alloc(machine_config(driver->machine_config));
1189         machine_config config(driver);
12061190         expansion += get_profile_ticks();
12071191
12081192         /* validate the driver entry */
12091193         driver_checks -= get_profile_ticks();
1210         error = validate_driver(drivnum, config, names, descriptions) || error;
1194         error = validate_driver(config, names, descriptions) || error;
12111195         driver_checks += get_profile_ticks();
12121196
12131197         /* validate the ROM information */
12141198         rom_checks -= get_profile_ticks();
1215         error = validate_roms(drivnum, config, &rgninfo, roms) || error;
1199         error = validate_roms(config, &rgninfo, roms) || error;
12161200         rom_checks += get_profile_ticks();
12171201
12181202         /* validate input ports */
12191203         input_checks -= get_profile_ticks();
1220         error = validate_inputs(drivnum, config, defstr, portlist) || error;
1204         error = validate_inputs(config, defstr, portlist) || error;
12211205         input_checks += get_profile_ticks();
12221206
12231207         /* validate the display */
12241208         display_checks -= get_profile_ticks();
1225         error = validate_display(drivnum, config) || error;
1209         error = validate_display(config) || error;
12261210         display_checks += get_profile_ticks();
12271211
12281212         /* validate the graphics decoding */
12291213         gfx_checks -= get_profile_ticks();
1230         error = validate_gfx(drivnum, config, &rgninfo) || error;
1214         error = validate_gfx(config, &rgninfo) || error;
12311215         gfx_checks += get_profile_ticks();
12321216
12331217         /* validate devices */
12341218         device_checks -= get_profile_ticks();
1235         error = validate_devices(drivnum, config, portlist, &rgninfo) || error;
1219         error = validate_devices(config, portlist, &rgninfo) || error;
12361220         device_checks += get_profile_ticks();
12371221      }
12381222      catch (emu_fatalerror &err)
12391223      {
1240         global_free(config);
1241         throw emu_fatalerror("Validating %s (%s): %s", driver->name, driver->source_file, err.string());
1224         throw emu_fatalerror("Validating %s (%s): %s", driver.name, driver.source_file, err.string());
12421225      }
1243
1244      global_free(config);
12451226   }
12461227
12471228#if (REPORT_TIMES)
src/emu/validity.h
r9023r9024
1515#define __VALIDITY_H__
1616
1717bool mame_validitychecks(const game_driver *driver);
18bool validate_tag(const game_driver *driver, const char *object, const char *tag);
18bool validate_tag(const game_driver &driver, const char *object, const char *tag);
1919
2020#endif
src/emu/romload.c
r9023r9024
138138***************************************************************************/
139139
140140/*-------------------------------------------------
141    rom_source_is_gamedrv - return TRUE if the
142    given rom_source refers to the game driver
143    itself
144-------------------------------------------------*/
145
146int rom_source_is_gamedrv(const game_driver *drv, const rom_source *source)
147{
148   return ((const game_driver *)source == drv);
149}
150
151
152/*-------------------------------------------------
153141    rom_first_source - return pointer to first ROM
154142    source
155143-------------------------------------------------*/
156144
157const rom_source *rom_first_source(const game_driver *drv, const machine_config *config)
145const rom_source *rom_first_source(const machine_config &config)
158146{
159   const device_config *devconfig;
147   /* look through devices */
148   for (const device_config *devconfig = config.m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
149      if (devconfig->rom_region() != NULL)
150         return devconfig;
160151
161   /* if the driver has a ROM pointer, that's what we want */
162   if (drv->rom != NULL)
163      return (rom_source *)drv;
164
165   /* otherwise, look through devices */
166   if (config != NULL)
167      for (devconfig = config->m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
168      {
169         const rom_entry *devromp = devconfig->rom_region();
170         if (devromp != NULL)
171            return (rom_source *)devconfig;
172      }
173152   return NULL;
174153}
175154
r9023r9024
179158    source
180159-------------------------------------------------*/
181160
182const rom_source *rom_next_source(const game_driver *drv, const machine_config *config, const rom_source *previous)
161const rom_source *rom_next_source(const rom_source &previous)
183162{
184   const device_config *devconfig;
185
186   /* if the previous was the driver, we want the first device */
187   if (rom_source_is_gamedrv(drv, previous))
188      devconfig = (config != NULL) ? config->m_devicelist.first() : NULL;
189   else
190      devconfig = ((const device_config *)previous)->next();
191
192163   /* look for further devices with ROM definitions */
193   for ( ; devconfig != NULL; devconfig = devconfig->next())
194   {
195      const rom_entry *devromp = devconfig->rom_region();
196      if (devromp != NULL)
164   for (const device_config *devconfig = previous.next(); devconfig != NULL; devconfig = devconfig->next())
165      if (devconfig->rom_region() != NULL)
197166         return (rom_source *)devconfig;
198   }
167
199168   return NULL;
200169}
201170
r9023r9024
205174    region
206175-------------------------------------------------*/
207176
208const rom_entry *rom_first_region(const game_driver *drv, const rom_source *source)
177const rom_entry *rom_first_region(const rom_source &source)
209178{
210   const rom_entry *romp;
211
212   if (source == NULL || rom_source_is_gamedrv(drv, source))
213      romp = drv->rom;
214   else
215      romp = ((const device_config *)source)->rom_region();
216
179   const rom_entry *romp = source.rom_region();
217180   return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL;
218181}
219182
r9023r9024
267230
268231astring &rom_region_name(astring &result, const game_driver *drv, const rom_source *source, const rom_entry *romp)
269232{
270   if (rom_source_is_gamedrv(drv, source))
271      result.cpy(ROMREGION_GETTAG(romp));
272   else
273   {
274      const device_config *devconfig = (const device_config *)source;
275      result.printf("%s:%s", devconfig->tag(), ROMREGION_GETTAG(romp));
276   }
277   return result;
233   return source->subtag(result, ROMREGION_GETTAG(romp));
278234}
279235
280236
r9023r9024
342298
343299   romdata->system_bios = 0;
344300
345   /* first determine the default BIOS name */
346   for (rom = romdata->machine->gamedrv->rom; !ROMENTRY_ISEND(rom); rom++)
347      if (ROMENTRY_ISDEFAULT_BIOS(rom))
348         defaultname = ROM_GETNAME(rom);
301   for (const rom_source *source = rom_first_source(*romdata->machine->config); source != NULL; source = rom_next_source(*source))
302   {
303      /* first determine the default BIOS name */
304      for (rom = source->rom_region(); !ROMENTRY_ISEND(rom); rom++)
305         if (ROMENTRY_ISDEFAULT_BIOS(rom))
306            defaultname = ROM_GETNAME(rom);
349307
350   /* look for a BIOS with a matching name */
351   for (rom = romdata->machine->gamedrv->rom; !ROMENTRY_ISEND(rom); rom++)
352      if (ROMENTRY_ISSYSTEM_BIOS(rom))
353      {
354         const char *biosname = ROM_GETNAME(rom);
355         int bios_flags = ROM_GETBIOSFLAGS(rom);
356         char bios_number[20];
308      /* look for a BIOS with a matching name */
309      for (rom = source->rom_region(); !ROMENTRY_ISEND(rom); rom++)
310         if (ROMENTRY_ISSYSTEM_BIOS(rom))
311         {
312            const char *biosname = ROM_GETNAME(rom);
313            int bios_flags = ROM_GETBIOSFLAGS(rom);
314            char bios_number[20];
357315
358         /* Allow '-bios n' to still be used */
359         sprintf(bios_number, "%d", bios_flags - 1);
360         if (strcmp(bios_number, specbios) == 0 || strcmp(biosname, specbios) == 0)
361            romdata->system_bios = bios_flags;
362         if (defaultname != NULL && strcmp(biosname, defaultname) == 0)
363            default_no = bios_flags;
364         bios_count++;
365      }
316            /* Allow '-bios n' to still be used */
317            sprintf(bios_number, "%d", bios_flags - 1);
318            if (strcmp(bios_number, specbios) == 0 || strcmp(biosname, specbios) == 0)
319               romdata->system_bios = bios_flags;
320            if (defaultname != NULL && strcmp(biosname, defaultname) == 0)
321               default_no = bios_flags;
322            bios_count++;
323         }
366324
367   /* if none found, use the default */
368   if (romdata->system_bios == 0 && bios_count > 0)
369   {
370      /* if we got neither an empty string nor 'default' then warn the user */
371      if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL)
325      /* if none found, use the default */
326      if (romdata->system_bios == 0 && bios_count > 0)
372327      {
373         romdata->errorstring.catprintf("%s: invalid bios\n", specbios);
374         romdata->warnings++;
328         /* if we got neither an empty string nor 'default' then warn the user */
329         if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL)
330         {
331            romdata->errorstring.catprintf("%s: invalid bios\n", specbios);
332            romdata->warnings++;
333         }
334
335         /* set to default */
336         romdata->system_bios = default_no;
375337      }
376338
377      /* set to default */
378      romdata->system_bios = default_no;
339      LOG(("Using System BIOS: %d\n", romdata->system_bios));
379340   }
380
381   LOG(("Using System BIOS: %d\n", romdata->system_bios));
382341}
383342
384343
r9023r9024
397356   romdata->romstotalsize = 0;
398357
399358   /* loop over regions, then over files */
400   for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source))
401      for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region))
359   for (source = rom_first_source(*romdata->machine->config); source != NULL; source = rom_next_source(*source))
360      for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
402361         for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
403362            if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->system_bios)
404363            {
r9023r9024
10451004   /* otherwise, look at our parents for a CHD with an identical checksum */
10461005   /* and try to open that */
10471006   for (drv = gamedrv; drv != NULL; drv = driver_get_clone(drv))
1048      for (source = rom_first_source(drv, NULL); source != NULL; source = rom_next_source(drv, NULL, source))
1049         for (region = rom_first_region(drv, source); region != NULL; region = rom_next_region(region))
1007   {
1008      machine_config config(*drv);
1009      for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
1010         for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
10501011            if (ROMREGION_ISDISKDATA(region))
10511012               for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
10521013
r9023r9024
10811042                        *image_file = NULL;
10821043                     }
10831044                  }
1045   }
10841046
10851047   return err;
10861048}
r9023r9024
13441306   const rom_entry *region;
13451307
13461308   /* loop until we hit the end */
1347   for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source))
1348      for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region))
1309   for (source = rom_first_source(*romdata->machine->config); source != NULL; source = rom_next_source(*source))
1310      for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
13491311      {
13501312         UINT32 regionlength = ROMREGION_GETLENGTH(region);
13511313         UINT32 regionflags = ROMREGION_GETFLAGS(region);
r9023r9024
13881350      }
13891351
13901352   /* now go back and post-process all the regions */
1391   for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source))
1392      for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region))
1353   for (source = rom_first_source(*romdata->machine->config); source != NULL; source = rom_next_source(*source))
1354      for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
13931355         region_post_process(romdata, ROMREGION_GETTAG(region));
13941356}
13951357
src/emu/romload.h
r9023r9024
123123    TYPE DEFINITIONS
124124***************************************************************************/
125125
126typedef struct _rom_source rom_source;
126typedef device_config rom_source;
127127
128128
129129struct rom_entry
r9023r9024
282282/* ----- ROM iteration ----- */
283283
284284/* return pointer to first ROM source */
285const rom_source *rom_first_source(const game_driver *drv, const machine_config *config);
285const rom_source *rom_first_source(const machine_config &config);
286286
287287/* return pointer to next ROM source */
288const rom_source *rom_next_source(const game_driver *drv, const machine_config *config, const rom_source *previous);
288const rom_source *rom_next_source(const rom_source &previous);
289289
290290/* return pointer to the first ROM region within a source */
291const rom_entry *rom_first_region(const game_driver *drv, const rom_source *romp);
291const rom_entry *rom_first_region(const rom_source &romp);
292292
293293/* return pointer to the next ROM region within a source */
294294const rom_entry *rom_next_region(const rom_entry *romp);
src/emu/info.c
r9023r9024
3939   const game_driver *drv;
4040   machine_config mconfig;
4141
42   parent_info(const game_driver *drv) : mconfig(drv->machine_config)
42   parent_info(const game_driver *drv) : mconfig(*drv)
4343   {
4444      this->drv = drv;
4545   }
r9023r9024
458458
459459   for (parent = 0; parent < parents; ++parent)
460460   {
461      const game_driver *clone_of = pinfoarray[parent]->drv;
462461      const machine_config *pconfig = &pinfoarray[parent]->mconfig;
463462      const rom_source *psource;
464463      const rom_entry *pregion, *prom;
465464
466465      /* scan the clone_of ROM for a matching ROM entry */
467      for (psource = rom_first_source(clone_of, pconfig); psource != NULL; psource = rom_next_source(clone_of, pconfig, psource))
468         for (pregion = rom_first_region(clone_of, psource); pregion != NULL; pregion = rom_next_region(pregion))
466      for (psource = rom_first_source(*pconfig); psource != NULL; psource = rom_next_source(*psource))
467         for (pregion = rom_first_region(*psource); pregion != NULL; pregion = rom_next_region(pregion))
469468            for (prom = rom_first_file(pregion); prom != NULL; prom = rom_next_file(prom))
470469               if (hash_data_is_equal(ROM_GETHASHDATA(rom), ROM_GETHASHDATA(prom), 0))
471470               {
r9023r9024
484483    the XML output
485484-------------------------------------------------*/
486485
487static void print_game_rom(FILE *out, const game_driver *game, const machine_config *config)
486static void print_game_rom(FILE *out, const game_driver *game, const machine_config &config)
488487{
489488   const game_driver *clone_of = driver_get_clone(game);
490489   int rom_type;
r9023r9024
504503      const rom_entry *region;
505504
506505      /* iterate over ROM sources: first the game, then any devices */
507      for (source = rom_first_source(game, config); source != NULL; source = rom_next_source(game, config, source))
508         for (region = rom_first_region(game, source); region != NULL; region = rom_next_region(region))
506      for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
507         for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
509508         {
510509            int is_disk = ROMREGION_ISDISKDATA(region);
511510            const rom_entry *rom;
r9023r9024
611610    attribute, if appropriate
612611-------------------------------------------------*/
613612
614static void print_game_sampleof(FILE *out, const game_driver *game, const machine_config *config)
613static void print_game_sampleof(FILE *out, const game_driver *game, const machine_config &config)
615614{
616615   const device_config_sound_interface *sound = NULL;
617616
618   for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
617   for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound))
619618      if (sound->devconfig().type() == SAMPLES)
620619      {
621620         const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames;
r9023r9024
642641    samples referenced by a game_driver
643642-------------------------------------------------*/
644643
645static void print_game_sample(FILE *out, const game_driver *game, const machine_config *config)
644static void print_game_sample(FILE *out, const game_driver *game, const machine_config &config)
646645{
647646   const device_config_sound_interface *sound = NULL;
648647
649648   /* iterate over sound chips looking for samples */
650   for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
649   for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound))
651650      if (sound->devconfig().type() == SAMPLES)
652651      {
653652         const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames;
r9023r9024
685684    sound chips used by a game
686685-------------------------------------------------*/
687686
688static void print_game_chips(FILE *out, const game_driver *game, const machine_config *config)
687static void print_game_chips(FILE *out, const game_driver *game, const machine_config &config)
689688{
690689   /* iterate over CPUs */
691690   const device_config_execute_interface *exec = NULL;
692   for (bool gotone = config->m_devicelist.first(exec); gotone; gotone = exec->next(exec))
691   for (bool gotone = config.m_devicelist.first(exec); gotone; gotone = exec->next(exec))
693692   {
694693      fprintf(out, "\t\t<chip");
695694      fprintf(out, " type=\"cpu\"");
r9023r9024
701700
702701   /* iterate over sound chips */
703702   const device_config_sound_interface *sound = NULL;
704   for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
703   for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound))
705704   {
706705      fprintf(out, "\t\t<chip");
707706      fprintf(out, " type=\"audio\"");
r9023r9024
719718    displays
720719-------------------------------------------------*/
721720
722static void print_game_display(FILE *out, const game_driver *game, const machine_config *config)
721static void print_game_display(FILE *out, const game_driver *game, const machine_config &config)
723722{
724723   const screen_device_config *devconfig;
725724
726725   /* iterate over screens */
727   for (devconfig = screen_first(*config); devconfig != NULL; devconfig = screen_next(devconfig))
726   for (devconfig = screen_first(config); devconfig != NULL; devconfig = screen_next(devconfig))
728727   {
729728      fprintf(out, "\t\t<display");
730729
r9023r9024
803802    displays
804803-------------------------------------------------*/
805804
806static void print_game_sound(FILE *out, const game_driver *game, const machine_config *config)
805static void print_game_sound(FILE *out, const game_driver *game, const machine_config &config)
807806{
808   int speakers = speaker_output_count(config);
807   int speakers = speaker_output_count(&config);
809808
810809   /* if we have no sound, zero out the speaker count */
811810   const device_config_sound_interface *sound = NULL;
812   if (!config->m_devicelist.first(sound))
811   if (!config.m_devicelist.first(sound))
813812      speakers = 0;
814813
815814   fprintf(out, "\t\t<sound channels=\"%d\"/>\n", speakers);
r9023r9024
820819    print_game_driver - print driver status
821820-------------------------------------------------*/
822821
823static void print_game_driver(FILE *out, const game_driver *game, const machine_config *config)
822static void print_game_driver(FILE *out, const game_driver *game, const machine_config &config)
824823{
825824   fprintf(out, "\t\t<driver");
826825
r9023r9024
874873   else
875874      fprintf(out, " savestate=\"unsupported\"");
876875
877   fprintf(out, " palettesize=\"%d\"", config->m_total_colors);
876   fprintf(out, " palettesize=\"%d\"", config.m_total_colors);
878877
879878   fprintf(out, "/>\n");
880879}
r9023r9024
918917    image devices
919918-------------------------------------------------*/
920919
921static void print_game_images(FILE *out, const game_driver *game, const machine_config *config)
920static void print_game_images(FILE *out, const game_driver *game, const machine_config &config)
922921{
923922   const device_config_image_interface *dev = NULL;
924923   const char *name;
925924   const char *shortname;
926925
927   for (bool gotone = config->m_devicelist.first(dev); gotone; gotone = dev->next(dev))
926   for (bool gotone = config.m_devicelist.first(dev); gotone; gotone = dev->next(dev))
928927   {
929928      /* print out device type */
930929      fprintf(out, "\t\t<device type=\"%s\"", xml_normalize_string(dev->image_type_name()));
r9023r9024
971970    for all known software lists for this system
972971-------------------------------------------------*/
973972
974static void print_game_software_list(FILE *out, const game_driver *game, const machine_config *config)
973static void print_game_software_list(FILE *out, const game_driver *game, const machine_config &config)
975974{
976   for (const device_config *dev = config->m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
975   for (const device_config *dev = config.m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
977976   {
978977      software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config();
979978
r9023r9024
996995static void print_game_info(FILE *out, const game_driver *game)
997996{
998997   const game_driver *clone_of;
999   machine_config *config;
998   machine_config config(*game);
1000999   ioport_list portlist;
10011000   const char *start;
10021001
r9023r9024
10051004      return;
10061005
10071006   /* start tracking resources and allocate the machine and input configs */
1008   config = global_alloc(machine_config(game->machine_config));
10091007   input_port_list_init(portlist, game->ipt, NULL, 0, FALSE);
10101008
10111009   /* print the header and the game name */
r9023r9024
10701068
10711069   /* close the topmost tag */
10721070   fprintf(out, "\t</" XML_TOP ">\n");
1073
1074   global_free(config);
10751071}
10761072
10771073
src/emu/audit.c
r9023r9024
5656
5757int audit_images(core_options *options, const game_driver *gamedrv, UINT32 validation, audit_record **audit)
5858{
59   machine_config *config = global_alloc(machine_config(gamedrv->machine_config));
59   machine_config config(*gamedrv);
6060   const rom_entry *region, *rom;
6161   const rom_source *source;
6262   audit_record *record;
r9023r9024
6767
6868   /* determine the number of records we will generate */
6969   records = 0;
70   for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source))
70   bool source_is_gamedrv = true;
71   for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
7172   {
72      int source_is_gamedrv = rom_source_is_gamedrv(gamedrv, source);
73      for (region = rom_first_region(gamedrv, source); region != NULL; region = rom_next_region(region))
73      for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
7474         for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
7575            if (ROMREGION_ISROMDATA(region) || ROMREGION_ISDISKDATA(region))
7676            {
r9023r9024
8383               }
8484               records++;
8585            }
86
87      source_is_gamedrv = false;
8688   }
8789
8890   if (records > 0)
r9023r9024
9294      record = *audit;
9395
9496      /* iterate over ROM sources and regions */
95      for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source))
97      bool source_is_gamedrv = true;
98      for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
9699      {
97         int source_is_gamedrv = rom_source_is_gamedrv(gamedrv, source);
98         for (region = rom_first_region(gamedrv, source); region != NULL; region = rom_next_region(region))
100         for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
99101         {
100102            const char *regiontag = ROMREGION_ISLOADBYNAME(region) ? ROM_GETNAME(region) : NULL;
101103            for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
r9023r9024
123125               record++;
124126            }
125127         }
128         source_is_gamedrv = false;
126129      }
127130   }
128131
r9023r9024
134137      records = 0;
135138   }
136139
137   global_free(config);
138140   return records;
139141}
140142
r9023r9024
146148
147149int audit_samples(core_options *options, const game_driver *gamedrv, audit_record **audit)
148150{
149   machine_config *config = global_alloc(machine_config(gamedrv->machine_config));
151   machine_config config(*gamedrv);
150152   audit_record *record;
151153   int records = 0;
152154   int sampnum;
153155
154156   /* count the number of sample records attached to this driver */
155157   const device_config_sound_interface *sound = NULL;
156   for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
158   for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound))
157159      if (sound->devconfig().type() == SAMPLES)
158160      {
159161         const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config();
r9023r9024
176178   record = *audit;
177179
178180   /* now iterate over sample entries */
179   for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
181   for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound))
180182      if (sound->devconfig().type() == SAMPLES)
181183      {
182184         const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config();
r9023r9024
219221      }
220222
221223skip:
222   global_free(config);
223224   return records;
224225}
225226
r9023r9024
524525   /* iterate up the parent chain */
525526   for (drv = driver_get_clone(gamedrv); drv != NULL; drv = driver_get_clone(drv))
526527   {
528      machine_config config(*drv);
527529      const rom_entry *region;
528530      const rom_entry *rom;
529531
530532      /* see if the parent has the same ROM or not */
531      for (region = rom_first_region(drv, NULL); region; region = rom_next_region(region))
532         for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
533            if (hash_data_is_equal(ROM_GETHASHDATA(rom), hash, 0))
534            {
535               if (parent != NULL)
536                  *parent = drv;
537               return TRUE;
538            }
533      for (const rom_source *source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
534         for (region = rom_first_region(*source); region; region = rom_next_region(region))
535            for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
536               if (hash_data_is_equal(ROM_GETHASHDATA(rom), hash, 0))
537               {
538                  if (parent != NULL)
539                     *parent = drv;
540                  return TRUE;
541               }
539542   }
540543
541544   return FALSE;
src/emu/mame.c
r9023r9024
189189      }
190190
191191      // create the machine configuration
192      const machine_config *config = global_alloc(machine_config(driver->machine_config));
192      const machine_config *config = global_alloc(machine_config(*driver));
193193
194194      // create the machine structure and driver
195      running_machine *machine = global_alloc(running_machine(*driver, *config, *options, started_empty));
195      running_machine *machine = global_alloc(running_machine(*config, *options, started_empty));
196196
197197      // looooong term: remove this
198198      global_machine = machine;
r9023r9024
519519#ifndef MESS
520520      const game_driver *parent = driver_get_clone(driver);
521521      const game_driver *gparent = (parent != NULL) ? driver_get_clone(parent) : NULL;
522      machine_config *config;
523522
524523      /* parse "vertical.ini" or "horizont.ini" */
525524      if (driver->flags & ORIENTATION_SWAP_XY)
r9023r9024
528527         parse_ini_file(options, "horizont", OPTION_PRIORITY_ORIENTATION_INI);
529528
530529      /* parse "vector.ini" for vector games */
531      config = global_alloc(machine_config(driver->machine_config));
532      for (const screen_device_config *devconfig = screen_first(*config); devconfig != NULL; devconfig = screen_next(devconfig))
533         if (devconfig->screen_type() == SCREEN_TYPE_VECTOR)
534         {
535            parse_ini_file(options, "vector", OPTION_PRIORITY_VECTOR_INI);
536            break;
537         }
538      global_free(config);
530      {
531         machine_config config(*driver);
532         for (const screen_device_config *devconfig = screen_first(config); devconfig != NULL; devconfig = screen_next(devconfig))
533            if (devconfig->screen_type() == SCREEN_TYPE_VECTOR)
534            {
535               parse_ini_file(options, "vector", OPTION_PRIORITY_VECTOR_INI);
536               break;
537            }
538      }
539539
540540      /* next parse "source/<sourcefile>.ini"; if that doesn't exist, try <sourcefile>.ini */
541541      astring sourcename;
src/emu/mconfig.c
r9023r9024
4949//  machine_config - constructor
5050//-------------------------------------------------
5151
52machine_config::machine_config(machine_config_constructor constructor)
52machine_config::machine_config(const game_driver &gamedrv)
5353   : m_minimum_quantum(attotime_zero),
5454     m_perfect_cpu_quantum(NULL),
5555     m_watchdog_vblank_count(0),
r9023r9024
6060     m_gfxdecodeinfo(NULL),
6161     m_total_colors(0),
6262     m_default_layout(NULL),
63     m_gamedrv(gamedrv),
6364     m_parse_level(0)
6465{
6566   // construct the config
66   (*constructor)(*this, NULL);
67   (*gamedrv.machine_config)(*this, NULL);
68   
69   // when finished, set the game driver
70   device_config *config = m_devicelist.find("root");
71   if (config == NULL)
72      throw emu_fatalerror("Machine configuration missing driver_device");
73   driver_device_config_base::static_set_game(config, &gamedrv);
6774
6875   // process any device-specific machine configurations
6976   for (device_config *devconfig = m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
src/emu/dimemory.c
r9023r9024
248248            {
249249               // look for the region
250250               bool found = false;
251               for (const rom_source *source = rom_first_source(&driver, &m_machine_config); source != NULL && !found; source = rom_next_source(&driver, &m_machine_config, source))
252                  for (const rom_entry *romp = rom_first_region(&driver, source); !ROMENTRY_ISEND(romp) && !found; romp++)
251               for (const rom_source *source = rom_first_source(m_machine_config); source != NULL && !found; source = rom_next_source(*source))
252                  for (const rom_entry *romp = rom_first_region(*source); !ROMENTRY_ISEND(romp) && !found; romp++)
253253                  {
254254                     const char *regiontag = ROMREGION_GETTAG(romp);
255255                     if (regiontag != NULL)
r9023r9024
295295//              }
296296
297297            // validate bank and share tags
298            if (entry->m_read.m_type == AMH_BANK && !validate_tag(&driver, "bank", entry->m_read.m_tag))
298            if (entry->m_read.m_type == AMH_BANK && !validate_tag(driver, "bank", entry->m_read.m_tag))
299299               error = true ;
300            if (entry->m_write.m_type == AMH_BANK && !validate_tag(&driver, "bank", entry->m_write.m_tag))
300            if (entry->m_write.m_type == AMH_BANK && !validate_tag(driver, "bank", entry->m_write.m_tag))
301301               error = true;
302            if (entry->m_share != NULL && !validate_tag(&driver, "share", entry->m_share))
302            if (entry->m_share != NULL && !validate_tag(driver, "share", entry->m_share))
303303               error = true;
304304         }
305305
src/emu/mconfig.h
r9023r9024
124124   friend class running_machine;
125125
126126public:
127   machine_config(machine_config_constructor constructor);
127   machine_config(const game_driver &gamedrv);
128128   ~machine_config();
129   
130   const game_driver &gamedrv() const { return m_gamedrv; }
129131
130132   attotime            m_minimum_quantum;         // minimum scheduling quantum
131133   const char *         m_perfect_cpu_quantum;      // tag of CPU to use for "perfect" scheduling
r9023r9024
149151   device_config *device_find(device_config *owner, const char *tag);
150152
151153private:
154   const game_driver &      m_gamedrv;
152155   int                  m_parse_level;            // nested parsing level
153156};
154157
src/mess/devices/cartslot.c
r9023r9024
153153   const rom_entry *romrgn, *roment;
154154   int result = 0;
155155
156   for (source = rom_first_source(image->device().machine->gamedrv, image->device().machine->config); source != NULL; source = rom_next_source(image->device().machine->gamedrv, image->device().machine->config, source))
156   for (source = rom_first_source(*image->device().machine->config); source != NULL; source = rom_next_source(*source))
157157   {
158      for (romrgn = rom_first_region(image->device().machine->gamedrv, source); romrgn != NULL; romrgn = rom_next_region(romrgn))
158      for (romrgn = rom_first_region(*source); romrgn != NULL; romrgn = rom_next_region(romrgn))
159159      {
160160         roment = romrgn + 1;
161161         while(!ROMENTRY_ISREGIONEND(roment))
src/mess/osd/winui/messui.c
r9023r9024
454454   SoftwareList_SetDriver(hwndSoftwareList, s_config);
455455
456456   /* allocate the machine config */
457   machine_config *config = global_alloc(machine_config( drivers[drvindex]->machine_config ));
457   machine_config config(*drivers[drvindex]);
458458
459459   core_options *options = mame_options_init(NULL);
460   for (const device_config *dev = config->m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
460   for (const device_config *dev = config.m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
461461   {
462462      software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config();
463463
r9023r9024
475475                  software_part *part = software_find_part(swinfo, NULL, NULL);
476476
477477                  // search for a device with the right interface
478                  for (bool gotone = config->m_devicelist.first(image); gotone; gotone = image->next(image))
478                  for (bool gotone = config.m_devicelist.first(image); gotone; gotone = image->next(image))
479479                  {
480480                     const char *interface = image->image_interface();
481481                     if (interface != NULL)
r9023r9024
493493         }
494494      }
495495   }
496
497   /* free the machine config */
498   global_free( config );
499496}
500497
501498
r9023r9024
510507
511508BOOL MessApproveImageList(HWND hParent, int drvindex)
512509{
513   machine_config *config;
514510   const device_config_image_interface *dev;
515511   char szMessage[256];
516512   LPCSTR pszSoftware;
r9023r9024
520516      return TRUE;
521517   }
522518   // allocate the machine config
523   config = global_alloc(machine_config(drivers[drvindex]->machine_config));
519   machine_config config(*drivers[drvindex]);
524520
525   for (bool gotone = config->m_devicelist.first(dev); gotone; gotone = dev->next(dev))
521   for (bool gotone = config.m_devicelist.first(dev); gotone; gotone = dev->next(dev))
526522   {
527523      // confirm any mandatory devices are loaded
528524      if (dev->must_be_loaded())
529525      {
530         pszSoftware = GetSelectedSoftware(drvindex, config, dev);
526         pszSoftware = GetSelectedSoftware(drvindex, &config, dev);
531527         if (!pszSoftware || !*pszSoftware)
532528         {
533529            snprintf(szMessage, ARRAY_LENGTH(szMessage),
r9023r9024
546542      win_message_box_utf8(hParent, szMessage, MAMEUINAME, MB_OK);
547543   }
548544
549   global_free(config);
550545   return bResult;
551546}
552547
r9023r9024
924919   int drvindex;
925920   HWND hwndList;
926921   char* utf8_filename;
927   machine_config *config;
928922   BOOL cfd_res;
929923
930924//  begin_resource_tracking();
r9023r9024
933927   drvindex = Picker_GetSelectedItem(hwndList);
934928
935929   // allocate the machine config
936   config = global_alloc(machine_config(drivers[drvindex]->machine_config));
930   machine_config config(*drivers[drvindex]);
937931
938   SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
939   cfd_res = CommonFileImageDialog(last_directory, cfd, filename, config, imagetypes);
932   SetupImageTypes(&config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
933   cfd_res = CommonFileImageDialog(last_directory, cfd, filename, &config, imagetypes);
940934   CleanupImageTypes(imagetypes, ARRAY_LENGTH(imagetypes));
941935
942936   if (cfd_res)
r9023r9024
948942      SoftwarePicker_AddFile(GetDlgItem(GetMainWindow(), IDC_SWLIST), utf8_filename);
949943      osd_free(utf8_filename);
950944   }
951
952   global_free(config);
953945}
954946
955947
src/mess/osd/winui/msuiutil.c
r9023r9024
88
99BOOL DriverIsComputer(int driver_index)
1010{
11   machine_config *config;
1211   ioport_list portlist;
13   config = global_alloc(machine_config(drivers[driver_index]->machine_config));
1412   input_port_list_init(portlist, drivers[driver_index]->ipt, NULL, 0, FALSE);
1513
1614   const input_field_config *field;
r9023r9024
2624            break;
2725      }
2826   }
29   global_free(config);
3027
3128   return has_keyboard;
3229}
r9023r9024
3936BOOL DriverHasDevice(const game_driver *gamedrv, iodevice_t type)
4037{
4138   BOOL b = FALSE;
42   machine_config *config;
4339   const device_config_image_interface *device;
4440
4541   // allocate the machine config
46   config = global_alloc(machine_config(gamedrv->machine_config));
42   machine_config config(*gamedrv);
4743
48   for (bool gotone = config->m_devicelist.first(device); gotone; gotone = device->next(device))
44   for (bool gotone = config.m_devicelist.first(device); gotone; gotone = device->next(device))
4945   {
5046      if (device->image_type() == type)
5147      {
r9023r9024
5349         break;
5450      }
5551   }
56
57   global_free(config);
5852   return b;
5953}
6054
src/mess/osd/winui/swconfig.c
r9023r9024
2121   memset(config,0,sizeof(software_config));
2222
2323   // allocate the machine config
24   config->mconfig = global_alloc(machine_config(drivers[driver_index]->machine_config));
24   config->mconfig = global_alloc(machine_config(*drivers[driver_index]));
2525
2626   // allocate the hash file
2727   driver = drivers[driver_index];
src/mess/osd/winui/propertiesms.c
r9023r9024
392392   UINT32 ram, current_ram;
393393   const char *this_ram_string;
394394   TCHAR* t_ramstring;
395   machine_config *cfg;
396395   const device_config *device;
397396
398397   // identify the driver
r9023r9024
403402   (void)ComboBox_ResetContent(control);
404403
405404   // allocate the machine config
406   cfg = global_alloc(machine_config(gamedrv->machine_config));
405   machine_config cfg(*gamedrv);
407406
408407   // identify how many options that we have
409   device = cfg->m_devicelist.first(MESSRAM);
408   device = cfg.m_devicelist.first(MESSRAM);
410409
411410   EnableWindow(control, (device != NULL));
412411   i = 0;
r9023r9024
482481      // set the combo box
483482      (void)ComboBox_SetCurSel(control, current_index);
484483   }
485   if (cfg != NULL)
486   {
487      /* Free the structure */
488      global_free(cfg);
489   }
490484   return TRUE;
491485}
492486
src/mess/mess.c
r9023r9024
5858 *************************************/
5959
6060/* device iteration helpers */
61#define ram_first(config)            (config)->m_devicelist.first(MESSRAM)
61#define ram_first(config)            (config).m_devicelist.first(MESSRAM)
6262#define ram_next(previous)            ((previous)->typenext())
6363
6464/*-------------------------------------------------
6565    print_game_ramoptions - prints out all RAM
6666    options for this system
6767-------------------------------------------------*/
68static void print_game_ramoptions(FILE *out, const game_driver *game, const machine_config *config)
68static void print_game_ramoptions(FILE *out, const game_driver *game, const machine_config &config)
6969{
7070   const device_config *device;
7171
r9023r9024
104104    information.
105105-------------------------------------------------*/
106106
107void print_mess_game_xml(FILE *out, const game_driver *game, const machine_config *config)
107void print_mess_game_xml(FILE *out, const game_driver *game, const machine_config &config)
108108{
109109   print_game_ramoptions( out, game, config );
110110}
src/mess/mess.h
r9023r9024
8080void mess_display_help(void);
8181
8282/* code used by print_mame_xml() */
83void print_mess_game_xml(FILE *out, const game_driver *game, const machine_config *config);
83void print_mess_game_xml(FILE *out, const game_driver *game, const machine_config &config);
8484
8585/* initialize MESS specific options (called from MAME core) */
8686void mess_options_init(core_options *opts);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team