Commit b40a614c authored by Stephen Anthony's avatar Stephen Anthony
Browse files

Rework `Cartridge::initializeStartBank()` to require a specific starting bank.

Randomization and reading from properties still work too.
Fixes issues in several ROMs that essentially were getting bank randomization even though it was disabled.
parent 497bfc92
......@@ -139,18 +139,16 @@ void Cartridge::initializeRAM(uInt8* arr, uInt32 size, uInt8 val) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge::initializeStartBank(int defaultBank)
uInt16 Cartridge::initializeStartBank(uInt16 defaultBank)
{
int propsBank = myStartBankFromPropsFunc();
bool userandom = randomStartBank() || (defaultBank < 0 && propsBank < 0);
if(userandom)
if(randomStartBank())
return myStartBank = mySystem->randGenerator().next() % bankCount();
else if(propsBank >= 0)
return myStartBank = BSPF::clamp(propsBank, 0, bankCount() - 1);
else
return myStartBank = BSPF::clamp(defaultBank, 0, bankCount() - 1);
return myStartBank = BSPF::clamp(int(defaultBank), 0, bankCount() - 1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
......@@ -258,11 +258,12 @@ class Cartridge : public Device
NOTE: If this method is used, it *must* be called from the cart reset()
method, *not* from the c'tor.
@param defaultBank The actual bank to use during reset
@param defaultBank The default bank to use during reset, if
randomization or properties aren't being used
@return The bank number that was determined
*/
uInt16 initializeStartBank(int defaultBank = -1);
uInt16 initializeStartBank(uInt16 defaultBank);
/**
Checks if initial RAM randomization is enabled.
......
......@@ -32,9 +32,8 @@ Cartridge0840::Cartridge0840(const BytePtr& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge0840::reset()
{
initializeStartBank();
// Upon reset we switch to the startup bank
initializeStartBank(0);
bank(startBank());
}
......
......@@ -57,10 +57,8 @@ void CartridgeDPC::reset()
myAudioCycles = 0;
myFractionalClocks = 0.0;
// Use random startup bank
initializeStartBank();
// Upon reset we switch to the startup bank
initializeStartBank(1);
bank(startBank());
}
......
......@@ -32,10 +32,8 @@ CartridgeF0::CartridgeF0(const BytePtr& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF0::reset()
{
// Use random startup bank
initializeStartBank();
// Upon reset we switch to the startup bank
initializeStartBank(15);
bank(startBank());
}
......
......@@ -33,10 +33,8 @@ CartridgeF4::CartridgeF4(const BytePtr& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4::reset()
{
// Use random startup bank
initializeStartBank();
// Upon reset we switch to the startup bank
initializeStartBank(0);
bank(startBank());
}
......
......@@ -33,7 +33,7 @@ CartridgeF4SC::CartridgeF4SC(const BytePtr& image, uInt32 size,
void CartridgeF4SC::reset()
{
initializeRAM(myRAM, 128);
initializeStartBank();
initializeStartBank(0);
// Upon reset we switch to the startup bank
bank(startBank());
......
......@@ -32,10 +32,8 @@ CartridgeF6::CartridgeF6(const BytePtr& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6::reset()
{
// Use random startup bank
initializeStartBank();
// Upon reset we switch to the startup bank
initializeStartBank(0);
bank(startBank());
}
......
......@@ -33,7 +33,7 @@ CartridgeF6SC::CartridgeF6SC(const BytePtr& image, uInt32 size,
void CartridgeF6SC::reset()
{
initializeRAM(myRAM, 128);
initializeStartBank();
initializeStartBank(0);
// Upon reset we switch to the startup bank
bank(startBank());
......
......@@ -33,7 +33,7 @@ CartridgeF8SC::CartridgeF8SC(const BytePtr& image, uInt32 size,
void CartridgeF8SC::reset()
{
initializeRAM(myRAM, 128);
initializeStartBank();
initializeStartBank(1);
// Upon reset we switch to the startup bank
bank(startBank());
......
......@@ -45,7 +45,7 @@ CartridgeFA2::CartridgeFA2(const BytePtr& image, uInt32 size,
void CartridgeFA2::reset()
{
initializeRAM(myRAM, 256);
initializeStartBank();
initializeStartBank(0);
// Upon reset we switch to the startup bank
bank(startBank());
......
......@@ -46,8 +46,7 @@ void CartridgeMNetwork::reset()
{
initializeRAM(myRAM, RAM_SIZE);
// Use random startup bank
initializeStartBank();
initializeStartBank(0);
uInt32 ramBank = randomStartBank() ?
mySystem->randGenerator().next() % 4 : 0;
......
......@@ -32,9 +32,8 @@ CartridgeUA::CartridgeUA(const BytePtr& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeUA::reset()
{
initializeStartBank();
// Upon reset we switch to the startup bank
initializeStartBank(0);
bank(startBank());
}
......
......@@ -34,9 +34,8 @@ CartridgeX07::CartridgeX07(const BytePtr& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeX07::reset()
{
initializeStartBank();
// Upon reset we switch to the startup bank
initializeStartBank(0);
bank(startBank());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment