mirror of https://github.com/stella-emu/stella.git
A slight restructuring of the Controller classes, to fix CompuMate
support broken in rev 3034. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3038 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
03f760cceb
commit
a48c4fc6a8
|
@ -26,8 +26,8 @@
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
MouseControl::MouseControl(Console& console, const string& mode)
|
||||
: myProps(console.properties()),
|
||||
myLeftController(console.controller(Controller::Left)),
|
||||
myRightController(console.controller(Controller::Right)),
|
||||
myLeftController(console.leftController()),
|
||||
myRightController(console.rightController()),
|
||||
myCurrentModeNum(0)
|
||||
{
|
||||
if(BSPF_equalsIgnoreCase(mode, "none"))
|
||||
|
|
|
@ -200,7 +200,8 @@ uInt8 RiotDebug::tim1024T(int newVal)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Controller& RiotDebug::controller(Controller::Jack jack) const
|
||||
{
|
||||
return myConsole.controller(jack);
|
||||
return jack == Controller::Left ? myConsole.leftController() :
|
||||
myConsole.rightController();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -150,7 +150,7 @@ CartridgeCMWidget::CartridgeCMWidget(
|
|||
void CartridgeCMWidget::saveOldState()
|
||||
{
|
||||
myOldState.swcha = myCart.mySWCHA;
|
||||
myOldState.column = myCart.myColumn;
|
||||
myOldState.column = myCart.column();
|
||||
|
||||
myOldState.internalram.clear();
|
||||
|
||||
|
@ -180,7 +180,7 @@ void CartridgeCMWidget::loadConfig()
|
|||
mySWCHA->setState(newbits, changed);
|
||||
|
||||
// Column
|
||||
myColumn->setList(0, myCart.myColumn, myCart.myColumn != myOldState.column);
|
||||
myColumn->setList(0, myCart.column(), myCart.column() != myOldState.column);
|
||||
|
||||
// Various bits from SWCHA and INPTx
|
||||
myIncrease->setState(swcha & 0x40);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
#include "CompuMate.hxx"
|
||||
#include "System.hxx"
|
||||
#include "M6532.hxx"
|
||||
#include "CartCM.hxx"
|
||||
|
@ -90,14 +91,21 @@ bool CartridgeCM::poke(uInt16 address, uInt8 value)
|
|||
{
|
||||
mySWCHA = value;
|
||||
bank(mySWCHA & 0x3);
|
||||
if(value & 0x20) myColumn = 0;
|
||||
if(value & 0x40) myColumn = (myColumn + 1) % 10;
|
||||
uInt8& column = myCompuMate->myColumn;
|
||||
if(value & 0x20) column = 0;
|
||||
if(value & 0x40) column = (column + 1) % 10;
|
||||
}
|
||||
mySystem->m6532().poke(address, value);
|
||||
}
|
||||
return myBankChanged;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 CartridgeCM::column() const
|
||||
{
|
||||
return myCompuMate->myColumn;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CartridgeCM::bank(uInt16 bank)
|
||||
{
|
||||
|
@ -196,7 +204,7 @@ bool CartridgeCM::save(Serializer& out) const
|
|||
out.putString(name());
|
||||
out.putShort(myCurrentBank);
|
||||
out.putByte(mySWCHA);
|
||||
out.putByte(myColumn);
|
||||
out.putByte(myCompuMate->myColumn);
|
||||
out.putByteArray(myRAM, 2048);
|
||||
}
|
||||
catch(...)
|
||||
|
@ -218,7 +226,7 @@ bool CartridgeCM::load(Serializer& in)
|
|||
|
||||
myCurrentBank = in.getShort();
|
||||
mySWCHA = in.getByte();
|
||||
myColumn = in.getByte();
|
||||
myCompuMate->myColumn = in.getByte();
|
||||
in.getByteArray(myRAM, 2048);
|
||||
}
|
||||
catch(...)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef CARTRIDGECM_HXX
|
||||
#define CARTRIDGECM_HXX
|
||||
|
||||
class CompuMate;
|
||||
class System;
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -226,13 +227,21 @@ class CartridgeCM : public Cartridge
|
|||
bool poke(uInt16 address, uInt8 value);
|
||||
|
||||
/**
|
||||
Get the current keybord column
|
||||
Inform the cartridge about the parent CompuMate controller
|
||||
*/
|
||||
void setCompuMate(CompuMate* cmate) { myCompuMate = cmate; }
|
||||
|
||||
/**
|
||||
Get the current keyboard column
|
||||
|
||||
@return The column referenced by SWCHA D6 and D5
|
||||
*/
|
||||
uInt8 column() const { return myColumn; }
|
||||
uInt8 column() const;
|
||||
|
||||
private:
|
||||
// The CompuMate device which interacts with this cartridge
|
||||
CompuMate* myCompuMate;
|
||||
|
||||
// Indicates which bank is currently active
|
||||
uInt16 myCurrentBank;
|
||||
|
||||
|
@ -244,9 +253,6 @@ class CartridgeCM : public Cartridge
|
|||
|
||||
// Current copy of SWCHA (controls ROM/RAM accesses)
|
||||
uInt8 mySWCHA;
|
||||
|
||||
// Column currently active
|
||||
uInt8 myColumn;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,21 +18,20 @@
|
|||
//============================================================================
|
||||
|
||||
#include "Control.hxx"
|
||||
#include "System.hxx"
|
||||
#include "StellaKeys.hxx"
|
||||
#include "CompuMate.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CompuMate::CompuMate(CartridgeCM& cart, const Event& event,
|
||||
CompuMate::CompuMate(const Console& console, const Event& event,
|
||||
const System& system)
|
||||
: myCart(cart),
|
||||
: myConsole(console),
|
||||
myEvent(event),
|
||||
mySystem(system),
|
||||
myLeftController(0),
|
||||
myRightController(0),
|
||||
myCycleAtLastUpdate(0)
|
||||
myLeftController(nullptr),
|
||||
myRightController(nullptr)
|
||||
{
|
||||
myLeftController = new CMControl(*this, Controller::Left, event, system);
|
||||
// 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->myAnalogPinValue[Controller::Nine] = Controller::maximumResistance;
|
||||
|
@ -58,19 +57,9 @@ void CompuMate::enableKeyHandling(bool enable)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CompuMate::update()
|
||||
{
|
||||
uInt32 cycle = mySystem.cycles();
|
||||
|
||||
// Only perform update once for both ports in the same cycle
|
||||
if(myCycleAtLastUpdate != cycle)
|
||||
{
|
||||
myCycleAtLastUpdate = cycle;
|
||||
return;
|
||||
}
|
||||
myCycleAtLastUpdate = cycle;
|
||||
|
||||
// Handle SWCHA changes - the following comes almost directly from z26
|
||||
Controller& lp = *myLeftController;
|
||||
Controller& rp = *myRightController;
|
||||
Controller& lp = myConsole.leftController();
|
||||
Controller& rp = myConsole.rightController();
|
||||
|
||||
lp.myAnalogPinValue[Controller::Nine] = Controller::maximumResistance;
|
||||
lp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance;
|
||||
|
@ -86,7 +75,8 @@ void CompuMate::update()
|
|||
|
||||
rp.myDigitalPinState[Controller::Three] = true;
|
||||
rp.myDigitalPinState[Controller::Four] = true;
|
||||
switch(myCart.column())
|
||||
|
||||
switch(myColumn)
|
||||
{
|
||||
case 0:
|
||||
if (myKeyTable[KBDK_7]) lp.myDigitalPinState[Controller::Six] = false;
|
||||
|
|
|
@ -42,17 +42,19 @@
|
|||
*/
|
||||
class CompuMate
|
||||
{
|
||||
friend class CartridgeCM;
|
||||
|
||||
public:
|
||||
/**
|
||||
Create a new CompuMate handler for both left and right ports.
|
||||
Note that this class creates CMControl controllers for both ports,
|
||||
but does not take responsibility for their deletion.
|
||||
|
||||
@param cart The CompuMate cartridge
|
||||
@param event The event object to use for events
|
||||
@param system The system using this controller
|
||||
@param console The console that owns the controller
|
||||
@param event The event object to use for events
|
||||
@param system The system using this controller
|
||||
*/
|
||||
CompuMate(CartridgeCM& cart, const Event& event, const System& system);
|
||||
CompuMate(const Console& console, const Event& event, const System& system);
|
||||
|
||||
/**
|
||||
Destructor
|
||||
|
@ -105,8 +107,7 @@ class CompuMate
|
|||
CMControl(class CompuMate& handler, Controller::Jack jack, const Event& event,
|
||||
const System& system)
|
||||
: Controller(jack, event, system, Controller::CompuMate),
|
||||
myHandler(handler)
|
||||
{ }
|
||||
myHandler(handler) { }
|
||||
|
||||
/**
|
||||
Destructor
|
||||
|
@ -116,10 +117,12 @@ class CompuMate
|
|||
public:
|
||||
/**
|
||||
Called after *all* digital pins have been written on Port A.
|
||||
Only update on the left controller; the right controller will
|
||||
happen at the same cycle and is redundant.
|
||||
|
||||
@param value The entire contents of the SWCHA register
|
||||
*/
|
||||
void controlWrite(uInt8) { myHandler.update(); }
|
||||
void controlWrite(uInt8) { if(myJack == Controller::Left) myHandler.update(); }
|
||||
|
||||
/**
|
||||
Update the entire digital and analog pin state according to the
|
||||
|
@ -133,23 +136,21 @@ class CompuMate
|
|||
|
||||
private:
|
||||
// Cart, Event and System objects
|
||||
CartridgeCM& myCart;
|
||||
const Console& myConsole;
|
||||
const Event& myEvent;
|
||||
const System& mySystem;
|
||||
|
||||
// Left and right controllers
|
||||
CMControl *myLeftController, *myRightController;
|
||||
|
||||
// Column currently active
|
||||
uInt8 myColumn;
|
||||
|
||||
// The keyboard state array (tells us the current state of the keyboard)
|
||||
const bool* myKeyTable;
|
||||
|
||||
// Array of keyboard key states when in the debugger (the normal keyboard
|
||||
// keys are ignored in such a case)
|
||||
bool myInternalKeyTable[KBDK_LAST];
|
||||
|
||||
// System cycle at which the update() method is called
|
||||
// Multiple calls at the same cycle should be ignored
|
||||
uInt32 myCycleAtLastUpdate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -93,8 +93,8 @@ Console::Console(OSystem& osystem, Cartridge* cart, const Properties& props)
|
|||
// For now, we just add dummy joystick controllers, since autodetection
|
||||
// runs the emulation for a while, and this may interfere with 'smart'
|
||||
// controllers such as the AVox and SaveKey
|
||||
myControllers[0] = new Joystick(Controller::Left, myEvent, *mySystem);
|
||||
myControllers[1] = new Joystick(Controller::Right, myEvent, *mySystem);
|
||||
myLeftControl = make_ptr<Joystick>(Controller::Left, myEvent, *mySystem);
|
||||
myRightControl = make_ptr<Joystick>(Controller::Right, myEvent, *mySystem);
|
||||
|
||||
// We can only initialize after all the devices/components have been created
|
||||
mySystem->initialize();
|
||||
|
@ -156,8 +156,8 @@ Console::Console(OSystem& osystem, Cartridge* cart, const Properties& props)
|
|||
// Finally, add remaining info about the console
|
||||
myConsoleInfo.CartName = myProperties.get(Cartridge_Name);
|
||||
myConsoleInfo.CartMD5 = myProperties.get(Cartridge_MD5);
|
||||
myConsoleInfo.Control0 = myControllers[0]->about();
|
||||
myConsoleInfo.Control1 = myControllers[1]->about();
|
||||
myConsoleInfo.Control0 = myLeftControl->about();
|
||||
myConsoleInfo.Control1 = myRightControl->about();
|
||||
myConsoleInfo.BankSwitch = myCart->about();
|
||||
|
||||
myCart->setRomName(myConsoleInfo.CartName);
|
||||
|
@ -167,8 +167,6 @@ Console::Console(OSystem& osystem, Cartridge* cart, const Properties& props)
|
|||
Console::~Console()
|
||||
{
|
||||
delete myCMHandler;
|
||||
delete myControllers[0];
|
||||
delete myControllers[1];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -181,7 +179,7 @@ bool Console::save(Serializer& out) const
|
|||
return false;
|
||||
|
||||
// Now save the console controllers and switches
|
||||
if(!(myControllers[0]->save(out) && myControllers[1]->save(out) &&
|
||||
if(!(myLeftControl->save(out) && myRightControl->save(out) &&
|
||||
mySwitches->save(out)))
|
||||
return false;
|
||||
}
|
||||
|
@ -204,7 +202,7 @@ bool Console::load(Serializer& in)
|
|||
return false;
|
||||
|
||||
// Then load the console controllers and switches
|
||||
if(!(myControllers[0]->load(in) && myControllers[1]->load(in) &&
|
||||
if(!(myLeftControl->load(in) && myRightControl->load(in) &&
|
||||
mySwitches->load(in)))
|
||||
return false;
|
||||
}
|
||||
|
@ -583,9 +581,6 @@ void Console::setTIAProperties()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::setControllers(const string& rommd5)
|
||||
{
|
||||
delete myControllers[0];
|
||||
delete myControllers[1];
|
||||
|
||||
// Setup the controllers based on properties
|
||||
const string& left = myProperties.get(Controller_Left);
|
||||
const string& right = myProperties.get(Controller_Right);
|
||||
|
@ -595,22 +590,21 @@ void Console::setControllers(const string& rommd5)
|
|||
if(left == "COMPUMATE" || right == "COMPUMATE")
|
||||
{
|
||||
delete myCMHandler;
|
||||
myCMHandler = new CompuMate(*((CartridgeCM*)&myCart), myEvent, *mySystem);
|
||||
myControllers[0] = myCMHandler->leftController();
|
||||
myControllers[1] = myCMHandler->rightController();
|
||||
myCMHandler = new 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);
|
||||
myCart = std::move(cartcm);
|
||||
|
||||
myLeftControl = unique_ptr<Controller>(myCMHandler->leftController());
|
||||
myRightControl = unique_ptr<Controller>(myCMHandler->rightController());
|
||||
return;
|
||||
}
|
||||
|
||||
// Swap the ports if necessary
|
||||
int leftPort, rightPort;
|
||||
if(myProperties.get(Console_SwapPorts) == "NO")
|
||||
{
|
||||
leftPort = 0; rightPort = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
leftPort = 1; rightPort = 0;
|
||||
}
|
||||
unique_ptr<Controller> leftC, rightC;
|
||||
|
||||
// Also check if we should swap the paddles plugged into a jack
|
||||
bool swapPaddles = myProperties.get(Controller_SwapPaddles) == "YES";
|
||||
|
@ -618,15 +612,15 @@ void Console::setControllers(const string& rommd5)
|
|||
// Construct left controller
|
||||
if(left == "BOOSTERGRIP")
|
||||
{
|
||||
myControllers[leftPort] = new BoosterGrip(Controller::Left, myEvent, *mySystem);
|
||||
leftC = make_ptr<BoosterGrip>(Controller::Left, myEvent, *mySystem);
|
||||
}
|
||||
else if(left == "DRIVING")
|
||||
{
|
||||
myControllers[leftPort] = new Driving(Controller::Left, myEvent, *mySystem);
|
||||
leftC = make_ptr<Driving>(Controller::Left, myEvent, *mySystem);
|
||||
}
|
||||
else if((left == "KEYBOARD") || (left == "KEYPAD"))
|
||||
{
|
||||
myControllers[leftPort] = new Keyboard(Controller::Left, myEvent, *mySystem);
|
||||
leftC = make_ptr<Keyboard>(Controller::Left, myEvent, *mySystem);
|
||||
}
|
||||
else if(BSPF_startsWithIgnoreCase(left, "PADDLES"))
|
||||
{
|
||||
|
@ -637,50 +631,49 @@ void Console::setControllers(const string& rommd5)
|
|||
swapDir = true;
|
||||
else if(left == "PADDLES_IAXDR")
|
||||
swapAxis = swapDir = true;
|
||||
myControllers[leftPort] =
|
||||
new Paddles(Controller::Left, myEvent, *mySystem,
|
||||
swapPaddles, swapAxis, swapDir);
|
||||
leftC = make_ptr<Paddles>(Controller::Left, myEvent, *mySystem,
|
||||
swapPaddles, swapAxis, swapDir);
|
||||
}
|
||||
else if(left == "TRACKBALL22")
|
||||
{
|
||||
myControllers[leftPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
|
||||
Controller::TrackBall22);
|
||||
leftC = make_ptr<TrackBall>(Controller::Left, myEvent, *mySystem,
|
||||
Controller::TrackBall22);
|
||||
}
|
||||
else if(left == "TRACKBALL80")
|
||||
{
|
||||
myControllers[leftPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
|
||||
Controller::TrackBall80);
|
||||
leftC = make_ptr<TrackBall>(Controller::Left, myEvent, *mySystem,
|
||||
Controller::TrackBall80);
|
||||
}
|
||||
else if(left == "AMIGAMOUSE")
|
||||
{
|
||||
myControllers[leftPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
|
||||
Controller::AmigaMouse);
|
||||
leftC = make_ptr<TrackBall>(Controller::Left, myEvent, *mySystem,
|
||||
Controller::AmigaMouse);
|
||||
}
|
||||
else if(left == "GENESIS")
|
||||
{
|
||||
myControllers[leftPort] = new Genesis(Controller::Left, myEvent, *mySystem);
|
||||
leftC = make_ptr<Genesis>(Controller::Left, myEvent, *mySystem);
|
||||
}
|
||||
else if(left == "MINDLINK")
|
||||
{
|
||||
myControllers[leftPort] = new MindLink(Controller::Left, myEvent, *mySystem);
|
||||
leftC = make_ptr<MindLink>(Controller::Left, myEvent, *mySystem);
|
||||
}
|
||||
else
|
||||
{
|
||||
myControllers[leftPort] = new Joystick(Controller::Left, myEvent, *mySystem);
|
||||
leftC = make_ptr<Joystick>(Controller::Left, myEvent, *mySystem);
|
||||
}
|
||||
|
||||
// Construct right controller
|
||||
if(right == "BOOSTERGRIP")
|
||||
{
|
||||
myControllers[rightPort] = new BoosterGrip(Controller::Right, myEvent, *mySystem);
|
||||
rightC = make_ptr<BoosterGrip>(Controller::Right, myEvent, *mySystem);
|
||||
}
|
||||
else if(right == "DRIVING")
|
||||
{
|
||||
myControllers[rightPort] = new Driving(Controller::Right, myEvent, *mySystem);
|
||||
rightC = make_ptr<Driving>(Controller::Right, myEvent, *mySystem);
|
||||
}
|
||||
else if((right == "KEYBOARD") || (right == "KEYPAD"))
|
||||
{
|
||||
myControllers[rightPort] = new Keyboard(Controller::Right, myEvent, *mySystem);
|
||||
rightC = make_ptr<Keyboard>(Controller::Right, myEvent, *mySystem);
|
||||
}
|
||||
else if(BSPF_startsWithIgnoreCase(right, "PADDLES"))
|
||||
{
|
||||
|
@ -691,53 +684,64 @@ void Console::setControllers(const string& rommd5)
|
|||
swapDir = true;
|
||||
else if(right == "PADDLES_IAXDR")
|
||||
swapAxis = swapDir = true;
|
||||
myControllers[rightPort] =
|
||||
new Paddles(Controller::Right, myEvent, *mySystem,
|
||||
swapPaddles, swapAxis, swapDir);
|
||||
rightC = make_ptr<Paddles>(Controller::Right, myEvent, *mySystem,
|
||||
swapPaddles, swapAxis, swapDir);
|
||||
}
|
||||
else if(right == "TRACKBALL22")
|
||||
{
|
||||
myControllers[rightPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
|
||||
Controller::TrackBall22);
|
||||
rightC = make_ptr<TrackBall>(Controller::Left, myEvent, *mySystem,
|
||||
Controller::TrackBall22);
|
||||
}
|
||||
else if(right == "TRACKBALL80")
|
||||
{
|
||||
myControllers[rightPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
|
||||
Controller::TrackBall80);
|
||||
rightC = make_ptr<TrackBall>(Controller::Left, myEvent, *mySystem,
|
||||
Controller::TrackBall80);
|
||||
}
|
||||
else if(right == "AMIGAMOUSE")
|
||||
{
|
||||
myControllers[rightPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
|
||||
Controller::AmigaMouse);
|
||||
rightC = make_ptr<TrackBall>(Controller::Left, myEvent, *mySystem,
|
||||
Controller::AmigaMouse);
|
||||
}
|
||||
else if(right == "ATARIVOX")
|
||||
{
|
||||
const string& nvramfile = myOSystem.nvramDir() + "atarivox_eeprom.dat";
|
||||
myControllers[rightPort] = new AtariVox(Controller::Right, myEvent,
|
||||
rightC = make_ptr<AtariVox>(Controller::Right, myEvent,
|
||||
*mySystem, myOSystem.serialPort(),
|
||||
myOSystem.settings().getString("avoxport"), nvramfile);
|
||||
}
|
||||
else if(right == "SAVEKEY")
|
||||
{
|
||||
const string& nvramfile = myOSystem.nvramDir() + "savekey_eeprom.dat";
|
||||
myControllers[rightPort] = new SaveKey(Controller::Right, myEvent, *mySystem,
|
||||
nvramfile);
|
||||
rightC = make_ptr<SaveKey>(Controller::Right, myEvent, *mySystem,
|
||||
nvramfile);
|
||||
}
|
||||
else if(right == "GENESIS")
|
||||
{
|
||||
myControllers[rightPort] = new Genesis(Controller::Right, myEvent, *mySystem);
|
||||
rightC = make_ptr<Genesis>(Controller::Right, myEvent, *mySystem);
|
||||
}
|
||||
else if(right == "KIDVID")
|
||||
{
|
||||
myControllers[rightPort] = new KidVid(Controller::Right, myEvent, *mySystem, rommd5);
|
||||
rightC = make_ptr<KidVid>(Controller::Right, myEvent, *mySystem, rommd5);
|
||||
}
|
||||
else if(right == "MINDLINK")
|
||||
{
|
||||
myControllers[rightPort] = new MindLink(Controller::Right, myEvent, *mySystem);
|
||||
rightC = make_ptr<MindLink>(Controller::Right, myEvent, *mySystem);
|
||||
}
|
||||
else
|
||||
{
|
||||
myControllers[rightPort] = new Joystick(Controller::Right, myEvent, *mySystem);
|
||||
rightC = make_ptr<Joystick>(Controller::Right, myEvent, *mySystem);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#ifndef CONSOLE_HXX
|
||||
#define CONSOLE_HXX
|
||||
|
||||
class Controller;
|
||||
class Event;
|
||||
class Switches;
|
||||
class System;
|
||||
|
@ -82,10 +81,8 @@ class Console : public Serializable
|
|||
|
||||
@return The specified controller
|
||||
*/
|
||||
Controller& controller(Controller::Jack jack) const
|
||||
{
|
||||
return *myControllers[jack];
|
||||
}
|
||||
Controller& leftController() const { return *myLeftControl; }
|
||||
Controller& rightController() const { return *myRightControl; }
|
||||
|
||||
/**
|
||||
Get the TIA for this console
|
||||
|
@ -129,14 +126,6 @@ class Console : public Serializable
|
|||
*/
|
||||
M6532& riot() const { return *myRiot; }
|
||||
|
||||
/**
|
||||
Get the CompuMate handler used by the console
|
||||
(only valid for CompuMate ROMs)
|
||||
|
||||
@return The CompuMate handler for this console (if it exists), otherwise 0
|
||||
*/
|
||||
CompuMate* compumate() const { return myCMHandler; }
|
||||
|
||||
/**
|
||||
Saves the current state of this console class to the given Serializer.
|
||||
|
||||
|
@ -357,7 +346,7 @@ class Console : public Serializable
|
|||
unique_ptr<Switches> mySwitches;
|
||||
|
||||
// Pointers to the left and right controllers
|
||||
Controller* myControllers[2];
|
||||
unique_ptr<Controller> myLeftControl, myRightControl;
|
||||
|
||||
// Pointer to CompuMate handler (only used in CompuMate ROMs)
|
||||
CompuMate* myCMHandler;
|
||||
|
|
|
@ -632,7 +632,7 @@ void EventHandler::handleJoyEvent(int stick, int button, uInt8 state)
|
|||
// enum; subtracting four gives us Controller 0 and 1
|
||||
if(myState == S_EMULATE)
|
||||
{
|
||||
switch(myOSystem.console().controller(Controller::Left).type())
|
||||
switch(myOSystem.console().leftController().type())
|
||||
{
|
||||
case Controller::Keyboard:
|
||||
if(button < 12) myEvent.set(SA_Key[joy->type-4][button], state);
|
||||
|
@ -640,7 +640,7 @@ void EventHandler::handleJoyEvent(int stick, int button, uInt8 state)
|
|||
default:
|
||||
if(button < 4) myEvent.set(SA_Button[joy->type-4][button], state);
|
||||
}
|
||||
switch(myOSystem.console().controller(Controller::Right).type())
|
||||
switch(myOSystem.console().rightController().type())
|
||||
{
|
||||
case Controller::Keyboard:
|
||||
if(button < 12) myEvent.set(SA_Key[joy->type-4][button], state);
|
||||
|
@ -1783,7 +1783,7 @@ void EventHandler::setMouseControllerMode(const string& enable)
|
|||
usemouse = false;
|
||||
else // 'analog'
|
||||
{
|
||||
switch(myOSystem.console().controller(Controller::Left).type())
|
||||
switch(myOSystem.console().leftController().type())
|
||||
{
|
||||
case Controller::Paddles:
|
||||
case Controller::Driving:
|
||||
|
@ -1796,7 +1796,7 @@ void EventHandler::setMouseControllerMode(const string& enable)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
switch(myOSystem.console().controller(Controller::Right).type())
|
||||
switch(myOSystem.console().rightController().type())
|
||||
{
|
||||
case Controller::Paddles:
|
||||
case Controller::Driving:
|
||||
|
@ -1909,8 +1909,7 @@ void EventHandler::setEventState(State state)
|
|||
myOverlay = NULL;
|
||||
myOSystem.sound().mute(false);
|
||||
enableTextEvents(false);
|
||||
if(myOSystem.console().controller(Controller::Left).type() ==
|
||||
Controller::CompuMate)
|
||||
if(myOSystem.console().leftController().type() == Controller::CompuMate)
|
||||
myUseCtrlKeyFlag = false;
|
||||
break;
|
||||
|
||||
|
|
|
@ -79,15 +79,15 @@ void M6532::systemCyclesReset()
|
|||
myCyclesWhenTimerSet -= mySystem->cycles();
|
||||
|
||||
// We should also inform any 'smart' controllers as well
|
||||
myConsole.controller(Controller::Left).systemCyclesReset();
|
||||
myConsole.controller(Controller::Right).systemCyclesReset();
|
||||
myConsole.leftController().systemCyclesReset();
|
||||
myConsole.rightController().systemCyclesReset();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void M6532::update()
|
||||
{
|
||||
Controller& port0 = myConsole.controller(Controller::Left);
|
||||
Controller& port1 = myConsole.controller(Controller::Right);
|
||||
Controller& port0 = myConsole.leftController();
|
||||
Controller& port1 = myConsole.rightController();
|
||||
|
||||
// Get current PA7 state
|
||||
bool prevPA7 = port0.myDigitalPinState[Controller::Four];
|
||||
|
@ -143,8 +143,8 @@ uInt8 M6532::peek(uInt16 addr)
|
|||
{
|
||||
case 0x00: // SWCHA - Port A I/O Register (Joystick)
|
||||
{
|
||||
uInt8 value = (myConsole.controller(Controller::Left).read() << 4) |
|
||||
myConsole.controller(Controller::Right).read();
|
||||
uInt8 value = (myConsole.leftController().read() << 4) |
|
||||
myConsole.rightController().read();
|
||||
|
||||
// Each pin is high (1) by default and will only go low (0) if either
|
||||
// (a) External device drives the pin low
|
||||
|
@ -311,8 +311,8 @@ void M6532::setPinState(bool swcha)
|
|||
if(DDR bit is input) set output as 1
|
||||
else if(DDR bit is output) set output as bit in ORA
|
||||
*/
|
||||
Controller& port0 = myConsole.controller(Controller::Left);
|
||||
Controller& port1 = myConsole.controller(Controller::Right);
|
||||
Controller& port0 = myConsole.leftController();
|
||||
Controller& port1 = myConsole.rightController();
|
||||
|
||||
uInt8 ioport = myOutA | ~myDDRA;
|
||||
|
||||
|
|
|
@ -1321,27 +1321,27 @@ uInt8 TIA::peek(uInt16 addr)
|
|||
|
||||
case INPT0:
|
||||
value = (value & 0x7F) |
|
||||
dumpedInputPort(myConsole.controller(Controller::Left).read(Controller::Nine));
|
||||
dumpedInputPort(myConsole.leftController().read(Controller::Nine));
|
||||
break;
|
||||
|
||||
case INPT1:
|
||||
value = (value & 0x7F) |
|
||||
dumpedInputPort(myConsole.controller(Controller::Left).read(Controller::Five));
|
||||
dumpedInputPort(myConsole.leftController().read(Controller::Five));
|
||||
break;
|
||||
|
||||
case INPT2:
|
||||
value = (value & 0x7F) |
|
||||
dumpedInputPort(myConsole.controller(Controller::Right).read(Controller::Nine));
|
||||
dumpedInputPort(myConsole.rightController().read(Controller::Nine));
|
||||
break;
|
||||
|
||||
case INPT3:
|
||||
value = (value & 0x7F) |
|
||||
dumpedInputPort(myConsole.controller(Controller::Right).read(Controller::Five));
|
||||
dumpedInputPort(myConsole.rightController().read(Controller::Five));
|
||||
break;
|
||||
|
||||
case INPT4:
|
||||
{
|
||||
uInt8 button = (myConsole.controller(Controller::Left).read(Controller::Six) ? 0x80 : 0x00);
|
||||
uInt8 button = (myConsole.leftController().read(Controller::Six) ? 0x80 : 0x00);
|
||||
myINPT4 = (myVBLANK & 0x40) ? (myINPT4 & button) : button;
|
||||
|
||||
value = (value & 0x7F) | myINPT4;
|
||||
|
@ -1350,7 +1350,7 @@ uInt8 TIA::peek(uInt16 addr)
|
|||
|
||||
case INPT5:
|
||||
{
|
||||
uInt8 button = (myConsole.controller(Controller::Right).read(Controller::Six) ? 0x80 : 0x00);
|
||||
uInt8 button = (myConsole.rightController().read(Controller::Six) ? 0x80 : 0x00);
|
||||
myINPT5 = (myVBLANK & 0x40) ? (myINPT5 & button) : button;
|
||||
|
||||
value = (value & 0x7F) | myINPT5;
|
||||
|
|
Loading…
Reference in New Issue