mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-04-10 19:15:14 +00:00
Changed save state file version (r340 changed Real3D save format, breaking compatibility with older states, and states were probably already incompatible with 0.2a)
This commit is contained in:
parent
3bd8e20639
commit
9baa0488e3
|
@ -615,18 +615,16 @@ static void LogConfig(void)
|
||||||
Different subsystems output their own blocks.
|
Different subsystems output their own blocks.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#define STATE_FILE_VERSION 1 // save state file version
|
static const int STATE_FILE_VERSION = 2; // save state file version
|
||||||
#define NVRAM_FILE_VERSION 0 // NVRAM file version
|
static const int NVRAM_FILE_VERSION = 0; // NVRAM file version
|
||||||
|
static unsigned s_saveSlot = 0; // save state slot #
|
||||||
static unsigned saveSlot = 0; // save state slot #
|
|
||||||
|
|
||||||
static void SaveState(CModel3 *Model3)
|
static void SaveState(CModel3 *Model3)
|
||||||
{
|
{
|
||||||
CBlockFile SaveState;
|
CBlockFile SaveState;
|
||||||
char filePath[24];
|
|
||||||
int fileVersion = STATE_FILE_VERSION;
|
|
||||||
|
|
||||||
sprintf(filePath, "Saves/%s.st%d", Model3->GetGameInfo()->id, saveSlot);
|
char filePath[24];
|
||||||
|
sprintf(filePath, "Saves/%s.st%d", Model3->GetGameInfo()->id, s_saveSlot);
|
||||||
if (OKAY != SaveState.Create(filePath, "Supermodel Save State", "Supermodel Version " SUPERMODEL_VERSION))
|
if (OKAY != SaveState.Create(filePath, "Supermodel Save State", "Supermodel Version " SUPERMODEL_VERSION))
|
||||||
{
|
{
|
||||||
ErrorLog("Unable to save state to '%s'.", filePath);
|
ErrorLog("Unable to save state to '%s'.", filePath);
|
||||||
|
@ -634,6 +632,7 @@ static void SaveState(CModel3 *Model3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write file format version and ROM set ID to header block
|
// Write file format version and ROM set ID to header block
|
||||||
|
int32_t fileVersion = STATE_FILE_VERSION;
|
||||||
SaveState.Write(&fileVersion, sizeof(fileVersion));
|
SaveState.Write(&fileVersion, sizeof(fileVersion));
|
||||||
SaveState.Write(Model3->GetGameInfo()->id, strlen(Model3->GetGameInfo()->id)+1);
|
SaveState.Write(Model3->GetGameInfo()->id, strlen(Model3->GetGameInfo()->id)+1);
|
||||||
|
|
||||||
|
@ -647,11 +646,10 @@ static void SaveState(CModel3 *Model3)
|
||||||
static void LoadState(CModel3 *Model3)
|
static void LoadState(CModel3 *Model3)
|
||||||
{
|
{
|
||||||
CBlockFile SaveState;
|
CBlockFile SaveState;
|
||||||
char filePath[24];
|
|
||||||
int fileVersion;
|
|
||||||
|
|
||||||
// Generate file path
|
// Generate file path
|
||||||
sprintf(filePath, "Saves/%s.st%d", Model3->GetGameInfo()->id, saveSlot);
|
char filePath[24];
|
||||||
|
sprintf(filePath, "Saves/%s.st%d", Model3->GetGameInfo()->id, s_saveSlot);
|
||||||
|
|
||||||
// Open and check to make sure format is correct
|
// Open and check to make sure format is correct
|
||||||
if (OKAY != SaveState.Load(filePath))
|
if (OKAY != SaveState.Load(filePath))
|
||||||
|
@ -666,6 +664,7 @@ static void LoadState(CModel3 *Model3)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t fileVersion;
|
||||||
SaveState.Read(&fileVersion, sizeof(fileVersion));
|
SaveState.Read(&fileVersion, sizeof(fileVersion));
|
||||||
if (fileVersion != STATE_FILE_VERSION)
|
if (fileVersion != STATE_FILE_VERSION)
|
||||||
{
|
{
|
||||||
|
@ -683,9 +682,8 @@ static void LoadState(CModel3 *Model3)
|
||||||
static void SaveNVRAM(CModel3 *Model3)
|
static void SaveNVRAM(CModel3 *Model3)
|
||||||
{
|
{
|
||||||
CBlockFile NVRAM;
|
CBlockFile NVRAM;
|
||||||
char filePath[24];
|
|
||||||
int fileVersion = NVRAM_FILE_VERSION;
|
|
||||||
|
|
||||||
|
char filePath[24];
|
||||||
sprintf(filePath, "NVRAM/%s.nv", Model3->GetGameInfo()->id);
|
sprintf(filePath, "NVRAM/%s.nv", Model3->GetGameInfo()->id);
|
||||||
if (OKAY != NVRAM.Create(filePath, "Supermodel NVRAM State", "Supermodel Version " SUPERMODEL_VERSION))
|
if (OKAY != NVRAM.Create(filePath, "Supermodel NVRAM State", "Supermodel Version " SUPERMODEL_VERSION))
|
||||||
{
|
{
|
||||||
|
@ -694,6 +692,7 @@ static void SaveNVRAM(CModel3 *Model3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write file format version and ROM set ID to header block
|
// Write file format version and ROM set ID to header block
|
||||||
|
int32_t fileVersion = NVRAM_FILE_VERSION;
|
||||||
NVRAM.Write(&fileVersion, sizeof(fileVersion));
|
NVRAM.Write(&fileVersion, sizeof(fileVersion));
|
||||||
NVRAM.Write(Model3->GetGameInfo()->id, strlen(Model3->GetGameInfo()->id)+1);
|
NVRAM.Write(Model3->GetGameInfo()->id, strlen(Model3->GetGameInfo()->id)+1);
|
||||||
|
|
||||||
|
@ -706,10 +705,9 @@ static void SaveNVRAM(CModel3 *Model3)
|
||||||
static void LoadNVRAM(CModel3 *Model3)
|
static void LoadNVRAM(CModel3 *Model3)
|
||||||
{
|
{
|
||||||
CBlockFile NVRAM;
|
CBlockFile NVRAM;
|
||||||
char filePath[24];
|
|
||||||
int fileVersion;
|
|
||||||
|
|
||||||
// Generate file path
|
// Generate file path
|
||||||
|
char filePath[24];
|
||||||
sprintf(filePath, "NVRAM/%s.nv", Model3->GetGameInfo()->id);
|
sprintf(filePath, "NVRAM/%s.nv", Model3->GetGameInfo()->id);
|
||||||
|
|
||||||
// Open and check to make sure format is correct
|
// Open and check to make sure format is correct
|
||||||
|
@ -725,6 +723,7 @@ static void LoadNVRAM(CModel3 *Model3)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t fileVersion;
|
||||||
NVRAM.Read(&fileVersion, sizeof(fileVersion));
|
NVRAM.Read(&fileVersion, sizeof(fileVersion));
|
||||||
if (fileVersion != NVRAM_FILE_VERSION)
|
if (fileVersion != NVRAM_FILE_VERSION)
|
||||||
{
|
{
|
||||||
|
@ -1085,9 +1084,9 @@ int Supermodel(const char *zipFile, CInputs *Inputs, COutputs *Outputs, CINIFile
|
||||||
else if (Inputs->uiChangeSlot->Pressed())
|
else if (Inputs->uiChangeSlot->Pressed())
|
||||||
{
|
{
|
||||||
// Change save slot
|
// Change save slot
|
||||||
++saveSlot;
|
++s_saveSlot;
|
||||||
saveSlot %= 10; // clamp to [0,9]
|
s_saveSlot %= 10; // clamp to [0,9]
|
||||||
printf("Save slot: %d\n", saveSlot);
|
printf("Save slot: %d\n", s_saveSlot);
|
||||||
}
|
}
|
||||||
else if (Inputs->uiLoadState->Pressed())
|
else if (Inputs->uiLoadState->Pressed())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue