Support for a distinct CGB-E boot ROM, internal support for an distinct AGB-0 boot ROM

This commit is contained in:
Lior Halphon 2024-06-09 22:49:49 +03:00
parent 2018f0ee01
commit a3128d89c0
5 changed files with 44 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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");
}
}

View File

@ -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);
}
}