Previous 15994 Revisions Next

r14580 Wednesday 22nd February, 2012 at 22:50:44 UTC by Fabio Priuli
info.c: several fixes and additions to listxml output [Fabio Priuli]
- appended to xml info about devices which can be optionally mounted to slots
- added a description attribute to slotoption to show which devices can be mounted
in each slot
- added to xml info of cpus/inputs/image/slots which are relative to devices (e.g. CPUs
or Dipswitches in the device itself)
- tags of elements directly attached to the root_device do not display anymore the
root colon (slot tags were already behaving in this way); elements attached to optional
devices use tags starting with colon (to be interpreted as a relative tags which gets
appended to the device tag, when such a device is selected in a slot)
- modified when necessary output routines to pass a root_device and a root_tag as
parameters, in order to simplify output of relative devices and avoid duplicated code
- updated DTD according to the new elements and attributes
These changes allow frontends to know in advance how drivers can be configured
through the various slot options (by matching option descriptions with device
descriptions), without the need to run -lx with the various slot combinations. This is
especially of use if a device adds e.g. dipswitches or image devices (for instance, additional
floppy drives or additional slot expansions, like in the case of IQ151 whose default
config do not supports disks even if the system has a floppy softlist), but also if one wants
to know e.g. how many sound channels a soundcard would add to a pc driver, or which
kind of screen parameters would be added by a specific choice of video card.
[src/emu]info.c info.h

src/emu/info.c
r14579r14580
179179"\t\t\t<!ATTLIST slot name CDATA #REQUIRED>\n"
180180"\t\t\t<!ELEMENT slotoption EMPTY>\n"
181181"\t\t\t\t<!ATTLIST slotoption name CDATA #REQUIRED>\n"
182"\t\t\t\t<!ATTLIST slotoption description CDATA #REQUIRED>\n"
182183"\t\t\t\t<!ATTLIST slotoption default (yes|no) \"no\">\n"
183184"\t\t<!ELEMENT softwarelist EMPTY>\n"
184185"\t\t\t<!ATTLIST softwarelist name CDATA #REQUIRED>\n"
r14579r14580
186187"\t\t\t<!ATTLIST softwarelist filter CDATA #IMPLIED>\n"
187188"\t\t<!ELEMENT ramoption (#PCDATA)>\n"
188189"\t\t\t<!ATTLIST ramoption default CDATA #IMPLIED>\n"
190"\t<!ELEMENT device (description, rom*, chip*, display*, sound?, input?, dipswitch*, configuration*, adjuster*, device*, slot*)>\n"
191"\t\t<!ATTLIST device name CDATA #IMPLIED>\n"
192"\t\t<!ELEMENT description (#PCDATA)>\n"
193"\t\t<!ELEMENT rom EMPTY>\n"
194"\t\t\t<!ATTLIST rom name CDATA #REQUIRED>\n"
195"\t\t\t<!ATTLIST rom bios CDATA #IMPLIED>\n"
196"\t\t\t<!ATTLIST rom size CDATA #REQUIRED>\n"
197"\t\t\t<!ATTLIST rom crc CDATA #IMPLIED>\n"
198"\t\t\t<!ATTLIST rom sha1 CDATA #IMPLIED>\n"
199"\t\t\t<!ATTLIST rom merge CDATA #IMPLIED>\n"
200"\t\t\t<!ATTLIST rom region CDATA #IMPLIED>\n"
201"\t\t\t<!ATTLIST rom offset CDATA #IMPLIED>\n"
202"\t\t\t<!ATTLIST rom status (baddump|nodump|good) \"good\">\n"
203"\t\t\t<!ATTLIST rom optional (yes|no) \"no\">\n"
204"\t\t<!ELEMENT chip EMPTY>\n"
205"\t\t\t<!ATTLIST chip name CDATA #REQUIRED>\n"
206"\t\t\t<!ATTLIST chip tag CDATA #IMPLIED>\n"
207"\t\t\t<!ATTLIST chip type (cpu|audio) #REQUIRED>\n"
208"\t\t\t<!ATTLIST chip clock CDATA #IMPLIED>\n"
209"\t\t<!ELEMENT display EMPTY>\n"
210"\t\t\t<!ATTLIST display type (raster|vector|lcd|unknown) #REQUIRED>\n"
211"\t\t\t<!ATTLIST display rotate (0|90|180|270) #REQUIRED>\n"
212"\t\t\t<!ATTLIST display flipx (yes|no) \"no\">\n"
213"\t\t\t<!ATTLIST display width CDATA #IMPLIED>\n"
214"\t\t\t<!ATTLIST display height CDATA #IMPLIED>\n"
215"\t\t\t<!ATTLIST display refresh CDATA #REQUIRED>\n"
216"\t\t\t<!ATTLIST display pixclock CDATA #IMPLIED>\n"
217"\t\t\t<!ATTLIST display htotal CDATA #IMPLIED>\n"
218"\t\t\t<!ATTLIST display hbend CDATA #IMPLIED>\n"
219"\t\t\t<!ATTLIST display hbstart CDATA #IMPLIED>\n"
220"\t\t\t<!ATTLIST display vtotal CDATA #IMPLIED>\n"
221"\t\t\t<!ATTLIST display vbend CDATA #IMPLIED>\n"
222"\t\t\t<!ATTLIST display vbstart CDATA #IMPLIED>\n"
223"\t\t<!ELEMENT sound EMPTY>\n"
224"\t\t\t<!ATTLIST sound channels CDATA #REQUIRED>\n"
225"\t\t<!ELEMENT input (control*)>\n"
226"\t\t\t<!ATTLIST input service (yes|no) \"no\">\n"
227"\t\t\t<!ATTLIST input tilt (yes|no) \"no\">\n"
228"\t\t\t<!ATTLIST input players CDATA #REQUIRED>\n"
229"\t\t\t<!ATTLIST input buttons CDATA #IMPLIED>\n"
230"\t\t\t<!ATTLIST input coins CDATA #IMPLIED>\n"
231"\t\t\t<!ELEMENT control EMPTY>\n"
232"\t\t\t\t<!ATTLIST control type CDATA #REQUIRED>\n"
233"\t\t\t\t<!ATTLIST control minimum CDATA #IMPLIED>\n"
234"\t\t\t\t<!ATTLIST control maximum CDATA #IMPLIED>\n"
235"\t\t\t\t<!ATTLIST control sensitivity CDATA #IMPLIED>\n"
236"\t\t\t\t<!ATTLIST control keydelta CDATA #IMPLIED>\n"
237"\t\t\t\t<!ATTLIST control reverse (yes|no) \"no\">\n"
238"\t\t\t\t<!ATTLIST control ways CDATA #IMPLIED>\n"
239"\t\t\t\t<!ATTLIST control ways2 CDATA #IMPLIED>\n"
240"\t\t\t\t<!ATTLIST control ways3 CDATA #IMPLIED>\n"
241"\t\t<!ELEMENT dipswitch (dipvalue*)>\n"
242"\t\t\t<!ATTLIST dipswitch name CDATA #REQUIRED>\n"
243"\t\t\t<!ATTLIST dipswitch tag CDATA #REQUIRED>\n"
244"\t\t\t<!ATTLIST dipswitch mask CDATA #REQUIRED>\n"
245"\t\t\t<!ELEMENT dipvalue EMPTY>\n"
246"\t\t\t\t<!ATTLIST dipvalue name CDATA #REQUIRED>\n"
247"\t\t\t\t<!ATTLIST dipvalue value CDATA #REQUIRED>\n"
248"\t\t\t\t<!ATTLIST dipvalue default (yes|no) \"no\">\n"
249"\t\t<!ELEMENT configuration (confsetting*)>\n"
250"\t\t\t<!ATTLIST configuration name CDATA #REQUIRED>\n"
251"\t\t\t<!ATTLIST configuration tag CDATA #REQUIRED>\n"
252"\t\t\t<!ATTLIST configuration mask CDATA #REQUIRED>\n"
253"\t\t\t<!ELEMENT confsetting EMPTY>\n"
254"\t\t\t\t<!ATTLIST confsetting name CDATA #REQUIRED>\n"
255"\t\t\t\t<!ATTLIST confsetting value CDATA #REQUIRED>\n"
256"\t\t\t\t<!ATTLIST confsetting default (yes|no) \"no\">\n"
257"\t\t<!ELEMENT adjuster EMPTY>\n"
258"\t\t\t<!ATTLIST adjuster name CDATA #REQUIRED>\n"
259"\t\t\t<!ATTLIST adjuster default CDATA #REQUIRED>\n"
260"\t\t<!ELEMENT device (instance*, extension*)>\n"
261"\t\t\t<!ATTLIST device type CDATA #REQUIRED>\n"
262"\t\t\t<!ATTLIST device tag CDATA #IMPLIED>\n"
263"\t\t\t<!ATTLIST device mandatory CDATA #IMPLIED>\n"
264"\t\t\t<!ATTLIST device interface CDATA #IMPLIED>\n"
265"\t\t\t<!ELEMENT instance EMPTY>\n"
266"\t\t\t\t<!ATTLIST instance name CDATA #REQUIRED>\n"
267"\t\t\t\t<!ATTLIST instance briefname CDATA #REQUIRED>\n"
268"\t\t\t<!ELEMENT extension EMPTY>\n"
269"\t\t\t\t<!ATTLIST extension name CDATA #REQUIRED>\n"
270"\t\t<!ELEMENT slot (slotoption*)>\n"
271"\t\t\t<!ATTLIST slot name CDATA #REQUIRED>\n"
272"\t\t\t<!ELEMENT slotoption EMPTY>\n"
273"\t\t\t\t<!ATTLIST slotoption name CDATA #REQUIRED>\n"
274"\t\t\t\t<!ATTLIST slotoption description CDATA #REQUIRED>\n"
275"\t\t\t\t<!ATTLIST slotoption default (yes|no) \"no\">\n"
189276"]>";
190277
191278
192extern const device_type *s_devices_sorted[];
193extern int m_device_count;
194
195279//**************************************************************************
196280//  INFO XML CREATOR
197281//**************************************************************************
r14579r14580
239323      CONFIG_VERSION
240324   );
241325
242   m_device_used.resize(m_device_count);
243   memset(m_device_used, 0, m_device_count);
244
245326   // iterate through the drivers, outputting one at a time
246327   while (m_drivlist.next())
247328      output_one();
248329
249   // iterate through the devices, and output their roms
330   // output devices (both devices with roms and slot devices)
250331   output_devices();
251332
252333   // close the top level tag
r14579r14580
255336
256337
257338//-------------------------------------------------
258//  output_devices - print the XML information
259//  for one particular game driver
260//-------------------------------------------------
261
262void info_xml_creator::output_devices()
263{
264   m_drivlist.reset();
265   m_drivlist.next();
266   machine_config &config = m_drivlist.config();
267   device_t &owner = config.root_device();
268
269   // check if all are listed, note that empty one is included
270   bool display_all = (driver_list::total() == m_drivlist.count() + 1);
271   for (int devnum = 0; devnum < m_device_count; devnum++)
272   {
273      if (display_all || m_device_used[devnum])
274      {
275         device_type type = *s_devices_sorted[devnum];
276         device_t *dev = (*type)(config, "dummy", &owner, 0);
277         dev->config_complete();
278
279         // print the header and the game name
280         fprintf(m_output, "\t<%s", emulator_info::get_xml_top());
281         fprintf(m_output, " name=\"%s\"", xml_normalize_string(dev->shortname()));
282         fprintf(m_output, " isdevice=\"yes\"");
283         fprintf(m_output, " runnable=\"no\"");
284         fprintf(m_output, ">\n");
285
286         // output device description
287         if (dev->name() != NULL)
288            fprintf(m_output, "\t\t<description>%s</description>\n", xml_normalize_string(dev->name()));
289
290         output_rom(*dev);
291
292         // close the topmost tag
293         fprintf(m_output, "\t</%s>\n", emulator_info::get_xml_top());
294         global_free(dev);
295      }
296   }
297}
298
299
300//-------------------------------------------------
301339//  output_one - print the XML information
302340//  for one particular game driver
303341//-------------------------------------------------
r14579r14580
365403   output_rom(m_drivlist.config().root_device());
366404   output_device_roms();
367405   output_sample();
368   output_chips();
369   output_display();
370   output_sound();
406   output_chips(m_drivlist.config().root_device(), "");
407   output_display(m_drivlist.config().root_device());
408   output_sound(m_drivlist.config().root_device());
371409   output_input(portlist);
372   output_switches(portlist, IPT_DIPSWITCH, "dipswitch", "dipvalue");
373   output_switches(portlist, IPT_CONFIG, "configuration", "confsetting");
410   output_switches(portlist, "", IPT_DIPSWITCH, "dipswitch", "dipvalue");
411   output_switches(portlist, "", IPT_CONFIG, "configuration", "confsetting");
374412   output_adjusters(portlist);
375413   output_driver();
376   output_images();
377   output_slots();
414   output_images(m_drivlist.config().root_device(), "");
415   output_slots(m_drivlist.config().root_device(), "");
378416   output_software_list();
379417   output_ramoptions();
380418
r14579r14580
383421}
384422
385423
424//-------------------------------------------------
425//  output_one_device - print the XML info for
426//  a single device
427//-------------------------------------------------
428
429void info_xml_creator::output_one_device(device_t &device, const char *innertag, const char *outertag)
430{
431   bool has_speaker = FALSE, has_input = FALSE;
432   // check if the device adds speakers to the system
433   sound_interface_iterator snditer(device);
434   if (snditer.first() != NULL)
435      has_speaker = TRUE;
436   // generate input list
437   ioport_list portlist;
438   astring errors;
439   device_iterator iptiter(device);
440   for (device_t *dev = iptiter.first(); dev != NULL; dev = iptiter.next())
441      input_port_list_init(*dev, portlist, errors);
442   // check if the device adds player inputs (other than dsw and configs) to the system
443   for (input_port_config *port = portlist.first(); port != NULL; port = port->next())
444      for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next())
445         if (field->type >= IPT_START1 && field->type < __ipt_ui_start)
446         {
447            has_input = TRUE;
448            break;
449         }
450
451   // start to output info
452   fprintf(m_output, "\t<%s", outertag);
453   // TODO: merge handling for devices with roms and other devices
454   if (outertag == emulator_info::get_xml_top())
455   {
456      // it's a device with roms necessary for this configuration
457      fprintf(m_output, " name=\"%s\"", xml_normalize_string(device.shortname()));
458      fprintf(m_output, " isdevice=\"yes\"");
459      fprintf(m_output, " runnable=\"no\"");
460   }
461   else
462   {
463      // it's a generic device
464      astring shrtnm(device.shortname());
465      if (shrtnm.cmp(""))
466         fprintf(m_output, " shortname=\"%s\"", shrtnm.cstr());
467   }
468   fprintf(m_output, ">\n");
469   fprintf(m_output, "\t\t<description>%s</description>\n", xml_normalize_string(device.name()));
470
471   output_rom(device);
472   output_chips(device, innertag);
473   output_display(device);
474   if (has_speaker)
475      output_sound(device);
476   if (has_input)
477      output_input(portlist);
478   output_switches(portlist, innertag, IPT_DIPSWITCH, "dipswitch", "dipvalue");
479   output_switches(portlist, innertag, IPT_CONFIG, "configuration", "confsetting");
480   output_adjusters(portlist);
481   output_images(device, innertag);
482   output_slots(device, innertag);
483   fprintf(m_output, "\t</%s>\n", outertag);
484}
485
486
487//-------------------------------------------------
488//  output_devices - print the XML info for devices
489//  with roms and for devices that can be mounted
490//  in slots
491//-------------------------------------------------
492
493typedef tagmap_t<const game_driver *> slot_map;
494
495void info_xml_creator::output_devices()
496{
497   m_drivlist.reset();
498   slot_map desc;
499   const game_driver &driver = m_drivlist.driver();
500
501   bool display_all = (driver_list::total() == m_drivlist.count() + 1);
502   // first, run through slot devices
503   while (m_drivlist.next())
504   {
505      device_iterator deviter(m_drivlist.config().root_device());
506      deviter.first();
507      for (device_t *device = deviter.next(); device != NULL; device = deviter.next())
508         if (device->rom_region() != NULL && device->shortname()!= NULL)
509         {
510            if (desc.add(device->name(), &driver, FALSE) != TMERR_DUPLICATE)
511               output_one_device(*device, device->tag(), emulator_info::get_xml_top());
512         }
513
514      if (display_all)
515      {
516         slot_interface_iterator iter(m_drivlist.config().root_device());
517         for (const device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next())
518         {
519            const slot_interface* intf = slot->get_slot_interfaces();
520            for (int i = 0; intf && intf[i].name != NULL; i++)
521            {
522               astring temptag("_");
523               temptag.cat(intf[i].name);
524               device_t *dev = const_cast<machine_config &>(m_drivlist.config()).device_add(&m_drivlist.config().root_device(), temptag.cstr(), intf[i].devtype, 0);
525
526               // notify this device and all its subdevices that they are now configured
527               device_iterator subiter(*dev);
528               for (device_t *device = subiter.first(); device != NULL; device = subiter.next())
529                  if (!device->configured())
530                     device->config_complete();
531
532               if (desc.add(dev->name(), &driver, FALSE) != TMERR_DUPLICATE)
533                  output_one_device(*dev, temptag.cstr(), "device");
534
535               const_cast<machine_config &>(m_drivlist.config()).device_remove(&m_drivlist.config().root_device(), temptag.cstr());
536               global_free(dev);
537            }
538         }
539      }
540   }
541}
542
543
386544//------------------------------------------------
387//  output_device_roms - print the device
388//  with roms, if appropriate
545//  output_device_roms - when a driver uses roms
546//  included in a device set, print a reference
389547//-------------------------------------------------
390548
391549void info_xml_creator::output_device_roms()
r14579r14580
393551   device_iterator deviter(m_drivlist.config().root_device());
394552   deviter.first();
395553   for (device_t *device = deviter.next(); device != NULL; device = deviter.next())
396      if (device->rom_region() != NULL && device->shortname()!=NULL)
397      {
554      if (device->owner() != NULL && device->rom_region() != NULL && device->shortname()!= NULL)
398555         fprintf(m_output, "\t\t<device_ref name=\"%s\"/>\n", xml_normalize_string(device->shortname()));
399         for (int devnum = 0; devnum < m_device_count; devnum++)
400            if (device->type() == *s_devices_sorted[devnum])
401               m_device_used[devnum] = 1;
402      }
403556}
404557
405558
r14579r14580
581734    sound chips used by a game
582735-------------------------------------------------*/
583736
584void info_xml_creator::output_chips()
737void info_xml_creator::output_chips(device_t &device, const char *root_tag)
585738{
586739   // iterate over executable devices
587   execute_interface_iterator execiter(m_drivlist.config().root_device());
740   execute_interface_iterator execiter(device);
588741   for (device_execute_interface *exec = execiter.first(); exec != NULL; exec = execiter.next())
589742   {
590      fprintf(m_output, "\t\t<chip");
591      fprintf(m_output, " type=\"cpu\"");
592      fprintf(m_output, " tag=\"%s\"", xml_normalize_string(exec->device().tag()));
593      fprintf(m_output, " name=\"%s\"", xml_normalize_string(exec->device().name()));
594      fprintf(m_output, " clock=\"%d\"", exec->device().clock());
595      fprintf(m_output, "/>\n");
743      if (strcmp(exec->device().tag(), device.tag()))
744      {
745         astring newtag(exec->device().tag()), oldtag(":");
746         newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());
747
748         fprintf(m_output, "\t\t<chip");
749         fprintf(m_output, " type=\"cpu\"");
750         fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));
751         fprintf(m_output, " name=\"%s\"", xml_normalize_string(exec->device().name()));
752         fprintf(m_output, " clock=\"%d\"", exec->device().clock());
753         fprintf(m_output, "/>\n");
754      }
596755   }
597756
598757   // iterate over sound devices
599   sound_interface_iterator sounditer(m_drivlist.config().root_device());
758   sound_interface_iterator sounditer(device);
600759   for (device_sound_interface *sound = sounditer.first(); sound != NULL; sound = sounditer.next())
601760   {
602      fprintf(m_output, "\t\t<chip");
603      fprintf(m_output, " type=\"audio\"");
604      fprintf(m_output, " tag=\"%s\"", xml_normalize_string(sound->device().tag()));
605      fprintf(m_output, " name=\"%s\"", xml_normalize_string(sound->device().name()));
606      if (sound->device().clock() != 0)
607         fprintf(m_output, " clock=\"%d\"", sound->device().clock());
608      fprintf(m_output, "/>\n");
761      if (strcmp(sound->device().tag(), device.tag()))
762      {
763         astring newtag(sound->device().tag()), oldtag(":");
764         newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());
765
766         fprintf(m_output, "\t\t<chip");
767         fprintf(m_output, " type=\"audio\"");
768         fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));
769         fprintf(m_output, " name=\"%s\"", xml_normalize_string(sound->device().name()));
770         if (sound->device().clock() != 0)
771            fprintf(m_output, " clock=\"%d\"", sound->device().clock());
772         fprintf(m_output, "/>\n");
773      }
609774   }
610775}
611776
r14579r14580
615780//  displays
616781//-------------------------------------------------
617782
618void info_xml_creator::output_display()
783void info_xml_creator::output_display(device_t &device)
619784{
620785   // iterate over screens
621   screen_device_iterator iter(m_drivlist.config().root_device());
622   for (const screen_device *device = iter.first(); device != NULL; device = iter.next())
786   screen_device_iterator iter(device);
787   for (const screen_device *screendev = iter.first(); screendev != NULL; screendev = iter.next())
623788   {
624789      fprintf(m_output, "\t\t<display");
625790
626      switch (device->screen_type())
791      switch (screendev->screen_type())
627792      {
628793         case SCREEN_TYPE_RASTER:   fprintf(m_output, " type=\"raster\"");   break;
629794         case SCREEN_TYPE_VECTOR:   fprintf(m_output, " type=\"vector\"");   break;
r14579r14580
661826      }
662827
663828      // output width and height only for games that are not vector
664      if (device->screen_type() != SCREEN_TYPE_VECTOR)
829      if (screendev->screen_type() != SCREEN_TYPE_VECTOR)
665830      {
666         const rectangle &visarea = device->visible_area();
831         const rectangle &visarea = screendev->visible_area();
667832         fprintf(m_output, " width=\"%d\"", visarea.width());
668833         fprintf(m_output, " height=\"%d\"", visarea.height());
669834      }
670835
671836      // output refresh rate
672      fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(device->refresh_attoseconds()));
837      fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds()));
673838
674839      // output raw video parameters only for games that are not vector
675840      // and had raw parameters specified
676      if (device->screen_type() != SCREEN_TYPE_VECTOR && !device->oldstyle_vblank_supplied())
841      if (screendev->screen_type() != SCREEN_TYPE_VECTOR && !screendev->oldstyle_vblank_supplied())
677842      {
678         int pixclock = device->width() * device->height() * ATTOSECONDS_TO_HZ(device->refresh_attoseconds());
843         int pixclock = screendev->width() * screendev->height() * ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds());
679844
680845         fprintf(m_output, " pixclock=\"%d\"", pixclock);
681         fprintf(m_output, " htotal=\"%d\"", device->width());
682         fprintf(m_output, " hbend=\"%d\"", device->visible_area().min_x);
683         fprintf(m_output, " hbstart=\"%d\"", device->visible_area().max_x+1);
684         fprintf(m_output, " vtotal=\"%d\"", device->height());
685         fprintf(m_output, " vbend=\"%d\"", device->visible_area().min_y);
686         fprintf(m_output, " vbstart=\"%d\"", device->visible_area().max_y+1);
846         fprintf(m_output, " htotal=\"%d\"", screendev->width());
847         fprintf(m_output, " hbend=\"%d\"", screendev->visible_area().min_x);
848         fprintf(m_output, " hbstart=\"%d\"", screendev->visible_area().max_x+1);
849         fprintf(m_output, " vtotal=\"%d\"", screendev->height());
850         fprintf(m_output, " vbend=\"%d\"", screendev->visible_area().min_y);
851         fprintf(m_output, " vbstart=\"%d\"", screendev->visible_area().max_y+1);
687852      }
688853      fprintf(m_output, " />\n");
689854   }
r14579r14580
692857
693858//-------------------------------------------------
694859//  output_sound - print a list of all the
695//  displays
860//  speakers
696861//------------------------------------------------
697862
698void info_xml_creator::output_sound()
863void info_xml_creator::output_sound(device_t &device)
699864{
700   speaker_device_iterator spkiter(m_drivlist.config().root_device());
865   speaker_device_iterator spkiter(device);
701866   int speakers = spkiter.count();
702867
703868   // if we have no sound, zero m_output the speaker count
704   sound_interface_iterator snditer(m_drivlist.config().root_device());
869   sound_interface_iterator snditer(device);
705870   if (snditer.first() == NULL)
706871      speakers = 0;
707872
r14579r14580
10131178//  DIP switch settings
10141179//-------------------------------------------------
10151180
1016void info_xml_creator::output_switches(const ioport_list &portlist, int type, const char *outertag, const char *innertag)
1181void info_xml_creator::output_switches(const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *innertag)
10171182{
10181183   // iterate looking for DIP switches
10191184   for (input_port_config *port = portlist.first(); port != NULL; port = port->next())
10201185      for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next())
10211186         if (field->type == type)
10221187         {
1188            astring newtag(field->port().tag()), oldtag(":");
1189            newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());
1190
10231191            // output the switch name information
10241192            fprintf(m_output, "\t\t<%s name=\"%s\"", outertag, xml_normalize_string(input_field_name(field)));
1025            fprintf(m_output, " tag=\"%s\"", xml_normalize_string(field->port().tag()));
1193            fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));
10261194            fprintf(m_output, " mask=\"%u\"", field->mask);
10271195            fprintf(m_output, ">\n");
10281196
r14579r14580
11261294//  image devices
11271295//-------------------------------------------------
11281296
1129void info_xml_creator::output_images()
1297void info_xml_creator::output_images(device_t &device, const char *root_tag)
11301298{
1131   image_interface_iterator iter(m_drivlist.config().root_device());
1132   for (const device_image_interface *dev = iter.first(); dev != NULL; dev = iter.next())
1299   image_interface_iterator iter(device);
1300   for (const device_image_interface *imagedev = iter.first(); imagedev != NULL; imagedev = iter.next())
11331301   {
1134      // print m_output device type
1135      fprintf(m_output, "\t\t<device type=\"%s\"", xml_normalize_string(dev->image_type_name()));
1302      if (strcmp(imagedev->device().tag(), device.tag()))
1303      {
1304         astring newtag(imagedev->device().tag()), oldtag(":");
1305         newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());
11361306
1137      // does this device have a tag?
1138      if (dev->device().tag())
1139         fprintf(m_output, " tag=\"%s\"", xml_normalize_string(dev->device().tag()));
1307         // print m_output device type
1308         fprintf(m_output, "\t\t<device type=\"%s\"", xml_normalize_string(imagedev->image_type_name()));
11401309
1141      // is this device mandatory?
1142      if (dev->must_be_loaded())
1143         fprintf(m_output, " mandatory=\"1\"");
1310         // does this device have a tag?
1311         if (imagedev->device().tag())
1312            fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));
11441313
1145      if (dev->image_interface() && dev->image_interface()[0])
1146         fprintf(m_output, " interface=\"%s\"", xml_normalize_string(dev->image_interface()));
1314         // is this device mandatory?
1315         if (imagedev->must_be_loaded())
1316            fprintf(m_output, " mandatory=\"1\"");
11471317
1148      // close the XML tag
1149      fprintf(m_output, ">\n");
1318         if (imagedev->image_interface() && imagedev->image_interface()[0])
1319            fprintf(m_output, " interface=\"%s\"", xml_normalize_string(imagedev->image_interface()));
11501320
1151      const char *name = dev->instance_name();
1152      const char *shortname = dev->brief_instance_name();
1321         // close the XML tag
1322         fprintf(m_output, ">\n");
11531323
1154      fprintf(m_output, "\t\t\t<instance");
1155      fprintf(m_output, " name=\"%s\"", xml_normalize_string(name));
1156      fprintf(m_output, " briefname=\"%s\"", xml_normalize_string(shortname));
1157      fprintf(m_output, "/>\n");
1324         const char *name = imagedev->instance_name();
1325         const char *shortname = imagedev->brief_instance_name();
11581326
1159      astring extensions(dev->file_extensions());
1327         fprintf(m_output, "\t\t\t<instance");
1328         fprintf(m_output, " name=\"%s\"", xml_normalize_string(name));
1329         fprintf(m_output, " briefname=\"%s\"", xml_normalize_string(shortname));
1330         fprintf(m_output, "/>\n");
11601331
1161      char *ext = strtok((char *)extensions.cstr(), ",");
1162      while (ext != NULL)
1163      {
1164         fprintf(m_output, "\t\t\t<extension");
1165         fprintf(m_output, " name=\"%s\"", xml_normalize_string(ext));
1166         fprintf(m_output, "/>\n");
1167         ext = strtok(NULL, ",");
1332         astring extensions(imagedev->file_extensions());
1333
1334         char *ext = strtok((char *)extensions.cstr(), ",");
1335         while (ext != NULL)
1336         {
1337            fprintf(m_output, "\t\t\t<extension");
1338            fprintf(m_output, " name=\"%s\"", xml_normalize_string(ext));
1339            fprintf(m_output, "/>\n");
1340            ext = strtok(NULL, ",");
1341         }
1342
1343         fprintf(m_output, "\t\t</device>\n");
11681344      }
1169
1170      fprintf(m_output, "\t\t</device>\n");
11711345   }
11721346}
11731347
r14579r14580
11761350//  output_images - prints all info about slots
11771351//-------------------------------------------------
11781352
1179void info_xml_creator::output_slots()
1353void info_xml_creator::output_slots(device_t &device, const char *root_tag)
11801354{
1181   slot_interface_iterator iter(m_drivlist.config().root_device());
1355   slot_interface_iterator iter(device);
11821356   for (const device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next())
11831357   {
1184      // print m_output device type
1185      fprintf(m_output, "\t\t<slot name=\"%s\">\n", xml_normalize_string(slot->device().tag()+1));
1358      if (strcmp(slot->device().tag(), device.tag()))
1359      {
1360         astring newtag(slot->device().tag()), oldtag(":");
1361         newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());
11861362
1187      /*
1188        if (slot->slot_interface()[0])
1189            fprintf(m_output, " interface=\"%s\"", xml_normalize_string(slot->slot_interface()));
1190         */
1363         // print m_output device type
1364         fprintf(m_output, "\t\t<slot name=\"%s\">\n", xml_normalize_string(newtag));
11911365
1192      const slot_interface* intf = slot->get_slot_interfaces();
1193      if (intf)
1194         for (int i = 0; intf[i].name != NULL; i++)
1366         /*
1367             if (slot->slot_interface()[0])
1368             fprintf(m_output, " interface=\"%s\"", xml_normalize_string(slot->slot_interface()));
1369             */
1370
1371         const slot_interface* intf = slot->get_slot_interfaces();
1372         for (int i = 0; intf && intf[i].name != NULL; i++)
11951373         {
1374            device_t *dev = const_cast<machine_config &>(m_drivlist.config()).device_add(&m_drivlist.config().root_device(), "dummy", intf[i].devtype, 0);
11961375            fprintf(m_output, "\t\t\t<slotoption");
11971376            fprintf(m_output, " name=\"%s\"", xml_normalize_string(intf[i].name));
1377            fprintf(m_output, " description=\"%s\"", xml_normalize_string(dev->name()));
11981378            if (slot->get_default_card(m_drivlist.config(), m_drivlist.options()))
11991379            {
12001380               if (slot->get_default_card(m_drivlist.config(), m_drivlist.options()) == intf[i].name)
12011381                  fprintf(m_output, " default=\"yes\"");
12021382            }
12031383            fprintf(m_output, "/>\n");
1384            const_cast<machine_config &>(m_drivlist.config()).device_remove(&m_drivlist.config().root_device(), "dummy");
12041385         }
12051386
1206      fprintf(m_output, "\t\t</slot>\n");
1387         fprintf(m_output, "\t\t</slot>\n");
1388      }
12071389   }
12081390}
12091391
src/emu/info.h
r14579r14580
6565   void output_rom(device_t &device);
6666   void output_device_roms();
6767   void output_sample();
68   void output_chips();
69   void output_display();
70   void output_sound();
68   void output_chips(device_t &device, const char *root_tag);
69   void output_display(device_t &device);
70   void output_sound(device_t &device);
7171   void output_input(const ioport_list &portlist);
72   void output_switches(const ioport_list &portlist, int type, const char *outertag, const char *innertag);
72   void output_switches(const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *innertag);
7373   void output_adjusters(const ioport_list &portlist);
74   void output_categories(const ioport_list &portlist);
7574   void output_driver();
76   void output_images();
77   void output_slots();
75   void output_images(device_t &device, const char *root_tag);
76   void output_slots(device_t &device, const char *root_tag);
7877   void output_software_list();
7978   void output_ramoptions();
8079
80   void output_one_device(device_t &device, const char *innertag, const char *outertag);
8181   void output_devices();
8282
8383   const char *get_merge_name(const hash_collection &romhashes);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team