diff --git a/src/gb/gb.c b/src/gb/gb.c index 7197bde15..cc02f0347 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -81,12 +81,13 @@ bool GBLoadROM(struct GB* gb, struct VFile* vf, struct VFile* sav, const char* f 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 diff --git a/src/gb/memory.c b/src/gb/memory.c index e6baee749..72c1c25bc 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -419,6 +419,11 @@ void _GBMBC5(struct GBMemory* memory, uint16_t address, uint8_t value) { 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);