From 7325cd8034c1a98e423937303aa7649c44253302 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Mon, 20 Mar 2017 00:31:29 +0100 Subject: [PATCH] Fully match missile starfield to hardware. --- src/emucore/tia/Missile.cxx | 28 ++++++++++++++-------------- src/emucore/tia/Missile.hxx | 6 +++--- src/emucore/tia/TIA.cxx | 12 ++++++------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/emucore/tia/Missile.cxx b/src/emucore/tia/Missile.cxx index 7a0c8498f..672efb8e8 100644 --- a/src/emucore/tia/Missile.cxx +++ b/src/emucore/tia/Missile.cxx @@ -151,42 +151,42 @@ void Missile::startMovement() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Missile::movementTick(uInt32 clock, bool apply) +bool Missile::movementTick(uInt8 clock, uInt8 hclock, bool apply) { myLastMovementTick = myCounter; if (clock == myHmmClocks) myIsMoving = false; if (myIsMoving && apply) { - render(); - tick(false); + render(hclock); + tick(hclock); } return myIsMoving; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Missile::render() +void Missile::render(uInt8 hclock) { - collision = (myIsRendering && myRenderCounter >= 0 && myIsEnabled) ? - myCollisionMaskEnabled : - myCollisionMaskDisabled; + bool render = + myIsRendering && + (myRenderCounter >= 0 || (myIsMoving && myRenderCounter == -1 && ((hclock + 1) % 4 == 3))) && + myIsEnabled; + + collision = render ? myCollisionMaskEnabled : myCollisionMaskDisabled; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Missile::tick(bool isReceivingMclock) +void Missile::tick(uInt8 hclock) { if (myDecodes[myCounter]) { myIsRendering = true; myRenderCounter = Count::renderCounterOffset; - } else if (myIsRendering) { - bool starfieldEffect = myIsMoving && isReceivingMclock; - uInt8 starfieldDelta = (myCounter + 160 - myLastMovementTick + 2) % 4; - if (myRenderCounter == -2 && starfieldEffect) { + if (myIsMoving && myRenderCounter == -1) { - switch (starfieldDelta) { + switch ((hclock + 1) % 4) { case 3: myEffectiveWidth = myWidth == 1 ? 2 : myWidth; if (myWidth < 4) myRenderCounter++; @@ -203,7 +203,7 @@ void Missile::tick(bool isReceivingMclock) } - if (++myRenderCounter >= (starfieldEffect ? myEffectiveWidth : myWidth)) myIsRendering = false; + if (++myRenderCounter >= (myIsMoving ? myEffectiveWidth : myWidth)) myIsRendering = false; } if (++myCounter >= 160) myCounter = 0; diff --git a/src/emucore/tia/Missile.hxx b/src/emucore/tia/Missile.hxx index 5634995f0..0670d4d70 100644 --- a/src/emucore/tia/Missile.hxx +++ b/src/emucore/tia/Missile.hxx @@ -46,11 +46,11 @@ class Missile : public Serializable void startMovement(); - bool movementTick(uInt32 clock, bool apply); + bool movementTick(uInt8 clock, uInt8 hclock, bool apply); - void render(); + void render(uInt8 hclock); - void tick(bool isReceivingMclock = true); + void tick(uInt8 hclock); void setColor(uInt8 color); diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 079d9e0bc..c9385dab8 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -897,8 +897,8 @@ void TIA::tickMovement() bool m = false; uInt8 movementCounter = myMovementClock > 15 ? 0 : myMovementClock; - m = myMissile0.movementTick(movementCounter, apply) || m; - m = myMissile1.movementTick(movementCounter, apply) || m; + 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; @@ -960,16 +960,16 @@ void TIA::renderSprites() { myPlayer0.render(); myPlayer1.render(); - myMissile0.render(); - myMissile1.render(); + myMissile0.render(myHctr); + myMissile1.render(myHctr); myBall.render(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::tickSprites() { - myMissile0.tick(); - myMissile1.tick(); + myMissile0.tick(myHctr); + myMissile1.tick(myHctr); myPlayer0.tick(); myPlayer1.tick(); myBall.tick();