bool generic_slot_device::call_load() { if (m_cart) { if (!m_device_image_load.isnull()) return m_device_image_load(*this); else { UINT32 len = common_get_size("rom"); rom_alloc(len, m_width, m_endianness); common_load_rom(get_rom_base(), len, "rom"); return IMAGE_INIT_PASS; } } return IMAGE_INIT_PASS; }
image_init_result generic_slot_device::call_load() { if (m_cart) { if (!m_device_image_load.isnull()) return m_device_image_load(*this); else { uint32_t len = common_get_size("rom"); rom_alloc(len, m_width, m_endianness); common_load_rom(get_rom_base(), len, "rom"); return image_init_result::PASS; } } return image_init_result::PASS; }
int split_rom_load(struct emu *emu, const char *filename, struct rom **romptr) { struct archive *archive; uint8_t *buffer; size_t size; struct rom_info *rom_info; struct rom *rom; int *chip_list; int i; if (!romptr) return -1; chip_list = NULL; *romptr = NULL; if (archive_open(&archive, filename)) return -1; chip_list = malloc(archive->file_list->count * sizeof(*chip_list)); if (!chip_list) return -1; rom_info = NULL; rom = NULL; buffer = NULL; do { rom_info = db_lookup_split_rom(archive, chip_list, rom_info); if (!rom_info) break; if (load_split_rom_parts(archive, chip_list, rom_info, &buffer, &size)) { break; } if (!buffer) continue; rom = rom_alloc(filename, buffer, size); if (!rom) break; /* Store the filename of the first PRG chip as the empty string; this allows patches to be included with split roms as well, but they need to be located in the top-level directory of the archive. */ rom->compressed_filename = strdup(""); buffer = NULL; memcpy(&rom->info, rom_info, sizeof(*rom_info)); if (rom_info->name) rom->info.name = strdup(rom_info->name); else rom->info.name = NULL; rom->offset = INES_HEADER_SIZE; rom_calculate_checksum(rom); for (i = 0; i < archive->file_list->count; i++) { char *basename; if (!archive->file_list->entries[i].name) continue; basename = strrchr(archive->file_list->entries[i].name, '/'); if (!basename) basename = archive->file_list->entries[i].name; /* Hack for PlayChoice ROMs; most of these are the same as NES carts, so check for a file called 'security.prm' to distinguish them. */ if (!strcasecmp(basename, "security.prm")) { if (rom->info.flags & ROM_FLAG_PLAYCHOICE) rom->info.system_type = EMU_SYSTEM_TYPE_PLAYCHOICE; } } /* Validate individual chip CRCs or SHA1s if present, then the combined CRC and/or SHA1, if present. */ if (!validate_checksums(rom, rom_info)) goto invalid; if ((rom->info.flags & ROM_FLAG_HAS_CRC) && (rom->info.combined_crc != rom_info->combined_crc)) { goto invalid; } if ((rom->info.flags & ROM_FLAG_HAS_SHA1) && memcmp(rom->info.combined_sha1, rom_info->combined_sha1, 20)) { goto invalid; } break; invalid: rom_free(rom); rom = NULL; } while (rom_info); archive_close(&archive); if (chip_list) free(chip_list); if (buffer) free(buffer); if (!rom) return -1; *romptr = rom; return 0; }