From 37180e18df2091a009c6d8bd051611deb7142643 Mon Sep 17 00:00:00 2001 From: "Darrell Spice, Jr" Date: Thu, 24 Feb 2022 00:59:29 -0600 Subject: [PATCH] Fixed CDFJ+ issue if the first byte of the cartridge contained a value of FF_OFFSET thru FF_OFFSET + $23 (#879) Updated Thumbulator's debug mode to allow run-time updating of the FF_OFFSET value. --- src/emucore/CartCDF.cxx | 7 ++++--- src/emucore/CartCDF.hxx | 5 ++++- src/emucore/Thumbulator.cxx | 9 ++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index 5504c3b2e..6dee96c40 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -153,8 +153,9 @@ void CartridgeCDF::setInitialState() // need to confirm with Chris myMode = 0xFF; - myBankOffset = myLDAXYimmediateOperandAddress = myJMPoperandAddress = 0; + myBankOffset = myJMPoperandAddress = 0; myFastJumpActive = myFastJumpStream = 0; + myLDAXYimmediateOperandAddress = LDAXY_OVERRIDE_INACTIVE; CartridgeARM::setInitialState(); } @@ -290,7 +291,7 @@ uInt8 CartridgeCDF::peek(uInt16 address) && peekvalue <= myAmplitudeStream); if (fastfetch) { - myLDAXYimmediateOperandAddress = 0; + myLDAXYimmediateOperandAddress = LDAXY_OVERRIDE_INACTIVE; if (myFastFetcherOffset) peekvalue -= myRAM[myFastFetcherOffset]; // normalize peekvalue to 0 - 35 if (peekvalue == myAmplitudeStream) @@ -329,7 +330,7 @@ uInt8 CartridgeCDF::peek(uInt16 address) return readFromDatastream(peekvalue); } } - myLDAXYimmediateOperandAddress = 0; + myLDAXYimmediateOperandAddress = LDAXY_OVERRIDE_INACTIVE; // Switch banks if necessary switch(address) diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index 5a822311d..1ec6b5622 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -58,6 +58,9 @@ class System; @authors: Darrell Spice Jr, Chris Walton, Fred Quimby, John Champeau Thomas Jentzsch, Stephen Anthony, Bradford W. Mott */ + +#define LDAXY_OVERRIDE_INACTIVE 0xFFFF + class CartridgeCDF : public CartridgeARM { friend class CartridgeCDFWidget; @@ -341,7 +344,7 @@ class CartridgeCDF : public CartridgeARM // set to address of #value if last byte peeked was A9 (LDA #), // or for CDFJ+ variations if A0 (LDY #) or A2 (LDX #) - uInt16 myLDAXYimmediateOperandAddress{0}; + uInt16 myLDAXYimmediateOperandAddress{LDAXY_OVERRIDE_INACTIVE}; // Some CDFJ+ drivers also override LDX # and/or LDY # for fast fetcher // use. These flag if this has been done. diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index 48c26ace9..a71f2cb5c 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -548,6 +548,11 @@ void Thumbulator::write32(uInt32 addr, uInt32 data) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Thumbulator::isProtected(uInt32 addr) { + // Protected is within the driver RAM. + // For CDF variations parts of the driver RAM are reused to hold the + // datastream information, so is not protected. + // Additionally for CDFJ+ the Fast Fetcher offset is not write protected. + if (addr < 0x40000000) return false; addr -= 0x40000000; @@ -562,9 +567,11 @@ bool Thumbulator::isProtected(uInt32 addr) return (addr < 0x0800) && (addr > 0x0028) && !((addr >= 0x00a0) && (addr < (0x00a0 + 284))); case ConfigureFor::CDFJ: - case ConfigureFor::CDFJplus: return (addr < 0x0800) && (addr > 0x0028) && !((addr >= 0x0098) && (addr < (0x0098 + 292))); + case ConfigureFor::CDFJplus: + return (addr < 0x0800) && (addr > 0x0028) && !((addr >= 0x0098) && (addr < (0x0098 + 292))) && addr != 0x3E0; + case ConfigureFor::BUS: return (addr < 0x06d8) && (addr > 0x0028); }