From a4e105737c43742d3a0e52ba8582730456569488 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 8 May 2018 10:20:58 -0700 Subject: [PATCH] GBA Savedata: Fix save mtime updating when r/o --- CHANGES | 1 + src/gba/savedata.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 55f2f0805..e243f9ff7 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,7 @@ Bugfixes: - GB Audio: Clock frame events on DIV - GBA Timer: Fix timers sometimes being late (fixes mgba.io/i/1012) - GBA Hardware: Fix RTC overriding light sensor (fixes mgba.io/i/1069) + - GBA Savedata: Fix savedata modified time updating when read-only 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/gba/savedata.c b/src/gba/savedata.c index ec41c4eb9..92f7741cb 100644 --- a/src/gba/savedata.c +++ b/src/gba/savedata.c @@ -516,12 +516,14 @@ void GBASavedataClean(struct GBASavedata* savedata, uint32_t frameCount) { if (savedata->maskWriteback) { GBASavedataUnmask(savedata); } - size_t size = GBASavedataSize(savedata); - savedata->dirty = 0; - if (savedata->data && savedata->vf->sync(savedata->vf, savedata->data, size)) { - mLOG(GBA_SAVE, INFO, "Savedata synced"); - } else { - mLOG(GBA_SAVE, INFO, "Savedata failed to sync!"); + if (savedata->mapMode & MAP_WRITE) { + size_t size = GBASavedataSize(savedata); + savedata->dirty = 0; + if (savedata->data && savedata->vf->sync(savedata->vf, savedata->data, size)) { + mLOG(GBA_SAVE, INFO, "Savedata synced"); + } else { + mLOG(GBA_SAVE, INFO, "Savedata failed to sync!"); + } } } }