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); }
static void display_rom_load_results(rom_load_data *romdata) { int region; /* final status display */ display_loading_rom_message(NULL, romdata); /* if we had errors, they are fatal */ if (romdata->errors != 0) { /* clean up any regions */ for (region = 0; region < MAX_MEMORY_REGIONS; region++) free_memory_region(Machine, region); /* create the error message and exit fatally */ strcat(romdata->errorbuf, "ERROR: required files are missing, the game cannot be run."); fatalerror_exitcode(MAMERR_MISSING_FILES, "%s", romdata->errorbuf); } /* if we had warnings, output them, but continue */ if (romdata->warnings) { strcat(romdata->errorbuf, "WARNING: the game might not run correctly."); mame_printf_warning("%s\n", romdata->errorbuf); } }
void rom_load_manager::display_rom_load_results(bool from_list) { /* final status display */ display_loading_rom_message(nullptr, from_list); /* if we had errors, they are fatal */ if (m_errors != 0) { /* create the error message and exit fatally */ osd_printf_error("%s", m_errorstring.c_str()); fatalerror_exitcode(machine(), MAMERR_MISSING_FILES, "Required files are missing, the machine cannot be run."); } /* if we had warnings, output them, but continue */ if ((m_warnings) || (m_knownbad)) { m_errorstring.append("WARNING: the machine might not run correctly."); osd_printf_warning("%s\n", m_errorstring.c_str()); } }
static void display_rom_load_results(romload_private *romdata, bool from_list) { /* final status display */ display_loading_rom_message(romdata, NULL, from_list); /* if we had errors, they are fatal */ if (romdata->errors != 0) { /* create the error message and exit fatally */ mame_printf_error("%s", romdata->errorstring.cstr()); fatalerror_exitcode(romdata->machine(), MAMERR_MISSING_FILES, "Required files are missing, the %s cannot be run.",emulator_info::get_gamenoun()); } /* if we had warnings, output them, but continue */ if ((romdata-> warnings) || (romdata->knownbad)) { romdata->errorstring.cat("WARNING: the "); romdata->errorstring.cat(emulator_info::get_gamenoun()); romdata->errorstring.cat(" might not run correctly."); mame_printf_warning("%s\n", romdata->errorstring.cstr()); } }
static int open_rom_file(romload_private *romdata, const char *regiontag, const rom_entry *romp, astring &tried_file_names, bool from_list) { file_error filerr = FILERR_NOT_FOUND; UINT32 romsize = rom_file_size(romp); tried_file_names = ""; /* update status display */ display_loading_rom_message(romdata, ROM_GETNAME(romp), from_list); /* extract CRC to use for searching */ UINT32 crc = 0; bool has_crc = hash_collection(ROM_GETHASHDATA(romp)).crc(crc); /* 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 (int drv = driver_list::find(romdata->machine().system()); romdata->file == NULL && drv != -1; drv = driver_list::clone(drv)) { if(tried_file_names.len() != 0) tried_file_names += " "; tried_file_names += driver_list::driver(drv).name; filerr = common_process_file(romdata->machine().options(), driver_list::driver(drv).name, has_crc, crc, romp, &romdata->file); } /* if the region is load by name, load the ROM from there */ if (romdata->file == NULL && regiontag != NULL) { // check if we are dealing with softwarelists. if so, locationtag // is actually a concatenation of: listname + setname + parentname // separated by '%' (parentname being present only for clones) astring tag1(regiontag), tag2, tag3, tag4, tag5; bool is_list = FALSE; bool has_parent = FALSE; int separator1 = tag1.chr(0, '%'); if (separator1 != -1) { is_list = TRUE; // we are loading through softlists, split the listname from the regiontag tag4.cpysubstr(tag1, separator1 + 1, tag1.len() - separator1 + 1); tag1.del(separator1, tag1.len() - separator1); tag1.cat(PATH_SEPARATOR); // check if we are loading a clone (if this is the case also tag1 have a separator '%') int separator2 = tag4.chr(0, '%'); if (separator2 != -1) { has_parent = TRUE; // we are loading a clone through softlists, split the setname from the parentname tag5.cpysubstr(tag4, separator2 + 1, tag4.len() - separator2 + 1); tag4.del(separator2, tag4.len() - separator2); } // prepare locations where we have to load from: list/parentname & list/clonename astring swlist(tag1.cstr()); tag2.cpy(swlist.cat(tag4)); if (has_parent) { swlist.cpy(tag1); tag3.cpy(swlist.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 if (!is_list) { tried_file_names += " " + tag1; filerr = common_process_file(romdata->machine().options(), tag1.cstr(), has_crc, crc, romp, &romdata->file); } else { // try to load from list/setname if ((romdata->file == NULL) && (tag2.cstr() != NULL)) { tried_file_names += " " + tag2; filerr = common_process_file(romdata->machine().options(), tag2.cstr(), has_crc, crc, romp, &romdata->file); } // try to load from list/parentname if ((romdata->file == NULL) && has_parent && (tag3.cstr() != NULL)) { tried_file_names += " " + tag3; filerr = common_process_file(romdata->machine().options(), tag3.cstr(), has_crc, crc, romp, &romdata->file); } // try to load from setname if ((romdata->file == NULL) && (tag4.cstr() != NULL)) { tried_file_names += " " + tag4; filerr = common_process_file(romdata->machine().options(), tag4.cstr(), has_crc, crc, romp, &romdata->file); } // try to load from parentname if ((romdata->file == NULL) && has_parent && (tag5.cstr() != NULL)) { tried_file_names += " " + tag5; filerr = common_process_file(romdata->machine().options(), tag5.cstr(), has_crc, crc, romp, &romdata->file); } } } /* update counters */ romdata->romsloaded++; romdata->romsloadedsize += romsize; /* return the result */ return (filerr == FILERR_NONE); }
int rom_load_manager::open_rom_file(const char *regiontag, const rom_entry *romp, std::string &tried_file_names, bool from_list) { osd_file::error filerr = osd_file::error::NOT_FOUND; UINT32 romsize = rom_file_size(romp); tried_file_names = ""; /* update status display */ display_loading_rom_message(ROM_GETNAME(romp), from_list); /* extract CRC to use for searching */ UINT32 crc = 0; bool has_crc = util::hash_collection(ROM_GETHASHDATA(romp)).crc(crc); /* attempt reading up the chain through the parents. It automatically also attempts any kind of load by checksum supported by the archives. */ m_file = nullptr; for (int drv = driver_list::find(machine().system()); m_file == nullptr && drv != -1; drv = driver_list::clone(drv)) { if (tried_file_names.length() != 0) tried_file_names += " "; tried_file_names += driver_list::driver(drv).name; m_file = common_process_file(machine().options(), driver_list::driver(drv).name, has_crc, crc, romp, filerr); } /* if the region is load by name, load the ROM from there */ if (m_file == nullptr && regiontag != nullptr) { // check if we are dealing with softwarelists. if so, locationtag // is actually a concatenation of: listname + setname + parentname // separated by '%' (parentname being present only for clones) std::string tag1(regiontag), tag2, tag3, tag4, tag5; bool is_list = FALSE; bool has_parent = FALSE; int separator1 = tag1.find_first_of('%'); if (separator1 != -1) { is_list = TRUE; // we are loading through softlists, split the listname from the regiontag tag4.assign(tag1.substr(separator1 + 1, tag1.length() - separator1 + 1)); tag1.erase(separator1, tag1.length() - separator1); tag1.append(PATH_SEPARATOR); // check if we are loading a clone (if this is the case also tag1 have a separator '%') int separator2 = tag4.find_first_of('%'); if (separator2 != -1) { has_parent = TRUE; // we are loading a clone through softlists, split the setname from the parentname tag5.assign(tag4.substr(separator2 + 1, tag4.length() - separator2 + 1)); tag4.erase(separator2, tag4.length() - separator2); } // prepare locations where we have to load from: list/parentname & list/clonename std::string swlist(tag1); tag2.assign(swlist.append(tag4)); if (has_parent) { swlist.assign(tag1); tag3.assign(swlist.append(tag5)); } } if (tag5.find_first_of('%') != -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 if (!is_list) { tried_file_names += " " + tag1; m_file = common_process_file(machine().options(), tag1.c_str(), has_crc, crc, romp, filerr); } else { // try to load from list/setname if ((m_file == nullptr) && (tag2.c_str() != nullptr)) { tried_file_names += " " + tag2; m_file = common_process_file(machine().options(), tag2.c_str(), has_crc, crc, romp, filerr); } // try to load from list/parentname if ((m_file == nullptr) && has_parent && (tag3.c_str() != nullptr)) { tried_file_names += " " + tag3; m_file = common_process_file(machine().options(), tag3.c_str(), has_crc, crc, romp, filerr); } // try to load from setname if ((m_file == nullptr) && (tag4.c_str() != nullptr)) { tried_file_names += " " + tag4; m_file = common_process_file(machine().options(), tag4.c_str(), has_crc, crc, romp, filerr); } // try to load from parentname if ((m_file == nullptr) && has_parent && (tag5.c_str() != nullptr)) { tried_file_names += " " + tag5; m_file = common_process_file(machine().options(), tag5.c_str(), has_crc, crc, romp, filerr); } } } /* update counters */ m_romsloaded++; m_romsloadedsize += romsize; /* return the result */ return (filerr == osd_file::error::NONE); }