void info_xml_creator::output_one_device(device_t &device, const char *devtag) { bool has_speaker = FALSE, has_input = FALSE; // check if the device adds speakers to the system sound_interface_iterator snditer(device); if (snditer.first() != NULL) has_speaker = TRUE; // generate input list ioport_list portlist; std::string errors; device_iterator iptiter(device); for (device_t *dev = iptiter.first(); dev != NULL; dev = iptiter.next()) portlist.append(*dev, errors); // check if the device adds player inputs (other than dsw and configs) to the system for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) if (field->type() >= IPT_START1 && field->type() < IPT_UI_FIRST) { has_input = TRUE; break; } // start to output info fprintf(m_output, "\t<%s", emulator_info::get_xml_top()); fprintf(m_output, " name=\"%s\"", xml_normalize_string(device.shortname())); std::string src(device.source()); strreplace(src,"../", ""); fprintf(m_output, " sourcefile=\"%s\"", xml_normalize_string(src.c_str())); fprintf(m_output, " isdevice=\"yes\""); fprintf(m_output, " runnable=\"no\""); output_sampleof(); fprintf(m_output, ">\n"); fprintf(m_output, "\t\t<description>%s</description>\n", xml_normalize_string(device.name())); output_rom(device); samples_device *samples = dynamic_cast<samples_device*>(&device); if (samples==NULL) output_sample(device); // ignore samples_device itself output_chips(device, devtag); output_display(device, devtag); if (has_speaker) output_sound(device); if (has_input) output_input(portlist); output_switches(portlist, devtag, IPT_DIPSWITCH, "dipswitch", "dipvalue"); output_switches(portlist, devtag, IPT_CONFIG, "configuration", "confsetting"); output_adjusters(portlist); output_images(device, devtag); output_slots(device, devtag); fprintf(m_output, "\t</%s>\n", emulator_info::get_xml_top()); }
void info_xml_creator::output_one() { // no action if not a game const game_driver &driver = m_drivlist.driver(); if (driver.flags & GAME_NO_STANDALONE) return; // allocate input ports machine_config &config = m_drivlist.config(); ioport_list portlist; astring errors; device_iterator iter(config.root_device()); for (device_t *device = iter.first(); device != NULL; device = iter.next()) portlist.append(*device, errors); // print the header and the game name fprintf(m_output, "\t<%s",emulator_info::get_xml_top()); fprintf(m_output, " name=\"%s\"", xml_normalize_string(driver.name)); // strip away any path information from the source_file and output it const char *start = strrchr(driver.source_file, '/'); if (start == NULL) start = strrchr(driver.source_file, '\\'); if (start == NULL) start = driver.source_file - 1; fprintf(m_output, " sourcefile=\"%s\"", xml_normalize_string(start + 1)); // append bios and runnable flags if (driver.flags & GAME_IS_BIOS_ROOT) fprintf(m_output, " isbios=\"yes\""); if (driver.flags & GAME_NO_STANDALONE) fprintf(m_output, " runnable=\"no\""); if (driver.flags & GAME_MECHANICAL) fprintf(m_output, " ismechanical=\"yes\""); // display clone information int clone_of = m_drivlist.find(driver.parent); if (clone_of != -1 && !(m_drivlist.driver(clone_of).flags & GAME_IS_BIOS_ROOT)) fprintf(m_output, " cloneof=\"%s\"", xml_normalize_string(m_drivlist.driver(clone_of).name)); if (clone_of != -1) fprintf(m_output, " romof=\"%s\"", xml_normalize_string(m_drivlist.driver(clone_of).name)); // display sample information and close the game tag output_sampleof(); fprintf(m_output, ">\n"); // output game description if (driver.description != NULL) fprintf(m_output, "\t\t<description>%s</description>\n", xml_normalize_string(driver.description)); // print the year only if is a number or another allowed character (? or +) if (driver.year != NULL && strspn(driver.year, "0123456789?+") == strlen(driver.year)) fprintf(m_output, "\t\t<year>%s</year>\n", xml_normalize_string(driver.year)); // print the manufacturer information if (driver.manufacturer != NULL) fprintf(m_output, "\t\t<manufacturer>%s</manufacturer>\n", xml_normalize_string(driver.manufacturer)); // now print various additional information output_bios(); output_rom(m_drivlist.config().root_device()); output_device_roms(); output_sample(m_drivlist.config().root_device()); output_chips(m_drivlist.config().root_device(), ""); output_display(m_drivlist.config().root_device(), ""); output_sound(m_drivlist.config().root_device()); output_input(portlist); output_switches(portlist, "", IPT_DIPSWITCH, "dipswitch", "dipvalue"); output_switches(portlist, "", IPT_CONFIG, "configuration", "confsetting"); output_ports(portlist); output_adjusters(portlist); output_driver(); output_images(m_drivlist.config().root_device(), ""); output_slots(m_drivlist.config().root_device(), ""); output_software_list(); output_ramoptions(); // close the topmost tag fprintf(m_output, "\t</%s>\n",emulator_info::get_xml_top()); }