From ece9d507d52129cde31cafb0011641c366939d6a Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 4 Nov 2023 17:37:29 +0100 Subject: [PATCH] enhanced color switches enhanced Stella version information --- src/emucore/EventHandler.cxx | 30 +++++++++++++++++++++++++++--- src/emucore/EventHandler.hxx | 7 +++++++ src/emucore/OSystem.cxx | 35 +++++++++++++++++++++-------------- 3 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 1ab4ca0e5..39417ab7a 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -1654,7 +1654,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) //////////////////////////////////////////////////////////////////////// // Events which relate to switches() case Event::ConsoleColor: - if(pressed && !repeated) + if(pressed && !repeated && !checkUI()) { myEvent.set(Event::ConsoleBlackWhite, 0); myEvent.set(Event::ConsoleColor, 1); @@ -1663,7 +1663,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) } return; case Event::ConsoleBlackWhite: - if(pressed && !repeated) + if(pressed && !repeated && !checkUI()) { myEvent.set(Event::ConsoleBlackWhite, 1); myEvent.set(Event::ConsoleColor, 0); @@ -1672,7 +1672,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) } return; case Event::ConsoleColorToggle: - if(pressed && !repeated) + if(pressed && !repeated && !checkUI()) { if(myOSystem.console().switches().tvColor()) { @@ -2822,6 +2822,30 @@ void EventHandler::exitEmulation(bool checkLauncher) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool EventHandler::checkUI() +{ + // Special entries to the UI + if(myEvent.get(Event::LeftJoystickFire) || myEvent.get(Event::RightJoystickFire)) + { + if(myEvent.get(Event::LeftJoystickRight) || myEvent.get(Event::RightJoystickRight)) + changeStateByEvent(Event::OptionsMenuMode); + else if(myEvent.get(Event::LeftJoystickLeft) || myEvent.get(Event::RightJoystickLeft)) + changeStateByEvent(Event::TogglePauseMode); + else if(myEvent.get(Event::LeftJoystickUp) || myEvent.get(Event::RightJoystickUp)) + { + myOSystem.createLauncher(); + setState(EventHandlerState::LAUNCHER); + } + else if(myEvent.get(Event::LeftJoystickDown) || myEvent.get(Event::RightJoystickDown)) + changeStateByEvent(Event::DebuggerMode); + else + changeStateByEvent(Event::CmdMenuMode); + return true; + } + return false; +} + #if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-field-initializers" #elif defined(__GNUC__) || defined(__GNUG__) diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index c6b4a3c2b..0bef9b6f0 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -481,6 +481,13 @@ class EventHandler static int getEmulActionListIndex(int idx, const Event::EventSet& events); static int getActionListIndex(int idx, Event::Group group); + /** + Check if UI shall be entered. + + @return Whether the UI is entered or not + */ + bool checkUI(); + private: // Structure used for action menu items struct ActionList { diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 8e7886d3a..eb2ec84a4 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -530,22 +530,29 @@ string OSystem::createConsole(const FSNode& rom, string_view md5sum, bool newrom myEventHandler->handleConsoleStartupEvents(); myConsole->riot().update(); - #ifdef DEBUGGER_SUPPORT - if(mySettings->getBool("debug")) - myEventHandler->enterDebugMode(); - #endif + #ifdef DEBUGGER_SUPPORT + if(mySettings->getBool("debug")) + myEventHandler->enterDebugMode(); + #endif - if(!showmessage && - settings().getBool(devSettings ? "dev.detectedinfo" : "plr.detectedinfo")) - { - ostringstream msg; + if(!showmessage) + if(settings().getBool(devSettings ? "dev.detectedinfo" : "plr.detectedinfo")) + { + ostringstream msg; - msg << myConsole->leftController().name() << "/" << myConsole->rightController().name() - << " - " << myConsole->cartridge().detectedType() - << (myConsole->cartridge().isPlusROM() ? " PlusROM " : "") - << " - " << myConsole->getFormatString(); - myFrameBuffer->showTextMessage(msg.str()); - } + msg << myConsole->leftController().name() << "/" << myConsole->rightController().name() + << " - " << myConsole->cartridge().detectedType() + << (myConsole->cartridge().isPlusROM() ? " PlusROM " : "") + << " - " << myConsole->getFormatString(); + myFrameBuffer->showTextMessage(msg.str()); + } + else if(!myLauncherUsed) + { + ostringstream msg; + + msg << "Stella " << STELLA_VERSION; + myFrameBuffer->showTextMessage(msg.str()); + } // Check for first PlusROM start if(myConsole->cartridge().isPlusROM()) {