From d25d4d30ff18bac9bb1542fa27a4402cb650e27e Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 25 Jul 2018 21:27:51 -0700 Subject: [PATCH] GB, GBA Savedata: Fix savestate loading overwriting saves on reset --- CHANGES | 1 + src/gb/gb.c | 2 +- src/gba/gba.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index c344df2b7..92d0912d8 100644 --- a/CHANGES +++ b/CHANGES @@ -43,6 +43,7 @@ Bugfixes: - GB I/O: DMA register is R/W - GB Video: Fix SCX timing - GBA Video: Improve sprite cycle counting (fixes mgba.io/i/1126) + - GB, GBA Savedata: Fix savestate loading overwriting saves on reset Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722) diff --git a/src/gb/gb.c b/src/gb/gb.c index cce40b5ce..d5f809fb2 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -295,7 +295,6 @@ void GBUnloadROM(struct GB* gb) { gb->isPristine = false; gb->sramMaskWriteback = false; - GBSavedataUnmask(gb); GBSramDeinit(gb); if (gb->sramRealVf) { gb->sramRealVf->close(gb->sramRealVf); @@ -468,6 +467,7 @@ void GBReset(struct LR35902Core* cpu) { cpu->memory.setActiveRegion(cpu, cpu->pc); + gb->sramMaskWriteback = false; GBSavedataUnmask(gb); } diff --git a/src/gba/gba.c b/src/gba/gba.c index 73a8378a3..45025f228 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -185,6 +185,7 @@ void GBAReset(struct ARMCore* cpu) { struct GBA* gba = (struct GBA*) cpu->master; if (!gba->rr || (!gba->rr->isPlaying(gba->rr) && !gba->rr->isRecording(gba->rr))) { + gba->memory.savedata.maskWriteback = false; GBASavedataUnmask(&gba->memory.savedata); }