int cli_info_listsamples(core_options *options, const char *gamename) { int count = 0; #if (HAS_SAMPLES) int drvindex; /* since we expand the machine driver, we need to set things up */ init_resource_tracking(); cpuintrf_init(NULL); sndintrf_init(NULL); /* iterate over drivers */ for (drvindex = 0; drivers[drvindex]; drvindex++) if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0) { machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config); int sndnum; /* find samples interfaces */ for (sndnum = 0; sndnum < MAX_SOUND && config->sound[sndnum].type != SOUND_DUMMY; sndnum++) if (config->sound[sndnum].type == SOUND_SAMPLES) { const char *const *samplenames = ((const struct Samplesinterface *)config->sound[sndnum].config)->samplenames; int sampnum; /* if the list is legit, walk it and print the sample info */ if (samplenames != NULL) for (sampnum = 0; samplenames[sampnum] != NULL; sampnum++) mame_printf_info("%s\n", samplenames[sampnum]); } count++; machine_config_free(config); } /* clean up our tracked resources */ exit_resource_tracking(); #else mame_printf_error("Samples not supported in this build\n"); #endif return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME; }
static void print_game_info(FILE *out, const game_driver *game) { const input_port_config *portconfig; const game_driver *clone_of; machine_config *config; const char *start; /* no action if not a game */ if (game->flags & GAME_NO_STANDALONE) return; /* start tracking resources and allocate the machine and input configs */ config = machine_config_alloc(game->machine_config); #ifdef MESS /* temporary hook until MESS device transition is complete */ mess_devices_setup(NULL, config, game); #endif /* MESS */ portconfig = input_port_config_alloc(game->ipt, NULL, 0); /* print the header and the game name */ fprintf(out, "\t<" XML_TOP); fprintf(out, " name=\"%s\"", xml_normalize_string(game->name) ); /* strip away any path information from the source_file and output it */ start = strrchr(game->source_file, '/'); if (start == NULL) start = strrchr(game->source_file, '\\'); if (start == NULL) start = game->source_file - 1; fprintf(out, " sourcefile=\"%s\"", xml_normalize_string(start + 1)); /* append bios and runnable flags */ if (game->flags & GAME_IS_BIOS_ROOT) fprintf(out, " isbios=\"yes\""); if (game->flags & GAME_NO_STANDALONE) fprintf(out, " runnable=\"no\""); /* display clone information */ clone_of = driver_get_clone(game); if (clone_of != NULL && !(clone_of->flags & GAME_IS_BIOS_ROOT)) fprintf(out, " cloneof=\"%s\"", xml_normalize_string(clone_of->name)); if (clone_of != NULL) fprintf(out, " romof=\"%s\"", xml_normalize_string(clone_of->name)); /* display sample information and close the game tag */ print_game_sampleof(out, game, config); fprintf(out, ">\n"); /* output game description */ if (game->description != NULL) fprintf(out, "\t\t<description>%s</description>\n", xml_normalize_string(game->description)); /* print the year only if is a number */ if (game->year != NULL && strspn(game->year, "0123456789") == strlen(game->year)) fprintf(out, "\t\t<year>%s</year>\n", xml_normalize_string(game->year)); /* print the manufacturer information */ if (game->manufacturer != NULL) fprintf(out, "\t\t<manufacturer>%s</manufacturer>\n", xml_normalize_string(game->manufacturer)); /* now print various additional information */ print_game_bios(out, game); print_game_rom(out, game, config); print_game_sample(out, game, config); print_game_chips(out, game, config); print_game_display(out, game, config); print_game_sound(out, game, config); print_game_input(out, game, portconfig); print_game_switches(out, game, portconfig); print_game_configs(out, game, portconfig); #ifdef MESS print_game_categories(out, game, portconfig); #endif /* MESS */ print_game_adjusters(out, game, portconfig); print_game_driver(out, game, config); #ifdef MESS print_game_device(out, game, config); print_game_ramoptions(out, game, config); #endif /* MESS */ /* close the topmost tag */ fprintf(out, "\t</" XML_TOP ">\n"); input_port_config_free(portconfig); machine_config_free(config); }
static void print_game_rom(FILE *out, const game_driver *game, const machine_config *config) { const game_driver *clone_of = driver_get_clone(game); int rom_type; machine_config *pconfig = (clone_of != NULL) ? machine_config_alloc(clone_of->machine_config) : NULL; /* iterate over 3 different ROM "types": BIOS, ROMs, DISKs */ for (rom_type = 0; rom_type < 3; rom_type++) { const rom_source *source; const rom_entry *region; /* iterate over ROM sources: first the game, then any devices */ for (source = rom_first_source(game, config); source != NULL; source = rom_next_source(game, config, source)) for (region = rom_first_region(game, source); region != NULL; region = rom_next_region(region)) { int is_disk = ROMREGION_ISDISKDATA(region); const rom_entry *rom; /* disk regions only work for disks */ if ((is_disk && rom_type != 2) || (!is_disk && rom_type == 2)) continue; /* iterate through ROM entries */ for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) { int is_bios = ROM_GETBIOSFLAGS(rom); const char *name = ROM_GETNAME(rom); int offset = ROM_GETOFFSET(rom); const rom_entry *parent_rom = NULL; char bios_name[100]; /* BIOS ROMs only apply to bioses */ if ((is_bios && rom_type != 0) || (!is_bios && rom_type == 0)) continue; /* if we have a valid ROM and we are a clone, see if we can find the parent ROM */ if (!ROM_NOGOODDUMP(rom) && clone_of != NULL) { const rom_source *psource; const rom_entry *pregion, *prom; /* scan the clone_of ROM for a matching ROM entry */ for (psource = rom_first_source(clone_of, pconfig); psource != NULL; psource = rom_next_source(clone_of, pconfig, psource)) for (pregion = rom_first_region(clone_of, psource); pregion != NULL; pregion = rom_next_region(pregion)) for (prom = rom_first_file(pregion); prom != NULL; prom = rom_next_file(prom)) if (hash_data_is_equal(ROM_GETHASHDATA(rom), ROM_GETHASHDATA(prom), 0)) { parent_rom = prom; break; } } /* scan for a BIOS name */ bios_name[0] = 0; if (!is_disk && is_bios) { const rom_entry *brom; /* scan backwards through the ROM entries */ for (brom = rom - 1; brom != game->rom; brom--) if (ROMENTRY_ISSYSTEM_BIOS(brom)) { strcpy(bios_name, ROM_GETNAME(brom)); break; } } /* opening tag */ if (!is_disk) fprintf(out, "\t\t<rom"); else fprintf(out, "\t\t<disk"); /* add name, merge, bios, and size tags */ if (name != NULL && name[0] != 0) fprintf(out, " name=\"%s\"", xml_normalize_string(name)); if (parent_rom != NULL) fprintf(out, " merge=\"%s\"", xml_normalize_string(ROM_GETNAME(parent_rom))); if (bios_name[0] != 0) fprintf(out, " bios=\"%s\"", xml_normalize_string(bios_name)); if (!is_disk) fprintf(out, " size=\"%d\"", rom_file_size(rom)); /* dump checksum information only if there is a known dump */ if (!hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) { char checksum[HASH_BUF_SIZE]; int hashtype; /* iterate over hash function types and print out their values */ for (hashtype = 0; hashtype < HASH_NUM_FUNCTIONS; hashtype++) if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), 1 << hashtype, checksum)) fprintf(out, " %s=\"%s\"", hash_function_name(1 << hashtype), checksum); } /* append a region name */ fprintf(out, " region=\"%s\"", ROMREGION_GETTAG(region)); /* add nodump/baddump flags */ if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) fprintf(out, " status=\"nodump\""); if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP)) fprintf(out, " status=\"baddump\""); /* for non-disk entries, print offset */ if (!is_disk) fprintf(out, " offset=\"%x\"", offset); /* for disk entries, add the disk index */ else fprintf(out, " index=\"%x\"", DISK_GETINDEX(rom)); /* add optional flag */ if ((!is_disk && ROM_ISOPTIONAL(rom)) || (is_disk && DISK_ISOPTIONAL(rom))) fprintf(out, " optional=\"yes\""); fprintf(out, "/>\n"); } } } if (pconfig != NULL) machine_config_free(pconfig); }