mirror of https://github.com/stella-emu/stella.git
slightly optimized movementTick
copied movementTick comments from ball to player and missile
This commit is contained in:
parent
6ead8ca42c
commit
d2c36ae159
|
@ -345,19 +345,20 @@ void Ball::movementTick(uInt32 clock, bool hblank)
|
||||||
{
|
{
|
||||||
myLastMovementTick = myCounter;
|
myLastMovementTick = myCounter;
|
||||||
|
|
||||||
// Stop movement once the number of clocks according to HMBL is reached
|
|
||||||
if (clock == myHmmClocks)
|
|
||||||
isMoving = false;
|
|
||||||
|
|
||||||
if(isMoving)
|
if(isMoving)
|
||||||
{
|
{
|
||||||
// Process the tick if we are in hblank. Otherwise, the tick is either masked
|
// Stop movement once the number of clocks according to HMBL is reached
|
||||||
// by an ordinary tick or merges two consecutive ticks into a single tick (inverted
|
if (clock == myHmmClocks)
|
||||||
// movement clock phase mode).
|
isMoving = false;
|
||||||
if (hblank) tick(false);
|
else
|
||||||
|
{
|
||||||
// Track a tick outside hblank for later processing
|
// Process the tick if we are in hblank. Otherwise, the tick is either masked
|
||||||
myInvertedPhaseClock = !hblank;
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
|
||||||
{
|
{
|
||||||
if (hblank) tick(hclock, false);
|
// Stop movement once the number of clocks according to HMMx is reached
|
||||||
myInvertedPhaseClock = !hblank;
|
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)
|
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:
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
if (hblank) tick();
|
// Stop movement once the number of clocks according to HMPx is reached
|
||||||
myInvertedPhaseClock = !hblank;
|
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()
|
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;
|
||||||
|
|
Loading…
Reference in New Issue