diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index a48d293ce..6586c9234 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -33,7 +33,6 @@ #include "CartDebugWidget.hxx" #include "CartRamWidget.hxx" #include "RomWidget.hxx" -#include "System.hxx" #include "Base.hxx" using Common::Base; using std::hex; diff --git a/src/debugger/gui/CartE0Widget.cxx b/src/debugger/gui/CartE0Widget.cxx index 893ea8608..13bdde580 100644 --- a/src/debugger/gui/CartE0Widget.cxx +++ b/src/debugger/gui/CartE0Widget.cxx @@ -51,7 +51,7 @@ CartridgeE0Widget::CartridgeE0Widget( " Hotspots $FF0 to $FF7\n" "Segment 3 accessible @ $FC00 - $FFFF\n" " Always points to last 1K of ROM\n" - "Startup slices = 0 / 1 / 2\n"; + "Startup slices = 4 / 5 / 6 or undetermined\n"; #if 0 // Eventually, we should query this from the debugger/disassembler diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 6b5586a9a..560d64a98 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -101,7 +101,13 @@ void Cartridge::initializeRAM(uInt8* arr, uInt32 size, uInt8 val) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge::randomizeStartBank() { - if(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.bankrandom" : "plr.bankrandom")) + if(randomStartBank()) myStartBank = mySystem->randGenerator().next() % bankCount(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::randomStartBank() const +{ + return mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.bankrandom" : "plr.bankrandom"); +} + diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 6ead1970c..41ba2ba37 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -81,12 +81,6 @@ class Cartridge : public Device */ uInt16 startBank() const { return myStartBank; } - /** - Defines the startup bank. if 'bank' is negative, a random bank will - be selected. - */ - void randomizeStartBank(); - /** Answer whether the bank has changed since the last time this method was called. Each cart class is able to override this @@ -201,6 +195,19 @@ class Cartridge : public Device */ void initializeRAM(uInt8* arr, uInt32 size, uInt8 val = 0) const; + /** + Defines the startup bank. if 'bank' is negative, a random bank will + be selected. + */ + void randomizeStartBank(); + + /** + Checks if startup bank randomization is enabled + + @return Whether the startup bank(s) should be randomized + */ + bool randomStartBank() const; + protected: // Settings class for the application const Settings& mySettings; diff --git a/src/emucore/CartE0.cxx b/src/emucore/CartE0.cxx index fea98c908..2ad89901c 100644 --- a/src/emucore/CartE0.cxx +++ b/src/emucore/CartE0.cxx @@ -32,9 +32,19 @@ CartridgeE0::CartridgeE0(const BytePtr& image, uInt32 size, void CartridgeE0::reset() { // Setup segments to some default slices - segmentZero(4); - segmentOne(5); - segmentTwo(6); + if(randomStartBank()) + { + segmentZero(mySystem->randGenerator().next() % 8); + segmentOne(mySystem->randGenerator().next() % 8); + segmentTwo(mySystem->randGenerator().next() % 8); + } + else + { + segmentZero(4); + segmentOne(5); + segmentTwo(6); + } + myCurrentSlice[3] = 7; // fixed myBankChanged = true; } @@ -54,7 +64,6 @@ void CartridgeE0::install(System& system) access.codeAccessBase = &myCodeAccessBase[7168 + (addr & 0x03FF)]; mySystem->setPageAccess(addr, access); } - myCurrentSlice[3] = 7; // Set the page accessing methods for the hot spots in the last segment access.directPeekBase = nullptr; @@ -63,11 +72,6 @@ void CartridgeE0::install(System& system) for(uInt16 addr = (0x1FE0 & ~System::PAGE_MASK); addr < 0x2000; addr += System::PAGE_SIZE) mySystem->setPageAccess(addr, access); - - // Install some default slices for the other segments - segmentZero(4); - segmentOne(5); - segmentTwo(6); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartMNetwork.cxx b/src/emucore/CartMNetwork.cxx index ece1723a9..21a7c11e5 100644 --- a/src/emucore/CartMNetwork.cxx +++ b/src/emucore/CartMNetwork.cxx @@ -49,7 +49,7 @@ void CartridgeMNetwork::reset() // define random startup banks randomizeStartBank(); - uInt32 ramBank = mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.bankrandom" : "plr.bankrandom") ? + uInt32 ramBank = randomStartBank() ? mySystem->randGenerator().next() % 4 : 0; // Install some default banks for the RAM and first segment