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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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