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.
This commit is contained in:
parent
691662f4c9
commit
ddcd8f3566
|
@ -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<newstart; ++i)
|
||||
{
|
||||
currMovieData.records[i].savestate.clear();
|
||||
currMovieData.records[i].GetSavestate().clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,8 +268,9 @@ bool JumpToFrame(int index)
|
|||
}
|
||||
|
||||
if (static_cast<unsigned int>(index)<currMovieData.records.size() &&
|
||||
!currMovieData.records[index].savestate.empty() &&
|
||||
MovieData::loadSavestateFrom(&currMovieData.records[index].savestate))
|
||||
!currMovieData.records[index].GetSavestate().empty() &&
|
||||
MovieData::loadSavestateFrom(&currMovieData.records[index].GetSavestate()))
|
||||
//MovieData::loadSavestateFrom(&currMovieData.records[index].savestate))
|
||||
{
|
||||
currFrameCounter = index;
|
||||
return true;
|
||||
|
@ -287,8 +288,8 @@ bool JumpToFrame(int index)
|
|||
/* Search for an earlier frame, and try warping to the current. */
|
||||
for (; i>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+60<index; // turbo unless close
|
||||
|
@ -299,7 +300,7 @@ bool JumpToFrame(int index)
|
|||
|
||||
poweron(true);
|
||||
currFrameCounter=0;
|
||||
MovieData::dumpSavestateTo(&currMovieData.records[0].savestate,0);
|
||||
MovieData::dumpSavestateTo(&currMovieData.records[0].GetSavestate(),0);
|
||||
turbo = index>60;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<unsigned int>(currMovieData.greenZoneCount)<currMovieData.records.size())
|
||||
{
|
||||
/* May be required in some malformed TAS projects. */
|
||||
MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].savestate,Z_DEFAULT_COMPRESSION);
|
||||
MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].GetSavestate(),Z_DEFAULT_COMPRESSION);
|
||||
currMovieData.greenZoneCount= currFrameCounter+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MovieRecord::MovieRecord()
|
||||
{
|
||||
joysticks.data[0] = 0;
|
||||
joysticks.data[1] = 0;
|
||||
joysticks.data[2] = 0;
|
||||
joysticks.data[3] = 0;
|
||||
|
||||
commands = 0;
|
||||
|
||||
zappers[0].b = 0;
|
||||
zappers[0].bogo = 0;
|
||||
zappers[0].x = 0;
|
||||
zappers[0].y = 0;
|
||||
zappers[0].zaphit = 0;
|
||||
|
||||
zappers[1].b = 0;
|
||||
zappers[1].bogo = 0;
|
||||
zappers[1].x = 0;
|
||||
zappers[1].y = 0;
|
||||
zappers[1].zaphit = 0;
|
||||
|
||||
savestate = NULL;
|
||||
}
|
||||
|
||||
MovieRecord::~MovieRecord()
|
||||
{
|
||||
if (savestate != NULL)
|
||||
delete savestate;
|
||||
}
|
||||
|
||||
void MovieRecord::clear()
|
||||
{
|
||||
commands = 0;
|
||||
|
@ -170,6 +200,7 @@ bool MovieRecord::Compare(MovieRecord& compareRec)
|
|||
//if (this->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)
|
||||
{
|
||||
|
|
14
src/movie.h
14
src/movie.h
|
@ -96,6 +96,8 @@ class MovieRecord
|
|||
{
|
||||
|
||||
public:
|
||||
MovieRecord();
|
||||
~MovieRecord();
|
||||
ValueArray<uint8,4> 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<char> 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<char>& GetSavestate()
|
||||
{
|
||||
if (savestate == NULL)
|
||||
savestate = new std::vector<char>;
|
||||
return *savestate;
|
||||
}
|
||||
private:
|
||||
//a waste of memory in lots of cases.. maybe make it a pointer later?
|
||||
std::vector<char> *savestate;
|
||||
|
||||
int mask(int bit) { return 1<<bit; }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue