mirror of https://github.com/stella-emu/stella.git
added QuadTari controller switch timer
This commit is contained in:
parent
e3e9eab72e
commit
d43a018c6c
|
@ -61,8 +61,17 @@ bool QuadTari::read(DigitalPin pin)
|
||||||
// can switch the controller multiple times per frame
|
// can switch the controller multiple times per frame
|
||||||
// (we can't just read 60 times per second in the ::update() method)
|
// (we can't just read 60 times per second in the ::update() method)
|
||||||
|
|
||||||
// If bit 7 of VBlank is not set, read first, else second controller
|
constexpr int MIN_CYCLES = 30 * 76; // minimal cycles required for stable input switch (TODO: define cycles)
|
||||||
if(!(mySystem.tia().registerValue(VBLANK) & 0x80))
|
bool readFirst;
|
||||||
|
|
||||||
|
if(mySystem.tia().dumpPortsCycles() < MIN_CYCLES)
|
||||||
|
// Random controller if read too soon after dump ports changed
|
||||||
|
readFirst = mySystem.randGenerator().next() % 2;
|
||||||
|
else
|
||||||
|
// If bit 7 of VBlank is not set, read first, else second controller
|
||||||
|
readFirst = !(mySystem.tia().registerValue(VBLANK) & 0x80);
|
||||||
|
|
||||||
|
if(readFirst)
|
||||||
return myFirstController->read(pin);
|
return myFirstController->read(pin);
|
||||||
else
|
else
|
||||||
return mySecondController->read(pin);
|
return mySecondController->read(pin);
|
||||||
|
|
|
@ -523,6 +523,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
|
||||||
|
|
||||||
for (PaddleReader& paddleReader : myPaddleReaders)
|
for (PaddleReader& paddleReader : myPaddleReaders)
|
||||||
paddleReader.vblank(value, myTimestamp);
|
paddleReader.vblank(value, myTimestamp);
|
||||||
|
updateDumpPorts(value);
|
||||||
|
|
||||||
myDelayQueue.push(VBLANK, value, Delay::vblank);
|
myDelayQueue.push(VBLANK, value, Delay::vblank);
|
||||||
|
|
||||||
|
@ -1981,6 +1982,24 @@ void TIA::toggleCollBLPF()
|
||||||
myCollisionMask ^= (CollisionMask::ball & CollisionMask::playfield);
|
myCollisionMask ^= (CollisionMask::ball & CollisionMask::playfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void TIA::updateDumpPorts(uInt8 value)
|
||||||
|
{
|
||||||
|
bool newIsDumped = value & 0x80;
|
||||||
|
|
||||||
|
if(myArePortsDumped != newIsDumped)
|
||||||
|
{
|
||||||
|
myArePortsDumped = newIsDumped;
|
||||||
|
myDumpPortsTimestamp = myTimestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Int64 TIA::dumpPortsCycles()
|
||||||
|
{
|
||||||
|
return (myTimestamp - myDumpPortsTimestamp) / 3;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUGGER_SUPPORT
|
#ifdef DEBUGGER_SUPPORT
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void TIA::createAccessArrays()
|
void TIA::createAccessArrays()
|
||||||
|
|
|
@ -334,6 +334,13 @@ class TIA : public Device
|
||||||
return uInt32(mySystem->cycles() - myCyclesAtFrameStart);
|
return uInt32(mySystem->cycles() - myCyclesAtFrameStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the CPU cycles since the last dump ports change.
|
||||||
|
*
|
||||||
|
* @return The number of CPU cycles since the last dump ports change
|
||||||
|
*/
|
||||||
|
Int64 dumpPortsCycles();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Answers whether the TIA is currently in being rendered
|
Answers whether the TIA is currently in being rendered
|
||||||
(we're in between the start and end of drawing a frame).
|
(we're in between the start and end of drawing a frame).
|
||||||
|
@ -695,6 +702,13 @@ class TIA : public Device
|
||||||
*/
|
*/
|
||||||
void applyDeveloperSettings();
|
void applyDeveloperSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the dump ports state with the time of change.
|
||||||
|
*
|
||||||
|
* @param value The value to be stored at VBLANK
|
||||||
|
*/
|
||||||
|
void updateDumpPorts(uInt8 value);
|
||||||
|
|
||||||
#ifdef DEBUGGER_SUPPORT
|
#ifdef DEBUGGER_SUPPORT
|
||||||
void createAccessArrays();
|
void createAccessArrays();
|
||||||
|
|
||||||
|
@ -894,6 +908,16 @@ class TIA : public Device
|
||||||
*/
|
*/
|
||||||
uInt64 myTimestamp{0};
|
uInt64 myTimestamp{0};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of CPU clocks since the last dump ports state change.
|
||||||
|
*/
|
||||||
|
uInt64 myDumpPortsTimestamp{0};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current dump ports state.
|
||||||
|
*/
|
||||||
|
bool myArePortsDumped{false};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "shadow registers" track the last written register value for the
|
* The "shadow registers" track the last written register value for the
|
||||||
* debugger.
|
* debugger.
|
||||||
|
|
Loading…
Reference in New Issue