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;
myCounter = 0;
myIsMoving = false;
myEffectiveWidth = 1;
myLastMovementTick = 0;
myWidth = 1;
myIsRendering = false;
myDebugEnabled = false;
@ -135,11 +137,13 @@ void Ball::startMovement()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Ball::movementTick(uInt32 clock, bool apply)
{
myLastMovementTick = myCounter;
if (clock == myHmmClocks) myIsMoving = false;
if (myIsMoving && apply) {
render();
tick();
tick(false);
}
return myIsMoving;
@ -154,13 +158,32 @@ void Ball::render()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::tick()
void Ball::tick(bool isReceivingMclock)
{
bool starfieldEffect = myIsMoving && isReceivingMclock;
if (myCounter == 156) {
myIsRendering = true;
myRenderCounter = Count::renderCounterOffset;
}
else if (myIsRendering && ++myRenderCounter >= myWidth)
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)

View File

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

View File

@ -45,7 +45,9 @@ void Missile::reset()
myHmmClocks = 0;
myCounter = 0;
myIsMoving = false;
myLastMovementTick = 0;
myWidth = 1;
myEffectiveWidth = 1;
myIsRendering = false;
myRenderCounter = 0;
myColor = myObjectColor = myDebugColor = 0;
@ -124,11 +126,13 @@ void Missile::startMovement()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Missile::movementTick(uInt32 clock, bool apply)
{
myLastMovementTick = myCounter;
if (clock == myHmmClocks) myIsMoving = false;
if (myIsMoving && apply) {
render();
tick();
tick(false);
}
return myIsMoving;
@ -143,14 +147,35 @@ void Missile::render()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::tick()
void Missile::tick(bool isReceivingMclock)
{
bool starfieldEffect = myIsMoving && isReceivingMclock;
if (myDecodes[myCounter]) {
myIsRendering = true;
myRenderCounter = Count::renderCounterOffset;
} else if (myIsRendering && ++myRenderCounter >= myWidth) {
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;
}

View File

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