Fix crash in BUS/CDF/CM schemes.

- bank initialization must happen in Cart::reset(), not the individual c'tors.
This commit is contained in:
Stephen Anthony 2018-09-17 09:38:23 -02:30
parent 9890c648cb
commit ea31d4b464
4 changed files with 13 additions and 9 deletions

View File

@ -218,6 +218,9 @@ class Cartridge : public Device
will take both randomization and properties settings into account.
See the actual method for more information on the logic used.
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
@return The bank number that was determined

View File

@ -78,6 +78,9 @@ void CartridgeBUS::reset()
{
initializeRAM(myBUSRAM+2048, 8192-2048);
// BUS always starts in bank 6
initializeStartBank(6);
// Update cycles to the current system cycles
myAudioCycles = myARMCycles = 0;
myFractionalClocks = 0.0;
@ -97,9 +100,6 @@ void CartridgeBUS::setInitialState()
for (int i=0; i < 3; ++i)
myMusicWaveformSize[i] = 27;
// BUS always starts in bank 6
initializeStartBank(6);
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
// need to confirm with Chris
myMode = 0xFF;

View File

@ -81,6 +81,9 @@ void CartridgeCDF::reset()
{
initializeRAM(myCDFRAM+2048, 8192-2048);
// CDF always starts in bank 6
initializeStartBank(6);
myAudioCycles = myARMCycles = 0;
myFractionalClocks = 0.0;
@ -99,9 +102,6 @@ void CartridgeCDF::setInitialState()
for (int i=0; i < 3; ++i)
myMusicWaveformSize[i] = 27;
// CDF always starts in bank 6
initializeStartBank(6);
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
// need to confirm with Chris
myMode = 0xFF;

View File

@ -30,9 +30,6 @@ CartridgeCM::CartridgeCM(const BytePtr& image, uInt32 size,
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(16384u, size));
createCodeAccessBase(16384);
// On powerup, the last bank of ROM is enabled and RAM is disabled
initializeStartBank(mySWCHA & 0x3);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -40,6 +37,10 @@ void CartridgeCM::reset()
{
initializeRAM(myRAM, 2048);
// On powerup, the last bank of ROM is enabled and RAM is disabled
mySWCHA = 0xFF;
initializeStartBank(mySWCHA & 0x3);
// Upon reset we switch to the startup bank
bank(startBank());
}