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
|
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
|
Get the current keyboard column
|
||||||
|
@ -240,7 +240,7 @@ class CartridgeCM : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The CompuMate device which interacts with this cartridge
|
// The CompuMate device which interacts with this cartridge
|
||||||
CompuMate* myCompuMate;
|
shared_ptr<CompuMate> myCompuMate;
|
||||||
|
|
||||||
// Indicates which bank is currently active
|
// Indicates which bank is currently active
|
||||||
uInt16 myCurrentBank;
|
uInt16 myCurrentBank;
|
||||||
|
|
|
@ -25,14 +25,12 @@
|
||||||
CompuMate::CompuMate(const Console& console, const Event& event,
|
CompuMate::CompuMate(const Console& console, const Event& event,
|
||||||
const System& system)
|
const System& system)
|
||||||
: myConsole(console),
|
: myConsole(console),
|
||||||
myEvent(event),
|
myEvent(event)
|
||||||
myLeftController(nullptr),
|
|
||||||
myRightController(nullptr)
|
|
||||||
{
|
{
|
||||||
// These controller pointers will be retrieved by the Console, which will
|
// These controller pointers will be retrieved by the Console, which will
|
||||||
// also take ownership of them
|
// also take ownership of them
|
||||||
myLeftController = new CMControl(*this, Controller::Left, event, system);
|
myLeftController = make_ptr<CMControl>(*this, Controller::Left, event, system);
|
||||||
myRightController = new CMControl(*this, Controller::Right, event, system);
|
myRightController = make_ptr<CMControl>(*this, Controller::Right, event, system);
|
||||||
|
|
||||||
myLeftController->myAnalogPinValue[Controller::Nine] = Controller::maximumResistance;
|
myLeftController->myAnalogPinValue[Controller::Nine] = Controller::maximumResistance;
|
||||||
myLeftController->myAnalogPinValue[Controller::Five] = Controller::minimumResistance;
|
myLeftController->myAnalogPinValue[Controller::Five] = Controller::minimumResistance;
|
||||||
|
|
|
@ -65,8 +65,8 @@ class CompuMate
|
||||||
/**
|
/**
|
||||||
Return the left and right CompuMate controllers
|
Return the left and right CompuMate controllers
|
||||||
*/
|
*/
|
||||||
Controller* leftController() const { return myLeftController; }
|
unique_ptr<Controller>& leftController() { return myLeftController; }
|
||||||
Controller* rightController() const { return myRightController; }
|
unique_ptr<Controller>& rightController() { return myRightController; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
In normal key-handling mode, the update handler receives key events
|
In normal key-handling mode, the update handler receives key events
|
||||||
|
@ -140,7 +140,7 @@ class CompuMate
|
||||||
const Event& myEvent;
|
const Event& myEvent;
|
||||||
|
|
||||||
// Left and right controllers
|
// Left and right controllers
|
||||||
CMControl *myLeftController, *myRightController;
|
unique_ptr<Controller> myLeftController, myRightController;
|
||||||
|
|
||||||
// Column currently active
|
// Column currently active
|
||||||
uInt8 myColumn;
|
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
|
// creates them for us, and also that they must be used in both ports
|
||||||
if(left == "COMPUMATE" || right == "COMPUMATE")
|
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
|
// A somewhat ugly bit of code that casts to CartridgeCM to
|
||||||
// add the CompuMate, and then back again for the actual
|
// add the CompuMate, and then back again for the actual
|
||||||
// Cartridge
|
// Cartridge
|
||||||
unique_ptr<CartridgeCM> cartcm(static_cast<CartridgeCM*>(myCart.release()));
|
unique_ptr<CartridgeCM> cartcm(static_cast<CartridgeCM*>(myCart.release()));
|
||||||
cartcm->setCompuMate(myCMHandler.get());
|
cartcm->setCompuMate(myCMHandler);
|
||||||
myCart = std::move(cartcm);
|
myCart = std::move(cartcm);
|
||||||
|
|
||||||
myLeftControl = unique_ptr<Controller>(myCMHandler->leftController());
|
myLeftControl = std::move(myCMHandler->leftController());
|
||||||
myRightControl = unique_ptr<Controller>(myCMHandler->rightController());
|
myRightControl = std::move(myCMHandler->rightController());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ class Console : public Serializable
|
||||||
unique_ptr<Controller> myLeftControl, myRightControl;
|
unique_ptr<Controller> myLeftControl, myRightControl;
|
||||||
|
|
||||||
// Pointer to CompuMate handler (only used in CompuMate ROMs)
|
// 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)
|
// The currently defined display format (NTSC/PAL/SECAM)
|
||||||
string myDisplayFormat;
|
string myDisplayFormat;
|
||||||
|
|
Loading…
Reference in New Issue