From 408e42e3289f22e98abdc6d32a17499e4c7bf7d0 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 19 Oct 2024 10:01:16 +0200 Subject: [PATCH] added PlusROM support developer option (fixes #1019) --- Changes.txt | 4 ++++ src/common/DevSettingsHandler.cxx | 3 +++ src/common/DevSettingsHandler.hxx | 1 + src/emucore/Cart.hxx | 7 +++++++ src/emucore/CartCDF.hxx | 8 ++++++++ src/emucore/CartDPCPlus.hxx | 7 +++++++ src/emucore/CartE7.hxx | 7 +++++++ src/emucore/CartEnhanced.hxx | 9 ++++++++- src/emucore/PlusROM.cxx | 1 - src/emucore/PlusROM.hxx | 17 ++++++++++++++--- src/emucore/Settings.cxx | 2 ++ src/gui/DeveloperDialog.cxx | 13 ++++++++++++- src/gui/DeveloperDialog.hxx | 1 + 13 files changed, 74 insertions(+), 6 deletions(-) diff --git a/Changes.txt b/Changes.txt index 9679c94ea..eaeba68fa 100644 --- a/Changes.txt +++ b/Changes.txt @@ -12,6 +12,10 @@ Release History =========================================================================== +7.0 to 7.1 (xxx x, 202x) + + * Added developer option for disabling PlusROM support (TODO: Doc) + 6.7.1 to 7.0 (October 5, 2024) * Enhanced ROM launcher to allow multiple images per ROM. diff --git a/src/common/DevSettingsHandler.cxx b/src/common/DevSettingsHandler.cxx index 4b569385e..0df1038de 100644 --- a/src/common/DevSettingsHandler.cxx +++ b/src/common/DevSettingsHandler.cxx @@ -46,6 +46,7 @@ void DevSettingsHandler::loadSettings(SettingsSet set) // AtariVox/SaveKey/PlusROM access myExternAccess[set] = settings.getBool(prefix + "extaccess"); myConsole[set] = settings.getString(prefix + "console") == "7800" ? 1 : 0; + myPlusROM[set] = devSettings ? settings.getBool("dev.plusroms.on") : true; // Randomization myRandomBank[set] = settings.getBool(prefix + "bankrandom"); myRandomizeTIA[set] = settings.getBool(prefix + "tiarandom"); @@ -118,6 +119,7 @@ void DevSettingsHandler::saveSettings(SettingsSet set) if(devSettings) { + settings.setValue("dev.plusroms.on", myPlusROM[set]); settings.setValue("dev.hsrandom", myRandomHotspots[set]); // Undriven TIA pins settings.setValue("dev.tiadriven", myUndrivenPins[set]); @@ -183,6 +185,7 @@ void DevSettingsHandler::applySettings(SettingsSet set) { myOSystem.console().cartridge().enableRandomHotspots(myRandomHotspots[set]); myOSystem.console().tia().driveUnusedPinsRandom(myUndrivenPins[set]); + myOSystem.console().cartridge().enablePlusROM(myPlusROM[set]); // Notes: // - thumb exceptions not updated, because set in cart constructor // - other missing settings are used on-the-fly diff --git a/src/common/DevSettingsHandler.hxx b/src/common/DevSettingsHandler.hxx index 16091f225..d13550f3f 100644 --- a/src/common/DevSettingsHandler.hxx +++ b/src/common/DevSettingsHandler.hxx @@ -51,6 +51,7 @@ class DevSettingsHandler std::array myDetectedInfo{}; std::array myExternAccess{}; std::array myConsole{}; + std::array myPlusROM{}; std::array myRandomBank{}; std::array myRandomizeTIA{}; std::array myRandomizeRAM{}; diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 4ef7ca8d3..b9326415c 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -149,6 +149,13 @@ class Cartridge : public Device */ virtual bool isPlusROM() const { return false; } + /** + Enable or disable PlusROM support. + + @param enabled Whether to enable the PlusROM support + */ + virtual void enablePlusROM(bool enable) { }; + /** Set the callback for displaying messages */ diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index 2bf13c9e2..ad6d1ccb1 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -272,6 +272,14 @@ class CartridgeCDF : public CartridgeARM */ bool isPlusROM() const override { return myPlusROM->isValid(); } + /** + Enable or disable PlusROM support. + + @param enabled Whether to enable the PlusROM support + */ + void enablePlusROM(bool enable) override { myPlusROM->enable(enable); } + + private: static constexpr uInt8 COMMSTREAM = 0x20, JUMPSTREAM_BASE = 0x21; static constexpr uInt16 LDAXY_OVERRIDE_INACTIVE = 0xFFFF; diff --git a/src/emucore/CartDPCPlus.hxx b/src/emucore/CartDPCPlus.hxx index 6c68d6ac4..17edad78c 100644 --- a/src/emucore/CartDPCPlus.hxx +++ b/src/emucore/CartDPCPlus.hxx @@ -157,6 +157,13 @@ class CartridgeDPCPlus : public CartridgeARM */ bool isPlusROM() const override { return myPlusROM->isValid(); } + /** + Enable or disable PlusROM support. + + @param enabled Whether to enable the PlusROM support + */ + void enablePlusROM(bool enable) override { myPlusROM->enable(enable); } + #ifdef DEBUGGER_SUPPORT /** Get debugger widget responsible for accessing the inner workings diff --git a/src/emucore/CartE7.hxx b/src/emucore/CartE7.hxx index ba380c8cd..4729adab8 100644 --- a/src/emucore/CartE7.hxx +++ b/src/emucore/CartE7.hxx @@ -193,6 +193,13 @@ class CartridgeE7 : public Cartridge */ bool isPlusROM() const override { return myPlusROM->isValid(); } + /** + Enable or disable PlusROM support. + + @param enabled Whether to enable the PlusROM support + */ + void enablePlusROM(bool enable) override { myPlusROM->enable(enable); } + /** Set the callback for displaying messages */ diff --git a/src/emucore/CartEnhanced.hxx b/src/emucore/CartEnhanced.hxx index 7a67e5023..f8167cb4b 100644 --- a/src/emucore/CartEnhanced.hxx +++ b/src/emucore/CartEnhanced.hxx @@ -194,6 +194,13 @@ class CartridgeEnhanced : public Cartridge */ bool isPlusROM() const override { return myPlusROM->isValid(); } + /** + Enable or disable PlusROM support. + + @param enabled Whether to enable the PlusROM support + */ + void enablePlusROM(bool enable) override { myPlusROM->enable(enable); } + /** Set the callback for displaying messages */ @@ -339,7 +346,7 @@ class CartridgeEnhanced : public Cartridge */ uInt16 ramAddressSegmentOffset(uInt16 address) const { return static_cast( - (myCurrentSegOffset[((address & ROM_MASK) >> myBankShift) % myBankSegs] - mySize) + (myCurrentSegOffset[((address & ROM_MASK) >> myBankShift) % myBankSegs] - mySize) >> (myBankShift - myRamBankShift)); } diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index 8810bb6dc..84b584d97 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -23,7 +23,6 @@ #include "PlusROM.hxx" #include "Logger.hxx" #include "Version.hxx" -#include "Settings.hxx" #include "CartDetector.hxx" #if defined(HTTP_LIB_SUPPORT) diff --git a/src/emucore/PlusROM.hxx b/src/emucore/PlusROM.hxx index 42277cc76..2d574cfac 100644 --- a/src/emucore/PlusROM.hxx +++ b/src/emucore/PlusROM.hxx @@ -18,13 +18,12 @@ #ifndef PLUSROM_HXX #define PLUSROM_HXX -class Settings; - #include #include "bspf.hxx" #include "Serializable.hxx" #include "Cart.hxx" +#include "Settings.hxx" /** Class used to emulate the 'PlusROM' meta-scheme, documented at @@ -75,7 +74,18 @@ class PlusROM : public Serializable @return Whether this is actually a PlusROM cart */ - bool isValid() const { return myIsPlusROM; } + bool isValid() const { + return myIsPlusROM && myIsEnabled; + } + + /** + Enable or disable PlusROM support. + + @param enabled Whether to enable the PlusROM support + */ + void enable(bool enabled) { + myIsEnabled = enabled; + } /** Read from hotspot addresses ($1FF2 and $1FF3). @@ -175,6 +185,7 @@ class PlusROM : public Serializable const Cartridge& myCart; bool myIsPlusROM{false}; + bool myIsEnabled{true}; string myHost; string myPath; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index f0a61eb8c..a84438858 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -313,6 +313,7 @@ Settings::Settings() setPermanent("dev.tm.horizon", "30s"); // = ~30 seconds setPermanent("dev.detectedinfo", "true"); setPermanent("dev.extaccess", "true"); + setPermanent("dev.plusroms.on", "true"); // Thumb ARM emulation options setPermanent("dev.thumb.trapfatal", "true"); setPermanent("dev.arm.mips", CartridgeELF::MIPS_DEF); @@ -810,6 +811,7 @@ void Settings::usage() << " -dev.thumb.mammode <0-3> Selects the LPC's MAM mode\n" #endif << " -dev.extaccess <1|0> Enable messages for external access\n" + << " -dev.plusroms.on <1|0> Enable PlusROM support\n" << " -dev.tia.type setToolTip("Display a message for any external access\n" "AtariVox/SaveKey EEPROM, PlusROM, Supercharger...)."); wid.push_back(myExternAccessWidget); @@ -147,6 +147,13 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) myConsoleWidget->setToolTip("Emulate Color/B&W/Pause key and zero\n" "page RAM initialization differently."); wid.push_back(myConsoleWidget); + + // PlusROM functionality + myPlusRomWidget = new CheckboxWidget(myTab, font, + myDetectedInfoWidget->getLeft(), ypos + 1, + "PlusROM support"); + myPlusRomWidget->setToolTip("Enable PlusROM support"); + wid.push_back(myPlusRomWidget); ypos += lineHeight + VGAP; // Randomize items @@ -748,6 +755,7 @@ void DeveloperDialog::getWidgetStates(SettingsSet set) // AtariVox/SaveKey/PlusROM access myExternAccess[set] = myExternAccessWidget->getState(); myConsole[set] = myConsoleWidget->getSelected() == 1; + myPlusROM[set] = myPlusRomWidget->getState() == 1; // Randomization myRandomBank[set] = myRandomBankWidget->getState(); myRandomizeTIA[set] = myRandomizeTIAWidget->getState(); @@ -812,6 +820,7 @@ void DeveloperDialog::setWidgetStates(SettingsSet set) // AtariVox/SaveKey/PlusROM access myExternAccessWidget->setState(myExternAccess[set]); myConsoleWidget->setSelectedIndex(myConsole[set]); + myPlusRomWidget->setState(myPlusROM[set]); // Randomization myRandomBankWidget->setState(myRandomBank[set]); myRandomizeTIAWidget->setState(myRandomizeTIA[set]); @@ -965,6 +974,7 @@ void DeveloperDialog::setDefaults() // AtariVox/SaveKey/PlusROM access myExternAccess[set] = devSettings; myConsole[set] = 0; + myPlusROM[set] = true; // Randomization myRandomBank[set] = devSettings; myRandomizeTIA[set] = devSettings; @@ -1149,6 +1159,7 @@ void DeveloperDialog::handleCommand(CommandSender* sender, int cmd, int data, in // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::handleSettings(bool devSettings) { + myPlusRomWidget->setEnabled(devSettings); myRandomHotspotsWidget->setEnabled(devSettings); myUndrivenPinsWidget->setEnabled(devSettings); #ifdef DEBUGGER_SUPPORT diff --git a/src/gui/DeveloperDialog.hxx b/src/gui/DeveloperDialog.hxx index 41418e901..55772e621 100644 --- a/src/gui/DeveloperDialog.hxx +++ b/src/gui/DeveloperDialog.hxx @@ -88,6 +88,7 @@ class DeveloperDialog : public Dialog, DevSettingsHandler CheckboxWidget* myFrameStatsWidget{nullptr}; CheckboxWidget* myDetectedInfoWidget{nullptr}; CheckboxWidget* myExternAccessWidget{nullptr}; + CheckboxWidget* myPlusRomWidget{nullptr}; PopUpWidget* myConsoleWidget{nullptr}; StaticTextWidget* myLoadingROMLabel{nullptr}; CheckboxWidget* myRandomBankWidget{nullptr};