Skip to content

Commit

Permalink
slightly optimized movementTick
Browse files Browse the repository at this point in the history
copied movementTick comments from ball to player and missile
  • Loading branch information
thrust26 committed Jan 20, 2024
1 parent 6ead8ca commit d2c36ae
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
23 changes: 12 additions & 11 deletions src/emucore/tia/Ball.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
23 changes: 18 additions & 5 deletions src/emucore/tia/Missile.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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:
Expand Down
19 changes: 14 additions & 5 deletions src/emucore/tia/Player.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d2c36ae

Please sign in to comment.