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()
|
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
|
// Create a new Serializer object if we need one
|
||||||
if(myStateList[myTop] == NULL)
|
if(myStateList[myTop] == NULL)
|
||||||
myStateList[myTop] = new Serializer();
|
myStateList[myTop] = new Serializer();
|
||||||
|
@ -983,12 +980,15 @@ bool Debugger::RewindManager::addState()
|
||||||
if(s.isValid())
|
if(s.isValid())
|
||||||
{
|
{
|
||||||
s.reset();
|
s.reset();
|
||||||
myOSystem.state().saveState(s);
|
if(myOSystem.state().saveState(s) && myOSystem.console().tia().saveDisplay(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;
|
myTop = (myTop + 1) % MAX_SIZE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,14 @@ Serializer::Serializer(void)
|
||||||
myUseFilestream(false)
|
myUseFilestream(false)
|
||||||
{
|
{
|
||||||
myStream = new stringstream(ios::in | ios::out | ios::binary);
|
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,6 +288,8 @@ bool StateManager::loadState(Serializer& in)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool StateManager::saveState(Serializer& out)
|
bool StateManager::saveState(Serializer& out)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
if(&myOSystem->console())
|
if(&myOSystem->console())
|
||||||
{
|
{
|
||||||
// Make sure the file can be opened for writing
|
// Make sure the file can be opened for writing
|
||||||
|
@ -305,6 +307,11 @@ bool StateManager::saveState(Serializer& out)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(const char* msg)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: StateManager::saveState(Serializer&)" << endl << msg << endl;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -496,7 +496,7 @@ bool TIA::load(Serializer& in)
|
||||||
// enableBits(true);
|
// enableBits(true);
|
||||||
myColorPtr = myColor;
|
myColorPtr = myColor;
|
||||||
}
|
}
|
||||||
catch(char *msg)
|
catch(const char* msg)
|
||||||
{
|
{
|
||||||
cerr << msg << endl;
|
cerr << msg << endl;
|
||||||
return false;
|
return false;
|
||||||
|
@ -521,7 +521,7 @@ bool TIA::saveDisplay(Serializer& out) const
|
||||||
for(int i = 0; i < 160*320; ++i)
|
for(int i = 0; i < 160*320; ++i)
|
||||||
out.putByte(myCurrentFrameBuffer[i]);
|
out.putByte(myCurrentFrameBuffer[i]);
|
||||||
}
|
}
|
||||||
catch(char *msg)
|
catch(const char* msg)
|
||||||
{
|
{
|
||||||
cerr << msg << endl;
|
cerr << msg << endl;
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue