made random hotspots peeks a developer option

added check for duplicate hotkeys
This commit is contained in:
thrust26 2024-01-30 15:40:48 +01:00
parent b83a74d256
commit 4acf4e3a73
16 changed files with 71 additions and 5 deletions

View File

@ -50,6 +50,8 @@
* Fixed broken 7800 pause key support.
* Added developer option for random hotspot peek values.
* Added user defined CPU cycle timers to debugger.
* Removed 'launcherroms' option, since it was causing some issues.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -3640,6 +3640,9 @@
</tr><tr>
<td><pre>-&lt;plr.|dev.&gt;cpurandom &lt;S,A,X,Y,P&gt;</pre></td>
<td>On reset, randomize the content of the specified CPU registers.</td>
</tr><tr>
<td><pre>-dev.hsrandom &lt;1|0&gt;</pre></td>
<td>When this option is enabled, peeks to hotspots return semi-random values.</td>
</tr><tr>
<td><pre>-dev.tiadriven &lt;1|0&gt;</pre></td>
<td>Set unused TIA pins to be randomly driven high or low on a read/peek.
@ -4567,6 +4570,11 @@
<td>When loading a ROM, randomize the content of the specified CPU registers</td>
<td>-plr.cpurandom<br/>-dev.cpurandom</td>
</tr>
<tr>
<td>Random hotspot peek values</td>
<td>Peeks to hotspots return semi-random values</td>
<td>-dev.hsrandom</td>
</tr>
<tr>
<td>Drive unused TIA pins ...</td>
<td>Unused TIA pins are read random instead of the last databus values</td>

View File

@ -23,6 +23,7 @@
#include "Settings.hxx"
#include "StateManager.hxx"
#include "TIA.hxx"
#include "Cart.hxx"
#include "DevSettingsHandler.hxx"
@ -47,6 +48,8 @@ void DevSettingsHandler::loadSettings(SettingsSet set)
myRandomizeTIA[set] = settings.getBool(prefix + "tiarandom");
myRandomizeRAM[set] = settings.getBool(prefix + "ramrandom");
myRandomizeCPU[set] = settings.getString(prefix + "cpurandom");
// Random hotspot peeks
myRandomHotspots[set] = devSettings ? settings.getBool("dev.hsrandom") : false;
// Undriven TIA pins
myUndrivenPins[set] = devSettings ? settings.getBool("dev.tiadriven") : false;
#ifdef DEBUGGER_SUPPORT
@ -110,6 +113,7 @@ void DevSettingsHandler::saveSettings(SettingsSet set)
if(devSettings)
{
settings.setValue("dev.hsrandom", myRandomHotspots[set]);
// Undriven TIA pins
settings.setValue("dev.tiadriven", myUndrivenPins[set]);
#ifdef DEBUGGER_SUPPORT
@ -168,6 +172,7 @@ void DevSettingsHandler::applySettings(SettingsSet set)
if(myOSystem.hasConsole())
{
myOSystem.console().cartridge().enableRandomHotspots(myRandomHotspots[set]);
myOSystem.console().tia().driveUnusedPinsRandom(myUndrivenPins[set]);
// Notes:
// - thumb exceptions not updated, because set in cart constructor

View File

@ -58,6 +58,7 @@ class DevSettingsHandler
std::array<int, numSets> myTVJitterSense;
std::array<int, numSets> myTVJitterRec;
std::array<bool, numSets> myDebugColors;
std::array<bool, numSets> myRandomHotspots;
std::array<bool, numSets> myUndrivenPins;
#ifdef DEBUGGER_SUPPORT
std::array<bool, numSets> myRWPortBreak;

View File

@ -70,8 +70,25 @@ PhysicalKeyboardHandler::PhysicalKeyboardHandler(OSystem& system, EventHandler&
#ifdef DEBUGGER_SUPPORT
setDefaultMapping(Event::NoType, EventMode::kPromptMode, updateDefaults);
#endif
#ifdef DEBUG_BUILD
verifyDefaultMapping(DefaultCommonMapping, EventMode::kEmulationMode, "EmulationMode");
verifyDefaultMapping(DefaultMenuMapping, EventMode::kMenuMode, "MenuMode");
#endif
}
#ifdef DEBUG_BUILD
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalKeyboardHandler::verifyDefaultMapping(
PhysicalKeyboardHandler::EventMappingArray mapping, EventMode mode, string_view name)
{
for(const auto& item1 : mapping)
for(const auto& item2 : mapping)
if(item1.event != item2.event && item1.key == item2.key && item1.mod == item2.mod)
cerr << "ERROR! Duplicate hotkey mapping found: " << name << ", "
<< myKeyMap.getDesc(KeyMap::Mapping(mode, item1.key, item1.mod)) << "\n";
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalKeyboardHandler::loadSerializedMappings(
string_view serializedMapping, EventMode mode)
@ -660,6 +677,7 @@ PhysicalKeyboardHandler::DefaultCommonMapping = {
{ Event::PhosphorDecrease, KBDK_4, KBDM_SHIFT | MOD3 },
{ Event::PhosphorIncrease, KBDK_4, MOD3 },
{ Event::TogglePhosphor, KBDK_P, MOD3 },
//{ Event::PhosphorModeDecrease, KBDK_P, KBDM_SHIFT | KBDM_CTRL | MOD3 },
{ Event::PhosphorModeIncrease, KBDK_P, KBDM_CTRL | MOD3 },
{ Event::ScanlinesDecrease, KBDK_5, KBDM_SHIFT | MOD3 },
{ Event::ScanlinesIncrease, KBDK_5, MOD3 },

View File

@ -124,6 +124,11 @@ class PhysicalKeyboardHandler
/** return event mode for given controller type */
static EventMode getMode(const Controller::Type type);
#ifdef DEBUG_BUILD
void verifyDefaultMapping(PhysicalKeyboardHandler::EventMappingArray mapping,
EventMode mode, string_view name);
#endif
private:
OSystem& myOSystem;
EventHandler& myHandler;

View File

@ -37,6 +37,8 @@ Cartridge::Cartridge(const Settings& settings, string_view md5)
for(uInt32 i = 0; i < 256; ++i)
myRWPRandomValues[i] = rand.next();
const bool devSettings = mySettings.getBool("dev.settings");
myRandomHotspots = devSettings ? mySettings.getBool("dev.randomhs") : false;
myRamReadAccesses.reserve(5);
}

View File

@ -90,6 +90,8 @@ class Cartridge : public Device
void unlockHotspots() { myHotspotsLocked = false; }
bool hotspotsLocked() const { return myHotspotsLocked; }
void enableRandomHotspots(bool enable) { myRandomHotspots = enable; }
/**
Get the default startup bank for a cart. This is the bank where
the system will look at address 0xFFFC to determine where to
@ -437,6 +439,9 @@ class Cartridge : public Device
// Semi-random values to use when a read from write port occurs
std::array<uInt8, 256> myRWPRandomValues;
// If myRandomHotspots is true, peeks to hotspots return semi-random values.
bool myRandomHotspots{false};
private:
// The startup bank to use (where to look for the reset vector address)
uInt16 myStartBank{0};

View File

@ -161,7 +161,7 @@ uInt8 CartridgeEnhanced::peek(uInt16 address)
// hotspots in TIA range are reacting to pokes only
if(hotspot() >= 0x80)
if(checkSwitchBank(address & ADDR_MASK, 0))
if(checkSwitchBank(address & ADDR_MASK, 0) && myRandomHotspots)
return myRWPRandomValues[address & 0xFF];
if(isRamBank(address))

View File

@ -15,6 +15,7 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "System.hxx"
#include "CartFA.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -30,8 +31,10 @@ CartridgeFA::CartridgeFA(const ByteBuffer& image, size_t size,
bool CartridgeFA::checkSwitchBank(uInt16 address, uInt8)
{
// Switch banks if necessary
if((address >= 0x1FF8) && (address <= 0x1FFA))
if((address >= 0x1FF8) && (address <= 0x1FFA)/* && (mySystem->getDataBusState() & 1) */)
{
//if((mySystem->getDataBusState() & 1) == 0)
//cerr << std::hex << address << ": " << (mySystem->getDataBusState() & 1) << ", ";
bank(address - 0x1FF8);
return true;
}

View File

@ -26,7 +26,8 @@
/**
Cartridge class used for CBS' RAM Plus cartridges. There are three 4K
banks, accessible by read/write at $1FF8 - $1FFA, and 256 bytes of RAM.
banks, accessible by read/write at $1FF8 - $1FFA (note: D0 has to be 1
for switching), and 256 bytes of RAM.
RAM read port is $1100 - $11FF, write port is $1000 - $10FF.
@author Bradford W. Mott, Thomas Jentzsch

View File

@ -278,6 +278,7 @@ Settings::Settings()
setPermanent("dev.ramrandom", "true");
setPermanent("dev.cpurandom", "SAXYP");
setPermanent("dev.tiarandom", "true");
setPermanent("dev.hsrandom", "true");
setPermanent("dev.colorloss", "true");
#ifdef GUI_SUPPORT
setPermanent("dev.tv.jitter", "true");
@ -784,6 +785,7 @@ void Settings::usage()
<< " -dev.tv.jitter <1|0> Enable TV jitter effect\n"
<< " -dev.tv.jitter_sense <1-10> Set TV jitter effect sensitivity\n"
<< " -dev.tv.jitter_recovery <1-20> Set recovery time for TV jitter effect\n"
<< " -dev.hsrandom <1|0> Randomize the hotspot peek values\n"
<< " -dev.tiadriven <1|0> Drive unqused TIA pins randomly on a\n"
<< " read/peek\n"
#ifdef DEBUGGER_SUPPORT

View File

@ -56,7 +56,7 @@ DeveloperDialog::DeveloperDialog(OSystem& osystem, DialogContainer& parent,
// Set real dimensions
setSize(53 * fontWidth + HBORDER * 2,
_th + VGAP * 3 + lineHeight + 13 * (lineHeight + VGAP) + buttonHeight + VBORDER * 3,
_th + VGAP * 3 + lineHeight + 14 * (lineHeight + VGAP) + buttonHeight + VBORDER * 3,
max_w, max_h);
// The tab widget
@ -183,6 +183,12 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font)
}
ypos += lineHeight + VGAP;
// How to handle undriven TIA pins
myRandomHotspotsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos + 1,
"Random hotspot peek values");
wid.push_back(myRandomHotspotsWidget);
ypos += lineHeight + VGAP;
// How to handle undriven TIA pins
myUndrivenPinsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos + 1,
"Drive unused TIA pins randomly on a read/peek");
@ -711,6 +717,8 @@ void DeveloperDialog::getWidgetStates(SettingsSet set)
if(myRandomizeCPUWidget[i]->getState())
cpurandom += cpuregs[i];
myRandomizeCPU[set] = cpurandom;
// Random hotspot peeks
myRandomHotspots[set] = myRandomHotspotsWidget->getState();
// Undriven TIA pins
myUndrivenPins[set] = myUndrivenPinsWidget->getState();
#ifdef DEBUGGER_SUPPORT
@ -768,6 +776,8 @@ void DeveloperDialog::setWidgetStates(SettingsSet set)
for(int i = 0; i < 5; ++i)
myRandomizeCPUWidget[i]->setState(BSPF::containsIgnoreCase(cpurandom, cpuregs[i]));
// Random hotspot peeks
myRandomHotspotsWidget->setState(myRandomHotspots[set]);
// Undriven TIA pins
myUndrivenPinsWidget->setState(myUndrivenPins[set]);
#ifdef DEBUGGER_SUPPORT
@ -915,6 +925,8 @@ void DeveloperDialog::setDefaults()
myRandomizeTIA[set] = devSettings;
myRandomizeRAM[set] = true;
myRandomizeCPU[set] = devSettings ? "SAXYP" : "AXYP";
// Random hotspot peeks
myRandomHotspots[set] = devSettings;
// Undriven TIA pins
myUndrivenPins[set] = devSettings;
#ifdef DEBUGGER_SUPPORT
@ -1091,6 +1103,7 @@ void DeveloperDialog::handleCommand(CommandSender* sender, int cmd, int data, in
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DeveloperDialog::handleSettings(bool devSettings)
{
myRandomHotspotsWidget->setEnabled(devSettings);
myUndrivenPinsWidget->setEnabled(devSettings);
#ifdef DEBUGGER_SUPPORT
myRWPortBreakWidget->setEnabled(devSettings);

View File

@ -93,8 +93,9 @@ class DeveloperDialog : public Dialog, DevSettingsHandler
CheckboxWidget* myRandomizeTIAWidget{nullptr};
CheckboxWidget* myRandomizeRAMWidget{nullptr};
StaticTextWidget* myRandomizeCPULabel{nullptr};
CheckboxWidget* myUndrivenPinsWidget{nullptr};
std::array<CheckboxWidget*, 5> myRandomizeCPUWidget{nullptr};
CheckboxWidget* myRandomHotspotsWidget{nullptr};
CheckboxWidget* myUndrivenPinsWidget{nullptr};
#ifdef DEBUGGER_SUPPORT
CheckboxWidget* myRWPortBreakWidget{nullptr};
CheckboxWidget* myWRPortBreakWidget{nullptr};