Skip to content

Commit

Permalink
Checkpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtyHairy committed Dec 13, 2016
1 parent f982f02 commit f0828c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
29 changes: 2 additions & 27 deletions src/emucore/tia/FrameManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ void FrameManager::reset()
myState = State::waitForVsyncStart;
myCurrentFrameTotalLines = myCurrentFrameFinalLines = 0;
myLineInState = 0;
myLinesWithoutVsync = 0;
myWaitForVsync = true;
myVsync = false;
myVblank = false;
myTotalFrames = 0;
Expand All @@ -84,21 +82,11 @@ void FrameManager::nextLine()
{
case State::waitForVsyncStart:
case State::waitForVsyncEnd:
if (myLinesWithoutVsync > myMaxLinesWithoutVsync) {
myWaitForVsync = false;
setState(State::waitForFrameStart);
}
break;

case State::waitForFrameStart:
if (myWaitForVsync) {
if (myLineInState >= (myVblank ? myVblankLines : myVblankLines - Metrics::maxUnderscan))
setState(State::frame);
} else {
if (!myVblank) {
setState(State::frame);
}
}
if (myLineInState >= (myVblank ? myVblankLines : myVblankLines - Metrics::maxUnderscan))
setState(State::frame);
break;

case State::frame:
Expand All @@ -107,17 +95,9 @@ void FrameManager::nextLine()
}
break;

case State::overscan:
if (myLineInState >= myOverscanLines - Metrics::visibleOverscan) {
setState(myWaitForVsync ? State::waitForVsyncStart : State::waitForFrameStart);
}
break;

default:
throw runtime_error("frame manager: invalid state");
}

if (myWaitForVsync) myLinesWithoutVsync++;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand All @@ -129,8 +109,6 @@ void FrameManager::setVblank(bool vblank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::setVsync(bool vsync)
{
if (!myWaitForVsync || vsync == myVsync) return;

#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "vsync " << myVsync << " -> " << vsync << ": state " << int(myState) << " @ " << myLineInState << "\n").flush();
#endif
Expand All @@ -141,14 +119,12 @@ void FrameManager::setVsync(bool vsync)
{
case State::waitForVsyncStart:
case State::waitForFrameStart:
case State::overscan:
if (myVsync) setState(State::waitForVsyncEnd);
break;

case State::waitForVsyncEnd:
if (!myVsync) {
setState(State::waitForFrameStart);
myLinesWithoutVsync = 0;
}
break;

Expand Down Expand Up @@ -220,7 +196,6 @@ void FrameManager::setTvMode(TvMode mode)
}

myFrameLines = Metrics::vsync + myVblankLines + myKernelLines + myOverscanLines;
myMaxLinesWithoutVsync = myFrameLines * Metrics::maxFramesWithoutVsync;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
8 changes: 2 additions & 6 deletions src/emucore/tia/FrameManager.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ class FrameManager : public Serializable
waitForVsyncStart,
waitForVsyncEnd,
waitForFrameStart,
frame,
overscan
frame
};

private:
Expand All @@ -86,7 +85,7 @@ class FrameManager : public Serializable

void setState(State state);

void finalizeFrame(State state = State::overscan);
void finalizeFrame(State state = State::waitForVsyncStart);

private:

Expand All @@ -95,9 +94,7 @@ class FrameManager : public Serializable

TvMode myMode;
State myState;
bool myWaitForVsync;
uInt32 myLineInState;
uInt32 myLinesWithoutVsync;
uInt32 myCurrentFrameTotalLines;
uInt32 myCurrentFrameFinalLines;

Expand All @@ -112,7 +109,6 @@ class FrameManager : public Serializable
uInt32 myKernelLines;
uInt32 myOverscanLines;
uInt32 myFrameLines;
uInt32 myMaxLinesWithoutVsync;

private:
FrameManager(const FrameManager&) = delete;
Expand Down

0 comments on commit f0828c5

Please sign in to comment.