From 7350e8f6c128a3d6e45d83cd7b1c5370b8b9b0cd Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 28 Jun 2015 22:32:36 +0000 Subject: [PATCH] Added mappable events for toggling TV color type and left/right A/B difficulty. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3180 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- Changes.txt | 5 ++ src/common/MouseControl.cxx | 4 +- src/emucore/Event.hxx | 1 + src/emucore/EventHandler.cxx | 100 ++++++++++++++++++++++++++++++++--- src/emucore/EventHandler.hxx | 2 +- src/emucore/Switches.hxx | 21 ++++++++ 6 files changed, 123 insertions(+), 10 deletions(-) diff --git a/Changes.txt b/Changes.txt index 70c719aae..0eda357e1 100644 --- a/Changes.txt +++ b/Changes.txt @@ -14,6 +14,11 @@ 4.6.1 to 4.7: (mmm dd, 2015) + * Added mappable events for swapping TV color/BW, left difficulty A/B + and right difficulty A/B. This means that one key. joystick button, + etc can be used to toggle each event. Thanks to Buzbard of AtariAge + for the suggestion. + * Changed 'hidecursor' commandline argument (and associated UI item) to 'cursor'. The new argument allows to set mouse cursor visibility separately for both UI and emulation modes. diff --git a/src/common/MouseControl.cxx b/src/common/MouseControl.cxx index ff4cf5fb9..f21a26095 100644 --- a/src/common/MouseControl.cxx +++ b/src/common/MouseControl.cxx @@ -162,8 +162,8 @@ MouseControl::MouseControl(Console& console, const string& mode) myModeList.push_back(MouseMode("Mouse not used for current controllers")); #if 0 - for(MouseMode m: myModeList) - cerr << mode << endl; + for(const auto& m: myModeList) + cerr << m << endl; #endif } diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 2d9b57d4a..9d32d378e 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -42,6 +42,7 @@ class Event ConsoleLeftDiffA, ConsoleLeftDiffB, ConsoleRightDiffA, ConsoleRightDiffB, ConsoleSelect, ConsoleReset, + ConsoleLeftDiffSwap, ConsoleRightDiffSwap, ConsoleColorSwap, JoystickZeroUp, JoystickZeroDown, JoystickZeroLeft, JoystickZeroRight, JoystickZeroFire, JoystickZeroFire5, JoystickZeroFire9, diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 9f06445e4..0458750a8 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -40,6 +40,7 @@ #include "Settings.hxx" #include "Sound.hxx" #include "StateManager.hxx" +#include "Switches.hxx" #include "M6532.hxx" #include "MouseControl.hxx" #include "Version.hxx" @@ -960,25 +961,107 @@ void EventHandler::handleEvent(Event::Type event, int state) return; //////////////////////////////////////////////////////////////////////// - // Events which generate messages + //////////////////////////////////////////////////////////////////////// + // Events which relate to switches() case Event::ConsoleColor: - if(state) myOSystem.frameBuffer().showMessage("Color Mode"); + if(state) + { + myEvent.set(Event::ConsoleBlackWhite, 0); + myOSystem.frameBuffer().showMessage("Color Mode"); + } break; case Event::ConsoleBlackWhite: - if(state) myOSystem.frameBuffer().showMessage("BW Mode"); + if(state) + { + myEvent.set(Event::ConsoleColor, 0); + myOSystem.frameBuffer().showMessage("BW Mode"); + } break; + case Event::ConsoleColorSwap: + if(state) + { + if(myOSystem.console().switches().tvColor()) + { + myEvent.set(Event::ConsoleBlackWhite, 1); + myEvent.set(Event::ConsoleColor, 0); + myOSystem.frameBuffer().showMessage("BW Mode"); + } + else + { + myEvent.set(Event::ConsoleBlackWhite, 0); + myEvent.set(Event::ConsoleColor, 1); + myOSystem.frameBuffer().showMessage("Color Mode"); + } + myOSystem.console().switches().update(); + } + return; + case Event::ConsoleLeftDiffA: - if(state) myOSystem.frameBuffer().showMessage("Left Difficulty A"); + if(state) + { + myEvent.set(Event::ConsoleLeftDiffB, 0); + myOSystem.frameBuffer().showMessage("Left Difficulty A"); + } break; case Event::ConsoleLeftDiffB: - if(state) myOSystem.frameBuffer().showMessage("Left Difficulty B"); + if(state) + { + myEvent.set(Event::ConsoleLeftDiffA, 0); + myOSystem.frameBuffer().showMessage("Left Difficulty B"); + } break; + case Event::ConsoleLeftDiffSwap: + if(state) + { + if(myOSystem.console().switches().leftDifficultyA()) + { + myEvent.set(Event::ConsoleLeftDiffA, 0); + myEvent.set(Event::ConsoleLeftDiffB, 1); + myOSystem.frameBuffer().showMessage("Left Difficulty B"); + } + else + { + myEvent.set(Event::ConsoleLeftDiffA, 1); + myEvent.set(Event::ConsoleLeftDiffB, 0); + myOSystem.frameBuffer().showMessage("Left Difficulty A"); + } + myOSystem.console().switches().update(); + } + return; + case Event::ConsoleRightDiffA: - if(state) myOSystem.frameBuffer().showMessage("Right Difficulty A"); + if(state) + { + myEvent.set(Event::ConsoleRightDiffB, 0); + myOSystem.frameBuffer().showMessage("Right Difficulty A"); + } break; case Event::ConsoleRightDiffB: - if(state) myOSystem.frameBuffer().showMessage("Right Difficulty B"); + if(state) + { + myEvent.set(Event::ConsoleRightDiffA, 0); + myOSystem.frameBuffer().showMessage("Right Difficulty B"); + } break; + case Event::ConsoleRightDiffSwap: + if(state) + { + if(myOSystem.console().switches().rightDifficultyA()) + { + myEvent.set(Event::ConsoleRightDiffA, 0); + myEvent.set(Event::ConsoleRightDiffB, 1); + myOSystem.frameBuffer().showMessage("Right Difficulty B"); + } + else + { + myEvent.set(Event::ConsoleRightDiffA, 1); + myEvent.set(Event::ConsoleRightDiffB, 0); + myOSystem.frameBuffer().showMessage("Right Difficulty A"); + } + myOSystem.console().switches().update(); + } + return; + //////////////////////////////////////////////////////////////////////// case Event::NoType: // Ignore unmapped events return; @@ -2013,10 +2096,13 @@ EventHandler::ActionList EventHandler::ourEmulActionList[kEmulActionListSize] = { Event::ConsoleReset, "Reset", 0, true }, { Event::ConsoleColor, "Color TV", 0, true }, { Event::ConsoleBlackWhite, "Black & White TV", 0, true }, + { Event::ConsoleColorSwap, "Swap Color / B&W TV", 0, true }, { Event::ConsoleLeftDiffA, "P0 Difficulty A", 0, true }, { Event::ConsoleLeftDiffB, "P0 Difficulty B", 0, true }, + { Event::ConsoleLeftDiffSwap, "P0 Swap Difficulty", 0, true }, { Event::ConsoleRightDiffA, "P1 Difficulty A", 0, true }, { Event::ConsoleRightDiffB, "P1 Difficulty B", 0, true }, + { Event::ConsoleRightDiffSwap,"P1 Swap Difficulty", 0, true }, { Event::SaveState, "Save State", 0, false }, { Event::ChangeState, "Change State", 0, false }, { Event::LoadState, "Load State", 0, false }, diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 98a759078..ddd600d6c 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -500,7 +500,7 @@ class EventHandler enum { kComboSize = 16, kEventsPerCombo = 8, - kEmulActionListSize = 75 + kComboSize, + kEmulActionListSize = 78 + kComboSize, kMenuActionListSize = 14 }; diff --git a/src/emucore/Switches.hxx b/src/emucore/Switches.hxx index ffb114ea4..8c8b14df7 100644 --- a/src/emucore/Switches.hxx +++ b/src/emucore/Switches.hxx @@ -89,6 +89,27 @@ class Switches : public Serializable */ string name() const { return "Switches"; } + /** + Query the 'Console_TelevisionType' switches bit. + + @return True if 'Color', false if 'BlackWhite' + */ + bool tvColor() const { return mySwitches & 0x08; } + + /** + Query the 'Console_LeftDifficulty' switches bit. + + @return True if 'A', false if 'B' + */ + bool leftDifficultyA() const { return mySwitches & 0x40; } + + /** + Query the 'Console_RightDifficulty' switches bit. + + @return True if 'A', false if 'B' + */ + bool rightDifficultyA() const { return mySwitches & 0x80; } + private: // Reference to the event object to use const Event& myEvent;