fixed a bad bug in memorystream which makes movie savestates work better
and now they work faster too
This commit is contained in:
parent
ce3a9796c3
commit
b82c266971
|
@ -658,7 +658,7 @@ void FCEU_SaveGameSave(CartInfo *LocalHWInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack, movie.c has to communicate with this function somehow
|
// hack, movie.cpp has to communicate with this function somehow
|
||||||
int disableBatteryLoading=0;
|
int disableBatteryLoading=0;
|
||||||
|
|
||||||
void FCEU_LoadGameSave(CartInfo *LocalHWInfo)
|
void FCEU_LoadGameSave(CartInfo *LocalHWInfo)
|
||||||
|
|
|
@ -276,8 +276,9 @@ void MovieData::installValue(std::string& key, std::string& val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovieData::dump(std::ostream *os)
|
int MovieData::dump(std::ostream *os)
|
||||||
{
|
{
|
||||||
|
int start = os->tellp();
|
||||||
*os << "version " << version << endl;
|
*os << "version " << version << endl;
|
||||||
*os << "emuVersion " << emuVersion << endl;
|
*os << "emuVersion " << emuVersion << endl;
|
||||||
*os << "recordCount " << recordCount << endl;
|
*os << "recordCount " << recordCount << endl;
|
||||||
|
@ -296,16 +297,10 @@ void MovieData::dump(std::ostream *os)
|
||||||
*os << "savestate " << BytesToString(&savestate[0],savestate.size()) << endl;
|
*os << "savestate " << BytesToString(&savestate[0],savestate.size()) << endl;
|
||||||
for(int i=0;i<(int)records.size();i++)
|
for(int i=0;i<(int)records.size();i++)
|
||||||
records[i].dump(this,os,i);
|
records[i].dump(this,os,i);
|
||||||
|
int end = os->tellp();
|
||||||
|
return end-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MovieData::dumpLen()
|
|
||||||
{
|
|
||||||
memorystream ms;
|
|
||||||
dump(&ms);
|
|
||||||
return ms.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int FCEUMOV_GetFrame(void)
|
int FCEUMOV_GetFrame(void)
|
||||||
{
|
{
|
||||||
return currFrameCounter;
|
return currFrameCounter;
|
||||||
|
@ -761,16 +756,8 @@ void FCEU_DrawMovies(uint8 *XBuf)
|
||||||
int FCEUMOV_WriteState(std::ostream* os)
|
int FCEUMOV_WriteState(std::ostream* os)
|
||||||
{
|
{
|
||||||
//we are supposed to dump the movie data into the savestate
|
//we are supposed to dump the movie data into the savestate
|
||||||
|
|
||||||
if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY)
|
if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY)
|
||||||
{
|
return currMovieData.dump(os);
|
||||||
int todo = currMovieData.dumpLen();
|
|
||||||
|
|
||||||
if(os)
|
|
||||||
currMovieData.dump(os);
|
|
||||||
|
|
||||||
return todo;
|
|
||||||
}
|
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,8 +163,7 @@ public:
|
||||||
|
|
||||||
void truncateAt(int frame);
|
void truncateAt(int frame);
|
||||||
void installValue(std::string& key, std::string& val);
|
void installValue(std::string& key, std::string& val);
|
||||||
void dump(std::ostream* os);
|
int dump(std::ostream* os);
|
||||||
int dumpLen();
|
|
||||||
void clearRecordRange(int start, int len);
|
void clearRecordRange(int start, int len);
|
||||||
|
|
||||||
static bool loadSavestateFrom(std::vector<char>* buf);
|
static bool loadSavestateFrom(std::vector<char>* buf);
|
||||||
|
|
|
@ -406,10 +406,13 @@ bool FCEUSS_SaveMS(std::ostream* outstream, int compressionLevel)
|
||||||
//do not save the movie state if we are in tasedit! that is a huge waste of time and space!
|
//do not save the movie state if we are in tasedit! that is a huge waste of time and space!
|
||||||
if(!FCEUMOV_Mode(MOVIEMODE_TASEDIT))
|
if(!FCEUMOV_Mode(MOVIEMODE_TASEDIT))
|
||||||
{
|
{
|
||||||
uint32 size = FCEUMOV_WriteState((std::ostream*)0);
|
os->seekp(5,std::ios::cur);
|
||||||
|
int size = FCEUMOV_WriteState(os);
|
||||||
|
os->seekp(-(size+5),std::ios::cur);
|
||||||
os->put(7);
|
os->put(7);
|
||||||
write32le(size, os);
|
write32le(size, os);
|
||||||
FCEUMOV_WriteState(os);
|
os->seekp(size,std::ios::cur);
|
||||||
|
|
||||||
totalsize += 5 + size;
|
totalsize += 5 + size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,10 @@ protected:
|
||||||
if(which & std::ios_base::in)
|
if(which & std::ios_base::in)
|
||||||
setg(buf, buf+pos, buf + length);
|
setg(buf, buf+pos, buf + length);
|
||||||
if(which & std::ios_base::out)
|
if(which & std::ios_base::out)
|
||||||
|
{
|
||||||
|
ww = pos;
|
||||||
setp(buf+pos, buf + capacity);
|
setp(buf+pos, buf + capacity);
|
||||||
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue