diff --git a/CHANGES b/CHANGES index 2a601ccb8..8c6dd7b28 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Other fixes: - Core: Don't attempt to restore rewind diffs past start of rewind - FFmpeg: Fix crash when encoding audio with some containers - GB: Fix temporary saves + - GB, GBA: Save writeback-pending masked saves on unload (fixes mgba.io/i/2396) Misc: - Core: Suspend runloop when a core crashes - GB Video: Add default SGB border diff --git a/src/gb/gb.c b/src/gb/gb.c index a350f4067..43f5d93a0 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -318,7 +318,9 @@ void GBUnloadROM(struct GB* gb) { gb->memory.mbcType = GB_MBC_AUTODETECT; gb->isPristine = false; - gb->sramMaskWriteback = false; + if (!gb->sramDirty) { + gb->sramMaskWriteback = false; + } GBSavedataUnmask(gb); GBSramDeinit(gb); if (gb->sramRealVf) { diff --git a/src/gba/gba.c b/src/gba/gba.c index 16d02fd2c..86b597dc2 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -149,7 +149,9 @@ void GBAUnloadROM(struct GBA* gba) { gba->memory.rom = NULL; gba->isPristine = false; - gba->memory.savedata.maskWriteback = false; + if (!gba->memory.savedata.dirty) { + gba->memory.savedata.maskWriteback = false; + } GBASavedataUnmask(&gba->memory.savedata); GBASavedataDeinit(&gba->memory.savedata); if (gba->memory.savedata.realVf) {