diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index e8d56c1b..091542fb 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -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 diff --git a/src/movie.cpp b/src/movie.cpp index 91978422..46a391e1 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -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 { diff --git a/src/movie.h b/src/movie.h index cb452240..49684b65 100644 --- a/src/movie.h +++ b/src/movie.h @@ -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?