GB MBC: Fix MBC2 bit selection
Vicki Pfau vi@endrift.com
Tue, 16 Jun 2020 20:49:07 -0700
6 files changed,
13 insertions(+),
6 deletions(-)
M
CHANGES
→
CHANGES
@@ -7,6 +7,7 @@ - ARM: Fix ALU reading PC after shifting
- ARM: Fix STR storing PC after address calculation - GB MBC: Fix MBC1 mode changing behavior - GB MBC: Fix MBC1 RAM enable bit selection + - GB MBC: Fix MBC2 bit selection - 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 BIOS: Implement dummy sound driver calls
M
cinema/gb/mooneye-gb/emulator-only/mbc2/bits_ramg/config.ini
→
cinema/gb/mooneye-gb/emulator-only/mbc2/bits_ramg/config.ini
@@ -1,2 +1,2 @@
[testinfo] -fail=1 +skip=360
M
cinema/gb/mooneye-gb/emulator-only/mbc2/bits_romb/config.ini
→
cinema/gb/mooneye-gb/emulator-only/mbc2/bits_romb/config.ini
@@ -1,2 +1,2 @@
[testinfo] -fail=1 +skip=360
M
src/gb/mbc.c
→
src/gb/mbc.c
@@ -480,9 +480,9 @@ void _GBMBC2(struct GB* gb, uint16_t address, uint8_t value) {
struct GBMemory* memory = &gb->memory; int shift = (address & 1) * 4; int bank = value & 0xF; - switch (address >> 13) { + switch ((address & 0xC100) >> 8) { case 0x0: - switch (value) { + switch (value & 0x0F) { case 0: memory->sramAccess = false; break;@@ -491,7 +491,7 @@ memory->sramAccess = true;
break; default: // TODO - mLOG(GB_MBC, STUB, "MBC1 unknown value %02X", value); + mLOG(GB_MBC, STUB, "MBC2 unknown value %02X", value); break; } break;@@ -501,7 +501,10 @@ ++bank;
} GBMBCSwitchBank(gb, bank); break; - case 0x5: + case 0x80: + case 0x81: + case 0x82: + case 0x83: if (!memory->sramAccess) { return; }@@ -517,6 +520,9 @@ }
} static uint8_t _GBMBC2Read(struct GBMemory* memory, uint16_t address) { + if (!memory->sramAccess) { + return 0xFF; + } address &= 0x1FF; int shift = (address & 1) * 4; return (memory->sramBank[(address >> 1)] >> shift) | 0xF0;