Fix VSYNC during kernel, retain conditional debug logging for later use.

This commit is contained in:
Christian Speckner 2016-12-11 20:50:12 +01:00
parent 18c31ebc2b
commit b9e2fc9022
2 changed files with 16 additions and 4 deletions

View File

@ -124,6 +124,10 @@ void FrameManager::setVsync(bool vsync)
{ {
if (!myWaitForVsync || vsync == myVsync) return; if (!myWaitForVsync || vsync == myVsync) return;
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "vsync " << myVsync << " -> " << vsync << ": state " << int(myState) << " @ " << myLineInState << "\n").flush();
#endif
myVsync = vsync; myVsync = vsync;
switch (myState) switch (myState)
@ -142,7 +146,7 @@ void FrameManager::setVsync(bool vsync)
break; break;
case State::frame: case State::frame:
if (myVsync) finalizeFrame(); if (myVsync) finalizeFrame(State::waitForVsyncEnd);
break; break;
default: default:
@ -220,6 +224,10 @@ void FrameManager::setState(FrameManager::State state)
{ {
if (myState == state) return; if (myState == state) return;
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "state change " << myState << " -> " << state << " @ " << myLineInState << "\n").flush();
#endif // TIA_FRAMEMANAGER_DEBUG_LOG
myState = state; myState = state;
myLineInState = 0; myLineInState = 0;
@ -227,7 +235,7 @@ void FrameManager::setState(FrameManager::State state)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::finalizeFrame() void FrameManager::finalizeFrame(FrameManager::State state)
{ {
const uInt32 const uInt32
deltaNTSC = abs(Int32(myCurrentFrameTotalLines) - Int32(frameLinesNTSC)), deltaNTSC = abs(Int32(myCurrentFrameTotalLines) - Int32(frameLinesNTSC)),
@ -241,9 +249,13 @@ void FrameManager::finalizeFrame()
myOnFrameComplete(); myOnFrameComplete();
} }
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "frame complete @ " << myLineInState << " (" << myCurrentFrameFinalLines << " total)" << "\n").flush();
#endif // TIA_FRAMEMANAGER_DEBUG_LOG
myCurrentFrameFinalLines = myCurrentFrameTotalLines; myCurrentFrameFinalLines = myCurrentFrameTotalLines;
myCurrentFrameTotalLines = 0; myCurrentFrameTotalLines = 0;
setState(State::overscan); setState(state);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -82,7 +82,7 @@ class FrameManager : public Serializable
void setState(State state); void setState(State state);
void finalizeFrame(); void finalizeFrame(State state = State::overscan);
private: private: