all repos — mgba @ 32f0bb9f1f3b9993af4b563865a038b43c7f0310

mGBA Game Boy Advance Emulator

GB Memory: Add SRAM bank switching to MBC5
Jeffrey Pfau jeffrey@endrift.com
Thu, 28 Jan 2016 02:43:40 -0800
commit

32f0bb9f1f3b9993af4b563865a038b43c7f0310

parent

a3d0b85d5651abde4317f5ba6692d060b52230d4

2 files changed, 10 insertions(+), 4 deletions(-)

jump to
M src/gb/gb.csrc/gb/gb.c

@@ -81,12 +81,13 @@ gb->memory.romSize = gb->pristineRomSize;

gb->romCrc32 = doCrc32(gb->memory.rom, gb->memory.romSize); gb->sramVf = sav; if (sav) { - if (sav->size(sav) < 0x8000) { - sav->truncate(sav, 0x8000); + // TODO: Do this in bank-switching code + if (sav->size(sav) < 0x20000) { + sav->truncate(sav, 0x20000); } - gb->memory.sram = sav->map(sav, 0x8000, MAP_WRITE); + gb->memory.sram = sav->map(sav, 0x20000, MAP_WRITE); } else { - gb->memory.sram = anonymousMemoryMap(0x8000); + gb->memory.sram = anonymousMemoryMap(0x20000); } return true; // TODO: error check
M src/gb/memory.csrc/gb/memory.c

@@ -419,6 +419,11 @@ break;

case 0x1: _switchBank(memory, bank); break; + case 0x2: + if (value < 0x10) { + _switchSramBank(memory, value); + } + break; default: // TODO mLOG(GB_MBC, STUB, "MBC5 unknown address: %04X:%02X", address, value);