Introduce shadow registers, start refactoring TIADebug to use them.

This commit is contained in:
Christian Speckner 2017-03-29 18:18:35 +02:00
parent eb209ee1dd
commit b3bfc86ccc
4 changed files with 16 additions and 3 deletions

View File

@ -185,7 +185,7 @@ bool TIADebug::vdelP0(int newVal)
if(newVal > -1)
mySystem.poke(VDELP0, bool(newVal));
return myTIA.myPlayer0.vdelp();
return (myTIA.valueLastWrittenToRegister(VDELP0) & 0x01) > 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -194,7 +194,7 @@ bool TIADebug::vdelP1(int newVal)
if(newVal > -1)
mySystem.poke(VDELP1, bool(newVal));
return myTIA.myPlayer1.vdelp();
return (myTIA.valueLastWrittenToRegister(VDELP1) & 0x01) > 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -44,7 +44,6 @@ class Player : public Serializable
bool refp() const { return myIsReflected; }
void vdelp(uInt8 value);
bool vdelp() const { return myIsDelaying; }
void toggleEnabled(bool enabled);

View File

@ -118,6 +118,8 @@ void TIA::reset()
mySubClock = 0;
myXDelta = 0;
memset(myShadowRegisters, 0, 64);
myBackground.reset();
myPlayfield.reset();
myMissile0.reset();
@ -432,6 +434,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
updateEmulation();
address &= 0x3F;
myShadowRegisters[address] = value;
switch (address)
{
@ -923,6 +926,12 @@ void TIA::updateScanlineByTrace(int target)
updateScanlineByStep();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIA::valueLastWrittenToRegister(uInt8 reg) const
{
return reg < 64 ? myShadowRegisters[reg] : 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::updateEmulation()
{

View File

@ -308,6 +308,9 @@ class TIA : public Device
*/
void updateScanlineByTrace(int target);
// Retrieve the last value written to a certain register
uInt8 valueLastWrittenToRegister(uInt8 reg) const;
/**
Save the current state of this device to the given Serializer.
@ -459,6 +462,8 @@ class TIA : public Device
double myTimestamp;
uInt8 myShadowRegisters[64];
// Automatic framerate correction based on number of scanlines
bool myAutoFrameEnabled;