From d1e3ad7790879330845b2bbcb63260cbc5505de4 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 25 Apr 2020 23:18:03 +0300 Subject: [PATCH] Better hueristics for wrong MBC type --- Core/gb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/gb.c b/Core/gb.c index 701a48a..966022b 100644 --- a/Core/gb.c +++ b/Core/gb.c @@ -484,13 +484,13 @@ done:; // Fix a common wrong MBC error if (gb->rom[0x147] == 3) { // MBC1 + RAM + Battery - if (gb->rom_size == 64 * 0x4000) { - for (unsigned i = 63 * 0x4000; i < 64 * 0x4000; i++) { + if (gb->rom_size >= 33 * 0x4000) { + for (unsigned i = 32 * 0x4000; i < 33 * 0x4000; i++) { if (gb->rom[i]) { gb->rom[0x147] = 0x10; // MBC3 + RTC + RAM + Battery GB_configure_cart(gb); gb->rom[0x147] = 0x3; - GB_log(gb, "ROM uses MBC1 but appears to use all 64 banks, assuming MBC3\n"); + GB_log(gb, "ROM claims to use MBC1 but appears to require MBC3 or 5, assuming MBC3.\n"); break; } }