mirror of https://github.com/stella-emu/stella.git
A few more pointer to reference conversions.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3018 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
af33538d5a
commit
09912c689b
|
@ -196,7 +196,7 @@ bool OSystem::create()
|
||||||
myMenu = new Menu(this);
|
myMenu = new Menu(this);
|
||||||
myCommandMenu = new CommandMenu(this);
|
myCommandMenu = new CommandMenu(this);
|
||||||
myLauncher = new Launcher(this);
|
myLauncher = new Launcher(this);
|
||||||
myStateManager = new StateManager(this);
|
myStateManager = new StateManager(*this);
|
||||||
|
|
||||||
// Create the sound object; the sound subsystem isn't actually
|
// Create the sound object; the sound subsystem isn't actually
|
||||||
// opened until needed, so this is non-blocking (on those systems
|
// opened until needed, so this is non-blocking (on those systems
|
||||||
|
@ -217,7 +217,7 @@ bool OSystem::create()
|
||||||
mySerialPort = new SerialPort();
|
mySerialPort = new SerialPort();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Let the random class know about us; it needs access to getTicks()
|
// Re-initialize random seed
|
||||||
myRandom->initSeed();
|
myRandom->initSeed();
|
||||||
|
|
||||||
// Create PNG handler
|
// Create PNG handler
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#define MOVIE_HEADER "03030000movie"
|
#define MOVIE_HEADER "03030000movie"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
StateManager::StateManager(OSystem* osystem)
|
StateManager::StateManager(OSystem& osystem)
|
||||||
: myOSystem(osystem),
|
: myOSystem(osystem),
|
||||||
myCurrentSlot(0),
|
myCurrentSlot(0),
|
||||||
myActiveMode(kOffMode)
|
myActiveMode(kOffMode)
|
||||||
|
@ -50,16 +50,16 @@ bool StateManager::toggleRecordMode()
|
||||||
{
|
{
|
||||||
myActiveMode = kOffMode;
|
myActiveMode = kOffMode;
|
||||||
|
|
||||||
string moviefile = /*myOSystem->baseDir() +*/ "test.inp";
|
string moviefile = /*myOSystem.baseDir() +*/ "test.inp";
|
||||||
if(myMovieWriter.isOpen())
|
if(myMovieWriter.isOpen())
|
||||||
myMovieWriter.close();
|
myMovieWriter.close();
|
||||||
if(!myMovieWriter.open(moviefile))
|
if(!myMovieWriter.open(moviefile))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Prepend the ROM md5 so this state file only works with that ROM
|
// Prepend the ROM md5 so this state file only works with that ROM
|
||||||
myMovieWriter.putString(myOSystem->console().properties().get(Cartridge_MD5));
|
myMovieWriter.putString(myOSystem.console().properties().get(Cartridge_MD5));
|
||||||
|
|
||||||
if(!myOSystem->console().save(myMovieWriter))
|
if(!myOSystem.console().save(myMovieWriter))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Save controller types for this ROM
|
// Save controller types for this ROM
|
||||||
|
@ -67,9 +67,9 @@ bool StateManager::toggleRecordMode()
|
||||||
// normal, and those states files wouldn't be compatible with normal
|
// normal, and those states files wouldn't be compatible with normal
|
||||||
// controllers.
|
// controllers.
|
||||||
myMovieWriter.putString(
|
myMovieWriter.putString(
|
||||||
myOSystem->console().controller(Controller::Left).name());
|
myOSystem.console().controller(Controller::Left).name());
|
||||||
myMovieWriter.putString(
|
myMovieWriter.putString(
|
||||||
myOSystem->console().controller(Controller::Right).name());
|
myOSystem.console().controller(Controller::Right).name());
|
||||||
|
|
||||||
// If we get this far, we're really in movie record mode
|
// If we get this far, we're really in movie record mode
|
||||||
myActiveMode = kMovieRecordMode;
|
myActiveMode = kMovieRecordMode;
|
||||||
|
@ -98,7 +98,7 @@ bool StateManager::toggleRewindMode()
|
||||||
{
|
{
|
||||||
myActiveMode = kOffMode;
|
myActiveMode = kOffMode;
|
||||||
|
|
||||||
string moviefile = /*myOSystem->baseDir() + */ "test.inp";
|
string moviefile = /*myOSystem.baseDir() + */ "test.inp";
|
||||||
if(myMovieReader.isOpen())
|
if(myMovieReader.isOpen())
|
||||||
myMovieReader.close();
|
myMovieReader.close();
|
||||||
if(!myMovieReader.open(moviefile))
|
if(!myMovieReader.open(moviefile))
|
||||||
|
@ -106,18 +106,18 @@ bool StateManager::toggleRewindMode()
|
||||||
|
|
||||||
// Check the ROM md5
|
// Check the ROM md5
|
||||||
if(myMovieReader.getString() !=
|
if(myMovieReader.getString() !=
|
||||||
myOSystem->console().properties().get(Cartridge_MD5))
|
myOSystem.console().properties().get(Cartridge_MD5))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!myOSystem->console().load(myMovieReader))
|
if(!myOSystem.console().load(myMovieReader))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check controller types
|
// Check controller types
|
||||||
const string& left = myMovieReader.getString();
|
const string& left = myMovieReader.getString();
|
||||||
const string& right = myMovieReader.getString();
|
const string& right = myMovieReader.getString();
|
||||||
|
|
||||||
if(left != myOSystem->console().controller(Controller::Left).name() ||
|
if(left != myOSystem.console().controller(Controller::Left).name() ||
|
||||||
right != myOSystem->console().controller(Controller::Right).name())
|
right != myOSystem.console().controller(Controller::Right).name())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If we get this far, we're really in movie record mode
|
// If we get this far, we're really in movie record mode
|
||||||
|
@ -142,15 +142,15 @@ void StateManager::update()
|
||||||
switch(myActiveMode)
|
switch(myActiveMode)
|
||||||
{
|
{
|
||||||
case kMovieRecordMode:
|
case kMovieRecordMode:
|
||||||
myOSystem->console().controller(Controller::Left).save(myMovieWriter);
|
myOSystem.console().controller(Controller::Left).save(myMovieWriter);
|
||||||
myOSystem->console().controller(Controller::Right).save(myMovieWriter);
|
myOSystem.console().controller(Controller::Right).save(myMovieWriter);
|
||||||
myOSystem->console().switches().save(myMovieWriter);
|
myOSystem.console().switches().save(myMovieWriter);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMoviePlaybackMode:
|
case kMoviePlaybackMode:
|
||||||
myOSystem->console().controller(Controller::Left).load(myMovieReader);
|
myOSystem.console().controller(Controller::Left).load(myMovieReader);
|
||||||
myOSystem->console().controller(Controller::Right).load(myMovieReader);
|
myOSystem.console().controller(Controller::Right).load(myMovieReader);
|
||||||
myOSystem->console().switches().load(myMovieReader);
|
myOSystem.console().switches().load(myMovieReader);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -162,13 +162,13 @@ void StateManager::update()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void StateManager::loadState(int slot)
|
void StateManager::loadState(int slot)
|
||||||
{
|
{
|
||||||
if(myOSystem->hasConsole())
|
if(myOSystem.hasConsole())
|
||||||
{
|
{
|
||||||
if(slot < 0) slot = myCurrentSlot;
|
if(slot < 0) slot = myCurrentSlot;
|
||||||
|
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
buf << myOSystem->stateDir()
|
buf << myOSystem.stateDir()
|
||||||
<< myOSystem->console().properties().get(Cartridge_Name)
|
<< myOSystem.console().properties().get(Cartridge_Name)
|
||||||
<< ".st" << slot;
|
<< ".st" << slot;
|
||||||
|
|
||||||
// Make sure the file can be opened in read-only mode
|
// Make sure the file can be opened in read-only mode
|
||||||
|
@ -177,7 +177,7 @@ void StateManager::loadState(int slot)
|
||||||
{
|
{
|
||||||
buf.str("");
|
buf.str("");
|
||||||
buf << "Can't open/load from state file " << slot;
|
buf << "Can't open/load from state file " << slot;
|
||||||
myOSystem->frameBuffer().showMessage(buf.str());
|
myOSystem.frameBuffer().showMessage(buf.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,9 +188,9 @@ void StateManager::loadState(int slot)
|
||||||
buf << "Incompatible state " << slot << " file";
|
buf << "Incompatible state " << slot << " file";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(in.getString() == myOSystem->console().cartridge().name())
|
if(in.getString() == myOSystem.console().cartridge().name())
|
||||||
{
|
{
|
||||||
if(myOSystem->console().load(in))
|
if(myOSystem.console().load(in))
|
||||||
buf << "State " << slot << " loaded";
|
buf << "State " << slot << " loaded";
|
||||||
else
|
else
|
||||||
buf << "Invalid data in state " << slot << " file";
|
buf << "Invalid data in state " << slot << " file";
|
||||||
|
@ -199,20 +199,20 @@ void StateManager::loadState(int slot)
|
||||||
buf << "State " << slot << " file doesn't match current ROM";
|
buf << "State " << slot << " file doesn't match current ROM";
|
||||||
}
|
}
|
||||||
|
|
||||||
myOSystem->frameBuffer().showMessage(buf.str());
|
myOSystem.frameBuffer().showMessage(buf.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void StateManager::saveState(int slot)
|
void StateManager::saveState(int slot)
|
||||||
{
|
{
|
||||||
if(myOSystem->hasConsole())
|
if(myOSystem.hasConsole())
|
||||||
{
|
{
|
||||||
if(slot < 0) slot = myCurrentSlot;
|
if(slot < 0) slot = myCurrentSlot;
|
||||||
|
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
buf << myOSystem->stateDir()
|
buf << myOSystem.stateDir()
|
||||||
<< myOSystem->console().properties().get(Cartridge_Name)
|
<< myOSystem.console().properties().get(Cartridge_Name)
|
||||||
<< ".st" << slot;
|
<< ".st" << slot;
|
||||||
|
|
||||||
// Make sure the file can be opened for writing
|
// Make sure the file can be opened for writing
|
||||||
|
@ -221,7 +221,7 @@ void StateManager::saveState(int slot)
|
||||||
{
|
{
|
||||||
buf.str("");
|
buf.str("");
|
||||||
buf << "Can't open/save to state file " << slot;
|
buf << "Can't open/save to state file " << slot;
|
||||||
myOSystem->frameBuffer().showMessage(buf.str());
|
myOSystem.frameBuffer().showMessage(buf.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,14 +230,14 @@ void StateManager::saveState(int slot)
|
||||||
out.putString(STATE_HEADER);
|
out.putString(STATE_HEADER);
|
||||||
|
|
||||||
// Sanity check; prepend the cart type/name
|
// Sanity check; prepend the cart type/name
|
||||||
out.putString(myOSystem->console().cartridge().name());
|
out.putString(myOSystem.console().cartridge().name());
|
||||||
|
|
||||||
// Do a complete state save using the Console
|
// Do a complete state save using the Console
|
||||||
buf.str("");
|
buf.str("");
|
||||||
if(myOSystem->console().save(out))
|
if(myOSystem.console().save(out))
|
||||||
{
|
{
|
||||||
buf << "State " << slot << " saved";
|
buf << "State " << slot << " saved";
|
||||||
if(myOSystem->settings().getBool("autoslot"))
|
if(myOSystem.settings().getBool("autoslot"))
|
||||||
{
|
{
|
||||||
myCurrentSlot = (slot + 1) % 10;
|
myCurrentSlot = (slot + 1) % 10;
|
||||||
buf << ", switching to slot " << slot;
|
buf << ", switching to slot " << slot;
|
||||||
|
@ -246,7 +246,7 @@ void StateManager::saveState(int slot)
|
||||||
else
|
else
|
||||||
buf << "Error saving state " << slot;
|
buf << "Error saving state " << slot;
|
||||||
|
|
||||||
myOSystem->frameBuffer().showMessage(buf.str());
|
myOSystem.frameBuffer().showMessage(buf.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,13 +258,13 @@ void StateManager::changeState()
|
||||||
// Print appropriate message
|
// Print appropriate message
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
buf << "Changed to slot " << myCurrentSlot;
|
buf << "Changed to slot " << myCurrentSlot;
|
||||||
myOSystem->frameBuffer().showMessage(buf.str());
|
myOSystem.frameBuffer().showMessage(buf.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool StateManager::loadState(Serializer& in)
|
bool StateManager::loadState(Serializer& in)
|
||||||
{
|
{
|
||||||
if(myOSystem->hasConsole())
|
if(myOSystem.hasConsole())
|
||||||
{
|
{
|
||||||
// Make sure the file can be opened for reading
|
// Make sure the file can be opened for reading
|
||||||
if(in.isValid())
|
if(in.isValid())
|
||||||
|
@ -272,8 +272,8 @@ bool StateManager::loadState(Serializer& in)
|
||||||
// First test if we have a valid header and cart type
|
// First test if we have a valid header and cart type
|
||||||
// If so, do a complete state load using the Console
|
// If so, do a complete state load using the Console
|
||||||
return in.getString() == STATE_HEADER &&
|
return in.getString() == STATE_HEADER &&
|
||||||
in.getString() == myOSystem->console().cartridge().name() &&
|
in.getString() == myOSystem.console().cartridge().name() &&
|
||||||
myOSystem->console().load(in);
|
myOSystem.console().load(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -284,7 +284,7 @@ bool StateManager::saveState(Serializer& out)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(myOSystem->hasConsole())
|
if(myOSystem.hasConsole())
|
||||||
{
|
{
|
||||||
// Make sure the file can be opened for writing
|
// Make sure the file can be opened for writing
|
||||||
if(out.isValid())
|
if(out.isValid())
|
||||||
|
@ -294,10 +294,10 @@ bool StateManager::saveState(Serializer& out)
|
||||||
out.putString(STATE_HEADER);
|
out.putString(STATE_HEADER);
|
||||||
|
|
||||||
// Sanity check; prepend the cart type/name
|
// Sanity check; prepend the cart type/name
|
||||||
out.putString(myOSystem->console().cartridge().name());
|
out.putString(myOSystem.console().cartridge().name());
|
||||||
|
|
||||||
// Do a complete state save using the Console
|
// Do a complete state save using the Console
|
||||||
if(myOSystem->console().save(out))
|
if(myOSystem.console().save(out))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,8 @@ void StateManager::reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
StateManager::StateManager(const StateManager&)
|
StateManager::StateManager(const StateManager& sm)
|
||||||
|
: myOSystem(sm.myOSystem)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class StateManager
|
||||||
/**
|
/**
|
||||||
Create a new statemananger class
|
Create a new statemananger class
|
||||||
*/
|
*/
|
||||||
StateManager(OSystem* osystem);
|
StateManager(OSystem& osystem);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -119,7 +119,7 @@ class StateManager
|
||||||
};
|
};
|
||||||
|
|
||||||
// The parent OSystem object
|
// The parent OSystem object
|
||||||
OSystem* myOSystem;
|
OSystem& myOSystem;
|
||||||
|
|
||||||
// The current slot for load/save states
|
// The current slot for load/save states
|
||||||
int myCurrentSlot;
|
int myCurrentSlot;
|
||||||
|
|
Loading…
Reference in New Issue