From 92d30c2a9c2e0d72909463f012e3191614473de2 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 3 May 2020 08:45:15 +0200 Subject: [PATCH] fixed 3E bankswitching --- src/emucore/Cart3E.cxx | 15 +++++++++++++++ src/emucore/Cart3E.hxx | 9 +++++++++ src/emucore/CartEnhanced.cxx | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index 642ac6ce1..be69d105d 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -71,3 +71,18 @@ uInt8 Cartridge3E::peek(uInt16 address) return CartridgeEnhanced::peek(peekAddress); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge3E::poke(uInt16 address, uInt8 value) +{ + uInt16 pokeAddress = address; + address &= ROM_MASK; + + if(address < 0x0040) // TIA access + { + checkSwitchBank(address, value); + return mySystem->tia().poke(address, value); + } + + return CartridgeEnhanced::poke(pokeAddress, value); +} diff --git a/src/emucore/Cart3E.hxx b/src/emucore/Cart3E.hxx index 613fa610c..f2ead51f5 100644 --- a/src/emucore/Cart3E.hxx +++ b/src/emucore/Cart3E.hxx @@ -113,6 +113,15 @@ class Cartridge3E : public CartridgeEnhanced */ uInt8 peek(uInt16 address) override; + /** + Change the byte at the specified address to the given value + + @param address The address where the value should be stored + @param value The value to be stored at the address + @return True if the poke changed the device address space, else false + */ + bool poke(uInt16 address, uInt8 value) override; + private: bool checkSwitchBank(uInt16 address, uInt8 value) override; diff --git a/src/emucore/CartEnhanced.cxx b/src/emucore/CartEnhanced.cxx index d5ccf6591..f5c38c9a3 100644 --- a/src/emucore/CartEnhanced.cxx +++ b/src/emucore/CartEnhanced.cxx @@ -232,7 +232,7 @@ bool CartridgeEnhanced::bank(uInt16 bank, uInt16 segment) uInt32 bankOffset = uInt32(mySize) + (ramBank << (myBankShift - 1)); // Remember what bank is in this segment - myCurrentSegOffset[segment] = bank << myBankShift; + myCurrentSegOffset[segment] = uInt32(mySize) + (ramBank << myBankShift); // Set the page accessing method for the RAM writing pages uInt16 fromAddr = (ROM_OFFSET + segmentOffset + myWriteOffset) & ~System::PAGE_MASK;