diff --git a/CHANGES b/CHANGES index 28500a1f8..50fd8a5d4 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Emulation fixes: - GB Audio: Fix deserializing audio channels 2 and 3 - GB Audio: Fix deserializing while audio was disabled (fixes mgba.io/i/1305) - GB MBC: Fix MBC1 mode changing behavior + - GB MBC: Fix some MBC3 bit masking - GB Video: Fix state after skipping BIOS (fixes mgba.io/i/1715 and mgba.io/i/1716) - GBA: Fix timing advancing too quickly in rare cases - GBA Audio: Fix deserializing SOUNDCNT_L diff --git a/src/gb/mbc.c b/src/gb/mbc.c index cdbbbef44..38a332c9f 100644 --- a/src/gb/mbc.c +++ b/src/gb/mbc.c @@ -601,7 +601,7 @@ void _GBMBC3(struct GB* gb, uint16_t address, uint8_t value) { int bank = value; switch (address >> 13) { case 0x0: - switch (value) { + switch (value & 0xF) { case 0: memory->sramAccess = false; break; @@ -625,11 +625,12 @@ void _GBMBC3(struct GB* gb, uint16_t address, uint8_t value) { GBMBCSwitchBank(gb, bank); break; case 0x2: - if (value < 8) { + bank &= 0xF; + if (bank < 8) { GBMBCSwitchSramBank(gb, value); memory->rtcAccess = false; - } else if (value <= 0xC) { - memory->activeRtcReg = value - 8; + } else if (bank <= 0xC) { + memory->activeRtcReg = bank - 8; memory->rtcAccess = true; } break;