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; for (device_t *device = config.devicelist().first(); device != NULL; device = device->next()) input_port_list_init(*device, portlist, errors); // print the header and the game name fprintf(m_output, "\t<" 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(); output_sample(); output_chips(); output_display(); output_sound(); output_input(portlist); output_switches(portlist, IPT_DIPSWITCH, "dipswitch", "dipvalue"); output_switches(portlist, IPT_CONFIG, "configuration", "confsetting"); output_categories(portlist); output_adjusters(portlist); output_driver(); output_images(); output_slots(); output_software_list(); output_ramoptions(); // close the topmost tag fprintf(m_output, "\t</" XML_TOP ">\n"); }
static struct DriversInfo* GetDriversInfo(int driver_index) { if (drivers_info == NULL) { int ndriver; drivers_info = (DriversInfo*)malloc(sizeof(struct DriversInfo) * driver_list_get_count(drivers)); for (ndriver = 0; ndriver < driver_list_get_count(drivers); ndriver++) { const game_driver *gamedrv = drivers[ndriver]; struct DriversInfo *gameinfo = &drivers_info[ndriver]; const rom_entry *region, *rom; windows_options pCurrentOpts; load_options(pCurrentOpts, OPTIONS_GLOBAL, driver_index); machine_config config(*gamedrv,pCurrentOpts); const rom_source *source; int num_speakers; gameinfo->isClone = (GetParentRomSetIndex(gamedrv) != -1); gameinfo->isBroken = ((gamedrv->flags & GAME_NOT_WORKING) != 0); gameinfo->supportsSaveState = ((gamedrv->flags & GAME_SUPPORTS_SAVE) != 0); gameinfo->isHarddisk = FALSE; gameinfo->isVertical = (gamedrv->flags & ORIENTATION_SWAP_XY) ? TRUE : FALSE; for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) { for (region = rom_first_region(*source); region; region = rom_next_region(region)) { if (ROMREGION_ISDISKDATA(region)) gameinfo->isHarddisk = TRUE; } } gameinfo->hasOptionalBIOS = FALSE; if (gamedrv->rom != NULL) { for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) { if (ROMENTRY_ISSYSTEM_BIOS(rom)) { gameinfo->hasOptionalBIOS = TRUE; break; } } } num_speakers = numberOfSpeakers(&config); gameinfo->isStereo = (num_speakers > 1); gameinfo->screenCount = numberOfScreens(&config); gameinfo->isVector = isDriverVector(&config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0); gameinfo->usesRoms = FALSE; for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) { for (region = rom_first_region(*source); region; region = rom_next_region(region)) { for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { gameinfo->usesRoms = TRUE; break; } } } gameinfo->usesSamples = FALSE; { const device_config_sound_interface *sound = NULL; const char * const * samplenames = NULL; for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound)) { if (sound->devconfig().type() == SAMPLES) { const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config(); samplenames = intf->samplenames; if (samplenames != 0 && samplenames[0] != 0) { gameinfo->usesSamples = TRUE; break; } } } } gameinfo->usesTrackball = FALSE; gameinfo->usesLightGun = FALSE; if (gamedrv->ipt != NULL) { const input_port_config *port; ioport_list portlist; input_port_list_init(portlist, gamedrv->ipt, NULL, 0, FALSE, NULL); for (device_config *cfg = config.m_devicelist.first(); cfg != NULL; cfg = cfg->next()) { if (cfg->input_ports()!=NULL) { input_port_list_init(portlist, cfg->input_ports(), NULL, 0, FALSE, cfg); } } for (port = portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; for (field = port->fieldlist; field != NULL; field = field->next) { UINT32 type; type = field->type; if (type == IPT_END) break; if (type == IPT_DIAL || type == IPT_PADDLE || type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y) gameinfo->usesTrackball = TRUE; if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y) gameinfo->usesLightGun = TRUE; if (type == IPT_MOUSE_X || type == IPT_MOUSE_Y) gameinfo->usesMouse = TRUE; } } } } } return &drivers_info[driver_index]; }
static void UpdateController(void) { struct control_cache_t *cache; const input_port_token *last_ipt = NULL; BOOL flags[CONTROLLER_MAX]; int nGames = GetNumGames(); int b = 0; int p = 0; int i; cache = (control_cache_t *)malloc(sizeof (*cache) * nGames); if (cache == NULL) return; for (i = 0; i < nGames; i++) { cache[i].ipt = (input_port_token *)drivers[i]->ipt; cache[i].num = i; } qsort(cache, nGames, sizeof (*cache), cmp_ipt); for (i = 0; i < nGames; i++) { struct DriversInfo *gameinfo = &drivers_info[cache[i].num]; if (!cache[i].ipt) continue; if (cache[i].ipt != last_ipt) { const input_port_config *port; ioport_list portlist; int w = CONTROLLER_JOY8WAY; BOOL lr = FALSE; BOOL ud = FALSE; BOOL dual = FALSE; last_ipt = cache[i].ipt; memset(flags, 0, sizeof flags); b = 0; p = 0; input_port_list_init(portlist, last_ipt, NULL, 0, FALSE); for (port = portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; for (field = port->fieldlist; field != NULL; field = field->next) { int n; if (p < field->player + 1) p = field->player + 1; n = field->type - IPT_BUTTON1 + 1; if (n >= 1 && n <= MAX_NORMAL_BUTTONS && n > b) { b = n; continue; } switch (field->type) { case IPT_JOYSTICKRIGHT_LEFT: case IPT_JOYSTICKRIGHT_RIGHT: case IPT_JOYSTICKLEFT_LEFT: case IPT_JOYSTICKLEFT_RIGHT: dual = TRUE; case IPT_JOYSTICK_LEFT: case IPT_JOYSTICK_RIGHT: lr = TRUE; if (field->way == 4) w = CONTROLLER_JOY4WAY; else if (field->way == 16) w = CONTROLLER_JOY16WAY; break; case IPT_JOYSTICKRIGHT_UP: case IPT_JOYSTICKRIGHT_DOWN: case IPT_JOYSTICKLEFT_UP: case IPT_JOYSTICKLEFT_DOWN: dual = TRUE; case IPT_JOYSTICK_UP: case IPT_JOYSTICK_DOWN: ud = TRUE; if (field->way == 4) w = CONTROLLER_JOY4WAY; else if (field->way == 16) w = CONTROLLER_JOY16WAY; break; case IPT_PADDLE: flags[CONTROLLER_PADDLE] = TRUE; break; case IPT_DIAL: flags[CONTROLLER_DIAL] = TRUE; break; case IPT_TRACKBALL_X: case IPT_TRACKBALL_Y: flags[CONTROLLER_TRACKBALL] = TRUE; break; case IPT_AD_STICK_X: case IPT_AD_STICK_Y: flags[CONTROLLER_ADSTICK] = TRUE; break; case IPT_LIGHTGUN_X: case IPT_LIGHTGUN_Y: flags[CONTROLLER_LIGHTGUN] = TRUE; break; case IPT_PEDAL: flags[CONTROLLER_PEDAL] = TRUE; break; } } } //input_port_list_deinit(&portlist); if (lr || ud) { if (lr && !ud) w = CONTROLLER_JOY2WAY; else if (!lr && ud) w = CONTROLLER_VJOY2WAY; if (dual) w += CONTROLLER_DOUBLEJOY2WAY - CONTROLLER_JOY2WAY; flags[w] = TRUE; } } gameinfo->numPlayers = p; gameinfo->numButtons = b; memcpy(gameinfo->usesController, flags, sizeof gameinfo->usesController); } global_free(cache); }
static struct DriversInfo* GetDriversInfo(int driver_index) { if (drivers_info == NULL) { int ndriver; drivers_info = (DriversInfo*)malloc(sizeof(struct DriversInfo) * GetNumGames()); for (ndriver = 0; ndriver < GetNumGames(); ndriver++) { const game_driver *gamedrv = drivers[ndriver]; struct DriversInfo *gameinfo = &drivers_info[ndriver]; const rom_entry *region, *rom; machine_config *config; const rom_source *source; int num_speakers; /* Allocate machine config */ config = global_alloc(machine_config(gamedrv->machine_config)); gameinfo->isClone = (GetParentRomSetIndex(gamedrv) != -1); gameinfo->isBroken = ((gamedrv->flags & GAME_NOT_WORKING) != 0); gameinfo->supportsSaveState = ((gamedrv->flags & GAME_SUPPORTS_SAVE) != 0); gameinfo->isHarddisk = FALSE; gameinfo->isVertical = (gamedrv->flags & ORIENTATION_SWAP_XY) ? TRUE : FALSE; for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source)) { for (region = rom_first_region(gamedrv, source); region; region = rom_next_region(region)) { if (ROMREGION_ISDISKDATA(region)) gameinfo->isHarddisk = TRUE; } } gameinfo->hasOptionalBIOS = FALSE; if (gamedrv->rom != NULL) { for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) { if (ROMENTRY_ISSYSTEM_BIOS(rom)) { gameinfo->hasOptionalBIOS = TRUE; break; } } } num_speakers = numberOfSpeakers(config); gameinfo->isStereo = (num_speakers > 1); gameinfo->screenCount = numberOfScreens(config); gameinfo->isVector = isDriverVector(config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0); gameinfo->usesRoms = FALSE; for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source)) { for (region = rom_first_region(gamedrv, source); region; region = rom_next_region(region)) { for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { gameinfo->usesRoms = TRUE; break; } } } gameinfo->usesSamples = FALSE; { const device_config_sound_interface *sound; const char * const * samplenames = NULL; for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) { if (sound->devconfig().type() == SOUND_SAMPLES) { const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config(); samplenames = intf->samplenames; if (samplenames != 0 && samplenames[0] != 0) { gameinfo->usesSamples = TRUE; break; } } } } gameinfo->numPlayers = 0; gameinfo->numButtons = 0; memset(gameinfo->usesController, 0, sizeof gameinfo->usesController); gameinfo->parentIndex = -1; if (gameinfo->isClone) { int i; for (i = 0; i < GetNumGames(); i++) { if (GetParentRomSetIndex(gamedrv) == i) { gameinfo->parentIndex = i; break; } } } gameinfo->biosIndex = -1; if (DriverIsBios(ndriver)) gameinfo->biosIndex = ndriver; else if (gameinfo->hasOptionalBIOS) { int parentIndex; if (gameinfo->isClone) parentIndex = gameinfo->parentIndex; else parentIndex = ndriver; while (1) { parentIndex = GetGameNameIndex(drivers[parentIndex]->parent); if (parentIndex == -1) { dprintf("bios for %s is not found", drivers[ndriver]->name); break; } if (DriverIsBios(parentIndex)) { gameinfo->biosIndex = parentIndex; break; } } } /* Free the structure */ global_free(config); gameinfo->usesTrackball = FALSE; gameinfo->usesLightGun = FALSE; if (gamedrv->ipt != NULL) { const input_port_config *port; ioport_list portlist; input_port_list_init(portlist, gamedrv->ipt, NULL, 0, FALSE); for (port = portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; for (field = port->fieldlist; field != NULL; field = field->next) { UINT32 type; type = field->type; if (type == IPT_END) break; if (type == IPT_DIAL || type == IPT_PADDLE || type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y) gameinfo->usesTrackball = TRUE; if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y) gameinfo->usesLightGun = TRUE; if (type == IPT_MOUSE_X || type == IPT_MOUSE_Y) gameinfo->usesMouse = TRUE; } } } } UpdateController(); } return &drivers_info[driver_index]; }
static struct DriversInfo* GetDriversInfo(int driver_index) { if (drivers_info == NULL) { UINT16 ndriver; drivers_info = (DriversInfo*)malloc(sizeof(struct DriversInfo) * GetNumGames()); for (ndriver = 0; ndriver < GetNumGames(); ndriver++) { const game_driver *gamedrv = &driver_list::driver(ndriver); struct DriversInfo *gameinfo = &drivers_info[ndriver]; const rom_entry *region, *rom; machine_config config(*gamedrv, MameUIGlobal()); const rom_source *source; int num_speakers; gameinfo->isClone = (GetParentRomSetIndex(gamedrv) != -1); gameinfo->isBroken = ((gamedrv->flags & GAME_NOT_WORKING) != 0); gameinfo->supportsSaveState = ((gamedrv->flags & GAME_SUPPORTS_SAVE) != 0); gameinfo->isHarddisk = FALSE; gameinfo->isVertical = (gamedrv->flags & ORIENTATION_SWAP_XY) ? TRUE : FALSE; for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) for (region = rom_first_region(*source); region; region = rom_next_region(region)) if (ROMREGION_ISDISKDATA(region)) gameinfo->isHarddisk = TRUE; gameinfo->hasOptionalBIOS = FALSE; if (gamedrv->rom != NULL) for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { gameinfo->hasOptionalBIOS = TRUE; break; } num_speakers = numberOfSpeakers(&config); gameinfo->isStereo = (num_speakers > 1); gameinfo->screenCount = numberOfScreens(&config); gameinfo->isVector = isDriverVector(&config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0); gameinfo->usesRoms = FALSE; for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) for (region = rom_first_region(*source); region; region = rom_next_region(region)) for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { gameinfo->usesRoms = TRUE; break; } gameinfo->usesSamples = FALSE; samples_device_iterator iter(config.root_device()); if (iter.first() != NULL) gameinfo->usesSamples = TRUE; gameinfo->numPlayers = 0; gameinfo->numButtons = 0; memset(gameinfo->usesController, 0, sizeof gameinfo->usesController); gameinfo->parentIndex = -1; if (gameinfo->isClone) { int i; for (i = 0; i < GetNumGames(); i++) { if (GetParentRomSetIndex(gamedrv) == i) { gameinfo->parentIndex = i; break; } } } gameinfo->biosIndex = -1; if (DriverIsBios(ndriver)) gameinfo->biosIndex = ndriver; else if (gameinfo->hasOptionalBIOS) { int parentIndex; if (gameinfo->isClone) parentIndex = gameinfo->parentIndex; else parentIndex = ndriver; while (1) { parentIndex = GetGameNameIndex(driver_list::driver(parentIndex).parent); if (parentIndex == -1) { dprintf("bios for %s is not found", driver_list::driver(ndriver).name); break; } if (DriverIsBios(parentIndex)) { gameinfo->biosIndex = parentIndex; break; } } } gameinfo->usesTrackball = FALSE; gameinfo->usesLightGun = FALSE; if (gamedrv->ipt != NULL) { input_port_config *port; ioport_list portlist; astring errors; device_iterator iter(config.root_device()); for (device_t *device = iter.first(); device != NULL; device = iter.next()) if (device->input_ports()!=NULL) input_port_list_init(*device, portlist, errors); for (port = portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; for (field = port->first_field(); field != NULL; field = field->next()) { UINT32 type; type = field->type; if (type == IPT_END) break; if (type == IPT_DIAL || type == IPT_PADDLE || type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y) gameinfo->usesTrackball = TRUE; if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y) gameinfo->usesLightGun = TRUE; if (type == IPT_MOUSE_X || type == IPT_MOUSE_Y) gameinfo->usesMouse = TRUE; } } } } UpdateController(); } return &drivers_info[driver_index]; }