From d3ec40b392db348f3ab1273e90d68e32e7717a15 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 30 Nov 2019 11:37:36 -0800 Subject: [PATCH] GB Memory: Support manual SRAM editing (fixes #1580) --- CHANGES | 2 ++ src/gb/memory.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index a451feeaa..c709f3851 100644 --- a/CHANGES +++ b/CHANGES @@ -97,6 +97,8 @@ Other fixes: - Core: Fix uninitialized memory issues with graphics caches - Vita: Fix analog controls (fixes mgba.io/i/1554) - Qt: Fix fast forward mute being reset (fixes mgba.io/i/1574) +Misc: + - GB Memory: Support manual SRAM editing (fixes mgba.io/i/1580) 0.8 beta 1: (2019-10-20) - Initial beta for 0.8 diff --git a/src/gb/memory.c b/src/gb/memory.c index e5817cefe..e60fbde18 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -649,7 +649,15 @@ void GBPatch8(struct LR35902Core* cpu, uint16_t address, int8_t value, int8_t* o break; case GB_REGION_EXTERNAL_RAM: case GB_REGION_EXTERNAL_RAM + 1: - mLOG(GB_MEM, STUB, "Unimplemented memory Patch8: 0x%08X", address); + if (memory->rtcAccess) { + memory->rtcRegs[memory->activeRtcReg] = value; + } else if (memory->sramAccess && memory->sram && memory->mbcType != GB_MBC2) { + // TODO: Remove sramAccess check? + memory->sramBank[address & (GB_SIZE_EXTERNAL_RAM - 1)] = value; + } else { + memory->mbcWrite(gb, address, value); + } + gb->sramDirty |= GB_SRAM_DIRT_NEW; return; case GB_REGION_WORKING_RAM_BANK0: case GB_REGION_WORKING_RAM_BANK0 + 2: