diff --git a/CHANGES b/CHANGES index fdf22f093..c437ef953 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Bugfixes: - GBA: Fix multiboot ROM loading - Libretro: Fix saving in GB games (fixes mgba.io/i/486) - LR35902: Fix pc overflowing current region off-by-one + - GB MBC: Fix ROM bank overflows getting set to bank 0 Misc: - Qt: Improved HiDPI support diff --git a/src/gb/mbc.c b/src/gb/mbc.c index 9357fcbe3..b82dba9f1 100644 --- a/src/gb/mbc.c +++ b/src/gb/mbc.c @@ -33,6 +33,9 @@ void GBMBCSwitchBank(struct GBMemory* memory, int bank) { mLOG(GB_MBC, GAME_ERROR, "Attempting to switch to an invalid ROM bank: %0X", bank); bankStart &= (memory->romSize - 1); bank = bankStart / GB_SIZE_CART_BANK0; + if (!bank) { + ++bank; + } } memory->romBank = &memory->rom[bankStart]; memory->currentBank = bank;