Checkpoint.

This commit is contained in:
Christian Speckner 2016-12-13 21:05:54 +01:00
parent f982f0257f
commit f0828c597d
2 changed files with 4 additions and 33 deletions

View File

@ -65,8 +65,6 @@ void FrameManager::reset()
myState = State::waitForVsyncStart; myState = State::waitForVsyncStart;
myCurrentFrameTotalLines = myCurrentFrameFinalLines = 0; myCurrentFrameTotalLines = myCurrentFrameFinalLines = 0;
myLineInState = 0; myLineInState = 0;
myLinesWithoutVsync = 0;
myWaitForVsync = true;
myVsync = false; myVsync = false;
myVblank = false; myVblank = false;
myTotalFrames = 0; myTotalFrames = 0;
@ -84,21 +82,11 @@ void FrameManager::nextLine()
{ {
case State::waitForVsyncStart: case State::waitForVsyncStart:
case State::waitForVsyncEnd: case State::waitForVsyncEnd:
if (myLinesWithoutVsync > myMaxLinesWithoutVsync) {
myWaitForVsync = false;
setState(State::waitForFrameStart);
}
break; break;
case State::waitForFrameStart: case State::waitForFrameStart:
if (myWaitForVsync) { if (myLineInState >= (myVblank ? myVblankLines : myVblankLines - Metrics::maxUnderscan))
if (myLineInState >= (myVblank ? myVblankLines : myVblankLines - Metrics::maxUnderscan)) setState(State::frame);
setState(State::frame);
} else {
if (!myVblank) {
setState(State::frame);
}
}
break; break;
case State::frame: case State::frame:
@ -107,17 +95,9 @@ void FrameManager::nextLine()
} }
break; break;
case State::overscan:
if (myLineInState >= myOverscanLines - Metrics::visibleOverscan) {
setState(myWaitForVsync ? State::waitForVsyncStart : State::waitForFrameStart);
}
break;
default: default:
throw runtime_error("frame manager: invalid state"); throw runtime_error("frame manager: invalid state");
} }
if (myWaitForVsync) myLinesWithoutVsync++;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -129,8 +109,6 @@ void FrameManager::setVblank(bool vblank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::setVsync(bool vsync) void FrameManager::setVsync(bool vsync)
{ {
if (!myWaitForVsync || vsync == myVsync) return;
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG #ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "vsync " << myVsync << " -> " << vsync << ": state " << int(myState) << " @ " << myLineInState << "\n").flush(); (cout << "vsync " << myVsync << " -> " << vsync << ": state " << int(myState) << " @ " << myLineInState << "\n").flush();
#endif #endif
@ -141,14 +119,12 @@ void FrameManager::setVsync(bool vsync)
{ {
case State::waitForVsyncStart: case State::waitForVsyncStart:
case State::waitForFrameStart: case State::waitForFrameStart:
case State::overscan:
if (myVsync) setState(State::waitForVsyncEnd); if (myVsync) setState(State::waitForVsyncEnd);
break; break;
case State::waitForVsyncEnd: case State::waitForVsyncEnd:
if (!myVsync) { if (!myVsync) {
setState(State::waitForFrameStart); setState(State::waitForFrameStart);
myLinesWithoutVsync = 0;
} }
break; break;
@ -220,7 +196,6 @@ void FrameManager::setTvMode(TvMode mode)
} }
myFrameLines = Metrics::vsync + myVblankLines + myKernelLines + myOverscanLines; myFrameLines = Metrics::vsync + myVblankLines + myKernelLines + myOverscanLines;
myMaxLinesWithoutVsync = myFrameLines * Metrics::maxFramesWithoutVsync;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -76,8 +76,7 @@ class FrameManager : public Serializable
waitForVsyncStart, waitForVsyncStart,
waitForVsyncEnd, waitForVsyncEnd,
waitForFrameStart, waitForFrameStart,
frame, frame
overscan
}; };
private: private:
@ -86,7 +85,7 @@ class FrameManager : public Serializable
void setState(State state); void setState(State state);
void finalizeFrame(State state = State::overscan); void finalizeFrame(State state = State::waitForVsyncStart);
private: private:
@ -95,9 +94,7 @@ class FrameManager : public Serializable
TvMode myMode; TvMode myMode;
State myState; State myState;
bool myWaitForVsync;
uInt32 myLineInState; uInt32 myLineInState;
uInt32 myLinesWithoutVsync;
uInt32 myCurrentFrameTotalLines; uInt32 myCurrentFrameTotalLines;
uInt32 myCurrentFrameFinalLines; uInt32 myCurrentFrameFinalLines;
@ -112,7 +109,6 @@ class FrameManager : public Serializable
uInt32 myKernelLines; uInt32 myKernelLines;
uInt32 myOverscanLines; uInt32 myOverscanLines;
uInt32 myFrameLines; uInt32 myFrameLines;
uInt32 myMaxLinesWithoutVsync;
private: private:
FrameManager(const FrameManager&) = delete; FrameManager(const FrameManager&) = delete;