From ddcd8f356653710c85b938e0f129ced392e69ee7 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 15 May 2010 01:05:42 +0000 Subject: [PATCH] Overhaul of MovieRecord class so it has a default contructor that initializes everything to 0, A deconstructor, and a get method for savestate vector. Fixes my timeline issues, but creates crash problems in TASEdit related to the deconstructor. --- src/drivers/win/tasedit.cpp | 19 ++++++++------- src/movie.cpp | 47 ++++++++++++++++++++++++++++++------- src/movie.h | 14 ++++++++--- 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 3dc1bfe3..ef986b06 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -105,11 +105,11 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg) SelectObject(msg->nmcd.hdc,debugSystem->hFixedFont); if((msg->iSubItem-2)/8==0) if((int)msg->nmcd.dwItemSpec < currMovieData.greenZoneCount && - !currMovieData.records[msg->nmcd.dwItemSpec].savestate.empty()) + !currMovieData.records[msg->nmcd.dwItemSpec].GetSavestate().empty()) msg->clrTextBk = RGB(192,255,192); else {} else if((int)msg->nmcd.dwItemSpec < currMovieData.greenZoneCount && - !currMovieData.records[msg->nmcd.dwItemSpec].savestate.empty()) + !currMovieData.records[msg->nmcd.dwItemSpec].GetSavestate().empty()) msg->clrTextBk = RGB(144,192,144); else msg->clrTextBk = RGB(192,192,192); return CDRF_DODEFAULT; @@ -233,7 +233,7 @@ void LockGreenZone(int newstart) { for (int i=1; i(index)0; --i) { - if (!currMovieData.records[i].savestate.empty() && - MovieData::loadSavestateFrom(&currMovieData.records[i].savestate)) + if (!currMovieData.records[i].GetSavestate().empty() && + MovieData::loadSavestateFrom(&currMovieData.records[i].GetSavestate())) { currFrameCounter=i; turbo=i+6060; pauseframe=index+1; } @@ -309,7 +310,7 @@ bool JumpToFrame(int index) { poweron(false); currFrameCounter=0; - MovieData::dumpSavestateTo(&currMovieData.records[0].savestate,0); + MovieData::dumpSavestateTo(&currMovieData.records[0].GetSavestate(),0); return true; } diff --git a/src/movie.cpp b/src/movie.cpp index 57cca92d..9242ed6d 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -130,7 +130,7 @@ void MovieData::TryDumpIncremental() { if (turbo && pauseframe-256>currFrameCounter && ((currFrameCounter-pauseframe)&0xff)) return; - MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].savestate,Z_DEFAULT_COMPRESSION); + MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].GetSavestate(),Z_DEFAULT_COMPRESSION); } if(currFrameCounter == currMovieData.greenZoneCount) { @@ -139,20 +139,50 @@ void MovieData::TryDumpIncremental() currMovieData.insertEmpty(-1,1); } - MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].savestate,Z_DEFAULT_COMPRESSION); + MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].GetSavestate(),Z_DEFAULT_COMPRESSION); currMovieData.greenZoneCount++; } else if (currFrameCounter < currMovieData.greenZoneCount || !movie_readonly) { - MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].savestate,Z_DEFAULT_COMPRESSION); + MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].GetSavestate(),Z_DEFAULT_COMPRESSION); } else if (currFrameCounter > currMovieData.greenZoneCount && static_cast(currMovieData.greenZoneCount)commands != compareRec.commands) // return false; + //if new commands are ever recordable, they need to be added here if we go with this method if(this->command_reset() != compareRec.command_reset()) return false; if(this->command_power() != compareRec.command_reset()) return false; if(this->command_fds_insert() != compareRec.command_fds_insert()) return false; @@ -497,14 +528,14 @@ int MovieData::dumpGreenzone(std::ostream *os, bool binary) int frame, size; for (int i=0; i<(int)records.size(); ++i) { - if (records[i].savestate.empty()) + if (records[i].GetSavestate().empty()) continue; frame=i; - size=records[i].savestate.size(); + size=records[i].GetSavestate().size(); write32le(frame, os); write32le(size, os); - os->write(&records[i].savestate[0], size); + os->write(&records[i].GetSavestate()[0], size); } frame=-1; size=currMovieData.greenZoneCount; @@ -1269,7 +1300,7 @@ bool FCEUMOV_ReadState(std::istream* is, uint32 size) if(movie_readonly) { - bool sameTimeline = true; //= CheckTimelines(tempMovieData, currMovieData); + bool sameTimeline = CheckTimelines(tempMovieData, currMovieData); if (sameTimeline) { diff --git a/src/movie.h b/src/movie.h index 49684b65..ecad6c05 100644 --- a/src/movie.h +++ b/src/movie.h @@ -96,6 +96,8 @@ class MovieRecord { public: + MovieRecord(); + ~MovieRecord(); ValueArray joysticks; struct { @@ -141,9 +143,6 @@ public: bool Compare(MovieRecord& compareRec); void clear(); - //a waste of memory in lots of cases.. maybe make it a pointer later? - std::vector savestate; - void parse(MovieData* md, std::istream* is); bool parseBinary(MovieData* md, std::istream* is); void dump(MovieData* md, std::ostream* os, int index); @@ -153,7 +152,16 @@ public: static const char mnemonics[8]; + std::vector& GetSavestate() + { + if (savestate == NULL) + savestate = new std::vector; + return *savestate; + } private: + //a waste of memory in lots of cases.. maybe make it a pointer later? + std::vector *savestate; + int mask(int bit) { return 1<