diff --git a/Cocoa/Document.m b/Cocoa/Document.m index 19dd1a4..ae79c95 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -647,7 +647,7 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency) GB_debugger_set_disabled(&_gb, false); } -- (void) loadBootROM: (GB_boot_rom_t)type +- (void)loadBootROM: (GB_boot_rom_t)type { static NSString *const names[] = { [GB_BOOT_ROM_DMG_0] = @"dmg0_boot", @@ -657,9 +657,24 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency) [GB_BOOT_ROM_SGB2] = @"sgb2_boot", [GB_BOOT_ROM_CGB_0] = @"cgb0_boot", [GB_BOOT_ROM_CGB] = @"cgb_boot", + [GB_BOOT_ROM_CGB_E] = @"cgbE_boot", + [GB_BOOT_ROM_AGB_0] = @"agb0_boot", [GB_BOOT_ROM_AGB] = @"agb_boot", }; - GB_load_boot_rom(&_gb, [[self bootROMPathForName:names[type]] UTF8String]); + NSString *name = names[type]; + NSString *path = [self bootROMPathForName:name]; + /* These boot types are not commonly available, and they are indentical + from an emulator perspective, so fall back to the more common variants + if they can't be found. */ + if (!path && type == GB_BOOT_ROM_CGB_E) { + [self loadBootROM:GB_BOOT_ROM_CGB]; + return; + } + if (!path && type == GB_BOOT_ROM_AGB_0) { + [self loadBootROM:GB_BOOT_ROM_AGB]; + return; + } + GB_load_boot_rom(&_gb, [path UTF8String]); } - (IBAction)reset:(id)sender diff --git a/Core/gb.c b/Core/gb.c index 90a1804..2369fbf 100644 --- a/Core/gb.c +++ b/Core/gb.c @@ -1665,9 +1665,11 @@ static void request_boot_rom(GB_gameboy_t *gb) case GB_MODEL_CGB_B: case GB_MODEL_CGB_C: case GB_MODEL_CGB_D: - case GB_MODEL_CGB_E: type = GB_BOOT_ROM_CGB; break; + case GB_MODEL_CGB_E: + type = GB_BOOT_ROM_CGB_E; + break; case GB_MODEL_AGB_A: case GB_MODEL_GBP_A: type = GB_BOOT_ROM_AGB; diff --git a/Core/gb.h b/Core/gb.h index 3dfbbca..65372dd 100644 --- a/Core/gb.h +++ b/Core/gb.h @@ -245,6 +245,8 @@ typedef enum { GB_BOOT_ROM_SGB2, GB_BOOT_ROM_CGB_0, GB_BOOT_ROM_CGB, + GB_BOOT_ROM_CGB_E, + GB_BOOT_ROM_AGB_0, GB_BOOT_ROM_AGB, } GB_boot_rom_t; diff --git a/SDL/main.c b/SDL/main.c index 173e42b..603215d 100644 --- a/SDL/main.c +++ b/SDL/main.c @@ -686,6 +686,8 @@ static void load_boot_rom(GB_gameboy_t *gb, GB_boot_rom_t type) [GB_BOOT_ROM_SGB2] = "sgb2_boot.bin", [GB_BOOT_ROM_CGB_0] = "cgb0_boot.bin", [GB_BOOT_ROM_CGB] = "cgb_boot.bin", + [GB_BOOT_ROM_CGB_E] = "cgbE_boot.bin", + [GB_BOOT_ROM_AGB_0] = "agb0_boot.bin", [GB_BOOT_ROM_AGB] = "agb_boot.bin", }; bool use_built_in = true; @@ -696,7 +698,16 @@ static void load_boot_rom(GB_gameboy_t *gb, GB_boot_rom_t type) } if (use_built_in) { start_capturing_logs(); - GB_load_boot_rom(gb, resource_path(names[type])); + if (GB_load_boot_rom(gb, resource_path(names[type]))) { + if (type == GB_BOOT_ROM_CGB_E) { + load_boot_rom(gb, GB_BOOT_ROM_CGB); + return; + } + if (type == GB_BOOT_ROM_AGB_0) { + load_boot_rom(gb, GB_BOOT_ROM_AGB); + return; + } + } end_capturing_logs(true, false, SDL_MESSAGEBOX_ERROR, "Error"); } } diff --git a/libretro/libretro.c b/libretro/libretro.c index 82acf45..ffb9b0e 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -504,6 +504,8 @@ static void boot_rom_load(GB_gameboy_t *gb, GB_boot_rom_t type) [GB_BOOT_ROM_SGB2] = "sgb2", [GB_BOOT_ROM_CGB_0] = "cgb0", [GB_BOOT_ROM_CGB] = "cgb", + [GB_BOOT_ROM_CGB_E] = "cgbE", + [GB_BOOT_ROM_AGB_0] = "agb0", [GB_BOOT_ROM_AGB] = "agb", }[type]; @@ -535,6 +537,14 @@ static void boot_rom_load(GB_gameboy_t *gb, GB_boot_rom_t type) log_cb(RETRO_LOG_INFO, "Loading boot image: %s\n", buf); if (GB_load_boot_rom(gb, buf)) { + if (type == GB_BOOT_ROM_CGB_E) { + boot_rom_load(gb, GB_BOOT_ROM_CGB); + return; + } + if (type == GB_BOOT_ROM_AGB_0) { + boot_rom_load(gb, GB_BOOT_ROM_AGB); + return; + } GB_load_boot_rom_from_buffer(gb, boot_code, boot_length); } }