GB MBC: Fix some MBC3 bit masking

This commit is contained in:
Vicki Pfau 2020-09-12 22:50:04 -07:00
parent 06a3770daa
commit e232e5ce41
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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;