mirror of https://github.com/stella-emu/stella.git
Make sure AtariVox and SaveKey controllers aren't messed up
when the Console runs autodetection routines at startup. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2344 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
293a8a69b4
commit
c26f0a1275
|
@ -31,7 +31,8 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system,
|
|||
myEEPROM(NULL),
|
||||
myShiftCount(0),
|
||||
myShiftRegister(0),
|
||||
myLastDataWriteCycle(0)
|
||||
myLastDataWriteCycle(0),
|
||||
myIsEnabled(false)
|
||||
{
|
||||
if(mySerialPort.openPort(portname))
|
||||
myAboutString = " (using serial port \'" + portname + "\')";
|
||||
|
@ -56,6 +57,9 @@ AtariVox::~AtariVox()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool AtariVox::read(DigitalPin pin)
|
||||
{
|
||||
if(!myIsEnabled)
|
||||
return Controller::read(pin);
|
||||
|
||||
// We need to override the Controller::read() method, since the timing
|
||||
// of the actual read is important for the EEPROM (we can't just read
|
||||
// 60 times per second in the ::update() method)
|
||||
|
@ -79,6 +83,9 @@ bool AtariVox::read(DigitalPin pin)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AtariVox::write(DigitalPin pin, bool value)
|
||||
{
|
||||
if(!myIsEnabled)
|
||||
return;
|
||||
|
||||
// Change the pin state based on value
|
||||
switch(pin)
|
||||
{
|
||||
|
|
|
@ -89,7 +89,14 @@ class AtariVox : public Controller
|
|||
*/
|
||||
void systemCyclesReset();
|
||||
|
||||
virtual string about() const;
|
||||
/**
|
||||
Notification to controllers that they should enable or disable
|
||||
reads and writes on their pins. Most controllers do not
|
||||
implement this.
|
||||
*/
|
||||
void enable(bool state) { myIsEnabled = state; }
|
||||
|
||||
string about() const;
|
||||
|
||||
private:
|
||||
void clockDataIn(bool value);
|
||||
|
@ -119,6 +126,9 @@ class AtariVox : public Controller
|
|||
// "close enough".
|
||||
uInt32 myLastDataWriteCycle;
|
||||
|
||||
// Whether we should process reads and writes
|
||||
bool myIsEnabled;
|
||||
|
||||
// Holds information concerning serial port usage
|
||||
string myAboutString;
|
||||
};
|
||||
|
|
|
@ -92,20 +92,8 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
// Construct the system and components
|
||||
mySystem = new System(13, 6);
|
||||
|
||||
#if 0
|
||||
// The real controllers for this console will be added later
|
||||
// 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
|
||||
// Note that the controllers must be added directly after the system
|
||||
// has been created, and before any other device is added
|
||||
// (particularly the M6532)
|
||||
myControllers[0] = new Joystick(Controller::Left, *myEvent, *mySystem);
|
||||
myControllers[1] = new Joystick(Controller::Right, *myEvent, *mySystem);
|
||||
#endif
|
||||
// Add the controllers for this system
|
||||
const string& md5 = myProperties.get(Cartridge_MD5);
|
||||
|
||||
// Add the real controllers for this system
|
||||
setControllers(md5);
|
||||
|
||||
// Bumper Bash always requires all 4 directions
|
||||
|
@ -214,6 +202,8 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
|
||||
// Reset the system to its power-on state
|
||||
mySystem->reset();
|
||||
myControllers[0]->enable(true);
|
||||
myControllers[1]->enable(true);
|
||||
|
||||
// Finally, add remaining info about the console
|
||||
myConsoleInfo.CartName = myProperties.get(Cartridge_Name);
|
||||
|
@ -755,6 +745,9 @@ void Console::setControllers(const string& rommd5)
|
|||
{
|
||||
myControllers[rightPort] = new Joystick(Controller::Right, *myEvent, *mySystem);
|
||||
}
|
||||
|
||||
myControllers[leftPort]->enable(false);
|
||||
myControllers[rightPort]->enable(false);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -106,32 +106,13 @@ uInt8 Controller::read()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Controller::read(DigitalPin pin)
|
||||
{
|
||||
switch(pin)
|
||||
{
|
||||
case One:
|
||||
case Two:
|
||||
case Three:
|
||||
case Four:
|
||||
case Six:
|
||||
return myDigitalPinState[pin];
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return myDigitalPinState[pin];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Int32 Controller::read(AnalogPin pin)
|
||||
{
|
||||
switch(pin)
|
||||
{
|
||||
case Five:
|
||||
case Nine:
|
||||
return myAnalogPinValue[pin];
|
||||
|
||||
default:
|
||||
return maximumResistance;
|
||||
}
|
||||
return myAnalogPinValue[pin];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -188,6 +188,13 @@ class Controller : public Serializable
|
|||
*/
|
||||
virtual void systemCyclesReset() { };
|
||||
|
||||
/**
|
||||
Notification to controllers that they should enable or disable
|
||||
reads and writes on their pins. Most controllers do not
|
||||
implement this.
|
||||
*/
|
||||
virtual void enable(bool state) { };
|
||||
|
||||
/**
|
||||
Determines how this controller will treat values received from the
|
||||
X and Y axis of the mouse. Since not all controllers use the mouse,
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
SaveKey::SaveKey(Jack jack, const Event& event, const System& system,
|
||||
const string& eepromfile)
|
||||
: Controller(jack, event, system, Controller::SaveKey),
|
||||
myEEPROM(NULL)
|
||||
myEEPROM(NULL),
|
||||
myIsEnabled(false)
|
||||
{
|
||||
myEEPROM = new MT24LC256(eepromfile, system);
|
||||
|
||||
|
@ -42,6 +43,9 @@ SaveKey::~SaveKey()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool SaveKey::read(DigitalPin pin)
|
||||
{
|
||||
if(!myIsEnabled)
|
||||
return Controller::read(pin);
|
||||
|
||||
// We need to override the Controller::read() method, since the timing
|
||||
// of the actual read is important for the EEPROM (we can't just read
|
||||
// 60 times per second in the ::update() method)
|
||||
|
@ -60,6 +64,9 @@ bool SaveKey::read(DigitalPin pin)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SaveKey::write(DigitalPin pin, bool value)
|
||||
{
|
||||
if(!myIsEnabled)
|
||||
return;
|
||||
|
||||
// Change the pin state based on value
|
||||
switch(pin)
|
||||
{
|
||||
|
|
|
@ -85,9 +85,19 @@ class SaveKey : public Controller
|
|||
*/
|
||||
void systemCyclesReset();
|
||||
|
||||
/**
|
||||
Notification to controllers that they should enable or disable
|
||||
reads and writes on their pins. Most controllers do not
|
||||
implement this.
|
||||
*/
|
||||
void enable(bool state) { myIsEnabled = state; }
|
||||
|
||||
private:
|
||||
// The EEPROM used in the SaveKey
|
||||
MT24LC256* myEEPROM;
|
||||
|
||||
// Whether we should process reads and writes
|
||||
bool myIsEnabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue