From 967408cbc16a45eed3149fe955f914c7be5ff37f Mon Sep 17 00:00:00 2001 From: nitsuja Date: Sat, 12 Dec 2009 22:52:01 +0000 Subject: [PATCH] fix a glaring desync that would happen if you load a savestate while the lid is closed --- desmume/src/NDSSystem.cpp | 16 +++++++++++++--- desmume/src/saves.cpp | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index bac914062..daa2f7cc8 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -1586,27 +1586,37 @@ static bool loadUserInput(EMUFILE* is, int version); void nds_savestate(EMUFILE* os) { //version - write32le(2,os); + write32le(3,os); sequencer.save(os); saveUserInput(os); + + write32le(LidClosed,os); + write8le(countLid,os); } bool nds_loadstate(EMUFILE* is, int size) { + // this isn't part of the savestate loading logic, but + // don't skip the next frame after loading a savestate + frameSkipper.OmitSkip(true, true); + //read version u32 version; if(read32le(&version,is) != 1) return false; - if(version > 2) return false; + if(version > 3) return false; bool temp = true; temp &= sequencer.load(is, version); if(version <= 1 || !temp) return temp; temp &= loadUserInput(is, version); - frameSkipper.OmitSkip(true, true); + if(version < 3) return temp; + + read32le(&LidClosed,is); + read8le(&countLid,is); return temp; } diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 8c5aacd01..31fc47a5c 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -176,6 +176,7 @@ SFORMAT SF_NDS[]={ { "_ENS", 4, 1, &nds.ensataEmulation}, { "_ENH", 4, 1, &nds.ensataHandshake}, { "_ENI", 4, 1, &nds.ensataIpcSyncCounter}, + { "_SLP", 4, 1, &nds.sleeping}, { 0 } };