Save-state: Game I/O Connector: change yaml

This commit is contained in:
tomcw 2023-01-01 18:47:21 +00:00
parent 4ca6aaea33
commit dee264483a
4 changed files with 23 additions and 8 deletions

View File

@ -31,6 +31,7 @@
Matthew D'Asaro Dec 2022
*/
#include "StdAfx.h"
#include <sstream>
#include "CopyProtectionDongles.h"
#include "Memory.h"
@ -82,7 +83,11 @@ int CopyProtectionDonglePB2(void)
}
}
const std::string& CopyProtectionDongle_GetSnapshotStructName_SDSSpeedStar(void)
//===========================================================================
static const UINT kUNIT_VERSION = 1;
static const std::string& GetSnapshotStructName_SDSSpeedStar(void)
{
static const std::string name("SDS SpeedStar dongle");
return name;
@ -92,7 +97,7 @@ void CopyProtectionDongleSaveSnapshot(YamlSaveHelper& yamlSaveHelper)
{
if (copyProtectionDongleType == DT_SDSSPEEDSTAR)
{
YamlSaveHelper::Label label(yamlSaveHelper, "%s: null\n", CopyProtectionDongle_GetSnapshotStructName_SDSSpeedStar().c_str());
yamlSaveHelper.SaveString(SS_YAML_KEY_DEVICE, GetSnapshotStructName_SDSSpeedStar());
// NB. No state for this dongle
}
else
@ -101,11 +106,20 @@ void CopyProtectionDongleSaveSnapshot(YamlSaveHelper& yamlSaveHelper)
}
}
void CopyProtectionDongleLoadSnapshot(YamlLoadHelper& yamlLoadHelper)
void CopyProtectionDongleLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version)
{
bool found = false;
std::string s = yamlLoadHelper.LoadString_NoThrow(CopyProtectionDongle_GetSnapshotStructName_SDSSpeedStar(), found);
if (found)
if (version < 1 || version > kUNIT_VERSION)
{
std::ostringstream msg;
msg << "Version " << version;
msg << " is not supported for game I/O device.";
throw std::runtime_error(msg.str());
}
std::string device = yamlLoadHelper.LoadString(SS_YAML_KEY_DEVICE);
if (device == GetSnapshotStructName_SDSSpeedStar())
{
copyProtectionDongleType = DT_SDSSPEEDSTAR;
}

View File

@ -13,4 +13,4 @@ int CopyProtectionDonglePB2(void);
bool SdsSpeedStar(void);
void CopyProtectionDongleSaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
void CopyProtectionDongleLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);
void CopyProtectionDongleLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT version);

View File

@ -341,7 +341,7 @@ static void ParseUnit(void)
}
else if (unit == GetSnapshotUnitGameIOConnectorName())
{
CopyProtectionDongleLoadSnapshot(yamlLoadHelper);
CopyProtectionDongleLoadSnapshot(yamlLoadHelper, unitVersion);
}
else if (unit == GetSnapshotUnitMiscName())
{

View File

@ -11,6 +11,7 @@
#define SS_YAML_KEY_TYPE "Type"
#define SS_YAML_KEY_CARD "Card"
#define SS_YAML_KEY_STATE "State"
#define SS_YAML_KEY_DEVICE "Device"
#define SS_YAML_VALUE_AWSS "AppleWin Save State"