From b3bfc86ccc522dbce4ada9c038c7ad5bfdee6f39 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Wed, 29 Mar 2017 18:18:35 +0200 Subject: [PATCH] Introduce shadow registers, start refactoring TIADebug to use them. --- src/debugger/TIADebug.cxx | 4 ++-- src/emucore/tia/Player.hxx | 1 - src/emucore/tia/TIA.cxx | 9 +++++++++ src/emucore/tia/TIA.hxx | 5 +++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 4bb8022e3..5bb5f6afd 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -185,7 +185,7 @@ bool TIADebug::vdelP0(int newVal) if(newVal > -1) mySystem.poke(VDELP0, bool(newVal)); - return myTIA.myPlayer0.vdelp(); + return (myTIA.valueLastWrittenToRegister(VDELP0) & 0x01) > 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -194,7 +194,7 @@ bool TIADebug::vdelP1(int newVal) if(newVal > -1) mySystem.poke(VDELP1, bool(newVal)); - return myTIA.myPlayer1.vdelp(); + return (myTIA.valueLastWrittenToRegister(VDELP1) & 0x01) > 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/tia/Player.hxx b/src/emucore/tia/Player.hxx index 1279dcfc1..07227478e 100644 --- a/src/emucore/tia/Player.hxx +++ b/src/emucore/tia/Player.hxx @@ -44,7 +44,6 @@ class Player : public Serializable bool refp() const { return myIsReflected; } void vdelp(uInt8 value); - bool vdelp() const { return myIsDelaying; } void toggleEnabled(bool enabled); diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 68e7cbc57..b5fc7bbe1 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -118,6 +118,8 @@ void TIA::reset() mySubClock = 0; myXDelta = 0; + memset(myShadowRegisters, 0, 64); + myBackground.reset(); myPlayfield.reset(); myMissile0.reset(); @@ -432,6 +434,7 @@ bool TIA::poke(uInt16 address, uInt8 value) updateEmulation(); address &= 0x3F; + myShadowRegisters[address] = value; switch (address) { @@ -923,6 +926,12 @@ void TIA::updateScanlineByTrace(int target) updateScanlineByStep(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt8 TIA::valueLastWrittenToRegister(uInt8 reg) const +{ + return reg < 64 ? myShadowRegisters[reg] : 0; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::updateEmulation() { diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index ee766a005..4a3ea8363 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -308,6 +308,9 @@ class TIA : public Device */ void updateScanlineByTrace(int target); + // Retrieve the last value written to a certain register + uInt8 valueLastWrittenToRegister(uInt8 reg) const; + /** Save the current state of this device to the given Serializer. @@ -459,6 +462,8 @@ class TIA : public Device double myTimestamp; + uInt8 myShadowRegisters[64]; + // Automatic framerate correction based on number of scanlines bool myAutoFrameEnabled;