Fix crash when using CompuMate scheme but not using CM controllers.

The code now never looks at the controller type for CM ROMs, but just creates the required controllers.
This means that we no longer actually need a special CompuMate controller type anywhere in the code, since selecting it has become redundant.
This commit is contained in:
Stephen Anthony 2017-10-03 20:17:23 -02:30
parent 1fa3f0cf0d
commit d99d3a16f5
2 changed files with 21 additions and 24 deletions

View File

@ -61,7 +61,6 @@ void CompuMate::update()
Controller& lp = myConsole.leftController();
Controller& rp = myConsole.rightController();
lp.myAnalogPinValue[Controller::Nine] = Controller::maximumResistance;
lp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance;
lp.myDigitalPinState[Controller::Six] = true;

View File

@ -682,13 +682,9 @@ void Console::setTIAProperties()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::setControllers(const string& rommd5)
{
// Setup the controllers based on properties
const string& left = myProperties.get(Controller_Left);
const string& right = myProperties.get(Controller_Right);
// Check for CompuMate controllers; they are special in that a handler
// creates them for us, and also that they must be used in both ports
if(left == "COMPUMATE" || right == "COMPUMATE")
// Check for CompuMate scheme; it is special in that a handler creates both
// controllers for us, and associates them with the bankswitching class
if(myCart->detectedType() == "CM")
{
myCMHandler = make_shared<CompuMate>(*this, myEvent, *mySystem);
@ -701,25 +697,27 @@ void Console::setControllers(const string& rommd5)
myLeftControl = std::move(myCMHandler->leftController());
myRightControl = std::move(myCMHandler->rightController());
return;
}
unique_ptr<Controller> leftC = std::move(myLeftControl),
rightC = std::move(myRightControl);
leftC = getControllerPort(rommd5, left, Controller::Left);
rightC = getControllerPort(rommd5, right, Controller::Right);
// Swap the ports if necessary
if(myProperties.get(Console_SwapPorts) == "NO")
{
myLeftControl = std::move(leftC);
myRightControl = std::move(rightC);
}
else
{
myLeftControl = std::move(rightC);
myRightControl = std::move(leftC);
// Setup the controllers based on properties
const string& left = myProperties.get(Controller_Left);
const string& right = myProperties.get(Controller_Right);
unique_ptr<Controller> leftC = getControllerPort(rommd5, left, Controller::Left),
rightC = getControllerPort(rommd5, right, Controller::Right);
// Swap the ports if necessary
if(myProperties.get(Console_SwapPorts) == "NO")
{
myLeftControl = std::move(leftC);
myRightControl = std::move(rightC);
}
else
{
myLeftControl = std::move(rightC);
myRightControl = std::move(leftC);
}
}
myTIA->bindToControllers();