mirror of https://github.com/stella-emu/stella.git
improve bankswitching masking in CartEnhanced
This commit is contained in:
parent
70cdfe6c13
commit
9e466214ba
|
@ -87,6 +87,8 @@ class Cartridge3F : public CartridgeEnhanced
|
|||
private:
|
||||
bool checkSwitchBank(uInt16 address, uInt8 value) override;
|
||||
|
||||
uInt16 hotspot() const override { return 0x003F; }
|
||||
|
||||
private:
|
||||
// log(ROM bank segment size) / log(2)
|
||||
static constexpr uInt16 BANK_SHIFT = 11; // = 2K = 0x0800
|
||||
|
|
|
@ -48,6 +48,8 @@ void CartridgeE0::reset()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CartridgeE0::checkSwitchBank(uInt16 address, uInt8)
|
||||
{
|
||||
address &= ROM_MASK;
|
||||
|
||||
// Switch banks if necessary
|
||||
if((address >= 0x0FE0) && (address <= 0x0FE7))
|
||||
{
|
||||
|
|
|
@ -114,8 +114,9 @@ uInt8 CartridgeEnhanced::peek(uInt16 address)
|
|||
{
|
||||
uInt16 peekAddress = address;
|
||||
|
||||
if (hotspot() != 0)
|
||||
checkSwitchBank(address & ROM_MASK);
|
||||
// hotspots in TIA range are reacting to pokes only
|
||||
if (hotspot() >= 0x80)
|
||||
checkSwitchBank(address & ADDR_MASK);
|
||||
|
||||
if(isRamBank(address))
|
||||
{
|
||||
|
@ -148,7 +149,7 @@ bool CartridgeEnhanced::poke(uInt16 address, uInt8 value)
|
|||
// Note: (TODO?)
|
||||
// The checkSwitchBank() call makes no difference between ROM and e.g TIA space
|
||||
// Writing to e.g. 0xf0xx might triger a bankswitch, is (and was!) this a bug???
|
||||
if (checkSwitchBank(address & ROM_MASK, value))
|
||||
if (checkSwitchBank(address & ADDR_MASK, value))
|
||||
return false;
|
||||
|
||||
if(myRamSize > 0)
|
||||
|
|
|
@ -232,6 +232,9 @@ class CartridgeEnhanced : public Cartridge
|
|||
size_t mySize{0};
|
||||
|
||||
protected:
|
||||
// The mask for 6507 address space
|
||||
static constexpr uInt16 ADDR_MASK = 0x1FFF;
|
||||
|
||||
// The offset into address space for accessing ROM
|
||||
static constexpr uInt16 ROM_OFFSET = 0x1000;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ CartridgeF0::CartridgeF0(const ByteBuffer& image, size_t size,
|
|||
bool CartridgeF0::checkSwitchBank(uInt16 address, uInt8)
|
||||
{
|
||||
// Switch banks if necessary
|
||||
if(address == 0x0FF0)
|
||||
if(address == 0x1FF0)
|
||||
{
|
||||
// Switch to next bank
|
||||
uInt8 nextBank = ((getBank()) + 1) & 0x0F;
|
||||
|
|
|
@ -29,9 +29,9 @@ bool CartridgeF4::checkSwitchBank(uInt16 address, uInt8)
|
|||
{
|
||||
// Switch banks if necessary
|
||||
// Note: addresses could be calculated from hotspot and bank count
|
||||
if((address >= 0x0FF4) && (address <= 0x0FFB))
|
||||
if((address >= 0x1FF4) && (address <= 0x1FFB))
|
||||
{
|
||||
bank(address - 0x0FF4);
|
||||
bank(address - 0x1FF4);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -29,9 +29,9 @@ bool CartridgeF6::checkSwitchBank(uInt16 address, uInt8)
|
|||
{
|
||||
// Switch banks if necessary
|
||||
// Note: addresses could be calculated from hotspot and bank count
|
||||
if((address >= 0x0FF6) && (address <= 0x0FF9))
|
||||
if((address >= 0x1FF6) && (address <= 0x1FF9))
|
||||
{
|
||||
bank(address - 0x0FF6);
|
||||
bank(address - 0x1FF6);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -30,12 +30,12 @@ bool CartridgeF8::checkSwitchBank(uInt16 address, uInt8)
|
|||
// Switch banks if necessary
|
||||
switch(address)
|
||||
{
|
||||
case 0x0FF8:
|
||||
case 0x1FF8:
|
||||
// Set the current bank to the lower 4k bank
|
||||
bank(0);
|
||||
return true;
|
||||
|
||||
case 0x0FF9:
|
||||
case 0x1FF9:
|
||||
// Set the current bank to the upper 4k bank
|
||||
bank(1);
|
||||
return true;
|
||||
|
|
|
@ -30,9 +30,9 @@ CartridgeFA::CartridgeFA(const ByteBuffer& image, size_t size,
|
|||
bool CartridgeFA::checkSwitchBank(uInt16 address, uInt8)
|
||||
{
|
||||
// Switch banks if necessary
|
||||
if((address >= 0x0FF8) && (address <= 0x0FFA))
|
||||
if((address >= 0x1FF8) && (address <= 0x1FFA))
|
||||
{
|
||||
bank(address - 0x0FF8);
|
||||
bank(address - 0x1FF8);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -42,9 +42,9 @@ CartridgeFA2::CartridgeFA2(const ByteBuffer& image, size_t size,
|
|||
bool CartridgeFA2::checkSwitchBank(uInt16 address, uInt8)
|
||||
{
|
||||
// Switch banks if necessary
|
||||
if((address >= 0x0FF5) && (address <= 0x0FFB))
|
||||
if((address >= 0x1FF5) && (address <= 0x1FFB))
|
||||
{
|
||||
bank(address - 0x0FF5);
|
||||
bank(address - 0x1FF5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -37,7 +37,7 @@ void CartridgeFC::reset()
|
|||
bool CartridgeFC::checkSwitchBank(uInt16 address, uInt8)
|
||||
{
|
||||
// Switch banks if necessary
|
||||
if(address == 0x0FFC)
|
||||
if(address == 0x1FFC)
|
||||
{
|
||||
// Trigger the bank switch
|
||||
bank(myTargetBank);
|
||||
|
|
Loading…
Reference in New Issue