From ea89ef01b4c8fca80121202467cc9dce26206753 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 24 Apr 2019 17:11:37 -0230 Subject: [PATCH] Refactor DPC+ code wrt 'jitter'. The code and commenting now properly indicates that it is a difference in mask values, and not actually jitter (TV 'jitter' effect is actually something else, and is not causing the screen shaking here). --- Changes.txt | 10 +++++----- src/common/StateManager.cxx | 2 +- src/emucore/CartDPCPlus.cxx | 20 +++++++------------- src/emucore/CartDPCPlus.hxx | 11 ++++++----- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Changes.txt b/Changes.txt index 27791b955..cc3b433a2 100644 --- a/Changes.txt +++ b/Changes.txt @@ -63,12 +63,12 @@ * Fixed 'Dancing Plate (Unknown) (PAL)' to use joystick. - * Allow the DPC+ scheme to not enable 'jitter' effect for certain older - DPC+ driver versions; this allows 'Epic Adventure' ROM to finally - work in Stella. + * Allow the DPC+ scheme to not enable playfield 'jitter' effect for + certain older DPC+ driver versions; this allows 'Epic Adventure' ROM + to finally work in Stella. - * PNG image support is now conditionally compiled into Stella. All - major ports (Linux/macOS/Windows) have it enabled by default. + * PNG/ZIP image support is now conditionally compiled into Stella. + All major ports (Linux/macOS/Windows) have it enabled by default. -Have fun! diff --git a/src/common/StateManager.cxx b/src/common/StateManager.cxx index b175639ff..d5b82621d 100644 --- a/src/common/StateManager.cxx +++ b/src/common/StateManager.cxx @@ -27,7 +27,7 @@ #include "StateManager.hxx" -#define STATE_HEADER "06000003state" +#define STATE_HEADER "06000002state" // #define MOVIE_HEADER "03030000movie" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index 37022e1e2..eecdc8af9 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -37,7 +37,7 @@ CartridgeDPCPlus::CartridgeDPCPlus(const BytePtr& image, uInt32 size, myARMCycles(0), myFractionalClocks(0.0), myBankOffset(0), - myJitterEnabled(true) + myFractionalLowMask(0x0F00FF) { // Image is always 32K, but in the case of ROM > 29K, the image is // copied to the end of the buffer @@ -65,10 +65,10 @@ CartridgeDPCPlus::CartridgeDPCPlus(const BytePtr& image, uInt32 size, Thumbulator::ConfigureFor::DPCplus, this); - // Disable jitter on certain DPC+ driver versions - string driverMD5; - driverMD5 = MD5::hash(image, 3*1024); - myJitterEnabled = driverMD5 != "8dd73b44fd11c488326ce507cbeb19d1"; + // Currently only one known DPC+ ARM driver exhibits a problem + // with the default mask to use for DFxFRACLOW + if(MD5::hash(image, 3*1024) == "8dd73b44fd11c488326ce507cbeb19d1") + myFractionalLowMask = 0x0F0000; setInitialState(); } @@ -403,10 +403,10 @@ bool CartridgeDPCPlus::poke(uInt16 address, uInt8 value) switch(function) { - //DFxFRACLOW - fractional data pointer low byte + // DFxFRACLOW - fractional data pointer low byte case 0x00: myFractionalCounters[index] = - (myFractionalCounters[index] & (myJitterEnabled ? 0x0F00FF : 0x0F0000)) | (uInt16(value) << 8); + (myFractionalCounters[index] & myFractionalLowMask) | (uInt16(value) << 8); break; // DFxFRACHI - fractional data pointer high byte @@ -685,9 +685,6 @@ bool CartridgeDPCPlus::save(Serializer& out) const // Clock info for Thumbulator out.putLong(myARMCycles); - - // Jitter effect - out.putBool(myJitterEnabled); } catch(...) { @@ -749,9 +746,6 @@ bool CartridgeDPCPlus::load(Serializer& in) // Clock info for Thumbulator myARMCycles = in.getLong(); - - // Jitter effect - myJitterEnabled = in.getBool(); } catch(...) { diff --git a/src/emucore/CartDPCPlus.hxx b/src/emucore/CartDPCPlus.hxx index 740585767..8594382da 100644 --- a/src/emucore/CartDPCPlus.hxx +++ b/src/emucore/CartDPCPlus.hxx @@ -270,11 +270,12 @@ class CartridgeDPCPlus : public Cartridge // Indicates the offset into the ROM image (aligns to current bank) uInt16 myBankOffset; - // Indicates whether 'jitter' should be emulated - // This is the default option, and should always be enabled - // However, certain ROMs were released with older DPC+ ARM drivers, - // before the scheme was finalized; this allows those ROMs to run - bool myJitterEnabled; + // Older DPC+ driver code had different behaviour wrt the mask used + // to retrieve 'DFxFRACLOW' (fractional data pointer low byte) + // ROMs built with an old DPC+ driver and using the newer mask can + // result in 'jittering' in the playfield display + // For current versions, this is 0x0F00FF; older versions need 0x0F0000 + uInt32 myFractionalLowMask; private: // Following constructors and assignment operators not supported