From 963905759ec240a2ab23247996c527e07c0288fb Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Tue, 12 Jun 2018 19:07:31 -0230 Subject: [PATCH] Controller/Genesis/Booster cleanup. - Made BoosterGrip set defaults for analog pins, just like Genesis - Removed superfluous call to update an unchangeable pin in Genesis - Renamed Controller resistance constants to indicate that they are actually constants --- Changes.txt | 15 +++++++++--- src/debugger/gui/BoosterWidget.cxx | 12 +++++----- src/debugger/gui/GenesisWidget.cxx | 6 ++--- src/emucore/Booster.cxx | 10 ++++---- src/emucore/CompuMate.cxx | 38 +++++++++++++++--------------- src/emucore/Control.cxx | 2 +- src/emucore/Control.hxx | 4 ++-- src/emucore/Genesis.cxx | 9 ++++--- src/emucore/Keyboard.cxx | 16 ++++++------- src/emucore/Paddles.cxx | 4 ++-- src/emucore/tia/TIA.cxx | 2 +- 11 files changed, 64 insertions(+), 54 deletions(-) diff --git a/Changes.txt b/Changes.txt index f41499110..106a30480 100644 --- a/Changes.txt +++ b/Changes.txt @@ -12,7 +12,7 @@ Release History =========================================================================== -5.1.2 to 5.2: (MMM d, 2018) +5.1.3 to 5.2: (MMM d, 2018) * Extra functionality for Time Machine dialog (start/stop recording; minor fixes; TODO button and initial key repeats...) @@ -21,14 +21,23 @@ * UI modernization (new widget look, dialog titles added, dialogs refactored) + * Fixed bug in autodetecting Genesis controllers. + * The Linux builds now use the system-installed PNG and ZLIB libraries by default. - * Fixed configure/build scripts to work natively under OpenBSD. - -Have fun! +5.1.2 to 5.1.3: (June 10, 2018) + + * Fixed crash in OpenBSD when quitting the app, which can also be + happening on other systems (no reports yet, but the problem is now + fixed for good). + + * Fixed configure/build scripts to work natively under OpenBSD. + + 5.1.1 to 5.1.2: (May 20, 2018) * Fixed bug with SaveKey autodetection; some ROMs were not correctly diff --git a/src/debugger/gui/BoosterWidget.cxx b/src/debugger/gui/BoosterWidget.cxx index bff2630fe..6066dfebe 100644 --- a/src/debugger/gui/BoosterWidget.cxx +++ b/src/debugger/gui/BoosterWidget.cxx @@ -85,9 +85,9 @@ void BoosterWidget::loadConfig() myPins[kJFire]->setState(!myController.read(ourPinNo[kJFire])); myPins[kJBooster]->setState( - myController.read(Controller::Five) == Controller::minimumResistance); + myController.read(Controller::Five) == Controller::MIN_RESISTANCE); myPins[kJTrigger]->setState( - myController.read(Controller::Nine) == Controller::minimumResistance); + myController.read(Controller::Nine) == Controller::MIN_RESISTANCE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -107,13 +107,13 @@ void BoosterWidget::handleCommand( break; case kJBooster: myController.set(Controller::Five, - myPins[id]->getState() ? Controller::minimumResistance : - Controller::maximumResistance); + myPins[id]->getState() ? Controller::MIN_RESISTANCE : + Controller::MAX_RESISTANCE); break; case kJTrigger: myController.set(Controller::Nine, - myPins[id]->getState() ? Controller::minimumResistance : - Controller::maximumResistance); + myPins[id]->getState() ? Controller::MIN_RESISTANCE : + Controller::MAX_RESISTANCE); break; } } diff --git a/src/debugger/gui/GenesisWidget.cxx b/src/debugger/gui/GenesisWidget.cxx index e49c360c0..67051d98f 100644 --- a/src/debugger/gui/GenesisWidget.cxx +++ b/src/debugger/gui/GenesisWidget.cxx @@ -79,7 +79,7 @@ void GenesisWidget::loadConfig() myPins[kJBbtn]->setState(!myController.read(ourPinNo[kJBbtn])); myPins[kJCbtn]->setState( - myController.read(Controller::Five) == Controller::maximumResistance); + myController.read(Controller::Five) == Controller::MAX_RESISTANCE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -99,8 +99,8 @@ void GenesisWidget::handleCommand( break; case kJCbtn: myController.set(Controller::Five, - myPins[id]->getState() ? Controller::maximumResistance : - Controller::minimumResistance); + myPins[id]->getState() ? Controller::MAX_RESISTANCE : + Controller::MIN_RESISTANCE); break; } } diff --git a/src/emucore/Booster.cxx b/src/emucore/Booster.cxx index 22f17a410..e09859ae1 100644 --- a/src/emucore/Booster.cxx +++ b/src/emucore/Booster.cxx @@ -47,7 +47,9 @@ BoosterGrip::BoosterGrip(Jack jack, const Event& event, const System& system) myXAxisValue = Event::SARightAxis0Value; myYAxisValue = Event::SARightAxis1Value; } - updateAnalogPin(Five, maximumResistance); + + updateAnalogPin(Five, MAX_RESISTANCE); + updateAnalogPin(Nine, MAX_RESISTANCE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -64,11 +66,11 @@ void BoosterGrip::update() // connected to the inputs usually used by paddles. updateAnalogPin( Five, - (myEvent.get(myTriggerEvent) != 0) ? minimumResistance : maximumResistance + (myEvent.get(myTriggerEvent) != 0) ? MIN_RESISTANCE : MAX_RESISTANCE ); updateAnalogPin( Nine, - (myEvent.get(myBoosterEvent) != 0) ? minimumResistance : maximumResistance + (myEvent.get(myBoosterEvent) != 0) ? MIN_RESISTANCE : MAX_RESISTANCE ); // Axis events (usually generated by the Stelladaptor) @@ -122,7 +124,7 @@ void BoosterGrip::update() if(myEvent.get(Event::MouseButtonLeftValue)) myDigitalPinState[Six] = false; if(myEvent.get(Event::MouseButtonRightValue)) - updateAnalogPin(Nine, minimumResistance); + updateAnalogPin(Nine, MIN_RESISTANCE); } } diff --git a/src/emucore/CompuMate.cxx b/src/emucore/CompuMate.cxx index b24d0556a..db4911085 100644 --- a/src/emucore/CompuMate.cxx +++ b/src/emucore/CompuMate.cxx @@ -32,10 +32,10 @@ CompuMate::CompuMate(const Console& console, const Event& event, myLeftController = make_unique(*this, Controller::Left, event, system); myRightController = make_unique(*this, Controller::Right, event, system); - myLeftController->updateAnalogPin(Controller::Nine, Controller::maximumResistance); - myLeftController->updateAnalogPin(Controller::Five, Controller::minimumResistance); - myRightController->updateAnalogPin(Controller::Nine, Controller::minimumResistance); - myRightController->updateAnalogPin(Controller::Five, Controller::maximumResistance); + myLeftController->updateAnalogPin(Controller::Nine, Controller::MAX_RESISTANCE); + myLeftController->updateAnalogPin(Controller::Five, Controller::MIN_RESISTANCE); + myRightController->updateAnalogPin(Controller::Nine, Controller::MIN_RESISTANCE); + myRightController->updateAnalogPin(Controller::Five, Controller::MAX_RESISTANCE); enableKeyHandling(false); } @@ -61,17 +61,17 @@ void CompuMate::update() Controller& lp = myConsole.leftController(); Controller& rp = myConsole.rightController(); - lp.myAnalogPinValue[Controller::Nine] = Controller::maximumResistance; - lp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + lp.myAnalogPinValue[Controller::Nine] = Controller::MAX_RESISTANCE; + lp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = true; - rp.myAnalogPinValue[Controller::Nine] = Controller::minimumResistance; - rp.myAnalogPinValue[Controller::Five] = Controller::maximumResistance; + rp.myAnalogPinValue[Controller::Nine] = Controller::MIN_RESISTANCE; + rp.myAnalogPinValue[Controller::Five] = Controller::MAX_RESISTANCE; rp.myDigitalPinState[Controller::Six] = true; if (myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]) - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; if (myKeyTable[KBDK_LCTRL] || myKeyTable[KBDK_RCTRL]) - lp.myAnalogPinValue[Controller::Nine] = Controller::minimumResistance; + lp.myAnalogPinValue[Controller::Nine] = Controller::MIN_RESISTANCE; rp.myDigitalPinState[Controller::Three] = true; rp.myDigitalPinState[Controller::Four] = true; @@ -89,7 +89,7 @@ void CompuMate::update() // Emulate the '?' character (Shift-6) with the actual question key if (myKeyTable[KBDK_SLASH] && (myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])) { - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = false; } if (myKeyTable[KBDK_Y]) rp.myDigitalPinState[Controller::Three] = false; @@ -101,7 +101,7 @@ void CompuMate::update() // Emulate the '[' character (Shift-8) with the actual key if (myKeyTable[KBDK_LEFTBRACKET] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])) { - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = false; } if (myKeyTable[KBDK_I]) rp.myDigitalPinState[Controller::Three] = false; @@ -113,7 +113,7 @@ void CompuMate::update() // Emulate the '-' character (Shift-2) with the actual minus key if (myKeyTable[KBDK_MINUS] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])) { - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = false; } if (myKeyTable[KBDK_W]) rp.myDigitalPinState[Controller::Three] = false; @@ -131,7 +131,7 @@ void CompuMate::update() // Emulate the quote character (Shift-0) with the actual quote key if (myKeyTable[KBDK_APOSTROPHE] && (myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])) { - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = false; } if (myKeyTable[KBDK_P]) rp.myDigitalPinState[Controller::Three] = false; @@ -141,7 +141,7 @@ void CompuMate::update() // Emulate Ctrl-space (aka backspace) with the actual Backspace key if (myKeyTable[KBDK_BACKSPACE]) { - lp.myAnalogPinValue[Controller::Nine] = Controller::minimumResistance; + lp.myAnalogPinValue[Controller::Nine] = Controller::MIN_RESISTANCE; rp.myDigitalPinState[Controller::Four] = false; } break; @@ -150,7 +150,7 @@ void CompuMate::update() // Emulate the ']' character (Shift-9) with the actual key if (myKeyTable[KBDK_RIGHTBRACKET] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])) { - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = false; } if (myKeyTable[KBDK_O]) rp.myDigitalPinState[Controller::Three] = false; @@ -162,7 +162,7 @@ void CompuMate::update() // Emulate the '=' character (Shift-5) with the actual equals key if (myKeyTable[KBDK_EQUALS] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])) { - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = false; } if (myKeyTable[KBDK_T]) rp.myDigitalPinState[Controller::Three] = false; @@ -174,7 +174,7 @@ void CompuMate::update() // Emulate the '+' character (Shift-1) with the actual plus key (Shift-=) if (myKeyTable[KBDK_EQUALS] && (myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])) { - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = false; } if (myKeyTable[KBDK_Q]) rp.myDigitalPinState[Controller::Three] = false; @@ -186,7 +186,7 @@ void CompuMate::update() // Emulate the '/' character (Shift-4) with the actual slash key if (myKeyTable[KBDK_SLASH] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])) { - rp.myAnalogPinValue[Controller::Five] = Controller::minimumResistance; + rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE; lp.myDigitalPinState[Controller::Six] = false; } if (myKeyTable[KBDK_R]) rp.myDigitalPinState[Controller::Three] = false; diff --git a/src/emucore/Control.cxx b/src/emucore/Control.cxx index 758a0b8ac..c522b3947 100644 --- a/src/emucore/Control.cxx +++ b/src/emucore/Control.cxx @@ -36,7 +36,7 @@ Controller::Controller(Jack jack, const Event& event, const System& system, myDigitalPinState[Six] = true; myAnalogPinValue[Five] = - myAnalogPinValue[Nine] = maximumResistance; + myAnalogPinValue[Nine] = MAX_RESISTANCE; switch(myType) { diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index 7d9eb13ef..6d962cb35 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -262,10 +262,10 @@ class Controller : public Serializable public: /// Constant which represents maximum resistance for analog pins - static constexpr Int32 maximumResistance = 0x7FFFFFFF; + static constexpr Int32 MAX_RESISTANCE = 0x7FFFFFFF; /// Constant which represents minimum resistance for analog pins - static constexpr Int32 minimumResistance = 0x00000000; + static constexpr Int32 MIN_RESISTANCE = 0x00000000; protected: void updateAnalogPin(AnalogPin, Int32 value); diff --git a/src/emucore/Genesis.cxx b/src/emucore/Genesis.cxx index d47cc1f49..74de86906 100644 --- a/src/emucore/Genesis.cxx +++ b/src/emucore/Genesis.cxx @@ -42,8 +42,8 @@ Genesis::Genesis(Jack jack, const Event& event, const System& system) myFire2Event = Event::JoystickOneFire5; } - updateAnalogPin(Five, minimumResistance); - updateAnalogPin(Nine, minimumResistance); + updateAnalogPin(Five, MIN_RESISTANCE); + updateAnalogPin(Nine, MIN_RESISTANCE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -61,9 +61,8 @@ void Genesis::update() // in that the logic is inverted updateAnalogPin( Five, - (myEvent.get(myFire2Event) == 0) ? minimumResistance : maximumResistance + (myEvent.get(myFire2Event) == 0) ? MIN_RESISTANCE : MAX_RESISTANCE ); - updateAnalogPin(Nine, minimumResistance); // Mouse motion and button events if(myControlID > -1) @@ -94,7 +93,7 @@ void Genesis::update() if(myEvent.get(Event::MouseButtonLeftValue)) myDigitalPinState[Six] = false; if(myEvent.get(Event::MouseButtonRightValue)) - updateAnalogPin(Five, maximumResistance); + updateAnalogPin(Five, MAX_RESISTANCE); } } diff --git a/src/emucore/Keyboard.cxx b/src/emucore/Keyboard.cxx index 92bc70c20..996053d32 100644 --- a/src/emucore/Keyboard.cxx +++ b/src/emucore/Keyboard.cxx @@ -68,26 +68,26 @@ void Keyboard::write(DigitalPin pin, bool value) if(!myDigitalPinState[Four]) { myDigitalPinState[Six] = (myEvent.get(myPoundEvent) == 0); - if(myEvent.get(myZeroEvent) != 0) resistanceFive = maximumResistance; - if(myEvent.get(myStarEvent) != 0) resistanceNine = maximumResistance; + if(myEvent.get(myZeroEvent) != 0) resistanceFive = MAX_RESISTANCE; + if(myEvent.get(myStarEvent) != 0) resistanceNine = MAX_RESISTANCE; } if(!myDigitalPinState[Three]) { myDigitalPinState[Six] = (myEvent.get(myNineEvent) == 0); - if(myEvent.get(myEightEvent) != 0) resistanceFive = maximumResistance; - if(myEvent.get(mySevenEvent) != 0) resistanceNine = maximumResistance; + if(myEvent.get(myEightEvent) != 0) resistanceFive = MAX_RESISTANCE; + if(myEvent.get(mySevenEvent) != 0) resistanceNine = MAX_RESISTANCE; } if(!myDigitalPinState[Two]) { myDigitalPinState[Six] = (myEvent.get(mySixEvent) == 0); - if(myEvent.get(myFiveEvent) != 0) resistanceFive = maximumResistance; - if(myEvent.get(myFourEvent) != 0) resistanceNine = maximumResistance; + if(myEvent.get(myFiveEvent) != 0) resistanceFive = MAX_RESISTANCE; + if(myEvent.get(myFourEvent) != 0) resistanceNine = MAX_RESISTANCE; } if(!myDigitalPinState[One]) { myDigitalPinState[Six] = (myEvent.get(myThreeEvent) == 0); - if(myEvent.get(myTwoEvent) != 0) resistanceFive = maximumResistance; - if(myEvent.get(myOneEvent) != 0) resistanceNine = maximumResistance; + if(myEvent.get(myTwoEvent) != 0) resistanceFive = MAX_RESISTANCE; + if(myEvent.get(myOneEvent) != 0) resistanceNine = MAX_RESISTANCE; } if (resistanceFive != read(Five)) { diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index ed90b3a1b..f6bca2b46 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -28,8 +28,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, { // We must start with minimum resistance; see commit // 38b452e1a047a0dca38c5bcce7c271d40f76736e for more information - updateAnalogPin(Five, minimumResistance); - updateAnalogPin(Nine, minimumResistance); + updateAnalogPin(Five, MIN_RESISTANCE); + updateAnalogPin(Nine, MIN_RESISTANCE); // The following logic reflects that mapping paddles to different // devices can be extremely complex diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 5babe0e7d..d1b55c0d4 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -1542,7 +1542,7 @@ void TIA::updatePaddle(uInt8 idx) } myPaddleReaders[idx].update( - (resistance == Controller::maximumResistance) ? -1 : (double(resistance) / Paddles::MAX_RESISTANCE), + (resistance == Controller::MAX_RESISTANCE) ? -1 : (double(resistance) / Paddles::MAX_RESISTANCE), myTimestamp, consoleTiming() );