int pegasus_state::load_cart(device_image_interface &image, generic_slot_device *slot, const char *reg_tag) { UINT32 size = slot->common_get_size(reg_tag); bool any_socket = false; if (size > 0x1000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } if (image.software_entry() != NULL && size == 0) { // we might be loading a cart compatible with all sockets! // so try to get region "rom" size = slot->common_get_size("rom"); any_socket = true; if (size == 0) { astring errmsg; errmsg.printf("Attempted to load a file that does not work in this socket.\nPlease check \"Usage\" field in the software list for the correct socket(s) to use."); image.seterror(IMAGE_ERROR_UNSPECIFIED, errmsg.cstr()); return IMAGE_INIT_FAIL; } } slot->rom_alloc(0x1000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); // we alloc 0x1000 also for smaller roms! slot->common_load_rom(slot->get_rom_base(), size, any_socket ? "rom" : reg_tag); // raw images have to be decrypted (in particular the ones from softlist) pegasus_decrypt_rom(slot->get_rom_base(), image.software_entry() != NULL); return IMAGE_INIT_PASS; }
INPUT_PORTS_END /*************************************************************************** MACHINE DRIVERS ***************************************************************************/ int aim65_state::load_cart(device_image_interface &image, generic_slot_device *slot, const char *slot_tag) { UINT32 size = slot->common_get_size(slot_tag); if (size > 0x1000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } if (image.software_entry() != NULL && image.get_software_region(slot_tag) == NULL) { astring errmsg; errmsg.printf("Attempted to load file with wrong extension\nSocket '%s' only accepts files with '.%s' extension", slot_tag, slot_tag); image.seterror(IMAGE_ERROR_UNSPECIFIED, errmsg.c_str()); return IMAGE_INIT_FAIL; } slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->common_load_rom(slot->get_rom_base(), size, slot_tag); return IMAGE_INIT_PASS; }
INPUT_PORTS_END /*************************************************************************** MACHINE DRIVERS ***************************************************************************/ image_init_result aim65_state::load_cart(device_image_interface &image, generic_slot_device *slot, const char *slot_tag) { uint32_t size = slot->common_get_size(slot_tag); if (size > 0x1000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported ROM size"); return image_init_result::FAIL; } if (image.loaded_through_softlist() && image.get_software_region(slot_tag) == nullptr) { std::string errmsg = string_format( "Attempted to load file with wrong extension\nSocket '%s' only accepts files with '.%s' extension", slot_tag, slot_tag); image.seterror(IMAGE_ERROR_UNSPECIFIED, errmsg.c_str()); return image_init_result::FAIL; } slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->common_load_rom(slot->get_rom_base(), size, slot_tag); return image_init_result::PASS; }
image_init_result nascom2_state::load_cart(device_image_interface &image, generic_slot_device *slot, int slot_id) { // loading directly from file if (image.software_entry() == nullptr) { if (slot->length() > 0x1000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported file size"); return image_init_result::FAIL; } slot->rom_alloc(slot->length(), GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->fread(slot->get_rom_base(), slot->length()); // we just assume that socket1 should be loaded to 0xc000 and socket2 to 0xd000 switch (slot_id) { case 1: m_maincpu->space(AS_PROGRAM).install_rom(0xc000, 0xc000 + slot->length() - 1, slot->get_rom_base()); break; case 2: m_maincpu->space(AS_PROGRAM).install_rom(0xd000, 0xd000 + slot->length() - 1, slot->get_rom_base()); break; } } // loading from software list. this supports multiple regions to load to else { UINT8 *region_b000 = image.get_software_region("b000"); UINT8 *region_c000 = image.get_software_region("c000"); UINT8 *region_d000 = image.get_software_region("d000"); if (region_b000 != nullptr) { UINT32 size = image.get_software_region_length("b000"); m_maincpu->space(AS_PROGRAM).install_rom(0xb000, 0xb000 + size - 1, region_b000); } if (region_c000 != nullptr) { UINT32 size = image.get_software_region_length("c000"); m_maincpu->space(AS_PROGRAM).install_rom(0xc000, 0xc000 + size - 1, region_c000); } if (region_d000 != nullptr) { UINT32 size = image.get_software_region_length("d000"); m_maincpu->space(AS_PROGRAM).install_rom(0xd000, 0xd000 + size - 1, region_d000); } } return image_init_result::PASS; }
int pcjr_state::load_cart(device_image_interface &image, generic_slot_device *slot) { UINT32 size = slot->common_get_size("rom"); bool imagic_hack = false; if (image.software_entry() == nullptr) { int header_size = 0; // Check for supported header sizes switch (size & 0x3ff) { case 0x80: header_size = 0x80; break; case 0x200: header_size = 0x200; break; default: image.seterror(IMAGE_ERROR_UNSUPPORTED, "Invalid header size" ); return IMAGE_INIT_FAIL; } if (size - header_size == 0xa000) { // alloc 64K for the imagic carts, so to handle the necessary mirroring size += 0x6000; imagic_hack = true; } size -= header_size; image.fseek(header_size, SEEK_SET); } slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->common_load_rom(slot->get_rom_base(), size, "rom"); if (imagic_hack) { // in this case the image consists of 2x8K chunks // the first chunk is unique, the second is repeated 4 times up to 0xa000 size // mirroring UINT8 *ROM = slot->get_rom_base(); memcpy(ROM + 0xe000, ROM + 0x2000, 0x2000); memcpy(ROM + 0xc000, ROM + 0x2000, 0x2000); memcpy(ROM + 0xa000, ROM + 0x2000, 0x2000); memcpy(ROM + 0x8000, ROM + 0x2000, 0x2000); memcpy(ROM + 0x6000, ROM, 0x2000); memcpy(ROM + 0x4000, ROM, 0x2000); memcpy(ROM + 0x2000, ROM, 0x2000); } return IMAGE_INIT_PASS; }
image_init_result atom_state::load_cart(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); if (size > 0x1000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return image_init_result::FAIL; } slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->common_load_rom(slot->get_rom_base(), size, "rom"); return image_init_result::PASS; }
image_init_result electron_rombox_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid size: Only 8K/16K is supported"); return image_init_result::FAIL; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->common_load_rom(slot->get_rom_base(), size, "rom"); // mirror 8K ROMs uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); return image_init_result::PASS; }
// MCFG_SOFTWARE_LIST_ADD("cart_list", "mzr8105_cart") MACHINE_CONFIG_END /*************************** Rom loading functions ****************************/ int mzr8105_state::mzr8105_load_cart(device_image_interface &image, generic_slot_device *slot) { UINT32 size = slot->common_get_size("rom"); if (size > 0x20000) // Max 128Kb - not verified { LOG( printf("Cartridge size exceeding max size (128Kb): %d\n", size) ); image.seterror(IMAGE_ERROR_UNSPECIFIED, "Cartridge size exceeding max size (128Kb)"); return IMAGE_INIT_FAIL; } slot->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_BIG); slot->common_load_rom(slot->get_rom_base(), size, "rom"); return IMAGE_INIT_PASS; }
// MCFG_SOFTWARE_LIST_ADD("cart_list", "fccpu1_cart") MACHINE_CONFIG_END /*************************** Rom loading functions ****************************/ image_init_result force68k_state::force68k_load_cart(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); if (size > 0x20000) // Max 128Kb { LOG("Cartridge size exceeding max size (128Kb): %d\n", size); image.seterror(IMAGE_ERROR_UNSPECIFIED, "Cartridge size exceeding max size (128Kb)"); return image_init_result::FAIL; } slot->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_BIG); slot->common_load_rom(slot->get_rom_base(), size, "rom"); return image_init_result::PASS; }
image_init_result alphatro_state::load_cart(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); if ((size != 0x4000) && (size != 0x2000)) { image.seterror(IMAGE_ERROR_UNSUPPORTED, "Invalid size, must be 8 or 16 K" ); return image_init_result::FAIL; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_BIG); if (size == 0x4000) // 16K ROMs come in at 0xA000 { slot->common_load_rom(slot->get_rom_base(), size, "rom"); } else // load 8K ROMs at an offset of 8K so they end up at 0xC000 { slot->common_load_rom(slot->get_rom_base()+0x2000, size, "rom"); } return image_init_result::PASS; }