mirror of https://github.com/stella-emu/stella.git
OK, this is the last commit about pointers for the CompuMate stuff.
Again, still learning the best way to use C++11 here. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3042 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
51737b9720
commit
73badae2d0
|
@ -229,7 +229,7 @@ class CartridgeCM : public Cartridge
|
|||
/**
|
||||
Inform the cartridge about the parent CompuMate controller
|
||||
*/
|
||||
void setCompuMate(CompuMate* cmate) { myCompuMate = cmate; }
|
||||
void setCompuMate(shared_ptr<CompuMate> cmate) { myCompuMate = cmate; }
|
||||
|
||||
/**
|
||||
Get the current keyboard column
|
||||
|
@ -240,7 +240,7 @@ class CartridgeCM : public Cartridge
|
|||
|
||||
private:
|
||||
// The CompuMate device which interacts with this cartridge
|
||||
CompuMate* myCompuMate;
|
||||
shared_ptr<CompuMate> myCompuMate;
|
||||
|
||||
// Indicates which bank is currently active
|
||||
uInt16 myCurrentBank;
|
||||
|
|
|
@ -25,14 +25,12 @@
|
|||
CompuMate::CompuMate(const Console& console, const Event& event,
|
||||
const System& system)
|
||||
: myConsole(console),
|
||||
myEvent(event),
|
||||
myLeftController(nullptr),
|
||||
myRightController(nullptr)
|
||||
myEvent(event)
|
||||
{
|
||||
// These controller pointers will be retrieved by the Console, which will
|
||||
// also take ownership of them
|
||||
myLeftController = new CMControl(*this, Controller::Left, event, system);
|
||||
myRightController = new CMControl(*this, Controller::Right, event, system);
|
||||
myLeftController = make_ptr<CMControl>(*this, Controller::Left, event, system);
|
||||
myRightController = make_ptr<CMControl>(*this, Controller::Right, event, system);
|
||||
|
||||
myLeftController->myAnalogPinValue[Controller::Nine] = Controller::maximumResistance;
|
||||
myLeftController->myAnalogPinValue[Controller::Five] = Controller::minimumResistance;
|
||||
|
|
|
@ -65,8 +65,8 @@ class CompuMate
|
|||
/**
|
||||
Return the left and right CompuMate controllers
|
||||
*/
|
||||
Controller* leftController() const { return myLeftController; }
|
||||
Controller* rightController() const { return myRightController; }
|
||||
unique_ptr<Controller>& leftController() { return myLeftController; }
|
||||
unique_ptr<Controller>& rightController() { return myRightController; }
|
||||
|
||||
/**
|
||||
In normal key-handling mode, the update handler receives key events
|
||||
|
@ -140,7 +140,7 @@ class CompuMate
|
|||
const Event& myEvent;
|
||||
|
||||
// Left and right controllers
|
||||
CMControl *myLeftController, *myRightController;
|
||||
unique_ptr<Controller> myLeftController, myRightController;
|
||||
|
||||
// Column currently active
|
||||
uInt8 myColumn;
|
||||
|
|
|
@ -587,17 +587,17 @@ void Console::setControllers(const string& rommd5)
|
|||
// creates them for us, and also that they must be used in both ports
|
||||
if(left == "COMPUMATE" || right == "COMPUMATE")
|
||||
{
|
||||
myCMHandler = make_ptr<CompuMate>(*this, myEvent, *mySystem);
|
||||
myCMHandler = make_shared<CompuMate>(*this, myEvent, *mySystem);
|
||||
|
||||
// A somewhat ugly bit of code that casts to CartridgeCM to
|
||||
// add the CompuMate, and then back again for the actual
|
||||
// Cartridge
|
||||
unique_ptr<CartridgeCM> cartcm(static_cast<CartridgeCM*>(myCart.release()));
|
||||
cartcm->setCompuMate(myCMHandler.get());
|
||||
cartcm->setCompuMate(myCMHandler);
|
||||
myCart = std::move(cartcm);
|
||||
|
||||
myLeftControl = unique_ptr<Controller>(myCMHandler->leftController());
|
||||
myRightControl = unique_ptr<Controller>(myCMHandler->rightController());
|
||||
myLeftControl = std::move(myCMHandler->leftController());
|
||||
myRightControl = std::move(myCMHandler->rightController());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ class Console : public Serializable
|
|||
unique_ptr<Controller> myLeftControl, myRightControl;
|
||||
|
||||
// Pointer to CompuMate handler (only used in CompuMate ROMs)
|
||||
unique_ptr<CompuMate> myCMHandler;
|
||||
shared_ptr<CompuMate> myCMHandler;
|
||||
|
||||
// The currently defined display format (NTSC/PAL/SECAM)
|
||||
string myDisplayFormat;
|
||||
|
|
Loading…
Reference in New Issue