mirror of https://github.com/stella-emu/stella.git
It seems that in Windows, stringstreams must be initialized with data immediately after creation before they can be used. This really doesn't make sense to me, but at least it allows the rewind code to work. I hope this fixes similar issues in OSX.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1859 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
ef5c5de54f
commit
28f347cf86
|
@ -972,9 +972,6 @@ Debugger::RewindManager::~RewindManager()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::RewindManager::addState()
|
||||
{
|
||||
// Are we still within the allowable size, or are we overwriting an item?
|
||||
mySize++; if(mySize > MAX_SIZE) mySize = MAX_SIZE;
|
||||
|
||||
// Create a new Serializer object if we need one
|
||||
if(myStateList[myTop] == NULL)
|
||||
myStateList[myTop] = new Serializer();
|
||||
|
@ -983,13 +980,16 @@ bool Debugger::RewindManager::addState()
|
|||
if(s.isValid())
|
||||
{
|
||||
s.reset();
|
||||
myOSystem.state().saveState(s);
|
||||
myOSystem.console().tia().saveDisplay(s);
|
||||
myTop = (myTop + 1) % MAX_SIZE;
|
||||
return true;
|
||||
if(myOSystem.state().saveState(s) && myOSystem.console().tia().saveDisplay(s))
|
||||
{
|
||||
// Are we still within the allowable size, or are we overwriting an item?
|
||||
mySize++; if(mySize > MAX_SIZE) mySize = MAX_SIZE;
|
||||
|
||||
myTop = (myTop + 1) % MAX_SIZE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -52,6 +52,14 @@ Serializer::Serializer(void)
|
|||
myUseFilestream(false)
|
||||
{
|
||||
myStream = new stringstream(ios::in | ios::out | ios::binary);
|
||||
|
||||
// For some reason, Windows and possibly OSX needs to store something in
|
||||
// the stream before it is used for the first time
|
||||
if(myStream)
|
||||
{
|
||||
putBool(true);
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -288,23 +288,30 @@ bool StateManager::loadState(Serializer& in)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool StateManager::saveState(Serializer& out)
|
||||
{
|
||||
if(&myOSystem->console())
|
||||
try
|
||||
{
|
||||
// Make sure the file can be opened for writing
|
||||
if(out.isValid())
|
||||
if(&myOSystem->console())
|
||||
{
|
||||
// Add header so that if the state format changes in the future,
|
||||
// we'll know right away, without having to parse the rest of the file
|
||||
out.putString(STATE_HEADER);
|
||||
// Make sure the file can be opened for writing
|
||||
if(out.isValid())
|
||||
{
|
||||
// Add header so that if the state format changes in the future,
|
||||
// we'll know right away, without having to parse the rest of the file
|
||||
out.putString(STATE_HEADER);
|
||||
|
||||
// Prepend the ROM md5 so this state file only works with that ROM
|
||||
out.putString(myOSystem->console().properties().get(Cartridge_MD5));
|
||||
// Prepend the ROM md5 so this state file only works with that ROM
|
||||
out.putString(myOSystem->console().properties().get(Cartridge_MD5));
|
||||
|
||||
// Do a complete state save using the Console
|
||||
if(myOSystem->console().save(out))
|
||||
return true;
|
||||
// Do a complete state save using the Console
|
||||
if(myOSystem->console().save(out))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const char* msg)
|
||||
{
|
||||
cerr << "ERROR: StateManager::saveState(Serializer&)" << endl << msg << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ bool TIA::load(Serializer& in)
|
|||
// enableBits(true);
|
||||
myColorPtr = myColor;
|
||||
}
|
||||
catch(char *msg)
|
||||
catch(const char* msg)
|
||||
{
|
||||
cerr << msg << endl;
|
||||
return false;
|
||||
|
@ -521,7 +521,7 @@ bool TIA::saveDisplay(Serializer& out) const
|
|||
for(int i = 0; i < 160*320; ++i)
|
||||
out.putByte(myCurrentFrameBuffer[i]);
|
||||
}
|
||||
catch(char *msg)
|
||||
catch(const char* msg)
|
||||
{
|
||||
cerr << msg << endl;
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue