startup bank for E0 bankswitch type randomized

This commit is contained in:
thrust26 2017-12-01 10:08:10 +01:00
parent 7fc1c54d4c
commit d333553ec2
6 changed files with 35 additions and 19 deletions

View File

@ -33,7 +33,6 @@
#include "CartDebugWidget.hxx" #include "CartDebugWidget.hxx"
#include "CartRamWidget.hxx" #include "CartRamWidget.hxx"
#include "RomWidget.hxx" #include "RomWidget.hxx"
#include "System.hxx"
#include "Base.hxx" #include "Base.hxx"
using Common::Base; using Common::Base;
using std::hex; using std::hex;

View File

@ -51,7 +51,7 @@ CartridgeE0Widget::CartridgeE0Widget(
" Hotspots $FF0 to $FF7\n" " Hotspots $FF0 to $FF7\n"
"Segment 3 accessible @ $FC00 - $FFFF\n" "Segment 3 accessible @ $FC00 - $FFFF\n"
" Always points to last 1K of ROM\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 #if 0
// Eventually, we should query this from the debugger/disassembler // Eventually, we should query this from the debugger/disassembler

View File

@ -101,7 +101,13 @@ void Cartridge::initializeRAM(uInt8* arr, uInt32 size, uInt8 val) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge::randomizeStartBank() void Cartridge::randomizeStartBank()
{ {
if(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.bankrandom" : "plr.bankrandom")) if(randomStartBank())
myStartBank = mySystem->randGenerator().next() % bankCount(); myStartBank = mySystem->randGenerator().next() % bankCount();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge::randomStartBank() const
{
return mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.bankrandom" : "plr.bankrandom");
}

View File

@ -81,12 +81,6 @@ class Cartridge : public Device
*/ */
uInt16 startBank() const { return myStartBank; } 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 Answer whether the bank has changed since the last time this
method was called. Each cart class is able to override 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; 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: protected:
// Settings class for the application // Settings class for the application
const Settings& mySettings; const Settings& mySettings;

View File

@ -32,9 +32,19 @@ CartridgeE0::CartridgeE0(const BytePtr& image, uInt32 size,
void CartridgeE0::reset() void CartridgeE0::reset()
{ {
// Setup segments to some default slices // Setup segments to some default slices
segmentZero(4); if(randomStartBank())
segmentOne(5); {
segmentTwo(6); 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; myBankChanged = true;
} }
@ -54,7 +64,6 @@ void CartridgeE0::install(System& system)
access.codeAccessBase = &myCodeAccessBase[7168 + (addr & 0x03FF)]; access.codeAccessBase = &myCodeAccessBase[7168 + (addr & 0x03FF)];
mySystem->setPageAccess(addr, access); mySystem->setPageAccess(addr, access);
} }
myCurrentSlice[3] = 7;
// Set the page accessing methods for the hot spots in the last segment // Set the page accessing methods for the hot spots in the last segment
access.directPeekBase = nullptr; access.directPeekBase = nullptr;
@ -63,11 +72,6 @@ void CartridgeE0::install(System& system)
for(uInt16 addr = (0x1FE0 & ~System::PAGE_MASK); addr < 0x2000; for(uInt16 addr = (0x1FE0 & ~System::PAGE_MASK); addr < 0x2000;
addr += System::PAGE_SIZE) addr += System::PAGE_SIZE)
mySystem->setPageAccess(addr, access); mySystem->setPageAccess(addr, access);
// Install some default slices for the other segments
segmentZero(4);
segmentOne(5);
segmentTwo(6);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -49,7 +49,7 @@ void CartridgeMNetwork::reset()
// define random startup banks // define random startup banks
randomizeStartBank(); randomizeStartBank();
uInt32 ramBank = mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.bankrandom" : "plr.bankrandom") ? uInt32 ramBank = randomStartBank() ?
mySystem->randGenerator().next() % 4 : 0; mySystem->randGenerator().next() % 4 : 0;
// Install some default banks for the RAM and first segment // Install some default banks for the RAM and first segment