From d2c36ae1593657c467c11f0612b6385c26d90a42 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 20 Jan 2024 10:29:34 +0100 Subject: [PATCH] slightly optimized movementTick copied movementTick comments from ball to player and missile --- src/emucore/tia/Ball.hxx | 23 ++++++++++++----------- src/emucore/tia/Missile.hxx | 23 ++++++++++++++++++----- src/emucore/tia/Player.hxx | 19 ++++++++++++++----- 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/emucore/tia/Ball.hxx b/src/emucore/tia/Ball.hxx index 667d070be..dc81b4289 100644 --- a/src/emucore/tia/Ball.hxx +++ b/src/emucore/tia/Ball.hxx @@ -345,19 +345,20 @@ void Ball::movementTick(uInt32 clock, bool hblank) { myLastMovementTick = myCounter; - // Stop movement once the number of clocks according to HMBL is reached - if (clock == myHmmClocks) - isMoving = false; - if(isMoving) { - // Process the tick if we are in hblank. Otherwise, the tick is either masked - // by an ordinary tick or merges two consecutive ticks into a single tick (inverted - // movement clock phase mode). - if (hblank) tick(false); - - // Track a tick outside hblank for later processing - myInvertedPhaseClock = !hblank; + // Stop movement once the number of clocks according to HMBL is reached + if (clock == myHmmClocks) + isMoving = false; + else + { + // Process the tick if we are in hblank. Otherwise, the tick is either masked + // by an ordinary tick or merges two consecutive ticks into a single tick (inverted + // movement clock phase mode). + if(hblank) tick(false); + // Track a tick outside hblank for later processing + myInvertedPhaseClock = !hblank; + } } } diff --git a/src/emucore/tia/Missile.hxx b/src/emucore/tia/Missile.hxx index 7432196bf..ae9a65593 100644 --- a/src/emucore/tia/Missile.hxx +++ b/src/emucore/tia/Missile.hxx @@ -143,18 +143,28 @@ class Missile : public Serializable // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Missile::movementTick(uInt8 clock, uInt8 hclock, bool hblank) { - if(clock == myHmmClocks) isMoving = false; - - if (isMoving) + if(isMoving) { - if (hblank) tick(hclock, false); - myInvertedPhaseClock = !hblank; + // Stop movement once the number of clocks according to HMMx is reached + if(clock == myHmmClocks) + isMoving = false; + else + { + // Process the tick if we are in hblank. Otherwise, the tick is either masked + // by an ordinary tick or merges two consecutive ticks into a single tick (inverted + // movement clock phase mode). + if(hblank) tick(hclock, false); + // Track a tick outside hblank for later processing + myInvertedPhaseClock = !hblank; + } } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Missile::tick(uInt8 hclock, bool isReceivingMclock) { + // If we are in inverted movement clock phase mode and a movement tick occurred, it + // will supress the tick. if(myUseInvertedPhaseClock && myInvertedPhaseClock) { myInvertedPhaseClock = false; @@ -165,6 +175,8 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock) myIsRendering && (myRenderCounter >= 0 || (isMoving && isReceivingMclock && myRenderCounter == -1 && myWidth < 4 && ((hclock + 1) % 4 == 3))); + // Consider enabled status and the signal to determine visibility (as represented + // by the collision mask) collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled; if (myDecodes[myCounter] && !myResmp) { @@ -174,6 +186,7 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock) } else if (myIsRendering) { if (myRenderCounter == -1) { + // Regular clock pulse during movement -> starfield mode if (isMoving && isReceivingMclock) { switch ((hclock + 1) % 4) { case 3: diff --git a/src/emucore/tia/Player.hxx b/src/emucore/tia/Player.hxx index f8d3686be..a6247005a 100644 --- a/src/emucore/tia/Player.hxx +++ b/src/emucore/tia/Player.hxx @@ -159,19 +159,28 @@ class Player : public Serializable // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Player::movementTick(uInt32 clock, bool hblank) { - if (clock == myHmmClocks) - isMoving = false; - if(isMoving) { - if (hblank) tick(); - myInvertedPhaseClock = !hblank; + // Stop movement once the number of clocks according to HMPx is reached + if (clock == myHmmClocks) + isMoving = false; + else + { + // Process the tick if we are in hblank. Otherwise, the tick is either masked + // by an ordinary tick or merges two consecutive ticks into a single tick (inverted + // movement clock phase mode). + if(hblank) tick(); + // Track a tick outside hblank for later processing + myInvertedPhaseClock = !hblank; + } } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Player::tick() { + // If we are in inverted movement clock phase mode and a movement tick occurred, it + // will supress the tick. if(myUseInvertedPhaseClock && myInvertedPhaseClock) { myInvertedPhaseClock = false;