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 EDITTEXT IDC_LABEL_LENGTH,76,68,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "Pal:",65494,10,153,59,8 RTEXT "Pal:",65494,10,153,59,8
EDITTEXT IDC_LABEL_PALUSED,76,153,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP EDITTEXT IDC_LABEL_PALUSED,76,153,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "New PPU:",65499,10,163,59,8 RTEXT "New PPU:",65499,10,164,59,8
EDITTEXT IDC_LABEL_NEWPPUUSED,76,163,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP EDITTEXT IDC_LABEL_NEWPPUUSED,76,164,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
END END
TASEDIT DIALOGEX 0, 0, 465, 382 TASEDIT DIALOGEX 0, 0, 465, 382

View File

@ -160,6 +160,32 @@ void MovieRecord::clear()
memset(zappers,0,sizeof(zappers)); 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'}; const char MovieRecord::mnemonics[8] = {'A','B','S','T','U','D','L','R'};
void MovieRecord::dumpJoy(std::ostream* os, uint8 joystate) void MovieRecord::dumpJoy(std::ostream* os, uint8 joystate)
{ {
@ -1146,6 +1172,28 @@ int FCEUMOV_WriteState(std::ostream* os)
else return 0; 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; static bool load_successful;
bool FCEUMOV_ReadState(std::istream* is, uint32 size) bool FCEUMOV_ReadState(std::istream* is, uint32 size)
@ -1215,9 +1263,13 @@ bool FCEUMOV_ReadState(std::istream* is, uint32 size)
closeRecordingMovie(); closeRecordingMovie();
if(movie_readonly) if(movie_readonly)
{
//bool sameTimeline = CheckTimelines(tempMovieData, currMovieData);
if (sameTimeline)
{ {
//if the frame counter is longer than our current movie, then error //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 if(currFrameCounter > (int)currMovieData.records.size()) //adelikat: TODO: finished mode needs something different here
{ {
FinishPlayback(); FinishPlayback();
//TODO: turn frame counter to red to get attention //TODO: turn frame counter to red to get attention
@ -1227,6 +1279,12 @@ bool FCEUMOV_ReadState(std::istream* is, uint32 size)
movieMode = MOVIEMODE_PLAY; movieMode = MOVIEMODE_PLAY;
} }
else else
{
//Wrong time line failed, do apprioriate logic here
FCEU_PrintError("Error: Savestate not in the same timeline as movie!");
}
}
else
{ {
//truncate before we copy, just to save some time //truncate before we copy, just to save some time
tempMovieData.truncateAt(currFrameCounter); tempMovieData.truncateAt(currFrameCounter);

View File

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