An attempt add doing "timeline" checks on movie savestates while in read-only mode. Commented out the function call since it isn't performing as expected.

This commit is contained in:
adelikat 2010-05-14 23:31:47 +00:00
parent 06b37466c2
commit d5aa6a69b2
3 changed files with 68 additions and 9 deletions

View File

@ -1304,8 +1304,8 @@ BEGIN
EDITTEXT IDC_LABEL_LENGTH,76,68,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "Pal:",65494,10,153,59,8
EDITTEXT IDC_LABEL_PALUSED,76,153,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "New PPU:",65499,10,163,59,8
EDITTEXT IDC_LABEL_NEWPPUUSED,76,163,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "New PPU:",65499,10,164,59,8
EDITTEXT IDC_LABEL_NEWPPUUSED,76,164,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
END
TASEDIT DIALOGEX 0, 0, 465, 382

View File

@ -160,6 +160,32 @@ void MovieRecord::clear()
memset(zappers,0,sizeof(zappers));
}
bool MovieRecord::Compare(MovieRecord& compareRec)
{
//Joysticks, Zappers, and commands
if (this->joysticks != compareRec.joysticks)
return false;
if (this->commands != compareRec.commands)
return false;
if (this->zappers[0].x != compareRec.zappers[0].x) return false;
if (this->zappers[0].y != compareRec.zappers[0].y) return false;
if (this->zappers[0].zaphit != compareRec.zappers[0].zaphit) return false;
if (this->zappers[0].b != compareRec.zappers[0].b) return false;
if (this->zappers[0].bogo != compareRec.zappers[0].bogo) return false;
if (this->zappers[1].x != compareRec.zappers[1].x) return false;
if (this->zappers[1].y != compareRec.zappers[1].y) return false;
if (this->zappers[1].zaphit != compareRec.zappers[1].zaphit) return false;
if (this->zappers[1].b != compareRec.zappers[1].b) return false;
if (this->zappers[1].bogo != compareRec.zappers[1].bogo) return false;
return true;
}
const char MovieRecord::mnemonics[8] = {'A','B','S','T','U','D','L','R'};
void MovieRecord::dumpJoy(std::ostream* os, uint8 joystate)
{
@ -1146,6 +1172,28 @@ int FCEUMOV_WriteState(std::ostream* os)
else return 0;
}
bool CheckTimelines(MovieData& stateMovie, MovieData& currMovie)
{
bool isInTimeline = true;
int length;
if (stateMovie.getNumRecords() > currMovie.getNumRecords())
return false; //TODO: this should be a precheck, so this function isn't even called in this situation
else
length = currMovie.getNumRecords();
for (int x = 0; x < stateMovie.getNumRecords(); x++)
{
if (!stateMovie.records[x].Compare(currMovie.records[x]))
{
isInTimeline = false;
break;
}
}
return isInTimeline;
}
static bool load_successful;
bool FCEUMOV_ReadState(std::istream* is, uint32 size)
@ -1216,15 +1264,25 @@ bool FCEUMOV_ReadState(std::istream* is, uint32 size)
if(movie_readonly)
{
//if the frame counter is longer than our current movie, then error
if(currFrameCounter > (int)currMovieData.records.size()) //adelikat: TODO: finished mode causes a crash if savestate is saved and loaded past movie frame count
//bool sameTimeline = CheckTimelines(tempMovieData, currMovieData);
if (sameTimeline)
{
FinishPlayback();
//TODO: turn frame counter to red to get attention
FCEU_PrintError("Savestate is from a frame (%d) after the final frame in the movie (%d). This is not permitted.", currFrameCounter, currMovieData.records.size()-1);
//return false;
//if the frame counter is longer than our current movie, then error
if(currFrameCounter > (int)currMovieData.records.size()) //adelikat: TODO: finished mode needs something different here
{
FinishPlayback();
//TODO: turn frame counter to red to get attention
FCEU_PrintError("Savestate is from a frame (%d) after the final frame in the movie (%d). This is not permitted.", currFrameCounter, currMovieData.records.size()-1);
//return false;
}
movieMode = MOVIEMODE_PLAY;
}
else
{
//Wrong time line failed, do apprioriate logic here
FCEU_PrintError("Error: Savestate not in the same timeline as movie!");
}
movieMode = MOVIEMODE_PLAY;
}
else
{

View File

@ -138,6 +138,7 @@ public:
return (joysticks[joy] & mask(bit))!=0;
}
bool Compare(MovieRecord& compareRec);
void clear();
//a waste of memory in lots of cases.. maybe make it a pointer later?