Fix vsync locked -> floating transition.

This commit is contained in:
Christian Speckner 2017-01-14 13:46:51 +01:00
parent bf1ff1aae0
commit b0b807407a
1 changed files with 16 additions and 1 deletions

View File

@ -149,6 +149,9 @@ void FrameManager::nextLineInVsync()
myLastVblankLines = myLineInState; myLastVblankLines = myLineInState;
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "leaving vblank in floating mode, should transition: " << shouldTransition << "\n").flush();
#endif
setState(State::frame); setState(State::frame);
} }
@ -162,6 +165,7 @@ void FrameManager::nextLineInVsync()
case VblankMode::locked: case VblankMode::locked:
if (myLineInState == myLastVblankLines) { if (myLineInState == myLastVblankLines) {
if (shouldTransition && !myVblankViolated) if (shouldTransition && !myVblankViolated)
myVblankViolations = 0; myVblankViolations = 0;
else { else {
@ -169,14 +173,20 @@ void FrameManager::nextLineInVsync()
myVblankViolated = true; myVblankViolated = true;
} }
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "leaving vblank in locked mode, should transition: " << shouldTransition << "\n").flush();
#endif
setState(State::frame); setState(State::frame);
} else if (shouldTransition){ } else if (shouldTransition){
if (!myVblankViolated) myVblankViolations++; if (!myVblankViolated) myVblankViolations++;
myVblankViolated = true; myVblankViolated = true;
} }
if (myVblankViolations > Metrics::maxVblankViolations) if (myVblankViolations > Metrics::maxVblankViolations) {
myVblankMode = VblankMode::floating; myVblankMode = VblankMode::floating;
myStableVblankFrames = 0;
}
break; break;
@ -353,6 +363,11 @@ uInt32 FrameManager::ystart() const {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::setVblank(bool vblank) void FrameManager::setVblank(bool vblank)
{ {
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
if (myVblank != vblank)
(cout << "vblank " << myVblank << " -> " << vblank << ": state " << int(myState) << " @ " << myLineInState << "\n").flush();
#endif
myVblank = vblank; myVblank = vblank;
} }