From 09ab12d0b6f291a41845b3ab57df074d9ca67b6d Mon Sep 17 00:00:00 2001 From: tomcw Date: Thu, 1 Nov 2018 21:14:16 +0000 Subject: [PATCH] Save-state: Keyboard - save 'Key Waiting' flag. (Fixes #591) --- source/Keyboard.cpp | 7 ++++++- source/Keyboard.h | 2 +- source/SaveState.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/Keyboard.cpp b/source/Keyboard.cpp index c28afd46..9fa5bdfe 100644 --- a/source/Keyboard.cpp +++ b/source/Keyboard.cpp @@ -552,6 +552,7 @@ void KeybSetSnapshot_v1(const BYTE LastKey) // #define SS_YAML_KEY_LASTKEY "Last Key" +#define SS_YAML_KEY_KEYWAITING "Key Waiting" static std::string KeybGetSnapshotStructName(void) { @@ -563,14 +564,18 @@ void KeybSaveSnapshot(YamlSaveHelper& yamlSaveHelper) { YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", KeybGetSnapshotStructName().c_str()); yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_LASTKEY, keycode); + yamlSaveHelper.SaveBool(SS_YAML_KEY_KEYWAITING, keywaiting ? true : false); } -void KeybLoadSnapshot(YamlLoadHelper& yamlLoadHelper) +void KeybLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version) { if (!yamlLoadHelper.GetSubMap(KeybGetSnapshotStructName())) return; keycode = (BYTE) yamlLoadHelper.LoadUint(SS_YAML_KEY_LASTKEY); + if (version == 2) + keywaiting = (BOOL) yamlLoadHelper.LoadBool(SS_YAML_KEY_KEYWAITING); + yamlLoadHelper.PopMap(); } diff --git a/source/Keyboard.h b/source/Keyboard.h index 65920f39..28b520b9 100644 --- a/source/Keyboard.h +++ b/source/Keyboard.h @@ -20,4 +20,4 @@ BYTE KeybReadData (void); BYTE KeybReadFlag (void); void KeybSetSnapshot_v1(const BYTE LastKey); void KeybSaveSnapshot(class YamlSaveHelper& yamlSaveHelper); -void KeybLoadSnapshot(class YamlLoadHelper& yamlLoadHelper); +void KeybLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT version); diff --git a/source/SaveState.cpp b/source/SaveState.cpp index c248b81b..e7c36fad 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -335,7 +335,7 @@ static void ParseUnitApple2(YamlLoadHelper& yamlLoadHelper, UINT version) m_ConfigNew.m_CpuType = GetMainCpu(); JoyLoadSnapshot(yamlLoadHelper); - KeybLoadSnapshot(yamlLoadHelper); + KeybLoadSnapshot(yamlLoadHelper, version); SpkrLoadSnapshot(yamlLoadHelper); VideoLoadSnapshot(yamlLoadHelper); MemLoadSnapshot(yamlLoadHelper, version);