diff --git a/src/emucore/Cart3F.hxx b/src/emucore/Cart3F.hxx index d9f3e9fa6..7bdcbd99c 100644 --- a/src/emucore/Cart3F.hxx +++ b/src/emucore/Cart3F.hxx @@ -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 diff --git a/src/emucore/CartE0.cxx b/src/emucore/CartE0.cxx index 97752e447..d9c37d7e4 100644 --- a/src/emucore/CartE0.cxx +++ b/src/emucore/CartE0.cxx @@ -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)) { diff --git a/src/emucore/CartEnhanced.cxx b/src/emucore/CartEnhanced.cxx index 05f954e3e..ea167b1d5 100644 --- a/src/emucore/CartEnhanced.cxx +++ b/src/emucore/CartEnhanced.cxx @@ -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) diff --git a/src/emucore/CartEnhanced.hxx b/src/emucore/CartEnhanced.hxx index ecf8a0a58..c3702d118 100644 --- a/src/emucore/CartEnhanced.hxx +++ b/src/emucore/CartEnhanced.hxx @@ -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; diff --git a/src/emucore/CartF0.cxx b/src/emucore/CartF0.cxx index 9f021a685..8747c57f3 100644 --- a/src/emucore/CartF0.cxx +++ b/src/emucore/CartF0.cxx @@ -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; diff --git a/src/emucore/CartF4.cxx b/src/emucore/CartF4.cxx index 0cb689228..6a8cd6e00 100644 --- a/src/emucore/CartF4.cxx +++ b/src/emucore/CartF4.cxx @@ -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; diff --git a/src/emucore/CartF6.cxx b/src/emucore/CartF6.cxx index 567424d7a..50e993e26 100644 --- a/src/emucore/CartF6.cxx +++ b/src/emucore/CartF6.cxx @@ -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; diff --git a/src/emucore/CartF8.cxx b/src/emucore/CartF8.cxx index 79b4708c4..5d898091c 100644 --- a/src/emucore/CartF8.cxx +++ b/src/emucore/CartF8.cxx @@ -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; diff --git a/src/emucore/CartFA.cxx b/src/emucore/CartFA.cxx index 3f1062f41..082e403f7 100644 --- a/src/emucore/CartFA.cxx +++ b/src/emucore/CartFA.cxx @@ -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; diff --git a/src/emucore/CartFA2.cxx b/src/emucore/CartFA2.cxx index 6662e8171..14c8f2156 100644 --- a/src/emucore/CartFA2.cxx +++ b/src/emucore/CartFA2.cxx @@ -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; diff --git a/src/emucore/CartFC.cxx b/src/emucore/CartFC.cxx index 925718d50..c415ba1af 100644 --- a/src/emucore/CartFC.cxx +++ b/src/emucore/CartFC.cxx @@ -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);