Refine and unify late RESx during hblank, comments.

This commit is contained in:
Christian Speckner 2016-12-18 22:47:24 +01:00
parent f4932b8bf5
commit 7d7c0f6c9e
8 changed files with 38 additions and 14 deletions

View File

@ -69,9 +69,9 @@ void Ball::hmbl(uInt8 value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::resbl(bool hblank, bool extendedHblank) void Ball::resbl(uInt8 counter)
{ {
myCounter = hblank ? (extendedHblank ? 158 : 159) : 157; myCounter = counter;
myIsRendering = true; myIsRendering = true;
myRenderCounter = Count::renderCounterOffset; myRenderCounter = Count::renderCounterOffset;

View File

@ -39,7 +39,7 @@ class Ball : public Serializable
void hmbl(uInt8 value); void hmbl(uInt8 value);
uInt8 hmbl() const { return myHmmClocks; } uInt8 hmbl() const { return myHmmClocks; }
void resbl(bool hblank, bool extendedHblank); void resbl(uInt8 counter);
void ctrlpf(uInt8 value); void ctrlpf(uInt8 value);

View File

@ -69,9 +69,9 @@ void Missile::hmm(uInt8 value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::resm(bool hblank, bool extendedHblank) void Missile::resm(uInt8 counter)
{ {
myCounter = hblank ? (extendedHblank ? 158 : 159) : 157; myCounter = counter;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -39,7 +39,7 @@ class Missile : public Serializable
void hmm(uInt8 value); void hmm(uInt8 value);
uInt32 hmm() const { return myHmmClocks; } uInt32 hmm() const { return myHmmClocks; }
void resm(bool hblank, bool extendHblank); void resm(uInt8 counter);
void resmp(uInt8 value, const Player& player); void resmp(uInt8 value, const Player& player);
bool resmp() const { return bool(myResmp); } bool resmp() const { return bool(myResmp); }

View File

@ -88,6 +88,8 @@ void Player::nusiz(uInt8 value)
if (myIsRendering && myRenderCounter >= myWidth) if (myIsRendering && myRenderCounter >= myWidth)
myIsRendering = false; myIsRendering = false;
// NUSIZ during decode seems to affect the decoding logic. The rods in Meltdown
// are highly sensitive to this effect, and this seems to model it adequately.
if (myIsRendering && myRenderCounter < 0 && myWidth > 8 && oldWidth == 8) if (myIsRendering && myRenderCounter < 0 && myWidth > 8 && oldWidth == 8)
myRenderCounter += (myRenderCounter < -2 ? -1 : 1); myRenderCounter += (myRenderCounter < -2 ? -1 : 1);
@ -95,12 +97,14 @@ void Player::nusiz(uInt8 value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::resp(bool hblank, bool extendedHblank) void Player::resp(uInt8 counter)
{ {
myCounter = hblank ? (extendedHblank ? 158 : 159) : 157; myCounter = counter;
const Int8 renderCounterOffset = myWidth > 8 ? Count::renderCounterOffsetWide : Count::renderCounterOffset; const Int8 renderCounterOffset = myWidth > 8 ? Count::renderCounterOffsetWide : Count::renderCounterOffset;
// This tries to account for the effects of RESP during draw counter decode as
// described in Andrew Towers' notes. Still room for tuning.'
if (myIsRendering && (myRenderCounter - renderCounterOffset) < 4) if (myIsRendering && (myRenderCounter - renderCounterOffset) < 4)
myRenderCounter = renderCounterOffset; myRenderCounter = renderCounterOffset;
} }

View File

@ -40,7 +40,7 @@ class Player : public Serializable
void nusiz(uInt8 value); void nusiz(uInt8 value);
void resp(bool hblank, bool extendedHblank); void resp(uInt8 counter);
void refp(uInt8 value); void refp(uInt8 value);
bool refp() const { return myIsReflected; } bool refp() const { return myIsReflected; }

View File

@ -57,6 +57,17 @@ enum DummyRegisters: uInt8 {
shuffleBL = 0xF2 shuffleBL = 0xF2
}; };
enum ResxCounter: uInt8 {
hblank = 159,
lateHblank = 158,
frame = 157
};
// This parameter still has room for tuning. If we go lower than 73, long005 will show
// a slight artifact (still have to crosscheck on real hardware), if we go lower than
// 70, the G.I. Joe will show an artifact (hole in roof).
static constexpr uInt8 resxLateHblankThreshold = 73;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIA::TIA(Console& console, Sound& sound, Settings& settings) TIA::TIA(Console& console, Sound& sound, Settings& settings)
: myConsole(console), : myConsole(console),
@ -451,12 +462,12 @@ bool TIA::poke(uInt16 address, uInt8 value)
case RESM0: case RESM0:
myLinesSinceChange = 0; myLinesSinceChange = 0;
myMissile0.resm(myHstate == HState::blank, myHctr >= 68); myMissile0.resm(resxCounter());
break; break;
case RESM1: case RESM1:
myLinesSinceChange = 0; myLinesSinceChange = 0;
myMissile1.resm(myHstate == HState::blank, myHctr >= 68); myMissile1.resm(resxCounter());
break; break;
case RESMP0: case RESMP0:
@ -520,12 +531,12 @@ bool TIA::poke(uInt16 address, uInt8 value)
case RESP0: case RESP0:
myLinesSinceChange = 0; myLinesSinceChange = 0;
myPlayer0.resp(myHstate == HState::blank, myHctr >= 68); myPlayer0.resp(resxCounter());
break; break;
case RESP1: case RESP1:
myLinesSinceChange = 0; myLinesSinceChange = 0;
myPlayer1.resp(myHstate == HState::blank, myHctr >= 68); myPlayer1.resp(resxCounter());
break; break;
case REFP0: case REFP0:
@ -560,7 +571,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
case RESBL: case RESBL:
myLinesSinceChange = 0; myLinesSinceChange = 0;
myBall.resbl(myHstate == HState::blank, myHctr >= 68); myBall.resbl(resxCounter());
break; break;
case VDELBL: case VDELBL:
@ -1235,6 +1246,13 @@ void TIA::updatePaddle(uInt8 idx)
myTimestamp, myFrameManager.tvMode()); myTimestamp, myFrameManager.tvMode());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIA::resxCounter()
{
return myHstate == HState::blank ?
(myHctr >= resxLateHblankThreshold ? ResxCounter::lateHblank : ResxCounter::hblank) : ResxCounter::frame;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIA::collCXM0P() const uInt8 TIA::collCXM0P() const
{ {

View File

@ -380,6 +380,8 @@ class TIA : public Device
void updatePaddle(uInt8 idx); void updatePaddle(uInt8 idx);
uInt8 resxCounter();
/** /**
Get the result of the specified collision register. Get the result of the specified collision register.
*/ */