Tentative fixes for collisions during HBLANK.

This commit is contained in:
Christian Speckner 2018-02-06 23:31:34 +01:00
parent 2874a7c504
commit 07f1051be0
8 changed files with 65 additions and 14 deletions

View File

@ -40,6 +40,7 @@ void Ball::reset()
myIsEnabledNew = false;
myIsEnabled = false;
myIsDelaying = false;
myIsVisible = false;
myHmmClocks = 0;
myCounter = 0;
myIsMoving = false;
@ -62,7 +63,11 @@ void Ball::enabl(uInt8 value)
if (myIsEnabledNew != enabledNewOldValue && !myIsDelaying) {
myTIA->flushLineCache();
updateEnabled();
collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
myTIA->updateCollision();
}
}
@ -173,9 +178,8 @@ bool Ball::movementTick(uInt32 clock, bool apply)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::tick(bool isReceivingMclock)
{
collision = (myIsRendering && myRenderCounter >= 0 && myIsEnabled) ?
myCollisionMaskEnabled :
myCollisionMaskDisabled;
myIsVisible = myIsRendering && myRenderCounter >= 0;
collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
bool starfieldEffect = myIsMoving && isReceivingMclock;
@ -207,6 +211,13 @@ void Ball::tick(bool isReceivingMclock)
myCounter = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::nextLine()
{
myIsVisible = myIsRendering && myRenderCounter >= 0;
collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::setENABLOld(bool enabled)
{

View File

@ -62,6 +62,8 @@ class Ball : public Serializable
void tick(bool isReceivingMclock = true);
void nextLine();
bool isOn() const { return (collision & 0x8000); }
uInt8 getColor() const { return myColor; }
@ -105,6 +107,7 @@ class Ball : public Serializable
bool myIsEnabled;
bool myIsSuppressed;
bool myIsDelaying;
bool myIsVisible;
uInt8 myHmmClocks;
uInt8 myCounter;

View File

@ -47,6 +47,7 @@ void Missile::reset()
myWidth = 1;
myEffectiveWidth = 1;
myIsRendering = false;
myIsVisible = false;
myRenderCounter = 0;
myColor = myObjectColor = myDebugColor = 0;
myDebugEnabled = false;
@ -62,9 +63,14 @@ void Missile::enam(uInt8 value)
myEnam = (value & 0x02) > 0;
if (oldEnam != myEnam) myTIA->flushLineCache();
if (oldEnam != myEnam) {
myTIA->flushLineCache();
updateEnabled();
updateEnabled();
collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
myTIA->updateCollision();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -174,12 +180,11 @@ bool Missile::movementTick(uInt8 clock, uInt8 hclock, bool apply)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::tick(uInt8 hclock)
{
const bool render =
myIsVisible =
myIsRendering &&
(myRenderCounter >= 0 || (myIsMoving && myRenderCounter == -1 && myWidth < 4 && ((hclock + 1) % 4 == 3))) &&
myIsEnabled;
(myRenderCounter >= 0 || (myIsMoving && myRenderCounter == -1 && myWidth < 4 && ((hclock + 1) % 4 == 3)));
collision = render ? myCollisionMaskEnabled : myCollisionMaskDisabled;
collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
if (myDecodes[myCounter] && !myResmp) {
myIsRendering = true;
@ -210,6 +215,13 @@ void Missile::tick(uInt8 hclock)
if (++myCounter >= 160) myCounter = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::nextLine()
{
myIsVisible = myIsRendering && (myRenderCounter >= 0);
collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::setColor(uInt8 color)
{

View File

@ -52,6 +52,8 @@ class Missile : public Serializable
void tick(uInt8 hclock);
void nextLine();
void setColor(uInt8 color);
void setDebugColor(uInt8 color);
@ -103,6 +105,7 @@ class Missile : public Serializable
uInt8 myLastMovementTick;
bool myIsRendering;
bool myIsVisible;
Int8 myRenderCounter;
const uInt8* myDecodes;

View File

@ -67,6 +67,11 @@ void Player::grp(uInt8 pattern)
if (!myIsDelaying && myPatternNew != oldPatternNew) {
myTIA->flushLineCache();
updatePattern();
if (myIsRendering && myRenderCounter >= myRenderCounterTripPoint) {
collision = (myPattern & (1 << mySampleCounter)) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
myTIA->updateCollision();
}
}
}
@ -309,6 +314,15 @@ void Player::tick()
if (++myCounter >= 160) myCounter = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::nextLine()
{
if (!myIsRendering || myRenderCounter < myRenderCounterTripPoint)
collision = myCollisionMaskDisabled;
else
collision = (myPattern & (1 << mySampleCounter)) ? myCollisionMaskEnabled : myCollisionMaskDisabled;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::shufflePatterns()
{

View File

@ -62,6 +62,9 @@ class Player : public Serializable
bool movementTick(uInt32 clock, bool apply);
void tick();
void nextLine();
uInt8 getClock() const { return myCounter; }
bool isOn() const { return (collision & 0x8000); }

View File

@ -1280,6 +1280,11 @@ void TIA::nextLine()
myHctrDelta = 0;
myFrameManager->nextLine();
myMissile0.nextLine();
myMissile1.nextLine();
myPlayer0.nextLine();
myPlayer1.nextLine();
myBall.nextLine();
if (myFrameManager->isRendering() && myFrameManager->getY() == 0) flushLineCache();

View File

@ -414,6 +414,11 @@ class TIA : public Device
*/
void flushLineCache();
/**
* Update the collision bitfield.
*/
void updateCollision();
/**
Create a new delayQueueIterator for the debugger.
*/
@ -510,11 +515,6 @@ class TIA : public Device
*/
void applyRsync();
/**
* Update the collision bitfield.
*/
void updateCollision();
/**
* Render the current pixel into the framebuffer.
*/