Add save-state support for new unit: 'Game I/O Connector'

This commit is contained in:
tomcw
2022-12-31 19:51:05 +00:00
parent 043bc49f3d
commit 4ca6aaea33
3 changed files with 63 additions and 1 deletions
+26 -1
View File
@@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Interface.h"
#include "CardManager.h"
#include "CopyProtectionDongles.h"
#include "Debug.h"
#include "Joystick.h"
#include "Keyboard.h"
@@ -66,10 +67,13 @@ static YamlHelper yamlHelper;
// v5: Extended: cpu (added 'Defer IRQ By 1 Opcode')
// v6: Added 'Unit Miscellaneous' for NoSlotClock(NSC)
// v7: Extended: joystick (added 'Paddle Inactive Cycle')
#define UNIT_APPLE2_VER 7
// v8: Added 'Unit Game I/O Connector' for Game I/O Connector
#define UNIT_APPLE2_VER 8
#define UNIT_SLOTS_VER 1
#define UNIT_GAME_IO_CONNECTOR_VER 1
#define UNIT_MISC_VER 1
//-----------------------------------------------------------------------------
@@ -178,6 +182,12 @@ static const std::string& GetSnapshotUnitSlotsName(void)
return name;
}
static const std::string& GetSnapshotUnitGameIOConnectorName(void)
{
static const std::string name("Game I/O Connector");
return name;
}
static const std::string& GetSnapshotUnitMiscName(void)
{
static const std::string name("Miscellaneous");
@@ -329,6 +339,10 @@ static void ParseUnit(void)
{
ParseSlots(yamlLoadHelper, unitVersion);
}
else if (unit == GetSnapshotUnitGameIOConnectorName())
{
CopyProtectionDongleLoadSnapshot(yamlLoadHelper);
}
else if (unit == GetSnapshotUnitMiscName())
{
// NB. could extend for other misc devices - see how ParseSlots() calls GetMapNextSlotNumber()
@@ -365,6 +379,8 @@ static void Snapshot_LoadState_v2(void)
GetCardMgr().Remove(slot);
GetCardMgr().RemoveAux();
SetCopyProtectionDongleType(DT_EMPTY);
MemReset(); // Also calls CpuInitialize()
GetPravets().Reset();
@@ -478,6 +494,15 @@ void Snapshot_SaveState(void)
GetCardMgr().SaveSnapshot(yamlSaveHelper);
}
// Unit: Game I/O Connector
if (GetCopyProtectionDongleType() != DT_EMPTY)
{
yamlSaveHelper.UnitHdr(GetSnapshotUnitGameIOConnectorName(), UNIT_GAME_IO_CONNECTOR_VER);
YamlSaveHelper::Label unit(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE);
CopyProtectionDongleSaveSnapshot(yamlSaveHelper);
}
// Miscellaneous
if (MemHasNoSlotClock())
{