diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 8b2a776ad..a12ff5995 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -116,7 +116,7 @@ void TIA::reset() myLastCycle = 0; mySubClock = 0; myXDelta = 0; - myLastFrameHeight = 0; + myLastFrameHeight[0] = myLastFrameHeight[1] = 0; myBackground.reset(); myPlayfield.reset(); @@ -889,10 +889,20 @@ void TIA::updateEmulation() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TIA::onFrameStart() +void TIA::swapBuffers() { myCurrentFrameBuffer.swap(myPreviousFrameBuffer); + uInt32 tmp = myLastFrameHeight[0]; + myLastFrameHeight[0] = myLastFrameHeight[1]; + myLastFrameHeight[1] = tmp; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIA::onFrameStart() +{ + swapBuffers(); + for (uInt8 i = 0; i < 4; i++) updatePaddle(i); } @@ -903,12 +913,12 @@ void TIA::onFrameComplete() mySystem->m6502().stop(); mySystem->resetCycles(); - Int32 missingScanlines = myLastFrameHeight - myFrameManager.getY(); + Int32 missingScanlines = myLastFrameHeight[0] - myFrameManager.getY(); if (missingScanlines > 0) memset(myCurrentFrameBuffer.get() + 160 * myFrameManager.getY(), 0, missingScanlines * 160); - myLastFrameHeight = myFrameManager.getY(); + myLastFrameHeight[0] = myFrameManager.getY(); // Recalculate framerate, attempting to auto-correct for scanline 'jumps' if(myAutoFrameEnabled) diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index 6d2b302b8..d46c73c73 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -383,6 +383,8 @@ class TIA : public Device uInt8 resxCounter(); + void swapBuffers(); + /** Get the result of the specified collision register. */ @@ -441,7 +443,7 @@ class TIA : public Device // Pointer to the current and previous frame buffers BytePtr myCurrentFrameBuffer; BytePtr myPreviousFrameBuffer; - uInt32 myLastFrameHeight; + uInt32 myLastFrameHeight[2]; Background myBackground; Playfield myPlayfield;