diff --git a/CHANGES b/CHANGES index 08180740d..d6fb54028 100644 --- a/CHANGES +++ b/CHANGES @@ -57,6 +57,7 @@ Bugfixes: - GBA DMA: Fix temporal sorting of DMAs of different priorities - FFmpeg: Fix encoding audio/video queue issues - GB Serialize: Fix IRQ pending/EI pending confusion + - GB MBC: Improve multicart detection heuristic (fixes mgba.io/i/1177) Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722) diff --git a/src/gb/mbc.c b/src/gb/mbc.c index 2da6a264e..817b3dc9d 100644 --- a/src/gb/mbc.c +++ b/src/gb/mbc.c @@ -95,17 +95,27 @@ void GBMBCSwitchHalfBank(struct GB* gb, int half, int bank) { } static bool _isMulticart(const uint8_t* mem) { - bool success = true; + bool success; struct VFile* vf; vf = VFileFromConstMemory(&mem[GB_SIZE_CART_BANK0 * 0x10], 1024); - success = success && GBIsROM(vf); + success = GBIsROM(vf); vf->close(vf); + if (!success) { + return false; + } + vf = VFileFromConstMemory(&mem[GB_SIZE_CART_BANK0 * 0x20], 1024); - success = success && GBIsROM(vf); + success = GBIsROM(vf); vf->close(vf); + if (!success) { + vf = VFileFromConstMemory(&mem[GB_SIZE_CART_BANK0 * 0x30], 1024); + success = GBIsROM(vf); + vf->close(vf); + } + return success; }