diff --git a/src/emucore/tia/Ball.cxx b/src/emucore/tia/Ball.cxx index 63144d6ea..2d627a086 100644 --- a/src/emucore/tia/Ball.cxx +++ b/src/emucore/tia/Ball.cxx @@ -44,7 +44,7 @@ void Ball::reset() myIsVisible = false; myHmmClocks = 0; myCounter = 0; - myIsMoving = false; + isMoving = false; myEffectiveWidth = 1; myLastMovementTick = 0; myWidth = 1; @@ -166,23 +166,7 @@ void Ball::setInvertedPhaseClock(bool enable) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Ball::startMovement() { - myIsMoving = true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Ball::movementTick(uInt32 clock, bool apply) -{ - myLastMovementTick = myCounter; - - if (clock == myHmmClocks) - myIsMoving = false; - else if(myIsMoving) - { - if(apply) tick(false); - else myInvertedPhaseClock = true; - } - - return myIsMoving; + isMoving = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -197,7 +181,7 @@ void Ball::tick(bool isReceivingMclock) myIsVisible = myIsRendering && myRenderCounter >= 0; collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled; - bool starfieldEffect = myIsMoving && isReceivingMclock; + bool starfieldEffect = isMoving && isReceivingMclock; if (myCounter == 156) { myIsRendering = true; @@ -325,7 +309,7 @@ bool Ball::save(Serializer& out) const out.putByte(myHmmClocks); out.putByte(myCounter); - out.putBool(myIsMoving); + out.putBool(isMoving); out.putByte(myWidth); out.putByte(myEffectiveWidth); out.putByte(myLastMovementTick); @@ -366,7 +350,7 @@ bool Ball::load(Serializer& in) myHmmClocks = in.getByte(); myCounter = in.getByte(); - myIsMoving = in.getBool(); + isMoving = in.getBool(); myWidth = in.getByte(); myEffectiveWidth = in.getByte(); myLastMovementTick = in.getByte(); diff --git a/src/emucore/tia/Ball.hxx b/src/emucore/tia/Ball.hxx index d1e8facb3..bf9085069 100644 --- a/src/emucore/tia/Ball.hxx +++ b/src/emucore/tia/Ball.hxx @@ -60,7 +60,20 @@ class Ball : public Serializable void startMovement(); - bool movementTick(uInt32 clock, bool apply); + void movementTick(uInt32 clock, bool hblank) + { + myLastMovementTick = myCounter; + + if (clock == myHmmClocks) + isMoving = false; + + if(isMoving) + { + if (hblank) tick(false); + myInvertedPhaseClock = !hblank; + } + } + void tick(bool isReceivingMclock = true); @@ -88,6 +101,7 @@ class Ball : public Serializable public: uInt32 collision; + bool isMoving; private: @@ -112,7 +126,6 @@ class Ball : public Serializable uInt8 myHmmClocks; uInt8 myCounter; - bool myIsMoving; uInt8 myWidth; uInt8 myEffectiveWidth; uInt8 myLastMovementTick; diff --git a/src/emucore/tia/Missile.cxx b/src/emucore/tia/Missile.cxx index b7265ac67..0ee3521b1 100644 --- a/src/emucore/tia/Missile.cxx +++ b/src/emucore/tia/Missile.cxx @@ -43,8 +43,7 @@ void Missile::reset() myResmp = 0; myHmmClocks = 0; myCounter = 0; - myIsMoving = false; - myLastMovementTick = 0; + isMoving = false; myWidth = 1; myEffectiveWidth = 1; myIsRendering = false; @@ -161,23 +160,7 @@ void Missile::nusiz(uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Missile::startMovement() { - myIsMoving = true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Missile::movementTick(uInt8 clock, uInt8 hclock, bool apply) -{ - myLastMovementTick = myCounter; - - if(clock == myHmmClocks) - myIsMoving = false; - else if(myIsMoving) - { - if(apply) tick(hclock, false); - else myInvertedPhaseClock = true; - } - - return myIsMoving; + isMoving = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -191,7 +174,7 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock) myIsVisible = myIsRendering && - (myRenderCounter >= 0 || (myIsMoving && isReceivingMclock && myRenderCounter == -1 && myWidth < 4 && ((hclock + 1) % 4 == 3))); + (myRenderCounter >= 0 || (isMoving && isReceivingMclock && myRenderCounter == -1 && myWidth < 4 && ((hclock + 1) % 4 == 3))); collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled; @@ -201,7 +184,7 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock) } else if (myIsRendering) { if (myRenderCounter == -1) { - if (myIsMoving && isReceivingMclock) { + if (isMoving && isReceivingMclock) { switch ((hclock + 1) % 4) { case 3: myEffectiveWidth = myWidth == 1 ? 2 : myWidth; @@ -221,7 +204,7 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock) } } - if (++myRenderCounter >= (myIsMoving ? myEffectiveWidth : myWidth)) myIsRendering = false; + if (++myRenderCounter >= (isMoving ? myEffectiveWidth : myWidth)) myIsRendering = false; } if (++myCounter >= TIA::H_PIXEL) myCounter = 0; @@ -334,10 +317,9 @@ bool Missile::save(Serializer& out) const out.putByte(myHmmClocks); out.putByte(myCounter); - out.putBool(myIsMoving); + out.putBool(isMoving); out.putByte(myWidth); out.putByte(myEffectiveWidth); - out.putByte(myLastMovementTick); out.putBool(myIsVisible); out.putBool(myIsRendering); @@ -375,10 +357,9 @@ bool Missile::load(Serializer& in) myHmmClocks = in.getByte(); myCounter = in.getByte(); - myIsMoving = in.getBool(); + isMoving = in.getBool(); myWidth = in.getByte(); myEffectiveWidth = in.getByte(); - myLastMovementTick = in.getByte(); myIsVisible = in.getBool(); myIsRendering = in.getBool(); diff --git a/src/emucore/tia/Missile.hxx b/src/emucore/tia/Missile.hxx index b4584abfe..ff6ceb557 100644 --- a/src/emucore/tia/Missile.hxx +++ b/src/emucore/tia/Missile.hxx @@ -48,7 +48,16 @@ class Missile : public Serializable void startMovement(); - bool movementTick(uInt8 clock, uInt8 hclock, bool apply); + void movementTick(uInt8 clock, uInt8 hclock, bool hblank) + { + if(clock == myHmmClocks) isMoving = false; + + if (isMoving) + { + if (hblank) tick(hclock, false); + myInvertedPhaseClock = !hblank; + } + } void tick(uInt8 hclock, bool isReceivingMclock = true); @@ -82,6 +91,7 @@ class Missile : public Serializable public: uInt32 collision; + bool isMoving; private: @@ -100,10 +110,9 @@ class Missile : public Serializable uInt8 myHmmClocks; uInt8 myCounter; - bool myIsMoving; + uInt8 myWidth; uInt8 myEffectiveWidth; - uInt8 myLastMovementTick; bool myIsRendering; bool myIsVisible; diff --git a/src/emucore/tia/Player.cxx b/src/emucore/tia/Player.cxx index 3a1b25507..c8b0163d5 100644 --- a/src/emucore/tia/Player.cxx +++ b/src/emucore/tia/Player.cxx @@ -40,7 +40,7 @@ void Player::reset() myDecodes = DrawCounterDecodes::get().playerDecodes()[myDecodesOffset]; myHmmClocks = 0; myCounter = 0; - myIsMoving = false; + isMoving = false; myIsRendering = false; myRenderCounter = 0; myPatternOld = 0; @@ -262,21 +262,7 @@ void Player::setInvertedPhaseClock(bool enable) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Player::startMovement() { - myIsMoving = true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Player::movementTick(uInt32 clock, bool apply) -{ - if (clock == myHmmClocks) - myIsMoving = false; - else if(myIsMoving) - { - if(apply) tick(); - else myInvertedPhaseClock = true; - } - - return myIsMoving; + isMoving = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -472,7 +458,7 @@ bool Player::save(Serializer& out) const out.putByte(myHmmClocks); out.putByte(myCounter); - out.putBool(myIsMoving); + out.putBool(isMoving); out.putBool(myIsRendering); out.putByte(myRenderCounter); @@ -518,7 +504,7 @@ bool Player::load(Serializer& in) myHmmClocks = in.getByte(); myCounter = in.getByte(); - myIsMoving = in.getBool(); + isMoving = in.getBool(); myIsRendering = in.getBool(); myRenderCounter = in.getByte(); diff --git a/src/emucore/tia/Player.hxx b/src/emucore/tia/Player.hxx index f6f6bee0c..87e8a5cb8 100644 --- a/src/emucore/tia/Player.hxx +++ b/src/emucore/tia/Player.hxx @@ -61,7 +61,17 @@ class Player : public Serializable void startMovement(); - bool movementTick(uInt32 clock, bool apply); + void movementTick(uInt32 clock, bool hblank) + { + if (clock == myHmmClocks) + isMoving = false; + + if(isMoving) + { + if (hblank) tick(); + myInvertedPhaseClock = !hblank; + } + } void tick(); @@ -93,6 +103,7 @@ class Player : public Serializable public: uInt32 collision; + bool isMoving; private: @@ -113,7 +124,6 @@ class Player : public Serializable uInt8 myHmmClocks; uInt8 myCounter; - bool myIsMoving; bool myIsRendering; Int8 myRenderCounter; diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index b805734c6..a4f2d2461 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -1291,18 +1291,21 @@ void TIA::tickMovement() if (!myMovementInProgress) return; if ((myHctr & 0x03) == 0) { - const bool apply = myHstate == HState::blank; - bool m = false; + const bool hblank = myHstate == HState::blank; uInt8 movementCounter = myMovementClock > 15 ? 0 : myMovementClock; - m = myMissile0.movementTick(movementCounter, myHctr, apply) || m; - m = myMissile1.movementTick(movementCounter, myHctr, apply) || m; - m = myPlayer0.movementTick(movementCounter, apply) || m; - m = myPlayer1.movementTick(movementCounter, apply) || m; - m = myBall.movementTick(movementCounter, apply) || m; + myMissile0.movementTick(movementCounter, myHctr, hblank); + myMissile1.movementTick(movementCounter, myHctr, hblank); + myPlayer0.movementTick(movementCounter, hblank); + myPlayer1.movementTick(movementCounter, hblank); + myBall.movementTick(movementCounter, hblank); - myMovementInProgress = m; - myCollisionUpdateRequired = m; + myMovementInProgress = + myMissile0.isMoving | + myMissile1.isMoving | + myPlayer0.isMoving | + myPlayer1.isMoving | + myBall.isMoving; ++myMovementClock; }