static int open_rom_file(rom_load_data *romdata, const rom_entry *romp) { mame_file_error filerr = FILERR_NOT_FOUND; const game_driver *drv; ++romdata->romsloaded; /* update status display */ display_loading_rom_message(ROM_GETNAME(romp), romdata); /* Attempt reading up the chain through the parents. It automatically also attempts any kind of load by checksum supported by the archives. */ romdata->file = NULL; for (drv = Machine->gamedrv; !romdata->file && drv; drv = driver_get_clone(drv)) if (drv->name && *drv->name) { UINT8 crcs[4]; char *fname; fname = assemble_3_strings(drv->name, PATH_SEPARATOR, ROM_GETNAME(romp)); if (hash_data_extract_binary_checksum(ROM_GETHASHDATA(romp), HASH_CRC, crcs)) { UINT32 crc = (crcs[0] << 24) | (crcs[1] << 16) | (crcs[2] << 8) | crcs[3]; filerr = mame_fopen_crc(SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ, &romdata->file); } else filerr = mame_fopen(SEARCHPATH_ROM, fname, OPEN_FLAG_READ, &romdata->file); free(fname); } /* return the result */ return (filerr == FILERR_NONE); }
file_error common_process_file(emu_options &options, const char *location, const char *ext, const rom_entry *romp, emu_file &image_file) { file_error filerr; if (location != NULL && strcmp(location, "") != 0) filerr = image_file.open(location, PATH_SEPARATOR, ROM_GETNAME(romp), ext); else filerr = image_file.open(ROM_GETNAME(romp), ext); return filerr; }
static void determine_bios_rom(rom_load_data *romdata) { const char *specbios = romdata->machine().options().bios(); const char *defaultname = NULL; const rom_entry *rom; int default_no = 1; int bios_count = 0; device_t &rootdevice = romdata->machine().config().root_device(); rootdevice.set_system_bios(0); /* first determine the default BIOS name */ for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISDEFAULT_BIOS(rom)) defaultname = ROM_GETNAME(rom); /* look for a BIOS with a matching name */ for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { const char *biosname = ROM_GETNAME(rom); int bios_flags = ROM_GETBIOSFLAGS(rom); char bios_number[20]; /* Allow '-bios n' to still be used */ sprintf(bios_number, "%d", bios_flags - 1); if (mame_stricmp(bios_number, specbios) == 0 || mame_stricmp(biosname, specbios) == 0) rootdevice.set_system_bios(bios_flags); if (defaultname != NULL && mame_stricmp(biosname, defaultname) == 0) default_no = bios_flags; bios_count++; } /* if none found, use the default */ if (rootdevice.system_bios() == 0 && bios_count > 0) { /* if we got neither an empty string nor 'default' then warn the user */ if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL) { romdata->errorstring.catprintf("%s: invalid bios\n", specbios); romdata->warnings++; } /* set to default */ rootdevice.set_system_bios(default_no); } rootdevice.set_default_bios(default_no); LOG(("Using System BIOS: %d\n", rootdevice.system_bios())); }
std::unique_ptr<emu_file> common_process_file(emu_options &options, const char *location, bool has_crc, UINT32 crc, const rom_entry *romp, file_error &filerr) { auto image_file = std::make_unique<emu_file>(options.media_path(), OPEN_FLAG_READ); if (has_crc) filerr = image_file->open(location, PATH_SEPARATOR, ROM_GETNAME(romp), crc); else filerr = image_file->open(location, PATH_SEPARATOR, ROM_GETNAME(romp)); if (filerr != FILERR_NONE) { image_file = nullptr; } return image_file; }
int cli_info_listcrc(core_options *options, const char *gamename) { int drvindex, count = 0; /* iterate over drivers */ for (drvindex = 0; drivers[drvindex]; drvindex++) if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0) { const rom_entry *region, *rom; /* iterate over regions, and then ROMs within the region */ for (region = rom_first_region(drivers[drvindex]); region; region = rom_next_region(region)) for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { char hashbuf[HASH_BUF_SIZE]; /* if we have a CRC, display it */ if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), HASH_CRC, hashbuf)) mame_printf_info("%s %-12s %s\n", hashbuf, ROM_GETNAME(rom), drivers[drvindex]->description); } count++; } /* return an error if none found */ return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME; }
static void copy_rom_data(romload_private *romdata, const rom_entry *romp) { UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp); const char *srcrgntag = ROM_GETNAME(romp); UINT32 numbytes = ROM_GETLENGTH(romp); UINT32 srcoffs = (FPTR)ROM_GETHASHDATA(romp); /* srcoffset in place of hashdata */ /* make sure we copy within the region space */ if (ROM_GETOFFSET(romp) + numbytes > romdata->region->bytes()) fatalerror("Error in RomModule definition: COPY out of target memory region space\n"); /* make sure the length was valid */ if (numbytes == 0) fatalerror("Error in RomModule definition: COPY has an invalid length\n"); /* make sure the source was valid */ memory_region *region = romdata->machine().root_device().memregion(srcrgntag); if (region == NULL) fatalerror("Error in RomModule definition: COPY from an invalid region\n"); /* make sure we find within the region space */ if (srcoffs + numbytes > region->bytes()) fatalerror("Error in RomModule definition: COPY out of source memory region space\n"); /* fill the data */ memcpy(base, region->base() + srcoffs, numbytes); }
HRESULT CRom::Init(const struct GameDriver *gamedrv, const struct RomModule *region, const struct RomModule *rom) { if ( !gamedrv || !region ||!rom ) return S_FALSE; m_gamedrv = gamedrv; m_region = region; m_rom = rom; m_pszName = ROM_GETNAME(m_rom); m_dwState = 0; m_dwLength = 0; m_dwExpLength = 0; const struct RomModule *chunk; for (chunk = rom_first_chunk(m_rom); chunk; chunk = rom_next_chunk(chunk)) m_dwExpLength += ROM_GETLENGTH(chunk); m_dwChecksum = 0; char szExpChecksum[256]; lstrcpy(szExpChecksum, ROM_GETHASHDATA(m_rom)); m_dwExpChecksum = GetChecksumFromHash(szExpChecksum); m_dwRegionFlags = ROMREGION_GETFLAGS(m_region); return S_OK; }
static void match_roms(core_options *options, const char *hash, int length, int *found) { int drvindex; /* iterate over drivers */ for (drvindex = 0; drivers[drvindex] != NULL; drvindex++) { machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config)); const rom_entry *region, *rom; const rom_source *source; /* iterate over sources, regions and files within the region */ for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source)) for (region = rom_first_region(drivers[drvindex], source); region; region = rom_next_region(region)) for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) if (hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0)) { int baddump = hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP); /* output information about the match */ if (*found != 0) mame_printf_info(" "); mame_printf_info("= %s%-20s %-10s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), drivers[drvindex]->name, drivers[drvindex]->description); (*found)++; } global_free(config); } softlist_match_roms( options, hash, length, found ); }
void rom_load_manager::determine_bios_rom(device_t *device, const char *specbios) { const char *defaultname = nullptr; const rom_entry *rom; int default_no = 1; int bios_count = 0; device->set_system_bios(0); /* first determine the default BIOS name */ for (rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISDEFAULT_BIOS(rom)) defaultname = ROM_GETNAME(rom); /* look for a BIOS with a matching name */ for (rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { const char *biosname = ROM_GETNAME(rom); int bios_flags = ROM_GETBIOSFLAGS(rom); char bios_number[20]; /* Allow '-bios n' to still be used */ sprintf(bios_number, "%d", bios_flags - 1); if (core_stricmp(bios_number, specbios) == 0 || core_stricmp(biosname, specbios) == 0) device->set_system_bios(bios_flags); if (defaultname != nullptr && core_stricmp(biosname, defaultname) == 0) default_no = bios_flags; bios_count++; } /* if none found, use the default */ if (device->system_bios() == 0 && bios_count > 0) { /* if we got neither an empty string nor 'default' then warn the user */ if (specbios[0] != 0 && strcmp(specbios, "default") != 0) { strcatprintf(m_errorstring, "%s: invalid bios\n", specbios); m_errors++; } /* set to default */ device->set_system_bios(default_no); } device->set_default_bios(default_no); LOG(("For \"%s\" using System BIOS: %d\n", device->tag().c_str(), device->system_bios())); }
file_error common_process_file(emu_options &options, const char *location, bool has_crc, UINT32 crc, const rom_entry *romp, emu_file **image_file) { *image_file = global_alloc(emu_file(options.media_path(), OPEN_FLAG_READ)); file_error filerr; if (has_crc) filerr = (*image_file)->open(location, PATH_SEPARATOR, ROM_GETNAME(romp), crc); else filerr = (*image_file)->open(location, PATH_SEPARATOR, ROM_GETNAME(romp)); if (filerr != FILERR_NONE) { global_free(*image_file); *image_file = NULL; } return filerr; }
audit_record::audit_record(const rom_entry &media, media_type type) : m_next(NULL), m_type(type), m_status(STATUS_ERROR), m_substatus(SUBSTATUS_ERROR), m_name(ROM_GETNAME(&media)), m_explength(rom_file_size(&media)), m_length(0) { m_exphashes.from_internal_string(ROM_GETHASHDATA(&media)); }
static int open_rom_file(struct rom_load_data *romdata, const struct RomModule *romp) { const struct GameDriver *drv; ++romdata->romsloaded; /* update status display */ if (osd_display_loading_rom_message(ROM_GETNAME(romp), romdata)) return 0; /* Attempt reading up the chain through the parents. It automatically also attempts any kind of load by checksum supported by the archives. */ romdata->file = NULL; for (drv = Machine->gamedrv; !romdata->file && drv; drv = drv->clone_of) if (drv->name && *drv->name) romdata->file = mame_fopen_rom(drv->name, ROM_GETNAME(romp), ROM_GETHASHDATA(romp)); /* return the result */ return (romdata->file != NULL); }
chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, chd_file **image) { const game_driver *drv; const rom_entry *region, *rom; const char *fname; chd_error err; /* attempt to open the properly named file */ fname = assemble_2_strings(ROM_GETNAME(romp), ".chd"); err = chd_open(fname, CHD_OPEN_READ, NULL, image); free((void *)fname); /* if that worked, we're done */ if (err == CHDERR_NONE) return err; /* otherwise, look at our parents for a CHD with an identical checksum */ /* and try to open that */ for (drv = gamedrv; drv != NULL; drv = driver_get_clone(drv)) for (region = rom_first_region(drv); region != NULL; region = rom_next_region(region)) if (ROMREGION_ISDISKDATA(region)) for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) /* look for a differing name but with the same hash data */ if (strcmp(ROM_GETNAME(romp), ROM_GETNAME(rom)) != 0 && hash_data_is_equal(ROM_GETHASHDATA(romp), ROM_GETHASHDATA(rom), 0)) { fname = assemble_2_strings(ROM_GETNAME(rom), ".chd"); err = chd_open(fname, CHD_OPEN_READ, NULL, image); free((void *)fname); /* if that worked, we're done */ if (err == CHDERR_NONE) return err; } return err; }
void ui_menu_machine_configure::setup_bios() { if (m_drv->rom == nullptr) return; std::string specbios(m_opts.bios()); std::string default_name; for (const rom_entry *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom) if (ROMENTRY_ISDEFAULT_BIOS(rom)) default_name = ROM_GETNAME(rom); int bios_count = 0; for (const rom_entry *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom) { if (ROMENTRY_ISSYSTEM_BIOS(rom)) { std::string name(ROM_GETHASHDATA(rom)); std::string biosname(ROM_GETNAME(rom)); int bios_flags = ROM_GETBIOSFLAGS(rom); std::string bios_number = std::to_string(bios_flags - 1); // check biosnumber and name if (bios_number == specbios || biosname == specbios) m_curbios = bios_count; if (biosname == default_name) { name.append(_(" (default)")); if (specbios == "default") m_curbios = bios_count; } m_bios.emplace_back(name, bios_flags - 1); bios_count++; } } }
void printromlist(const struct RomModule *romp,const char *basename) { const struct RomModule *region, *rom, *chunk; char buf[512]; if (!romp) return; #ifdef MESS if (!strcmp(basename,"nes")) return; #endif printf("This is the list of the ROMs required for driver \"%s\".\n" "Name Size Checksum\n",basename); for (region = romp; region; region = rom_next_region(region)) { for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { const char *name = ROM_GETNAME(rom); const char* hash = ROM_GETHASHDATA(rom); int length = -1; /* default is for disks! */ if (ROMREGION_ISROMDATA(region)) { length = 0; for (chunk = rom_first_chunk(rom); chunk; chunk = rom_next_chunk(chunk)) length += ROM_GETLENGTH(chunk); } printf("%-12s ", name); if (length >= 0) printf("%7d",length); else printf(" "); if (!hash_data_has_info(hash, HASH_INFO_NO_DUMP)) { if (hash_data_has_info(hash, HASH_INFO_BAD_DUMP)) printf(" BAD"); hash_data_print(hash, 0, buf); printf(" %s", buf); } else printf(" NO GOOD DUMP KNOWN"); printf("\n"); } } }
static void handle_missing_file(rom_load_data *romdata, const rom_entry *romp) { /* optional files are okay */ if (ROM_ISOPTIONAL(romp)) { sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "OPTIONAL %s NOT FOUND\n", ROM_GETNAME(romp)); romdata->warnings++; } /* no good dumps are okay */ else if (ROM_NOGOODDUMP(romp)) { sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s NOT FOUND (NO GOOD DUMP KNOWN)\n", ROM_GETNAME(romp)); romdata->warnings++; } /* anything else is bad */ else { sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s NOT FOUND\n", ROM_GETNAME(romp)); romdata->errors++; } }
static void handle_missing_file(rom_load_data *romdata, const rom_entry *romp) { /* optional files are okay */ if (ROM_ISOPTIONAL(romp)) { romdata->errorstring.catprintf("OPTIONAL %s NOT FOUND\n", ROM_GETNAME(romp)); romdata->warnings++; } /* no good dumps are okay */ else if (hash_collection(ROM_GETHASHDATA(romp)).flag(hash_collection::FLAG_NO_DUMP)) { romdata->errorstring.catprintf("%s NOT FOUND (NO GOOD DUMP KNOWN)\n", ROM_GETNAME(romp)); romdata->knownbad++; } /* anything else is bad */ else { romdata->errorstring.catprintf("%s NOT FOUND\n", ROM_GETNAME(romp)); romdata->errors++; } }
/*------------------------------------------------- softlist_match_roms - scan for a matching software ROM by hash -------------------------------------------------*/ static void softlist_match_roms(core_options *options, const char *hash, int length, int *found) { int drvindex; /* iterate over drivers */ for (drvindex = 0; drivers[drvindex] != NULL; drvindex++) { machine_config *config = global_alloc(machine_config(drivers[drvindex]->machine_config)); for (const device_config *dev = config->m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext()) { software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config(); for ( int i = 0; i < DEVINFO_STR_SWLIST_MAX - DEVINFO_STR_SWLIST_0; i++ ) { if ( swlist->list_name[i] ) { software_list *list = software_list_open( options, swlist->list_name[i], FALSE, NULL ); for ( software_info *swinfo = software_list_find( list, "*", NULL ); swinfo != NULL; swinfo = software_list_find( list, "*", swinfo ) ) { for ( software_part *part = software_find_part( swinfo, NULL, NULL ); part != NULL; part = software_part_next( part ) ) { for ( const rom_entry *region = part->romdata; region != NULL; region = rom_next_region(region) ) { for ( const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom) ) { if ( hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0) ) { int baddump = hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP); /* output information about the match */ if (*found != 0) mame_printf_info(" "); mame_printf_info("= %s%-20s %s:%s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), swlist->list_name[i], swinfo->shortname, swinfo->longname); (*found)++; } } } } } software_list_close( list ); } } } global_free(config); } }
device_t *media_auditor::find_shared_device(device_t &device, const char *name, const hash_collection &romhashes, UINT64 romlength) { bool dumped = !romhashes.flag(hash_collection::FLAG_NO_DUMP); // special case for non-root devices device_t *highest_device = nullptr; if (device.owner() != nullptr) { for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region)) for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) if (ROM_GETLENGTH(rom) == romlength) { hash_collection hashes(ROM_GETHASHDATA(rom)); if ((dumped && hashes == romhashes) || (!dumped && ROM_GETNAME(rom) == name)) highest_device = &device; } } else { // iterate up the parent chain for (int drvindex = m_enumerator.find(m_enumerator.driver().parent); drvindex != -1; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent)) { device_iterator deviter(m_enumerator.config(drvindex).root_device()); for (device_t *scandevice = deviter.first(); scandevice != nullptr; scandevice = deviter.next()) for (const rom_entry *region = rom_first_region(*scandevice); region; region = rom_next_region(region)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) if (ROM_GETLENGTH(rom) == romlength) { hash_collection hashes(ROM_GETHASHDATA(rom)); if ((dumped && hashes == romhashes) || (!dumped && ROM_GETNAME(rom) == name)) highest_device = scandevice; } } } return highest_device; }
void media_identifier::file_info::match( std::string const &list, software_info const &software, rom_entry const &rom, util::hash_collection const &hashes) { if (hashes == m_hashes) { m_matches.emplace_back( util::string_format("%s:%s", list, software.shortname()), std::string(software.longname()), ROM_GETNAME(&rom), hashes.flag(util::hash_collection::FLAG_BAD_DUMP), false); } }
void info_xml_creator::output_bios() { // skip if no ROMs if (m_drivlist.driver().rom == NULL) return; // iterate over ROM entries and look for BIOSes for (const rom_entry *rom = m_drivlist.driver().rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { // output extracted name and descriptions fprintf(m_output, "\t\t<biosset"); fprintf(m_output, " name=\"%s\"", xml_normalize_string(ROM_GETNAME(rom))); fprintf(m_output, " description=\"%s\"", xml_normalize_string(ROM_GETHASHDATA(rom))); if (ROM_GETBIOSFLAGS(rom) == 1) fprintf(m_output, " default=\"yes\""); fprintf(m_output, "/>\n"); } }
/*------------------------------------------------- load_software - software image loading -------------------------------------------------*/ bool legacy_image_device_base::load_software(char *swlist, char *swname, rom_entry *start) { const rom_entry *region; astring regiontag; bool retVal = FALSE; for (region = start; region != NULL; region = rom_next_region(region)) { /* loop until we hit the end of this region */ const rom_entry *romp = region + 1; while (!ROMENTRY_ISREGIONEND(romp)) { /* handle files */ if (ROMENTRY_ISFILE(romp)) { UINT32 crc = 0; UINT8 crcbytes[4]; file_error filerr; bool has_crc = hash_data_extract_binary_checksum(ROM_GETHASHDATA(romp), HASH_CRC, crcbytes); if (has_crc) crc = (crcbytes[0] << 24) | (crcbytes[1] << 16) | (crcbytes[2] << 8) | crcbytes[3]; astring fname(swlist, PATH_SEPARATOR, swname, PATH_SEPARATOR, ROM_GETNAME(romp)); if (has_crc) filerr = mame_fopen_crc(libretro_content_directory, fname, crc, OPEN_FLAG_READ, &m_mame_file); else filerr = mame_fopen(libretro_content_directory, fname, OPEN_FLAG_READ, &m_mame_file); if (filerr == FILERR_NONE) { m_file = mame_core_file(m_mame_file); retVal = TRUE; } break; // load first item for start } romp++; /* something else; skip */ } } return retVal; }
const char *info_xml_creator::get_merge_name(const hash_collection &romhashes) { const char *merge_name = NULL; // walk the parent chain for (int clone_of = m_drivlist.find(m_drivlist.driver().parent); clone_of != -1; clone_of = m_drivlist.find(m_drivlist.driver(clone_of).parent)) // look in the parent's ROMs for (const rom_source *psource = rom_first_source(m_drivlist.config(clone_of,m_lookup_options)); psource != NULL; psource = rom_next_source(*psource)) for (const rom_entry *pregion = rom_first_region(*psource); pregion != NULL; pregion = rom_next_region(pregion)) for (const rom_entry *prom = rom_first_file(pregion); prom != NULL; prom = rom_next_file(prom)) { hash_collection phashes(ROM_GETHASHDATA(prom)); if (!phashes.flag(hash_collection::FLAG_NO_DUMP) && romhashes == phashes) { // stop when we find a match merge_name = ROM_GETNAME(prom); break; } } return merge_name; }
static void handle_missing_file(romload_private *romdata, const rom_entry *romp, astring tried_file_names, chd_error chderr) { if(tried_file_names.len() != 0) tried_file_names = " (tried in " + tried_file_names + ")"; astring name(ROM_GETNAME(romp)); bool is_chd = (chderr != CHDERR_NONE); if (is_chd) name += ".chd"; bool is_chd_error = (is_chd && chderr != CHDERR_FILE_NOT_FOUND); if (is_chd_error) romdata->errorstring.catprintf("%s CHD ERROR: %s\n", name.cstr(), chd_file::error_string(chderr)); /* optional files are okay */ if (ROM_ISOPTIONAL(romp)) { if (!is_chd_error) romdata->errorstring.catprintf("OPTIONAL %s NOT FOUND%s\n", name.cstr(), tried_file_names.cstr()); romdata->warnings++; } /* no good dumps are okay */ else if (hash_collection(ROM_GETHASHDATA(romp)).flag(hash_collection::FLAG_NO_DUMP)) { if (!is_chd_error) romdata->errorstring.catprintf("%s NOT FOUND (NO GOOD DUMP KNOWN)%s\n", name.cstr(), tried_file_names.cstr()); romdata->knownbad++; } /* anything else is bad */ else { if (!is_chd_error) romdata->errorstring.catprintf("%s NOT FOUND%s\n", name.cstr(), tried_file_names.cstr()); romdata->errors++; } }
void rom_load_manager::handle_missing_file(const rom_entry *romp, std::string tried_file_names, chd_error chderr) { if(tried_file_names.length() != 0) tried_file_names = " (tried in " + tried_file_names + ")"; std::string name(ROM_GETNAME(romp)); bool is_chd = (chderr != CHDERR_NONE); if (is_chd) name += ".chd"; bool is_chd_error = (is_chd && chderr != CHDERR_FILE_NOT_FOUND); if (is_chd_error) strcatprintf(m_errorstring, "%s CHD ERROR: %s\n", name.c_str(), chd_file::error_string(chderr)); /* optional files are okay */ if (ROM_ISOPTIONAL(romp)) { if (!is_chd_error) strcatprintf(m_errorstring, "OPTIONAL %s NOT FOUND%s\n", name.c_str(), tried_file_names.c_str()); m_warnings++; } /* no good dumps are okay */ else if (hash_collection(ROM_GETHASHDATA(romp)).flag(hash_collection::FLAG_NO_DUMP)) { if (!is_chd_error) strcatprintf(m_errorstring, "%s NOT FOUND (NO GOOD DUMP KNOWN)%s\n", name.c_str(), tried_file_names.c_str()); m_knownbad++; } /* anything else is bad */ else { if (!is_chd_error) strcatprintf(m_errorstring, "%s NOT FOUND%s\n", name.c_str(), tried_file_names.c_str()); m_errors++; } }
static chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd_file &source, chd_file &diff_chd) { astring fname(ROM_GETNAME(romp), ".dif"); /* try to open the diff */ LOG(("Opening differencing image file: %s\n", fname.cstr())); emu_file diff_file(options.diff_directory(), OPEN_FLAG_READ | OPEN_FLAG_WRITE); file_error filerr = diff_file.open(fname); if (filerr == FILERR_NONE) { astring fullpath(diff_file.fullpath()); diff_file.close(); LOG(("Opening differencing image file: %s\n", fullpath.cstr())); return diff_chd.open(fullpath, true, &source); } /* didn't work; try creating it instead */ LOG(("Creating differencing image: %s\n", fname.cstr())); diff_file.set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); filerr = diff_file.open(fname); if (filerr == FILERR_NONE) { astring fullpath(diff_file.fullpath()); diff_file.close(); /* create the CHD */ LOG(("Creating differencing image file: %s\n", fullpath.cstr())); chd_codec_type compression[4] = { CHD_CODEC_NONE }; chd_error err = diff_chd.create(fullpath, source.logical_bytes(), source.hunk_bytes(), compression, source); if (err != CHDERR_NONE) return err; return diff_chd.clone_all_metadata(source); } return CHDERR_FILE_NOT_FOUND; }
/* Identifies a rom from from this checksum */ static void match_roms(const struct GameDriver *driver,const char* hash,int *found) { const struct RomModule *region, *rom; for (region = rom_first_region(driver); region; region = rom_next_region(region)) { for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { if (hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0)) { char baddump = hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP); if (!silentident) { if (*found != 0) fprintf(stdout_file, " "); fprintf(stdout_file, "= %s%-12s %s\n",baddump ? "(BAD) " : "",ROM_GETNAME(rom),driver->description); } (*found)++; } } } }
static void print_game_bios(FILE *out, const game_driver *game) { const rom_entry *rom; /* skip if no ROMs */ if (game->rom == NULL) return; /* iterate over ROM entries and look for BIOSes */ for (rom = game->rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { const char *name = ROM_GETNAME(rom); const char *description = ROM_GETHASHDATA(rom); /* output extracted name and descriptions */ fprintf(out, "\t\t<biosset"); fprintf(out, " name=\"%s\"", xml_normalize_string(name)); fprintf(out, " description=\"%s\"", xml_normalize_string(description)); if (ROM_GETBIOSFLAGS(rom) == 1) fprintf(out, " default=\"yes\""); fprintf(out, "/>\n"); } }
static void match_roms(const char *hash, int length, int *found) { int drvindex; /* iterate over drivers */ for (drvindex = 0; drivers[drvindex]; drvindex++) { const rom_entry *region, *rom; /* iterate over regions and files within the region */ for (region = rom_first_region(drivers[drvindex]); region; region = rom_next_region(region)) for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) if (hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0)) { int baddump = hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP); /* output information about the match */ if (*found != 0) mame_printf_info(" "); mame_printf_info("= %s%-20s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), drivers[drvindex]->description); (*found)++; } } }
/*------------------------------------------------- load_software - software image loading -------------------------------------------------*/ bool device_image_interface::load_software(char *swlist, char *swname, rom_entry *start) { astring locationtag, breakstr("%"); const rom_entry *region; astring regiontag; bool retVal = FALSE; int warningcount = 0; for (region = start; region != NULL; region = rom_next_region(region)) { /* loop until we hit the end of this region */ const rom_entry *romp = region + 1; while (!ROMENTRY_ISREGIONEND(romp)) { /* handle files */ if (ROMENTRY_ISFILE(romp)) { file_error filerr = FILERR_NOT_FOUND; UINT32 crc = 0; bool has_crc = hash_collection(ROM_GETHASHDATA(romp)).crc(crc); // attempt reading up the chain through the parents and create a locationtag astring in the format // " swlist % clonename % parentname " // below, we have the code to split the elements and to create paths to load from software_list *software_list_ptr = software_list_open(device().machine().options(), swlist, FALSE, NULL); if (software_list_ptr) { for (software_info *swinfo = software_list_find(software_list_ptr, swname, NULL); swinfo != NULL; ) { { astring tmp(swinfo->shortname); locationtag.cat(tmp); locationtag.cat(breakstr); //printf("%s\n", locationtag.cstr()); } const char *parentname = software_get_clone(device().machine().options(), swlist, swinfo->shortname); if (parentname != NULL) swinfo = software_list_find(software_list_ptr, parentname, NULL); else swinfo = NULL; } // strip the final '%' locationtag.del(locationtag.len() - 1, 1); software_list_close(software_list_ptr); } if (software_get_support(device().machine().options(), swlist, swname) == SOFTWARE_SUPPORTED_PARTIAL) mame_printf_error("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist); if (software_get_support(device().machine().options(), swlist, swname) == SOFTWARE_SUPPORTED_NO) mame_printf_error("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist); // check if locationtag actually contains two locations separated by '%' // (i.e. check if we are dealing with a clone in softwarelist) astring tag2, tag3, tag4(locationtag), tag5; int separator = tag4.chr(0, '%'); if (separator != -1) { // we are loading a clone through softlists, split the setname from the parentname tag5.cpysubstr(tag4, separator + 1, tag4.len() - separator + 1); tag4.del(separator, tag4.len() - separator); } // prepare locations where we have to load from: list/parentname & list/clonename astring tag1(swlist); tag1.cat(PATH_SEPARATOR); tag2.cpy(tag1.cat(tag4)); tag1.cpy(swlist); tag1.cat(PATH_SEPARATOR); tag3.cpy(tag1.cat(tag5)); if (tag5.chr(0, '%') != -1) fatalerror("We do not support clones of clones!\n"); // try to load from the available location(s): // - if we are not using lists, we have regiontag only; // - if we are using lists, we have: list/clonename, list/parentname, clonename, parentname // try to load from list/setname if ((m_mame_file == NULL) && (tag2.cstr() != NULL)) filerr = common_process_file(device().machine().options(), tag2.cstr(), has_crc, crc, romp, &m_mame_file); // try to load from list/parentname if ((m_mame_file == NULL) && (tag3.cstr() != NULL)) filerr = common_process_file(device().machine().options(), tag3.cstr(), has_crc, crc, romp, &m_mame_file); // try to load from setname if ((m_mame_file == NULL) && (tag4.cstr() != NULL)) filerr = common_process_file(device().machine().options(), tag4.cstr(), has_crc, crc, romp, &m_mame_file); // try to load from parentname if ((m_mame_file == NULL) && (tag5.cstr() != NULL)) filerr = common_process_file(device().machine().options(), tag5.cstr(), has_crc, crc, romp, &m_mame_file); warningcount += verify_length_and_hash(m_mame_file,ROM_GETNAME(romp),ROM_GETLENGTH(romp),hash_collection(ROM_GETHASHDATA(romp))); if (filerr == FILERR_NONE) { m_file = *m_mame_file; retVal = TRUE; } break; // load first item for start } romp++; /* something else; skip */ } } if (warningcount > 0) { mame_printf_error("WARNING: the software item might not run correctly.\n"); } return retVal; }