Fixed display of FPS in the TIA message window. This also fixes sound

issues, since the correct framerate is being communicated to the
emulation core.
This commit is contained in:
Stephen Anthony 2016-12-17 13:06:56 -03:30
parent d77d2f2e61
commit e618a6c72c
4 changed files with 20 additions and 18 deletions

View File

@ -65,6 +65,7 @@ void FrameManager::reset()
{ {
myState = State::waitForVsyncStart; myState = State::waitForVsyncStart;
myCurrentFrameTotalLines = myCurrentFrameFinalLines = 0; myCurrentFrameTotalLines = myCurrentFrameFinalLines = 0;
myFrameRate = 60.0;
myLineInState = 0; myLineInState = 0;
myVsync = false; myVsync = false;
myVblank = false; myVblank = false;
@ -323,6 +324,9 @@ void FrameManager::finalizeFrame(FrameManager::State state)
if (myFramesInMode > Metrics::framesForModeConfirmation) if (myFramesInMode > Metrics::framesForModeConfirmation)
myModeConfirmed = true; myModeConfirmed = true;
myFrameRate = (myMode == TvMode::pal ? 15600.0 : 15720.0) /
myCurrentFrameFinalLines;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -63,6 +63,8 @@ class FrameManager : public Serializable
uInt32 frameCount() const { return myTotalFrames; } uInt32 frameCount() const { return myTotalFrames; }
float frameRate() const { return myFrameRate; }
/** /**
Serializable methods (see that class for more information). Serializable methods (see that class for more information).
*/ */
@ -104,6 +106,7 @@ class FrameManager : public Serializable
uInt32 myLineInState; uInt32 myLineInState;
uInt32 myCurrentFrameTotalLines; uInt32 myCurrentFrameTotalLines;
uInt32 myCurrentFrameFinalLines; uInt32 myCurrentFrameFinalLines;
float myFrameRate;
uInt32 myTotalFrames; uInt32 myTotalFrames;
uInt32 myFramesInMode; uInt32 myFramesInMode;

View File

@ -79,6 +79,10 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings)
[this] () { [this] () {
mySystem->m6502().stop(); mySystem->m6502().stop();
mySystem->resetCycles(); mySystem->resetCycles();
// Recalculate framerate, attempting to auto-correct for scanline 'jumps'
if(myAutoFrameEnabled)
myConsole.setFramerate(myFrameManager.frameRate());
} }
); );
@ -104,8 +108,8 @@ void TIA::reset()
myCollisionMask = 0; myCollisionMask = 0;
myLinesSinceChange = 0; myLinesSinceChange = 0;
myCollisionUpdateRequired = false; myCollisionUpdateRequired = false;
myAutoFrameEnabled = false;
myColorHBlank = 0; myColorHBlank = 0;
myLastCycle = 0; myLastCycle = 0;
mySubClock = 0; mySubClock = 0;
@ -138,6 +142,8 @@ void TIA::frameReset()
// Clear frame buffers // Clear frame buffers
clearBuffers(); clearBuffers();
myAutoFrameEnabled = (mySettings.getInt("framerate") <= 0);
// TODO - make use of ystart and height, maybe move to FrameManager // TODO - make use of ystart and height, maybe move to FrameManager
} }
@ -621,9 +627,9 @@ void TIA::setYStart(uInt32 ystart)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: stub
void TIA::enableAutoFrame(bool enabled) void TIA::enableAutoFrame(bool enabled)
{ {
myAutoFrameEnabled = enabled;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -657,13 +663,6 @@ bool TIA::partialFrame() const
return myFrameManager.isRendering(); return myFrameManager.isRendering();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: stub
uInt32 TIA::startScanline() const
{
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: stub // TODO: stub
bool TIA::scanlinePos(uInt16& x, uInt16& y) const bool TIA::scanlinePos(uInt16& x, uInt16& y) const

View File

@ -179,14 +179,14 @@ class TIA : public Device
Enables/disables auto-frame calculation. If enabled, the TIA Enables/disables auto-frame calculation. If enabled, the TIA
re-adjusts the framerate at regular intervals. re-adjusts the framerate at regular intervals.
@param mode Whether to enable or disable all auto-frame calculation @param enabled Whether to enable or disable all auto-frame calculation
*/ */
void enableAutoFrame(bool enabled); void enableAutoFrame(bool enabled);
/** /**
Enables/disables color-loss for PAL modes only. Enables/disables color-loss for PAL modes only.
@param mode Whether to enable or disable PAL color-loss mode @param enabled Whether to enable or disable PAL color-loss mode
*/ */
void enableColorLoss(bool enabled); void enableColorLoss(bool enabled);
@ -219,13 +219,6 @@ class TIA : public Device
*/ */
bool partialFrame() const; bool partialFrame() const;
/**
Answers the first scanline at which drawing occured in the last frame.
@return The starting scanline
*/
uInt32 startScanline() const;
/** /**
Answers the current position of the virtual 'electron beam' used to Answers the current position of the virtual 'electron beam' used to
draw the TIA image. If not in partial frame mode, the position is draw the TIA image. If not in partial frame mode, the position is
@ -438,6 +431,9 @@ class TIA : public Device
double myTimestamp; double myTimestamp;
// Automatic framerate correction based on number of scanlines
bool myAutoFrameEnabled;
// Pointer to the current and previous frame buffers // Pointer to the current and previous frame buffers
BytePtr myCurrentFrameBuffer; BytePtr myCurrentFrameBuffer;
BytePtr myPreviousFrameBuffer; BytePtr myPreviousFrameBuffer;