Effective discription of starfield width modulation for missiles and ball.

This commit is contained in:
Christian Speckner 2016-12-09 00:47:52 +01:00
parent a9d1ed3741
commit 400b333386
4 changed files with 62 additions and 10 deletions

View File

@ -46,6 +46,8 @@ void Ball::reset()
myHmmClocks = 0; myHmmClocks = 0;
myCounter = 0; myCounter = 0;
myIsMoving = false; myIsMoving = false;
myEffectiveWidth = 1;
myLastMovementTick = 0;
myWidth = 1; myWidth = 1;
myIsRendering = false; myIsRendering = false;
myDebugEnabled = false; myDebugEnabled = false;
@ -135,11 +137,13 @@ void Ball::startMovement()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Ball::movementTick(uInt32 clock, bool apply) bool Ball::movementTick(uInt32 clock, bool apply)
{ {
myLastMovementTick = myCounter;
if (clock == myHmmClocks) myIsMoving = false; if (clock == myHmmClocks) myIsMoving = false;
if (myIsMoving && apply) { if (myIsMoving && apply) {
render(); render();
tick(); tick(false);
} }
return myIsMoving; return myIsMoving;
@ -154,13 +158,32 @@ void Ball::render()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::tick() void Ball::tick(bool isReceivingMclock)
{ {
bool starfieldEffect = myIsMoving && isReceivingMclock;
if (myCounter == 156) { if (myCounter == 156) {
myIsRendering = true; myIsRendering = true;
myRenderCounter = Count::renderCounterOffset; myRenderCounter = Count::renderCounterOffset;
uInt8 starfieldDelta = (myCounter + 160 - myLastMovementTick) % 4;
if (starfieldEffect && starfieldDelta == 3) myRenderCounter++;
switch (starfieldDelta) {
case 3:
myEffectiveWidth = myWidth == 1 ? 2 : myWidth;
break;
case 2:
myEffectiveWidth = 0;
break;
default:
myEffectiveWidth = myWidth;
break;
} }
else if (myIsRendering && ++myRenderCounter >= myWidth)
} else if (myIsRendering && ++myRenderCounter >= (starfieldEffect ? myEffectiveWidth : myWidth))
myIsRendering = false; myIsRendering = false;
if (++myCounter >= 160) if (++myCounter >= 160)

View File

@ -60,7 +60,7 @@ class Ball : public Serializable
void render(); void render();
void tick(); void tick(bool isReceivingMclock = true);
uInt8 getPixel(uInt8 colorIn) const { uInt8 getPixel(uInt8 colorIn) const {
return (collision & 0x8000) ? myColor : colorIn; return (collision & 0x8000) ? myColor : colorIn;
@ -103,6 +103,8 @@ class Ball : public Serializable
uInt8 myCounter; uInt8 myCounter;
bool myIsMoving; bool myIsMoving;
uInt8 myWidth; uInt8 myWidth;
uInt8 myEffectiveWidth;
uInt8 myLastMovementTick;
bool myIsRendering; bool myIsRendering;
Int8 myRenderCounter; Int8 myRenderCounter;

View File

@ -45,7 +45,9 @@ void Missile::reset()
myHmmClocks = 0; myHmmClocks = 0;
myCounter = 0; myCounter = 0;
myIsMoving = false; myIsMoving = false;
myLastMovementTick = 0;
myWidth = 1; myWidth = 1;
myEffectiveWidth = 1;
myIsRendering = false; myIsRendering = false;
myRenderCounter = 0; myRenderCounter = 0;
myColor = myObjectColor = myDebugColor = 0; myColor = myObjectColor = myDebugColor = 0;
@ -124,11 +126,13 @@ void Missile::startMovement()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Missile::movementTick(uInt32 clock, bool apply) bool Missile::movementTick(uInt32 clock, bool apply)
{ {
myLastMovementTick = myCounter;
if (clock == myHmmClocks) myIsMoving = false; if (clock == myHmmClocks) myIsMoving = false;
if (myIsMoving && apply) { if (myIsMoving && apply) {
render(); render();
tick(); tick(false);
} }
return myIsMoving; return myIsMoving;
@ -143,15 +147,36 @@ void Missile::render()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::tick() void Missile::tick(bool isReceivingMclock)
{ {
bool starfieldEffect = myIsMoving && isReceivingMclock;
if (myDecodes[myCounter]) { if (myDecodes[myCounter]) {
myIsRendering = true; myIsRendering = true;
myRenderCounter = Count::renderCounterOffset; myRenderCounter = Count::renderCounterOffset;
} else if (myIsRendering && ++myRenderCounter >= myWidth) {
myIsRendering = false; uInt8 starfieldDelta = (myCounter + 160 - myLastMovementTick) % 4;
if (starfieldEffect && starfieldDelta == 3) myRenderCounter++;
switch (starfieldDelta) {
case 3:
myEffectiveWidth = myWidth == 1 ? 2 : myWidth;
break;
case 2:
myEffectiveWidth = 0;
break;
default:
myEffectiveWidth = myWidth;
break;
} }
} else if (
myIsRendering && ++myRenderCounter >= (starfieldEffect ? myEffectiveWidth : myWidth)
)
myIsRendering = false;
if (++myCounter >= 160) myCounter = 0; if (++myCounter >= 160) myCounter = 0;
} }

View File

@ -51,7 +51,7 @@ class Missile : public Serializable
void render(); void render();
void tick(); void tick(bool isReceivingMclock = true);
void setColor(uInt8 color); void setColor(uInt8 color);
@ -96,6 +96,8 @@ class Missile : public Serializable
uInt8 myCounter; uInt8 myCounter;
bool myIsMoving; bool myIsMoving;
uInt8 myWidth; uInt8 myWidth;
uInt8 myEffectiveWidth;
uInt8 myLastMovementTick;
bool myIsRendering; bool myIsRendering;
Int8 myRenderCounter; Int8 myRenderCounter;