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:
stephena 2014-10-26 16:19:58 +00:00
parent af33538d5a
commit 09912c689b
3 changed files with 45 additions and 44 deletions

View File

@ -196,7 +196,7 @@ bool OSystem::create()
myMenu = new Menu(this);
myCommandMenu = new CommandMenu(this);
myLauncher = new Launcher(this);
myStateManager = new StateManager(this);
myStateManager = new StateManager(*this);
// Create the sound object; the sound subsystem isn't actually
// opened until needed, so this is non-blocking (on those systems
@ -217,7 +217,7 @@ bool OSystem::create()
mySerialPort = new SerialPort();
#endif
// Let the random class know about us; it needs access to getTicks()
// Re-initialize random seed
myRandom->initSeed();
// Create PNG handler

View File

@ -34,7 +34,7 @@
#define MOVIE_HEADER "03030000movie"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StateManager::StateManager(OSystem* osystem)
StateManager::StateManager(OSystem& osystem)
: myOSystem(osystem),
myCurrentSlot(0),
myActiveMode(kOffMode)
@ -50,16 +50,16 @@ bool StateManager::toggleRecordMode()
{
myActiveMode = kOffMode;
string moviefile = /*myOSystem->baseDir() +*/ "test.inp";
string moviefile = /*myOSystem.baseDir() +*/ "test.inp";
if(myMovieWriter.isOpen())
myMovieWriter.close();
if(!myMovieWriter.open(moviefile))
return false;
// 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;
// Save controller types for this ROM
@ -67,9 +67,9 @@ bool StateManager::toggleRecordMode()
// normal, and those states files wouldn't be compatible with normal
// controllers.
myMovieWriter.putString(
myOSystem->console().controller(Controller::Left).name());
myOSystem.console().controller(Controller::Left).name());
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
myActiveMode = kMovieRecordMode;
@ -98,7 +98,7 @@ bool StateManager::toggleRewindMode()
{
myActiveMode = kOffMode;
string moviefile = /*myOSystem->baseDir() + */ "test.inp";
string moviefile = /*myOSystem.baseDir() + */ "test.inp";
if(myMovieReader.isOpen())
myMovieReader.close();
if(!myMovieReader.open(moviefile))
@ -106,18 +106,18 @@ bool StateManager::toggleRewindMode()
// Check the ROM md5
if(myMovieReader.getString() !=
myOSystem->console().properties().get(Cartridge_MD5))
myOSystem.console().properties().get(Cartridge_MD5))
return false;
if(!myOSystem->console().load(myMovieReader))
if(!myOSystem.console().load(myMovieReader))
return false;
// Check controller types
const string& left = myMovieReader.getString();
const string& right = myMovieReader.getString();
if(left != myOSystem->console().controller(Controller::Left).name() ||
right != myOSystem->console().controller(Controller::Right).name())
if(left != myOSystem.console().controller(Controller::Left).name() ||
right != myOSystem.console().controller(Controller::Right).name())
return false;
// If we get this far, we're really in movie record mode
@ -142,15 +142,15 @@ void StateManager::update()
switch(myActiveMode)
{
case kMovieRecordMode:
myOSystem->console().controller(Controller::Left).save(myMovieWriter);
myOSystem->console().controller(Controller::Right).save(myMovieWriter);
myOSystem->console().switches().save(myMovieWriter);
myOSystem.console().controller(Controller::Left).save(myMovieWriter);
myOSystem.console().controller(Controller::Right).save(myMovieWriter);
myOSystem.console().switches().save(myMovieWriter);
break;
case kMoviePlaybackMode:
myOSystem->console().controller(Controller::Left).load(myMovieReader);
myOSystem->console().controller(Controller::Right).load(myMovieReader);
myOSystem->console().switches().load(myMovieReader);
myOSystem.console().controller(Controller::Left).load(myMovieReader);
myOSystem.console().controller(Controller::Right).load(myMovieReader);
myOSystem.console().switches().load(myMovieReader);
break;
default:
@ -162,13 +162,13 @@ void StateManager::update()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StateManager::loadState(int slot)
{
if(myOSystem->hasConsole())
if(myOSystem.hasConsole())
{
if(slot < 0) slot = myCurrentSlot;
ostringstream buf;
buf << myOSystem->stateDir()
<< myOSystem->console().properties().get(Cartridge_Name)
buf << myOSystem.stateDir()
<< myOSystem.console().properties().get(Cartridge_Name)
<< ".st" << slot;
// Make sure the file can be opened in read-only mode
@ -177,7 +177,7 @@ void StateManager::loadState(int slot)
{
buf.str("");
buf << "Can't open/load from state file " << slot;
myOSystem->frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showMessage(buf.str());
return;
}
@ -188,9 +188,9 @@ void StateManager::loadState(int slot)
buf << "Incompatible state " << slot << " file";
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";
else
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";
}
myOSystem->frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showMessage(buf.str());
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StateManager::saveState(int slot)
{
if(myOSystem->hasConsole())
if(myOSystem.hasConsole())
{
if(slot < 0) slot = myCurrentSlot;
ostringstream buf;
buf << myOSystem->stateDir()
<< myOSystem->console().properties().get(Cartridge_Name)
buf << myOSystem.stateDir()
<< myOSystem.console().properties().get(Cartridge_Name)
<< ".st" << slot;
// Make sure the file can be opened for writing
@ -221,7 +221,7 @@ void StateManager::saveState(int slot)
{
buf.str("");
buf << "Can't open/save to state file " << slot;
myOSystem->frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showMessage(buf.str());
return;
}
@ -230,14 +230,14 @@ void StateManager::saveState(int slot)
out.putString(STATE_HEADER);
// 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
buf.str("");
if(myOSystem->console().save(out))
if(myOSystem.console().save(out))
{
buf << "State " << slot << " saved";
if(myOSystem->settings().getBool("autoslot"))
if(myOSystem.settings().getBool("autoslot"))
{
myCurrentSlot = (slot + 1) % 10;
buf << ", switching to slot " << slot;
@ -246,7 +246,7 @@ void StateManager::saveState(int slot)
else
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
ostringstream buf;
buf << "Changed to slot " << myCurrentSlot;
myOSystem->frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showMessage(buf.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::loadState(Serializer& in)
{
if(myOSystem->hasConsole())
if(myOSystem.hasConsole())
{
// Make sure the file can be opened for reading
if(in.isValid())
@ -272,8 +272,8 @@ bool StateManager::loadState(Serializer& in)
// First test if we have a valid header and cart type
// If so, do a complete state load using the Console
return in.getString() == STATE_HEADER &&
in.getString() == myOSystem->console().cartridge().name() &&
myOSystem->console().load(in);
in.getString() == myOSystem.console().cartridge().name() &&
myOSystem.console().load(in);
}
}
return false;
@ -284,7 +284,7 @@ bool StateManager::saveState(Serializer& out)
{
try
{
if(myOSystem->hasConsole())
if(myOSystem.hasConsole())
{
// Make sure the file can be opened for writing
if(out.isValid())
@ -294,10 +294,10 @@ bool StateManager::saveState(Serializer& out)
out.putString(STATE_HEADER);
// 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
if(myOSystem->console().save(out))
if(myOSystem.console().save(out))
return true;
}
}
@ -333,7 +333,8 @@ void StateManager::reset()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StateManager::StateManager(const StateManager&)
StateManager::StateManager(const StateManager& sm)
: myOSystem(sm.myOSystem)
{
}

View File

@ -38,7 +38,7 @@ class StateManager
/**
Create a new statemananger class
*/
StateManager(OSystem* osystem);
StateManager(OSystem& osystem);
public:
/**
@ -119,7 +119,7 @@ class StateManager
};
// The parent OSystem object
OSystem* myOSystem;
OSystem& myOSystem;
// The current slot for load/save states
int myCurrentSlot;