diff --git a/Core/gb.c b/Core/gb.c index 6109c93..dc6a847 100755 --- a/Core/gb.c +++ b/Core/gb.c @@ -146,6 +146,25 @@ void GB_free(GB_gameboy_t *gb) memset(gb, 0, sizeof(*gb)); } +#ifdef __LIBRETRO__ +#include "../libretro/cgb_boot.h" +#include "../libretro/dmg_boot.h" + +int GB_load_boot_rom_dmg(GB_gameboy_t *gb) +{ + memset(gb->boot_rom, 0x900, sizeof(gb->boot_rom)); + memcpy(gb->boot_rom, dmg_boot, dmg_boot_length); + return 0; +} + +int GB_load_boot_rom_cgb(GB_gameboy_t *gb) +{ + memset(gb->boot_rom, 0x900, sizeof(gb->boot_rom)); + memcpy(gb->boot_rom, cgb_boot, cgb_boot_length); + return 0; +} +#endif + int GB_load_boot_rom(GB_gameboy_t *gb, const char *path) { FILE *f = fopen(path, "rb"); diff --git a/Core/gb.h b/Core/gb.h index 91f9fea..4564515 100644 --- a/Core/gb.h +++ b/Core/gb.h @@ -521,6 +521,11 @@ void *GB_get_direct_access(GB_gameboy_t *gb, GB_direct_access_t access, size_t * void *GB_get_user_data(GB_gameboy_t *gb); void GB_set_user_data(GB_gameboy_t *gb, void *data); +#ifdef __LIBRETRO__ +int GB_load_boot_rom_dmg(GB_gameboy_t *gb); +int GB_load_boot_rom_cgb(GB_gameboy_t *gb); +#endif + int GB_load_boot_rom(GB_gameboy_t *gb, const char *path); int GB_load_rom(GB_gameboy_t *gb, const char *path); diff --git a/libretro/cgb_boot.h b/libretro/cgb_boot.h new file mode 100644 index 0000000..424542d --- /dev/null +++ b/libretro/cgb_boot.h @@ -0,0 +1,214 @@ +const char cgb_boot[2305] = { + 0x31, 0xfe, 0xff, 0xaf, 0xea, 0x40, 0xc0, 0x21, 0x00, 0x80, 0xcd, + 0x60, 0x06, 0x26, 0xd0, 0xcd, 0x60, 0x06, 0x21, 0x00, 0xfe, 0x0e, + 0xa0, 0xaf, 0x22, 0x0d, 0x20, 0xfc, 0x3e, 0x80, 0xe0, 0x26, 0xe0, + 0x11, 0x3e, 0xf3, 0xe0, 0x12, 0xe0, 0x25, 0x3e, 0x77, 0xe0, 0x24, + 0x21, 0x30, 0xff, 0xaf, 0x0e, 0x10, 0x22, 0x2f, 0x0d, 0x20, 0xfb, + 0x3e, 0xfc, 0xe0, 0x47, 0x11, 0x04, 0x01, 0x21, 0x10, 0x80, 0x1a, + 0x47, 0xcd, 0x2e, 0x06, 0xcd, 0x2e, 0x06, 0x13, 0x7b, 0xee, 0x34, + 0x20, 0xf2, 0xcd, 0xa1, 0x06, 0x3e, 0x01, 0xe0, 0x4f, 0xaf, 0x21, + 0x00, 0x80, 0xcd, 0x60, 0x06, 0x11, 0x96, 0x04, 0x21, 0x80, 0x80, + 0x0e, 0xc0, 0x1a, 0x22, 0x23, 0x13, 0x1a, 0x22, 0x23, 0x13, 0x0d, + 0x20, 0xf5, 0x11, 0x04, 0x01, 0x0e, 0x06, 0xc5, 0xcd, 0x92, 0x06, + 0xc1, 0x0d, 0x20, 0xf8, 0x23, 0xcd, 0xa1, 0x06, 0x21, 0xc2, 0x98, + 0x06, 0x03, 0x3e, 0x08, 0x0e, 0x10, 0x77, 0xf5, 0x3e, 0x01, 0xe0, + 0x4f, 0x3e, 0x08, 0x77, 0xaf, 0xe0, 0x4f, 0xf1, 0x22, 0x3c, 0x0d, + 0x20, 0xee, 0x11, 0x10, 0x00, 0x19, 0x05, 0x20, 0xe5, 0xfe, 0x38, + 0x20, 0x09, 0x21, 0xa7, 0x99, 0x06, 0x01, 0x0e, 0x07, 0x18, 0xda, + 0x11, 0x16, 0x06, 0x0e, 0x08, 0x21, 0x00, 0xc0, 0xaf, 0x2f, 0x22, + 0x22, 0x1a, 0x13, 0x22, 0x1a, 0x13, 0x22, 0xaf, 0x22, 0x22, 0x22, + 0x22, 0x0d, 0x20, 0xef, 0x21, 0x00, 0xc0, 0x16, 0x40, 0x1e, 0x00, + 0xcd, 0xb2, 0x06, 0x3e, 0x91, 0xe0, 0x40, 0xcd, 0xdd, 0x06, 0x06, + 0x2d, 0xcd, 0x4f, 0x06, 0x3e, 0x83, 0xcd, 0x59, 0x06, 0x06, 0x05, + 0xcd, 0x4f, 0x06, 0x3e, 0xc1, 0xcd, 0x59, 0x06, 0x06, 0x1e, 0xcd, + 0x4f, 0x06, 0xcd, 0xef, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x16, 0x36, 0xd1, + 0xdb, 0xf2, 0x3c, 0x8c, 0x92, 0x3d, 0x5c, 0x58, 0xc9, 0x3e, 0x70, + 0x1d, 0x59, 0x69, 0x19, 0x35, 0xa8, 0x14, 0xaa, 0x75, 0x95, 0x99, + 0x34, 0x6f, 0x15, 0xff, 0x97, 0x4b, 0x90, 0x17, 0x10, 0x39, 0xf7, + 0xf6, 0xa2, 0x49, 0x4e, 0xc3, 0x68, 0xe0, 0x8b, 0xf0, 0xce, 0x0c, + 0x29, 0xe8, 0xb7, 0x86, 0x9a, 0x52, 0x01, 0x9d, 0x71, 0x9c, 0xbd, + 0x5d, 0x6d, 0x67, 0x3f, 0x6b, 0xb3, 0x46, 0x28, 0xa5, 0xc6, 0xd3, + 0x27, 0x61, 0x18, 0x66, 0x6a, 0xbf, 0x0d, 0xf4, 0xb3, 0x46, 0x28, + 0xa5, 0xc6, 0xd3, 0x27, 0x61, 0x18, 0x66, 0x6a, 0xbf, 0x0d, 0xf4, + 0xb3, 0x00, 0x04, 0x05, 0x23, 0x22, 0x03, 0x1f, 0x0f, 0x0a, 0x05, + 0x13, 0x24, 0x87, 0x25, 0x1e, 0x2c, 0x15, 0x20, 0x1f, 0x14, 0x05, + 0x21, 0x0d, 0x0e, 0x05, 0x1d, 0x05, 0x12, 0x09, 0x03, 0x02, 0x1a, + 0x19, 0x19, 0x29, 0x2a, 0x1a, 0x2d, 0x2a, 0x2d, 0x24, 0x26, 0x1a, + 0x2a, 0x1e, 0x29, 0x22, 0x22, 0x05, 0x2a, 0x06, 0x05, 0x21, 0x19, + 0x2a, 0x2a, 0x28, 0x02, 0x10, 0x19, 0x2a, 0x2a, 0x05, 0x00, 0x27, + 0x24, 0x16, 0x19, 0x06, 0x20, 0x0c, 0x24, 0x0b, 0x27, 0x12, 0x27, + 0x18, 0x1f, 0x32, 0x11, 0x2e, 0x06, 0x1b, 0x00, 0x2f, 0x29, 0x29, + 0x00, 0x00, 0x13, 0x22, 0x17, 0x12, 0x1d, 0x42, 0x45, 0x46, 0x41, + 0x41, 0x52, 0x42, 0x45, 0x4b, 0x45, 0x4b, 0x20, 0x52, 0x2d, 0x55, + 0x52, 0x41, 0x52, 0x20, 0x49, 0x4e, 0x41, 0x49, 0x4c, 0x49, 0x43, + 0x45, 0x20, 0x52, 0x20, 0x20, 0xe8, 0x90, 0x90, 0x90, 0xa0, 0xa0, + 0xa0, 0xc0, 0xc0, 0xc0, 0x48, 0x48, 0x48, 0x00, 0x00, 0x00, 0xd8, + 0xd8, 0xd8, 0x28, 0x28, 0x28, 0x60, 0x60, 0x60, 0xd0, 0xd0, 0xd0, + 0x80, 0x40, 0x40, 0x20, 0xe0, 0xe0, 0x20, 0x10, 0x10, 0x18, 0x20, + 0x20, 0x20, 0xe8, 0xe8, 0xe0, 0x20, 0xe0, 0x10, 0x88, 0x10, 0x80, + 0x80, 0x40, 0x20, 0x20, 0x38, 0x20, 0x20, 0x90, 0x20, 0x20, 0xa0, + 0x98, 0x98, 0x48, 0x18, 0x18, 0x58, 0x88, 0x88, 0x10, 0x20, 0x20, + 0x10, 0x20, 0x20, 0x18, 0xe0, 0xe0, 0x00, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x08, 0x90, 0xb0, 0x90, 0xa0, 0xb0, 0xa0, 0xc0, 0xb0, 0xc0, + 0x80, 0xb0, 0x40, 0x88, 0x20, 0x68, 0xd8, 0x00, 0x70, 0xd8, 0x20, + 0x78, 0x98, 0xb0, 0x48, 0x80, 0xe0, 0x50, 0x20, 0xb8, 0xe0, 0x88, + 0xb0, 0x10, 0x20, 0x00, 0x10, 0x20, 0xe0, 0x18, 0xe0, 0x18, 0x00, + 0x18, 0xe0, 0x20, 0xa8, 0xe0, 0x20, 0x18, 0xe0, 0x00, 0xc8, 0x18, + 0xe0, 0x00, 0xe0, 0x40, 0x20, 0x18, 0xe0, 0xe0, 0x18, 0x30, 0x20, + 0xe0, 0xe8, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8, 0xf8, 0xe0, 0x20, 0x08, + 0x00, 0x00, 0x10, 0xff, 0x7f, 0xbf, 0x32, 0xd0, 0x00, 0x00, 0x00, + 0x9f, 0x63, 0x79, 0x42, 0xb0, 0x15, 0xcb, 0x04, 0xff, 0x7f, 0x31, + 0x6e, 0x4a, 0x45, 0x00, 0x00, 0xff, 0x7f, 0xef, 0x1b, 0x00, 0x02, + 0x00, 0x00, 0xff, 0x7f, 0x1f, 0x42, 0xf2, 0x1c, 0x00, 0x00, 0xff, + 0x7f, 0x94, 0x52, 0x4a, 0x29, 0x00, 0x00, 0xff, 0x7f, 0xff, 0x03, + 0x2f, 0x01, 0x00, 0x00, 0xff, 0x7f, 0xef, 0x03, 0xd6, 0x01, 0x00, + 0x00, 0xff, 0x7f, 0xb5, 0x42, 0xc8, 0x3d, 0x00, 0x00, 0x74, 0x7e, + 0xff, 0x03, 0x80, 0x01, 0x00, 0x00, 0xff, 0x67, 0xac, 0x77, 0x13, + 0x1a, 0x6b, 0x2d, 0xd6, 0x7e, 0xff, 0x4b, 0x75, 0x21, 0x00, 0x00, + 0xff, 0x53, 0x5f, 0x4a, 0x52, 0x7e, 0x00, 0x00, 0xff, 0x4f, 0xd2, + 0x7e, 0x4c, 0x3a, 0xe0, 0x1c, 0xed, 0x03, 0xff, 0x7f, 0x5f, 0x25, + 0x00, 0x00, 0x6a, 0x03, 0x1f, 0x02, 0xff, 0x03, 0xff, 0x7f, 0xff, + 0x7f, 0xdf, 0x01, 0x12, 0x01, 0x00, 0x00, 0x1f, 0x23, 0x5f, 0x03, + 0xf2, 0x00, 0x09, 0x00, 0xff, 0x7f, 0xea, 0x03, 0x1f, 0x01, 0x00, + 0x00, 0x9f, 0x29, 0x1a, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xff, 0x7f, + 0x7f, 0x02, 0x1f, 0x00, 0x00, 0x00, 0xff, 0x7f, 0xe0, 0x03, 0x06, + 0x02, 0x20, 0x01, 0xff, 0x7f, 0xeb, 0x7e, 0x1f, 0x00, 0x00, 0x7c, + 0xff, 0x7f, 0xff, 0x3f, 0x00, 0x7e, 0x1f, 0x00, 0xff, 0x7f, 0xff, + 0x03, 0x1f, 0x00, 0x00, 0x00, 0xff, 0x03, 0x1f, 0x00, 0x0c, 0x00, + 0x00, 0x00, 0xff, 0x7f, 0x3f, 0x03, 0x93, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x42, 0x7f, 0x03, 0xff, 0x7f, 0xff, 0x7f, 0x8c, 0x7e, + 0x00, 0x7c, 0x00, 0x00, 0xff, 0x7f, 0xef, 0x1b, 0x80, 0x61, 0x00, + 0x00, 0xff, 0x7f, 0xea, 0x7f, 0x5f, 0x7d, 0x00, 0x00, 0x77, 0x1b, + 0xd2, 0x0a, 0xe9, 0x25, 0x45, 0x15, 0x01, 0x30, 0x05, 0x08, 0x00, + 0x28, 0x2b, 0x03, 0x06, 0x07, 0x1c, 0x31, 0x33, 0x34, 0x35, 0x36, + 0x3c, 0x42, 0xb9, 0xa5, 0xb9, 0xa5, 0x42, 0x3c, 0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, 0x6a, 0x18, 0x02, 0x0e, 0x68, + 0x3e, 0x80, 0xb3, 0xe2, 0x0c, 0x2a, 0xe2, 0x15, 0x20, 0xfb, 0xc9, + 0x21, 0xc0, 0x98, 0x0e, 0x03, 0x7e, 0xfe, 0x0f, 0x28, 0x08, 0x3c, + 0x77, 0xe6, 0x07, 0xfe, 0x01, 0x28, 0x03, 0x23, 0x18, 0xf0, 0x7d, + 0xf6, 0x1f, 0x6f, 0x23, 0x0d, 0xc8, 0x18, 0xe7, 0x3e, 0x01, 0xe0, + 0x4f, 0x16, 0x1a, 0x06, 0x02, 0xcd, 0x4f, 0x06, 0xcd, 0xbf, 0x06, + 0x15, 0x20, 0xf5, 0xc9, 0xcd, 0xf8, 0x07, 0xcd, 0x1b, 0x08, 0xaf, + 0xe0, 0x4f, 0xcd, 0x1b, 0x08, 0xfa, 0x43, 0x01, 0xcb, 0x7f, 0x20, + 0x03, 0xcd, 0x18, 0x07, 0xe0, 0x4c, 0xfa, 0x40, 0xc0, 0xa7, 0x20, + 0x03, 0x3e, 0x11, 0xc9, 0xcd, 0x18, 0x07, 0xe0, 0x4c, 0x3e, 0x01, + 0xc9, 0x3e, 0x01, 0xe0, 0x6c, 0xcd, 0x41, 0x07, 0xcb, 0x7f, 0xc4, + 0xc6, 0x08, 0xe6, 0x7f, 0x47, 0xfa, 0x40, 0xc0, 0xa7, 0x28, 0x0a, + 0x21, 0x7d, 0x04, 0x4f, 0x06, 0x00, 0x09, 0x7e, 0x18, 0x01, 0x78, + 0xcd, 0x43, 0x06, 0xcd, 0x90, 0x07, 0x3e, 0x04, 0xc9, 0xfa, 0x4b, + 0x01, 0xfe, 0x33, 0x28, 0x06, 0xfe, 0x01, 0x20, 0x42, 0x18, 0x0e, + 0xfa, 0x44, 0x01, 0xfe, 0x30, 0x20, 0x39, 0xfa, 0x45, 0x01, 0xfe, + 0x31, 0x20, 0x32, 0x21, 0x34, 0x01, 0x0e, 0x10, 0x06, 0x00, 0x2a, + 0x80, 0x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x21, 0x51, 0xff, 0x3e, + 0xd0, 0x22, 0xaf, 0x22, 0x3e, 0x98, 0x22, 0x3e, 0xa0, 0x22, 0x3e, + 0x12, 0x22, 0xc9, 0x3e, 0x20, 0xe0, 0x00, 0xf0, 0x00, 0x2f, 0xe6, + 0x0f, 0xc8, 0xc5, 0x0e, 0x00, 0x0c, 0x1f, 0x30, 0xfc, 0x3e, 0x10, + 0xe0, 0x00, 0xf0, 0x00, 0x2f, 0x17, 0x17, 0xe6, 0x0c, 0x81, 0x47, + 0xfa, 0x40, 0xc0, 0x4f, 0x78, 0xea, 0x40, 0xc0, 0xb9, 0xc1, 0xc8, + 0xf5, 0xe5, 0xc5, 0xd5, 0x21, 0x7d, 0x04, 0x4f, 0x06, 0x00, 0x09, + 0x7e, 0x47, 0x80, 0x80, 0x21, 0xdb, 0x02, 0x06, 0x00, 0x4f, 0x09, + 0x7e, 0x21, 0x7f, 0x03, 0x06, 0x00, 0x4f, 0x09, 0x3a, 0xfe, 0x7f, + 0x20, 0x02, 0x23, 0x23, 0xf5, 0x2a, 0xe5, 0x21, 0x00, 0xc0, 0xcd, + 0xbb, 0x08, 0xe1, 0xea, 0x02, 0xc0, 0x2a, 0xe5, 0x21, 0x01, 0xc0, + 0xcd, 0xbb, 0x08, 0xe1, 0xea, 0x03, 0xc0, 0xf1, 0x28, 0x02, 0x23, + 0x23, 0x2a, 0xea, 0x3a, 0xc0, 0x2a, 0xea, 0x3b, 0xc0, 0x2a, 0xea, + 0x04, 0xc0, 0x7e, 0xea, 0x05, 0xc0, 0xcd, 0x43, 0x06, 0x21, 0x00, + 0xc0, 0x16, 0x40, 0x1e, 0x00, 0xcd, 0xb2, 0x06, 0xd1, 0xc1, 0xe1, + 0xf1, 0xc9, 0x11, 0x08, 0x00, 0x0e, 0x08, 0x77, 0x19, 0x0d, 0x20, + 0xfb, 0xc9, 0xf5, 0xcd, 0x43, 0x06, 0x3e, 0x19, 0xea, 0x10, 0x99, + 0x21, 0x2f, 0x99, 0x0e, 0x0c, 0x3d, 0x28, 0x08, 0x32, 0x0d, 0x20, + 0xf9, 0x2e, 0x0f, 0x18, 0xf5, 0xf1, 0xc9, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +const int cgb_boot_length = 2305; diff --git a/libretro/dmg_boot.h b/libretro/dmg_boot.h new file mode 100644 index 0000000..1e424b6 --- /dev/null +++ b/libretro/dmg_boot.h @@ -0,0 +1,28 @@ +const char dmg_boot[257] = { + 0x31, 0xfe, 0xff, 0x21, 0x00, 0x80, 0x22, 0xcb, 0x6c, 0x28, 0xfb, + 0x3e, 0x80, 0xe0, 0x26, 0xe0, 0x11, 0x3e, 0xf3, 0xe0, 0x12, 0xe0, + 0x25, 0x3e, 0x77, 0xe0, 0x24, 0x3e, 0xfc, 0xe0, 0x47, 0x11, 0x04, + 0x01, 0x21, 0x10, 0x80, 0x1a, 0x47, 0xcd, 0x82, 0x00, 0xcd, 0x82, + 0x00, 0x13, 0x7b, 0xee, 0x34, 0x20, 0xf2, 0x11, 0xac, 0x00, 0x0e, + 0x08, 0x1a, 0x13, 0x22, 0x23, 0x0d, 0x20, 0xf9, 0x3e, 0x19, 0xea, + 0x10, 0x99, 0x21, 0x2f, 0x99, 0x0e, 0x0c, 0x3d, 0x28, 0x08, 0x32, + 0x0d, 0x20, 0xf9, 0x2e, 0x0f, 0x18, 0xf5, 0x3e, 0x91, 0xe0, 0x40, + 0x06, 0x2d, 0xcd, 0x9e, 0x00, 0x3e, 0x83, 0xcd, 0xa5, 0x00, 0x06, + 0x0f, 0xcd, 0x9e, 0x00, 0x3e, 0xc1, 0xcd, 0xa5, 0x00, 0x06, 0x96, + 0xcd, 0x9e, 0x00, 0x21, 0xb0, 0x01, 0xe5, 0xf1, 0x21, 0x4d, 0x01, + 0x01, 0x13, 0x00, 0x11, 0xd8, 0x00, 0xc3, 0xfe, 0x00, 0x3e, 0x04, + 0x0e, 0x00, 0xcb, 0x20, 0xf5, 0xcb, 0x11, 0xf1, 0xcb, 0x11, 0x3d, + 0x20, 0xf5, 0x79, 0x22, 0x23, 0x22, 0x23, 0xc9, 0xf0, 0x44, 0xfe, + 0x90, 0x20, 0xfa, 0xc9, 0xcd, 0x97, 0x00, 0x05, 0x20, 0xfa, 0xc9, + 0xe0, 0x13, 0x3e, 0x87, 0xe0, 0x14, 0xc9, 0x3c, 0x42, 0xb9, 0xa5, + 0xb9, 0xa5, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x50, 0x00 +}; + +const int dmg_boot_length = 257; diff --git a/libretro/libretro.c b/libretro/libretro.c index 57abff1..a841ae4 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -6,6 +6,7 @@ #include #include + #define AUDIO_FREQUENCY 44100 #ifdef _WIN32 @@ -313,13 +314,20 @@ bool retro_load_game(const struct retro_game_info *info) GB_init(&gb); snprintf(buf, sizeof(buf), "%s%cdmg_boot.bin", retro_base_directory, slash); err = GB_load_boot_rom(&gb, buf); + + if (err) + err = GB_load_boot_rom_dmg(&gb); } else { GB_init_cgb(&gb); snprintf(buf, sizeof(buf), "%s%ccgb_boot.bin", retro_base_directory, slash); err = GB_load_boot_rom(&gb, buf); + + if (err) + err = GB_load_boot_rom_cgb(&gb); } + if (err) log_cb(RETRO_LOG_INFO, "Failed to load boot ROM %s %d\n", buf, err); (void)info;