diff --git a/Changes.txt b/Changes.txt
index 1587ac356..b69a94b6b 100644
--- a/Changes.txt
+++ b/Changes.txt
@@ -27,18 +27,20 @@
and they will be added and removed automatically. Also fixed is
a bug whereby sometimes custom joystick mappings weren't being saved.
- * The 'cpurandom' option now also randomizes the SP register, and the
- randomization is now disabled by default. If you are experiencing
- weird graphics corruption, display problems, etc, consider disabling
- this option.
+ * The 'cpurandom' option is now broken down by register type, so you
+ can selectively enable/disable randomization for each one. The
+ default is to disable randomization for all registers.
* Fixed 'MDM' scheme to trigger bankswitching on writes to hotspots
(previously it only triggered on reads). Also, the scheme has been
modified as originally designed by E. Blink; hotspots are now in the
range $800-$BFF instead of $800-$FFF.
- * The OSX app icon now includes 32x32 and 16x16 versions, so 'small'
- icons will be viewable in Finder, Get Info, etc.
+ * The OSX app-icon now includes 32x32 and 16x16 versions, so 'small'
+ icons will be viewable in 'Finder', 'Get Info', etc.
+
+ * The Linux port now uses an app-icon; this seems to be needed for
+ some window managers.
-Have fun!
diff --git a/docs/graphics/debugger_iotab.png b/docs/graphics/debugger_iotab.png
index e22666661..173d291e5 100644
Binary files a/docs/graphics/debugger_iotab.png and b/docs/graphics/debugger_iotab.png differ
diff --git a/docs/index.html b/docs/index.html
index b8f9d91ff..e5cb5fe52 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -2246,8 +2246,8 @@
- -cpurandom <1|0> |
- On reset, randomize the content CPU registers. |
+ -cpurandom <S,A,X,Y,P> |
+ On reset, randomize the content of the specified CPU registers. |
diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx
index 630d381d2..e6d90e290 100644
--- a/src/debugger/gui/RiotWidget.cxx
+++ b/src/debugger/gui/RiotWidget.cxx
@@ -218,21 +218,30 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
lfont.getStringWidth("When loading a ROM:"), fontHeight,
"When loading a ROM:", kTextAlignLeft);
- // Randomize CPU
- xpos += 30; ypos += lineHeight + 4;
- myRandomizeCPU = new CheckboxWidget(boss, lfont, xpos, ypos+1,
- "Randomize CPU registers (SP/A/X/Y/PS)", kCheckActionCmd);
- myRandomizeCPU->setID(kRandCPUID);
- myRandomizeCPU->setTarget(this);
- addFocusWidget(myRandomizeCPU);
-
// Randomize RAM
- ypos += lineHeight + 4;
+ xpos += 30; ypos += lineHeight + 4;
myRandomizeRAM = new CheckboxWidget(boss, lfont, xpos, ypos+1,
"Randomize zero-page and extended RAM", kCheckActionCmd);
myRandomizeRAM->setID(kRandRAMID);
myRandomizeRAM->setTarget(this);
addFocusWidget(myRandomizeRAM);
+
+ // Randomize CPU
+ ypos += lineHeight + 8;
+ lwidth = lfont.getStringWidth("Randomize CPU ");
+ new StaticTextWidget(boss, lfont, xpos, ypos+1,
+ lwidth, fontHeight, "Randomize CPU ", kTextAlignLeft);
+ xpos += lwidth + 10;
+ const char* cpuregs[] = { "SP", "A", "X", "Y", "PS" };
+ for(int i = 0; i < 5; ++i)
+ {
+ myRandomizeCPU[i] = new CheckboxWidget(boss, lfont, xpos, ypos+1,
+ cpuregs[i], kCheckActionCmd);
+ myRandomizeCPU[i]->setID(kRandCPUID);
+ myRandomizeCPU[i]->setTarget(this);
+ addFocusWidget(myRandomizeCPU[i]);
+ xpos += CheckboxWidget::boxSize() + lfont.getStringWidth("XX") + 20;
+ }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -335,8 +344,12 @@ void RiotWidget::loadConfig()
myLeftControl->loadConfig();
myRightControl->loadConfig();
- myRandomizeCPU->setState(instance().settings().getBool("cpurandom"));
myRandomizeRAM->setState(instance().settings().getBool("ramrandom"));
+
+ const string& cpurandom = instance().settings().getString("cpurandom");
+ const char* cpuregs[] = { "S", "A", "X", "Y", "P" };
+ for(int i = 0; i < 5; ++i)
+ myRandomizeCPU[i]->setState(BSPF_containsIgnoreCase(cpurandom, cpuregs[i]));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -401,12 +414,12 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kResetID:
riot.reset(!myReset->getState());
break;
- case kRandCPUID:
- instance().settings().setValue("cpurandom", myRandomizeCPU->getState());
- break;
case kRandRAMID:
instance().settings().setValue("ramrandom", myRandomizeRAM->getState());
break;
+ case kRandCPUID:
+ handleRandomCPU();
+ break;
}
break;
@@ -450,3 +463,15 @@ ControllerWidget* RiotWidget::addControlWidget(GuiObject* boss, const GUI::Font&
return new NullControlWidget(boss, font, x, y, controller);
}
}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+void RiotWidget::handleRandomCPU()
+{
+ string cpurandom;
+ const char* cpuregs[] = { "S", "A", "X", "Y", "P" };
+ for(int i = 0; i < 5; ++i)
+ if(myRandomizeCPU[i]->getState())
+ cpurandom += cpuregs[i];
+
+ instance().settings().setValue("cpurandom", cpurandom);
+}
diff --git a/src/debugger/gui/RiotWidget.hxx b/src/debugger/gui/RiotWidget.hxx
index 919f5edc5..005b6d4e5 100644
--- a/src/debugger/gui/RiotWidget.hxx
+++ b/src/debugger/gui/RiotWidget.hxx
@@ -45,6 +45,8 @@ class RiotWidget : public Widget, public CommandSender
ControllerWidget* addControlWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, Controller& controller);
+ void handleRandomCPU();
+
private:
ToggleBitWidget* mySWCHAReadBits;
ToggleBitWidget* mySWCHAWriteBits;
@@ -67,7 +69,7 @@ class RiotWidget : public Widget, public CommandSender
CheckboxWidget* mySelect;
CheckboxWidget* myReset;
- CheckboxWidget* myRandomizeCPU;
+ CheckboxWidget* myRandomizeCPU[5];
CheckboxWidget* myRandomizeRAM;
// ID's for the various widgets
diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx
index 198f95c6a..06ce9c560 100644
--- a/src/emucore/M6502.cxx
+++ b/src/emucore/M6502.cxx
@@ -109,22 +109,18 @@ void M6502::reset()
// Clear the execution status flags
myExecutionStatus = 0;
- // Set registers to default values
- SP = 0xff;
- if(mySettings.getBool("cpurandom"))
- {
- SP = mySystem->randGenerator().next();
- A = mySystem->randGenerator().next();
- X = mySystem->randGenerator().next();
- Y = mySystem->randGenerator().next();
- PS(mySystem->randGenerator().next());
- }
- else
- {
- SP = 0xff;
- A = X = Y = 0;
- PS(0x20);
- }
+ // Set registers to random or default values
+ const string& cpurandom = mySettings.getString("cpurandom");
+ SP = BSPF_containsIgnoreCase(cpurandom, "S") ?
+ mySystem->randGenerator().next() : 0xff;
+ A = BSPF_containsIgnoreCase(cpurandom, "A") ?
+ mySystem->randGenerator().next() : 0x00;
+ X = BSPF_containsIgnoreCase(cpurandom, "X") ?
+ mySystem->randGenerator().next() : 0x00;
+ Y = BSPF_containsIgnoreCase(cpurandom, "Y") ?
+ mySystem->randGenerator().next() : 0x00;
+ PS(BSPF_containsIgnoreCase(cpurandom, "P") ?
+ mySystem->randGenerator().next() : 0x20);
// Reset access flag
myLastAccessWasRead = true;
diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx
index 9bf591ac9..94b5e10ed 100644
--- a/src/emucore/Settings.cxx
+++ b/src/emucore/Settings.cxx
@@ -130,7 +130,7 @@ Settings::Settings(OSystem& osystem)
setInternal("loglevel", "1");
setInternal("logtoconsole", "0");
setInternal("tiadriven", "false");
- setInternal("cpurandom", "false");
+ setInternal("cpurandom", "");
setInternal("ramrandom", "true");
setInternal("avoxport", "");
setInternal("stats", "false");