slightly optimized movementTick

copied movementTick comments from ball to player and missile
This commit is contained in:
thrust26 2024-01-20 10:29:34 +01:00
parent 6ead8ca42c
commit d2c36ae159
3 changed files with 44 additions and 21 deletions

View File

@ -345,21 +345,22 @@ void Ball::movementTick(uInt32 clock, bool hblank)
{ {
myLastMovementTick = myCounter; myLastMovementTick = myCounter;
if(isMoving)
{
// Stop movement once the number of clocks according to HMBL is reached // Stop movement once the number of clocks according to HMBL is reached
if (clock == myHmmClocks) if (clock == myHmmClocks)
isMoving = false; isMoving = false;
else
if(isMoving)
{ {
// Process the tick if we are in hblank. Otherwise, the tick is either masked // 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 // by an ordinary tick or merges two consecutive ticks into a single tick (inverted
// movement clock phase mode). // movement clock phase mode).
if(hblank) tick(false); if(hblank) tick(false);
// Track a tick outside hblank for later processing // Track a tick outside hblank for later processing
myInvertedPhaseClock = !hblank; myInvertedPhaseClock = !hblank;
} }
} }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::tick(bool isReceivingRegularClock) void Ball::tick(bool isReceivingRegularClock)

View File

@ -143,18 +143,28 @@ class Missile : public Serializable
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::movementTick(uInt8 clock, uInt8 hclock, bool hblank) void Missile::movementTick(uInt8 clock, uInt8 hclock, bool hblank)
{ {
if(clock == myHmmClocks) isMoving = false;
if(isMoving) if(isMoving)
{ {
// 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); if(hblank) tick(hclock, false);
// Track a tick outside hblank for later processing
myInvertedPhaseClock = !hblank; myInvertedPhaseClock = !hblank;
} }
} }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::tick(uInt8 hclock, bool isReceivingMclock) 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) if(myUseInvertedPhaseClock && myInvertedPhaseClock)
{ {
myInvertedPhaseClock = false; myInvertedPhaseClock = false;
@ -165,6 +175,8 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock)
myIsRendering && myIsRendering &&
(myRenderCounter >= 0 || (isMoving && isReceivingMclock && myRenderCounter == -1 && myWidth < 4 && ((hclock + 1) % 4 == 3))); (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; collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
if (myDecodes[myCounter] && !myResmp) { if (myDecodes[myCounter] && !myResmp) {
@ -174,6 +186,7 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock)
} else if (myIsRendering) { } else if (myIsRendering) {
if (myRenderCounter == -1) { if (myRenderCounter == -1) {
// Regular clock pulse during movement -> starfield mode
if (isMoving && isReceivingMclock) { if (isMoving && isReceivingMclock) {
switch ((hclock + 1) % 4) { switch ((hclock + 1) % 4) {
case 3: case 3:

View File

@ -159,19 +159,28 @@ class Player : public Serializable
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::movementTick(uInt32 clock, bool hblank) void Player::movementTick(uInt32 clock, bool hblank)
{ {
if (clock == myHmmClocks)
isMoving = false;
if(isMoving) if(isMoving)
{ {
// 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(); if(hblank) tick();
// Track a tick outside hblank for later processing
myInvertedPhaseClock = !hblank; myInvertedPhaseClock = !hblank;
} }
} }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::tick() 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) if(myUseInvertedPhaseClock && myInvertedPhaseClock)
{ {
myInvertedPhaseClock = false; myInvertedPhaseClock = false;