diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index c4195fec5..e84f4b93a 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -321,7 +321,7 @@ void RiotWidget::loadConfig() myP1Diff->setSelectedIndex(riot.diffP1()); bool devSettings = instance().settings().getBool("dev.settings"); - myConsole->setText(devSettings && instance().settings().getString("dev.console") == "7800" ? "Atari 7800" : "Atari 2600"); + myConsole->setText(instance().settings().getString(devSettings ? "dev.console" : "plr.console") == "7800" ? "Atari 7800" : "Atari 2600"); myConsole->setEditable(false, true); myTVType->setSelectedIndex(riot.tvType()); @@ -470,7 +470,7 @@ void RiotWidget::handleConsole() { RiotDebug& riot = instance().debugger().riotDebug(); bool devSettings = instance().settings().getBool("dev.settings"); - bool is7800 = devSettings && instance().settings().getString("dev.console") == "7800"; + bool is7800 = instance().settings().getString(devSettings ? "dev.console" : "plr.console") == "7800"; myTVType->setEnabled(!is7800); myPause->setEnabled(is7800); diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index aa0f23bdd..6b5586a9a 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -91,7 +91,7 @@ void Cartridge::createCodeAccessBase(uInt32 size) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge::initializeRAM(uInt8* arr, uInt32 size, uInt8 val) const { - if(mySettings.getBool("dev.settings") && mySettings.getBool("dev.ramrandom")) + if(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.ramrandom" : "plr.ramrandom")) for(uInt32 i = 0; i < size; ++i) arr[i] = mySystem->randGenerator().next(); else @@ -101,7 +101,7 @@ void Cartridge::initializeRAM(uInt8* arr, uInt32 size, uInt8 val) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge::randomizeStartBank() { - if(mySettings.getBool("dev.settings") && mySettings.getBool("dev.bankrandom")) + if(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.bankrandom" : "plr.bankrandom")) myStartBank = mySystem->randGenerator().next() % bankCount(); } diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 664121f93..aae053122 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -363,6 +363,9 @@ void Console::toggleColorLoss() bool colorloss = !myTIA->colorLossEnabled(); if(myTIA->enableColorLoss(colorloss)) { + myOSystem.settings().setValue( + myOSystem.settings().getBool("dev.settings") ? "dev.colorloss" : "plr.colorloss", colorloss); + string message = string("PAL color-loss ") + (colorloss ? "enabled" : "disabled"); myOSystem.frameBuffer().showMessage(message); @@ -527,8 +530,8 @@ FBInitStatus Console::initializeVideo(bool full) if(fbstatus != kSuccess) return fbstatus; - myOSystem.frameBuffer().showFrameStats(myOSystem.settings().getBool("dev.settings") && - myOSystem.settings().getBool("dev.stats")); + myOSystem.frameBuffer().showFrameStats( + myOSystem.settings().getBool(myOSystem.settings().getBool("dev.settings") ? "dev.stats" : "plr.stats")); generateColorLossPalette(); } setPalette(myOSystem.settings().getString("palette")); diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index a9f452377..f505096b7 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -901,7 +901,7 @@ void EventHandler::handleEvent(Event::Type event, int state) // Take care of special events that aren't part of the emulation core // or need to be preprocessed before passing them on bool devSettings = myOSystem.settings().getBool("dev.settings"); - bool is7800 = devSettings && (myOSystem.settings().getString("dev.console") == "7800"); + bool is7800 = (myOSystem.settings().getString(devSettings ? "dev.console" : "plr.console") == "7800"); switch(event) { diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index e74496356..5b635c52a 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -372,6 +372,8 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position, void FrameBuffer::toggleFrameStats() { showFrameStats(!myStatsEnabled); + myOSystem.settings().setValue( + myOSystem.settings().getBool("dev.settings") ? "dev.stats" : "plr.stats", myStatsEnabled); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -619,6 +621,7 @@ void FrameBuffer::toggleGrabMouse() { myGrabMouse = !myGrabMouse; setCursorState(); + myOSystem.settings().setValue("grabmouse", myGrabMouse); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index f53d86d25..2df1db8eb 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -87,7 +87,7 @@ void M6502::reset() // Set registers to random or default values bool devSettings = mySettings.getBool("dev.settings"); - const string& cpurandom = devSettings ? mySettings.getString("dev.cpurandom") : ""; + const string& cpurandom = mySettings.getString(devSettings ? "dev.cpurandom" : "plr.cpurandom"); SP = BSPF::containsIgnoreCase(cpurandom, "S") ? mySystem->randGenerator().next() : 0xfd; A = BSPF::containsIgnoreCase(cpurandom, "A") ? diff --git a/src/emucore/M6532.cxx b/src/emucore/M6532.cxx index c2d903e95..a0d966c4d 100644 --- a/src/emucore/M6532.cxx +++ b/src/emucore/M6532.cxx @@ -56,10 +56,10 @@ void M6532::reset() // Initialize the 128 bytes of memory bool devSettings = mySettings.getBool("dev.settings"); - if(devSettings && mySettings.getString("dev.console") == "7800") + if(mySettings.getString(devSettings ? "dev.console" : "plr.console") == "7800") for(uInt32 t = 0; t < 128; ++t) myRAM[t] = RAM_7800[t]; - else if(devSettings && mySettings.getBool("dev.ramrandom")) + else if(mySettings.getBool(devSettings ? "dev.ramrandom" : "plr.ramrandom")) for(uInt32 t = 0; t < 128; ++t) myRAM[t] = mySystem->randGenerator().next(); else diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 551ca1dbe..38be6010b 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -145,25 +145,24 @@ Settings::Settings(OSystem& osystem) #endif // player settings - setInternal("plr.settings", "false"); setInternal("plr.stats", "false"); - setInternal("plr.bankrandom", "true"); - setInternal("plr.ramrandom", "true"); - setInternal("plr.cpurandom", "SAXYP"); - setInternal("plr.colorloss", "true"); + setInternal("plr.bankrandom", "false"); + setInternal("plr.ramrandom", "false"); + setInternal("plr.cpurandom", ""); + setInternal("plr.colorloss", "false"); setInternal("plr.tv.jitter", "true"); - setInternal("plr.tv.jitter_recovery", "2"); + setInternal("plr.tv.jitter_recovery", "10"); setInternal("plr.debugcolors", "false"); - setInternal("plr.tiadriven", "true"); + setInternal("plr.tiadriven", "false"); setInternal("plr.console", "2600"); // 7800 setInternal("plr.rewind", false); setInternal("plr.rewind.size", 100); - setInternal("plr.rewind.interval", 2); // = 1 frame - setInternal("plr.rewind.horizon", 3); // = ~10 seconds + setInternal("plr.rewind.interval", 4); // = 1 frame + setInternal("plr.rewind.horizon", 5); // = ~10 minutes // developer settings setInternal("dev.settings", "false"); - setInternal("dev.stats", "false"); + setInternal("dev.stats", "true"); setInternal("dev.bankrandom", "true"); setInternal("dev.ramrandom", "true"); setInternal("dev.cpurandom", "SAXYP"); @@ -554,6 +553,7 @@ void Settings::usage() const << " -plr.debugcolors <1|0> Enable debug colors\n" << endl << " The same parameters but for developer settings mode\n" + << " -dev.settings <1|0> Select developer settings mode\n" << " -dev.console <2600|7800> Select console for B/W and Pause key handling\n" << " -dev.stats <1|0> Overlay console info during emulation\n" << " -dev.tiadriven <1|0> Drive unused TIA pins randomly on a read/peek\n" diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 8b3afa3d7..8deaf9c2f 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -80,7 +80,7 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings) myCollisionsEnabledBits(0xFF) { bool devSettings = mySettings.getBool("dev.settings"); - myTIAPinsDriven = devSettings && mySettings.getBool("dev.tiadriven"); + myTIAPinsDriven = mySettings.getBool(devSettings ? "dev.tiadriven" : "plr.tiadriven"); myBackground.setTIA(this); myPlayfield.setTIA(this); @@ -90,8 +90,8 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings) myMissile1.setTIA(this); myBall.setTIA(this); - myEnableJitter = devSettings ? mySettings.getBool("dev.tv.jitter") : false; - myJitterFactor = devSettings ? mySettings.getInt("dev.tv.jitter_recovery") : 10; + myEnableJitter = mySettings.getBool(devSettings ? "dev.tv.jitter" : "plr.tv.jitter"); + myJitterFactor = mySettings.getInt(devSettings ? "dev.tv.jitter_recovery" : "plr.tv.jitter_recovery"); reset(); } @@ -173,7 +173,7 @@ void TIA::reset() frameReset(); // Recalculate the size of the display // Must be done last, after all other items have reset - enableFixedColors(mySettings.getBool("dev.settings") && mySettings.getBool("dev.debugcolors")); + enableFixedColors(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.debugcolors" : "plr.debugcolors")); setFixedColorPalette(mySettings.getString("tia.dbgcolors")); #ifdef DEBUGGER_SUPPORT @@ -186,7 +186,7 @@ void TIA::frameReset() { memset(myFramebuffer, 0, 160 * TIAConstants::frameBufferHeight); myAutoFrameEnabled = mySettings.getInt("framerate") <= 0; - enableColorLoss(mySettings.getBool("dev.settings") && mySettings.getBool("dev.colorloss")); + enableColorLoss(mySettings.getBool("dev.settings") ? "dev.colorloss" : "plr.colorloss"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1007,7 +1007,7 @@ bool TIA::driveUnusedPinsRandom(uInt8 mode) if (mode == 0 || mode == 1) { myTIAPinsDriven = bool(mode); - //mySettings.setValue("dev.tiadriven", myTIAPinsDriven); + mySettings.setValue(mySettings.getBool("dev.settings") ? "dev.tiadriven" : "plr.tiadriven", myTIAPinsDriven); } return myTIAPinsDriven; } diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 984f2dd5c..05996bfd7 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -26,6 +26,7 @@ #include "EventMappingWidget.hxx" #include "EditTextWidget.hxx" #include "PopUpWidget.hxx" +#include "RadioButtonWidget.hxx" #include "TabWidget.hxx" #include "Widget.hxx" #include "Font.hxx" @@ -81,12 +82,18 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) VariantList items; int tabID = myTab->addTab(" Emulation "); - myDevSettings = new CheckboxWidget(myTab, font, HBORDER, ypos, "Enable developer settings", kDevSettings); - wid.push_back(myDevSettings); + mySettingsGroup = new RadioButtonGroup(); + + myPlayerSettingsWidget = new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, "Player settings", mySettingsGroup, kPlrSettings); + wid.push_back(myPlayerSettingsWidget); ypos += lineHeight + VGAP; - myFrameStats = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos, "Show frame statistics"); - wid.push_back(myFrameStats); + myDevSettingsWidget = new RadioButtonWidget(myTab, font, HBORDER, ypos, "Developer settings", mySettingsGroup, kDevSettings); + wid.push_back(myDevSettingsWidget); + ypos += lineHeight + VGAP; + + myFrameStatsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos, "Show frame statistics"); + wid.push_back(myFrameStatsWidget); ypos += lineHeight + VGAP; // 2600/7800 mode @@ -96,8 +103,8 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) int lwidth = font.getStringWidth("Console "); int pwidth = font.getStringWidth("Atari 2600"); - myConsole = new PopUpWidget(myTab, font, HBORDER + INDENT * 1, ypos, pwidth, lineHeight, items, "Console ", lwidth, kConsole); - wid.push_back(myConsole); + myConsoleWidget = new PopUpWidget(myTab, font, HBORDER + INDENT * 1, ypos, pwidth, lineHeight, items, "Console ", lwidth, kConsole); + wid.push_back(myConsoleWidget); ypos += lineHeight + VGAP; // Randomize items @@ -105,14 +112,14 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) wid.push_back(myLoadingROMLabel); ypos += lineHeight + VGAP; - myRandomBank = new CheckboxWidget(myTab, font, HBORDER + INDENT * 2, ypos + 1, "Random startup bank"); - wid.push_back(myRandomBank); + myRandomBankWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 2, ypos + 1, "Random startup bank"); + wid.push_back(myRandomBankWidget); ypos += lineHeight + VGAP; // Randomize RAM - myRandomizeRAM = new CheckboxWidget(myTab, font, HBORDER + INDENT * 2, ypos + 1, + myRandomizeRAMWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 2, ypos + 1, "Randomize zero-page and extended RAM", kRandRAMID); - wid.push_back(myRandomizeRAM); + wid.push_back(myRandomizeRAMWidget); ypos += lineHeight + VGAP; // Randomize CPU @@ -124,43 +131,43 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) const char* const cpuregs[] = { "SP", "A", "X", "Y", "PS" }; for(int i = 0; i < 5; ++i) { - myRandomizeCPU[i] = new CheckboxWidget(myTab, font, xpos, ypos + 2, + myRandomizeCPUWidget[i] = new CheckboxWidget(myTab, font, xpos, ypos + 2, cpuregs[i], kRandCPUID); - wid.push_back(myRandomizeCPU[i]); + wid.push_back(myRandomizeCPUWidget[i]); xpos += CheckboxWidget::boxSize() + font.getStringWidth("XX") + 20; } ypos += lineHeight + VGAP; // debug colors - myDebugColors = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos + 1, "Debug colors"); - wid.push_back(myDebugColors); + myDebugColorsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos + 1, "Debug colors"); + wid.push_back(myDebugColorsWidget); ypos += lineHeight + VGAP; - myColorLoss = new CheckboxWidget(myTab, font, HBORDER + INDENT*1, ypos + 1, "PAL color-loss"); - wid.push_back(myColorLoss); + myColorLossWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT*1, ypos + 1, "PAL color-loss"); + wid.push_back(myColorLossWidget); ypos += lineHeight + VGAP; // TV jitter effect - myTVJitter = new CheckboxWidget(myTab, font, HBORDER + INDENT*1, ypos + 1, "Jitter/Roll effect", kTVJitter); - wid.push_back(myTVJitter); - myTVJitterRec = new SliderWidget(myTab, font, - myTVJitter->getRight()+ 16, ypos - 1, + myTVJitterWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT*1, ypos + 1, "Jitter/Roll effect", kTVJitter); + wid.push_back(myTVJitterWidget); + myTVJitterRecWidget = new SliderWidget(myTab, font, + myTVJitterWidget->getRight()+ 16, ypos - 1, 8 * fontWidth, lineHeight, "recovery ", font.getStringWidth("recovery "), kTVJitterChanged); - myTVJitterRec->setMinValue(1); myTVJitterRec->setMaxValue(20); - wid.push_back(myTVJitterRec); + myTVJitterRecWidget->setMinValue(1); myTVJitterRecWidget->setMaxValue(20); + wid.push_back(myTVJitterRecWidget); - myTVJitterRecLabel = new StaticTextWidget(myTab, font, - myTVJitterRec->getRight() + 4, myTVJitterRec->getTop(), + myTVJitterRecLabelWidget = new StaticTextWidget(myTab, font, + myTVJitterRecWidget->getRight() + 4, myTVJitterRecWidget->getTop(), 5 * fontWidth, fontHeight, "", kTextAlignLeft); - myTVJitterRecLabel->setFlags(WIDGET_CLEARBG); - wid.push_back(myTVJitterRecLabel); + myTVJitterRecLabelWidget->setFlags(WIDGET_CLEARBG); + wid.push_back(myTVJitterRecLabelWidget); ypos += lineHeight + VGAP; // How to handle undriven TIA pins - myUndrivenPins = new CheckboxWidget(myTab, font, HBORDER + INDENT*1, ypos + 1, + myUndrivenPinsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT*1, ypos + 1, "Drive unused TIA pins randomly on a read/peek"); - wid.push_back(myUndrivenPins); + wid.push_back(myUndrivenPinsWidget); // Add items for tab 0 addToFocusList(wid, myTab, tabID); @@ -339,36 +346,119 @@ void DeveloperDialog::addDefaultOKCancelButtons(const GUI::Font& font) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DeveloperDialog::loadConfig() +void DeveloperDialog::copySettingsToSet(SettingsSet set) { - myDevSettings->setState(instance().settings().getBool("dev.settings")); + string prefix = set == SettingsSet::player ? "plr." : "dev."; - myFrameStats->setState(instance().settings().getBool("dev.stats")); - myConsole->setSelectedIndex(instance().settings().getString("dev.console") == "7800" ? 1 : 0); - myRandomBank->setState(instance().settings().getBool("dev.bankrandom")); - myRandomizeRAM->setState(instance().settings().getBool("dev.ramrandom")); + myFrameStats[set] = instance().settings().getBool(prefix + "stats"); + myConsole[set] = instance().settings().getString(prefix + "console") == "7800" ? 1 : 0; + // Randomization + myRandomBank[set] = instance().settings().getBool(prefix + "bankrandom"); + myRandomizeRAM[set] = instance().settings().getBool(prefix + "ramrandom"); + myRandomizeCPU[set] = instance().settings().getString(prefix + "cpurandom"); + // Debug colors + myDebugColors[set] = instance().settings().getBool(prefix + "debugcolors"); + // PAL color-loss effect + myColorLoss[set] = instance().settings().getBool(prefix + "colorloss"); + // Jitter + myTVJitter[set] = instance().settings().getBool(prefix + "tv.jitter"); + myTVJitterRec[set] = instance().settings().getInt(prefix + "tv.jitter_recovery"); + // Undriven TIA pins + myUndrivenPins[set] = instance().settings().getBool(prefix + "tiadriven"); +} - const string& cpurandom = instance().settings().getString("dev.cpurandom"); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeveloperDialog::copySetToSettings(SettingsSet set) +{ + string prefix = set == SettingsSet::player ? "plr." : "dev."; + + instance().settings().setValue(prefix + "stats", myFrameStats[set]); + instance().settings().setValue(prefix + "console", myConsole[set] == 1 ? "7800" : "2600"); + // Randomization + instance().settings().setValue(prefix + "bankrandom", myRandomBank[set]); + instance().settings().setValue(prefix + "ramrandom", myRandomizeRAM[set]); + instance().settings().setValue(prefix + "cpurandom", myRandomizeCPU[set]); + // Debug colors + instance().settings().setValue(prefix + "debugcolors", myDebugColors[set]); + // PAL color loss + instance().settings().setValue(prefix + "colorloss", myColorLoss[set]); + // Jitter + instance().settings().setValue(prefix + "tv.jitter", myTVJitter[set]); + instance().settings().setValue(prefix + "tv.jitter_recovery", myTVJitterRec[set]); + + instance().settings().setValue(prefix + "tiadriven", myUndrivenPins[set]); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeveloperDialog::copyStateToSet(SettingsSet set) +{ + myFrameStats[set] = myFrameStatsWidget->getState(); + myConsole[set] = myConsoleWidget->getSelected() == 1; + // Randomization + myRandomBank[set] = myRandomBankWidget->getState(); + myRandomizeRAM[set] = myRandomizeRAMWidget->getState(); + string cpurandom; const char* const cpuregs[] = { "S", "A", "X", "Y", "P" }; for(int i = 0; i < 5; ++i) - myRandomizeCPU[i]->setState(BSPF::containsIgnoreCase(cpurandom, cpuregs[i])); - + if(myRandomizeCPUWidget[i]->getState()) + cpurandom += cpuregs[i]; + myRandomizeCPU[set] = cpurandom; + // Debug colors + myDebugColors[set] = myDebugColorsWidget->getState(); // PAL color-loss effect - myColorLoss->setState(instance().settings().getBool("dev.colorloss")); - - myTVJitter->setState(instance().settings().getBool("dev.tv.jitter")); - myTVJitterRec->setValue(instance().settings().getInt("dev.tv.jitter_recovery")); - - myDebugColors->setState(instance().settings().getBool("dev.debugcolors")); + myColorLoss[set] = myColorLossWidget->getState(); + // Jitter + myTVJitter[set] = myTVJitterWidget->getState(); + myTVJitterRec[set] = myTVJitterRecWidget->getValue(); // Undriven TIA pins - myUndrivenPins->setState(instance().settings().getBool("dev.tiadriven")); + myUndrivenPins[set] = myUndrivenPinsWidget->getState(); +} - handleDeveloperOptions(); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeveloperDialog::copySetToState(SettingsSet set) +{ + myFrameStatsWidget->setState(myFrameStats[set]); + myConsoleWidget->setSelectedIndex(myConsole[set]); + // Randomization + myRandomBankWidget->setState(myRandomBank[set]); + myRandomizeRAMWidget->setState(myRandomizeRAM[set]); - myContinuousRewind->setState(instance().settings().getBool("dev.rewind")); - myStateSize->setValue(instance().settings().getInt("dev.rewind.size")); - myStateInterval->setValue(instance().settings().getInt("dev.rewind.interval")); - myStateHorizon->setValue(instance().settings().getInt("dev.rewind.horizon")); + const string& cpurandom = myRandomizeCPU[set]; + const char* const cpuregs[] = { "S", "A", "X", "Y", "P" }; + for(int i = 0; i < 5; ++i) + myRandomizeCPUWidget[i]->setState(BSPF::containsIgnoreCase(cpurandom, cpuregs[i])); + // Debug colors + myDebugColorsWidget->setState(myDebugColors[set]); + // PAL color-loss effect + myColorLossWidget->setState(myColorLoss[set]); + // Jitter + myTVJitterWidget->setState(myTVJitter[set]); + myTVJitterRecWidget->setValue(myTVJitterRec[set]); + // Undriven TIA pins + myUndrivenPinsWidget->setState(myUndrivenPins[set]); + + handleConsole(); + handleTVJitterChange(myTVJitterWidget->getState()); + handleDebugColors(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeveloperDialog::loadConfig() +{ + bool devSettings = instance().settings().getBool("dev.settings"); + myDevSettingsWidget->setState(devSettings); + myPlayerSettingsWidget->setState(!devSettings); + + // load both setting sets... + copySettingsToSet(SettingsSet::player); + copySettingsToSet(SettingsSet::developer); + // ...and select the current one + copySetToState(devSettings ? SettingsSet::developer : SettingsSet::player); + + myContinuousRewind->setState(instance().settings().getBool(devSettings ? "dev.rewind" : "plr.rewind")); + myStateSize->setValue(instance().settings().getInt(devSettings ? "dev.rewind.size": "plr.rewind.size")); + myStateInterval->setValue(instance().settings().getInt(devSettings ? "dev.rewind.interval" : "plr.rewind.interval")); + myStateHorizon->setValue(instance().settings().getInt(devSettings ? "dev.rewind.horizon" : "plr.rewind.horizon")); handleRewind(); handleSize(); @@ -405,55 +495,25 @@ void DeveloperDialog::loadConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::saveConfig() { - bool devSettings = myDevSettings->getState(); + bool devSettings = myDevSettingsWidget->getState(); + instance().settings().setValue("dev.settings", devSettings); + copyStateToSet(devSettings ? SettingsSet::developer : SettingsSet::player); + copySetToSettings(SettingsSet::player); + copySetToSettings(SettingsSet::developer); - instance().settings().setValue("dev.stats", myFrameStats->getState()); - instance().frameBuffer().showFrameStats(devSettings && myFrameStats->getState()); - - bool is7800 = myConsole->getSelected() == 1; - instance().settings().setValue("dev.console", is7800 ? "7800" : "2600"); - - instance().settings().setValue("dev.bankrandom", myRandomBank->getState()); - instance().settings().setValue("dev.ramrandom", myRandomizeRAM->getState()); - - string cpurandom; - const char* const cpuregs[] = { "S", "A", "X", "Y", "P" }; - for(int i = 0; i < 5; ++i) - if(myRandomizeCPU[i]->getState()) - cpurandom += cpuregs[i]; - instance().settings().setValue("dev.cpurandom", cpurandom); - + //activate the current ones + instance().frameBuffer().showFrameStats(myFrameStatsWidget->getState()); // jitter - instance().settings().setValue("dev.tv.jitter", myTVJitter->getState()); - instance().settings().setValue("dev.tv.jitter_recovery", myTVJitterRecLabel->getLabel()); if(instance().hasConsole()) { - if (devSettings) - { - instance().console().tia().toggleJitter(myTVJitter->getState() ? 1 : 0); - instance().console().tia().setJitterRecoveryFactor(myTVJitterRec->getValue()); - } - else - { - instance().console().tia().toggleJitter(0); - } + instance().console().tia().toggleJitter(myTVJitterWidget->getState() ? 1 : 0); + instance().console().tia().setJitterRecoveryFactor(myTVJitterRecWidget->getValue()); } - - instance().settings().setValue("dev.debugcolors", myDebugColors->getState()); handleDebugColors(); - // PAL color loss - instance().settings().setValue("dev.colorloss", myColorLoss->getState()); if(instance().hasConsole()) - { - if(devSettings) - instance().console().enableColorLoss(myColorLoss->getState()); - else - instance().console().enableColorLoss(false); - } - - instance().settings().setValue("dev.tiadriven", myUndrivenPins->getState()); + instance().console().enableColorLoss(myColorLossWidget->getState()); // Finally, issue a complete framebuffer re-initialization //instance().createFrameBuffer(); @@ -512,33 +572,33 @@ void DeveloperDialog::saveConfig() void DeveloperDialog::setDefaults() { - myDevSettings->setState(false); + bool devSettings = myDevSettingsWidget->getState(); switch(myTab->getActiveTab()) { case 0: - myFrameStats->setState(true); - myConsole->setSelectedIndex(0); - myRandomBank->setState(true); - myRandomizeRAM->setState(true); - for(int i = 0; i < 5; ++i) - myRandomizeCPU[i]->setState(true); + { + SettingsSet set = devSettings ? SettingsSet::developer : SettingsSet::player; + myFrameStats[set] = devSettings ? true : false; + myConsole[set] = 0; + // Randomization + myRandomBank[set] = devSettings ? true : false; + myRandomizeRAM[set] = devSettings ? true : false; + myRandomizeCPU[set] = devSettings ? "SAXYP" : ""; + // Debug colors + myDebugColors[set] = false; // PAL color-loss effect - myColorLoss->setState(true); - // jitter - myTVJitter->setState(true); - myTVJitterRec->setValue(2); - // debug colors - myDebugColors->setState(false); + myColorLoss[set] = devSettings ? true : false; + // Jitter + myTVJitter[set] = true; + myTVJitterRec[set] = devSettings ? 2 : 10; // Undriven TIA pins - myUndrivenPins->setState(true); + myUndrivenPins[set] = devSettings ? true : false; - handleDeveloperOptions(); - handleTVJitterChange(false); - handleDebugColors(); + copySetToState(set); break; - + } case 1: // States myContinuousRewind->setState(false); myStateSize->setValue(100); @@ -576,8 +636,12 @@ void DeveloperDialog::handleCommand(CommandSender* sender, int cmd, int data, in { switch(cmd) { + case kPlrSettings: + handleSettings(false); + break; + case kDevSettings: - handleDeveloperOptions(); + handleSettings(true); break; case kConsole: @@ -585,15 +649,15 @@ void DeveloperDialog::handleCommand(CommandSender* sender, int cmd, int data, in break; case kTVJitter: - handleTVJitterChange(myTVJitter->getState()); + handleTVJitterChange(myTVJitterWidget->getState()); break; case kTVJitterChanged: - myTVJitterRecLabel->setValue(myTVJitterRec->getValue()); + myTVJitterRecLabelWidget->setValue(myTVJitterRecWidget->getValue()); break; case kPPinCmd: - instance().console().tia().driveUnusedPinsRandom(myUndrivenPins->getState()); + instance().console().tia().driveUnusedPinsRandom(myUndrivenPinsWidget->getState()); break; case kRewind: @@ -646,43 +710,28 @@ void DeveloperDialog::handleCommand(CommandSender* sender, int cmd, int data, in } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DeveloperDialog::handleDeveloperOptions() +void DeveloperDialog::handleSettings(bool devSettings) { - bool enable = myDevSettings->getState(); + myDevSettingsWidget->setState(devSettings ); - myFrameStats->setEnabled(enable); - myConsole->setEnabled(enable); - // CPU - myLoadingROMLabel->setEnabled(enable); - myRandomBank->setEnabled(enable); - myRandomizeRAM->setEnabled(enable); - myRandomizeCPULabel->setEnabled(enable); - for(int i = 0; i < 5; ++i) - myRandomizeCPU[i]->setEnabled(enable); - handleConsole(); - - // TIA - myColorLoss->setEnabled(enable); - myTVJitter->setEnabled(enable); - handleTVJitterChange(enable && myTVJitter->getState()); - myDebugColors->setEnabled(enable); - myUndrivenPins->setEnabled(enable); + copyStateToSet(devSettings ? SettingsSet::player : SettingsSet::developer); + copySetToState(devSettings ? SettingsSet::developer : SettingsSet::player); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::handleTVJitterChange(bool enable) { - myTVJitterRec->setEnabled(enable); - myTVJitterRecLabel->setEnabled(enable); + myTVJitterRecWidget->setEnabled(enable); + myTVJitterRecLabelWidget->setEnabled(enable); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::handleDebugColors() { - if(instance().hasConsole() && myDevSettings->getState()) + if(instance().hasConsole() && myDevSettingsWidget->getState()) { bool fixed = instance().console().tia().usingFixedColors(); - if(fixed != myDebugColors->getState()) + if(fixed != myDebugColorsWidget->getState()) instance().console().tia().toggleFixedColors(); } } @@ -690,12 +739,11 @@ void DeveloperDialog::handleDebugColors() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::handleConsole() { - bool is7800 = myConsole->getSelected() == 1; - bool enable = myDevSettings->getState(); + bool is7800 = myConsoleWidget->getSelected() == 1; - myRandomizeRAM->setEnabled(enable && !is7800); + myRandomizeRAMWidget->setEnabled(!is7800); if(is7800) - myRandomizeRAM->setState(false); + myRandomizeRAMWidget->setState(false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/DeveloperDialog.hxx b/src/gui/DeveloperDialog.hxx index 5a0759207..5ac980e52 100644 --- a/src/gui/DeveloperDialog.hxx +++ b/src/gui/DeveloperDialog.hxx @@ -25,6 +25,8 @@ class EventMappingWidget; class CheckboxWidget; class EditTextWidget; class PopUpWidget; +class RadioButtonGroup; +class RadioButtonWidget; class SliderWidget; class StaticTextWidget; @@ -52,7 +54,8 @@ class DeveloperDialog : public Dialog private: enum { - kDevSettings = 'DVst', + kPlrSettings = 'DVpl', + kDevSettings = 'DVdv', kConsole = 'DVco', kRandRAMID = 'DVrm', kRandCPUID = 'DVcp', @@ -69,6 +72,11 @@ class DeveloperDialog : public Dialog kDFontSizeChanged = 'UIfs', #endif }; + enum SettingsSet + { + player, + developer + }; static const int NUM_INTERVALS = 6; // TODO: check for intervals shorter than 1 frame (adjust horizon too!) @@ -84,42 +92,55 @@ class DeveloperDialog : public Dialog TabWidget* myTab; // Emulator - CheckboxWidget* myDevSettings; - CheckboxWidget* myFrameStats; - PopUpWidget* myConsole; - StaticTextWidget* myLoadingROMLabel; - CheckboxWidget* myRandomBank; - CheckboxWidget* myRandomizeRAM; - StaticTextWidget* myRandomizeCPULabel; - CheckboxWidget* myRandomizeCPU[5]; - CheckboxWidget* myColorLoss; - CheckboxWidget* myTVJitter; - SliderWidget* myTVJitterRec; - StaticTextWidget* myTVJitterRecLabel; - CheckboxWidget* myDebugColors; - CheckboxWidget* myUndrivenPins; + RadioButtonGroup* mySettingsGroup; + RadioButtonWidget* myPlayerSettingsWidget; + RadioButtonWidget* myDevSettingsWidget; + CheckboxWidget* myFrameStatsWidget; + PopUpWidget* myConsoleWidget; + StaticTextWidget* myLoadingROMLabel; + CheckboxWidget* myRandomBankWidget; + CheckboxWidget* myRandomizeRAMWidget; + StaticTextWidget* myRandomizeCPULabel; + CheckboxWidget* myRandomizeCPUWidget[5]; + CheckboxWidget* myColorLossWidget; + CheckboxWidget* myTVJitterWidget; + SliderWidget* myTVJitterRecWidget; + StaticTextWidget* myTVJitterRecLabelWidget; + CheckboxWidget* myDebugColorsWidget; + CheckboxWidget* myUndrivenPinsWidget; // States - CheckboxWidget* myContinuousRewind; - SliderWidget* myStateSize; - StaticTextWidget* myStateSizeLabel; - SliderWidget* myStateInterval; - StaticTextWidget* myStateIntervalLabel; - SliderWidget* myStateHorizon; - StaticTextWidget* myStateHorizonLabel; + CheckboxWidget* myContinuousRewind; + SliderWidget* myStateSize; + StaticTextWidget* myStateSizeLabel; + SliderWidget* myStateInterval; + StaticTextWidget* myStateIntervalLabel; + SliderWidget* myStateHorizon; + StaticTextWidget* myStateHorizonLabel; #ifdef DEBUGGER_SUPPORT // Debugger UI - SliderWidget* myDebuggerWidthSlider; - StaticTextWidget* myDebuggerWidthLabel; - SliderWidget* myDebuggerHeightSlider; - StaticTextWidget* myDebuggerHeightLabel; - PopUpWidget* myDebuggerFontSize; - PopUpWidget* myDebuggerFontStyle; + SliderWidget* myDebuggerWidthSlider; + StaticTextWidget* myDebuggerWidthLabel; + SliderWidget* myDebuggerHeightSlider; + StaticTextWidget* myDebuggerHeightLabel; + PopUpWidget* myDebuggerFontSize; + PopUpWidget* myDebuggerFontStyle; #endif // Maximum width and height for this dialog int myMaxWidth, myMaxHeight; + bool myFrameStats[2]; + int myConsole[2]; + bool myRandomBank[2]; + bool myRandomizeRAM[2]; + string myRandomizeCPU[2]; + bool myColorLoss[2]; + bool myTVJitter[2]; + int myTVJitterRec[2]; + bool myDebugColors[2]; + bool myUndrivenPins[2]; + private: void addEmulationTab(const GUI::Font& font); void addDebuggerTab(const GUI::Font& font); @@ -127,14 +148,19 @@ class DeveloperDialog : public Dialog // Add Defaults, OK and Cancel buttons void addDefaultOKCancelButtons(const GUI::Font& font); - void handleDeveloperOptions(); + void copySettingsToSet(SettingsSet set); + void copySetToSettings(SettingsSet set); + void copyStateToSet(SettingsSet set); + void copySetToState(SettingsSet set); + + void handleSettings(bool devSettings); void handleTVJitterChange(bool enable); void handleDebugColors(); void handleConsole(); void handleRewind(); void handleSize(); void handleInterval(); - void handleHorizon(); + void handleHorizon(); void handleFontSize(); // Following constructors and assignment operators not supported diff --git a/src/gui/RadioButtonWidget.cxx b/src/gui/RadioButtonWidget.cxx index 18fa63b6f..2dd42f776 100644 --- a/src/gui/RadioButtonWidget.cxx +++ b/src/gui/RadioButtonWidget.cxx @@ -114,12 +114,7 @@ void RadioButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) if(isEnabled() && _editable && x >= 0 && x < _w && y >= 0 && y < _h) { if(!_state) - { setState(true); - - // We only send a command when the widget has been changed interactively - sendCommand(_cmd, _state, _id); - } } } @@ -130,7 +125,7 @@ void RadioButtonWidget::setState(bool state, bool send) { _state = state; setDirty(); - if(send) + if(_state && send) sendCommand(_cmd, _state, _id); if (state) myGroup->select(this); diff --git a/src/gui/VideoDialog.cxx b/src/gui/VideoDialog.cxx index 4fdf85b4a..edc60bfc1 100644 --- a/src/gui/VideoDialog.cxx +++ b/src/gui/VideoDialog.cxx @@ -462,8 +462,6 @@ void VideoDialog::loadConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoDialog::saveConfig() { - bool devSettings = instance().settings().getBool("dev.settings"); - // Renderer setting instance().settings().setValue("video", myRenderer->getSelectedTag().toString());