restore savestate error recovery functionality. This should have the side effect of guaranteeing that ( SF [ 2040761 ] Wrong savestate bug - crashes FCEUX) is resolved.

[[Split portion of a mixed commit.]]
This commit is contained in:
zeromus 2008-08-14 07:50:41 +00:00
parent f6cb29ca1c
commit ddae078b3a
2 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,6 @@
---version 2.0.2 released---
14-aug-2008 - zeromus - restore savestate error recovery functionality. This should have the side effect of guaranteeing that ( SF [ 2040761 ] Wrong savestate bug - crashes FCEUX) is resolved.
14-aug-2008 - zeromus - SF [ 2047001 ] Low speeds crash FCEUX
14-aug-2008 - zeromus - SF [ 2050371 ] FCM>FM2 converter should release file handle
13-aug-2008 - zeromus - restore ungzipping (and unzipping in sdl) capability which was lost when archive support was added

View File

@ -548,6 +548,12 @@ int FCEUSS_LoadFP_old(std::istream* is, ENUM_SSLOADPARAMS params)
bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params)
{
//maybe make a backup savestate
memorystream msBackupSavestate;
bool backup = (params == SSLOADPARAM_BACKUP);
if(backup)
FCEUSS_SaveMS(&msBackupSavestate,Z_NO_COMPRESSION);
uint8 header[16];
//read and analyze the header
@ -558,6 +564,7 @@ bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params)
FCEU_state_loading_old_format = true;
bool ret = FCEUSS_LoadFP_old(is,params)!=0;
FCEU_state_loading_old_format = false;
if(!ret && backup) FCEUSS_LoadFP(&msBackupSavestate,SSLOADPARAM_NOBACKUP);
return ret;
}
@ -578,6 +585,7 @@ bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params)
int error = uncompress((uint8*)&buf[0],&uncomprlen,(uint8*)&cbuf[0],comprlen);
if(error != Z_OK || uncomprlen != totalsize)
return false;
//we dont need to restore the backup here because we havent messed with the emulator state yet
}
else
{
@ -604,6 +612,8 @@ bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params)
x=FCEUMOV_PostLoad();
}
if(!x && backup) FCEUSS_LoadFP(&msBackupSavestate,SSLOADPARAM_NOBACKUP);
return x;
}