Remove dead code from FrameManager (temporarily disables jitter).

This commit is contained in:
Christian Speckner 2017-10-12 00:26:08 +02:00
parent d0da98aef9
commit 0e5525223b
2 changed files with 15 additions and 73 deletions

View File

@ -41,7 +41,8 @@ enum Metrics: uInt32 {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameManager::FrameManager() : FrameManager::FrameManager() :
myHeight(0) myHeight(0),
myYStart(0)
{ {
onLayoutChange(); onLayoutChange();
} }
@ -49,14 +50,11 @@ FrameManager::FrameManager() :
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::onReset() void FrameManager::onReset()
{ {
myVblankManager.reset();
myState = State::waitForVsyncStart; myState = State::waitForVsyncStart;
myLineInState = 0; myLineInState = 0;
myTotalFrames = 0; myTotalFrames = 0;
myVsyncLines = 0; myVsyncLines = 0;
myY = 0; myY = 0;
myFramePending = false;
myStableFrameLines = -1; myStableFrameLines = -1;
myStableFrameHeightCountdown = 0; myStableFrameHeightCountdown = 0;
@ -85,8 +83,7 @@ void FrameManager::onNextLine()
break; break;
case State::waitForFrameStart: case State::waitForFrameStart:
if (myVblankManager.nextLine(myTotalFrames <= Metrics::initialGarbageFrames)) if (myLineInState >= myYStart) setState(State::frame);
setState(State::frame);
break; break;
case State::frame: case State::frame:
@ -107,7 +104,7 @@ void FrameManager::onNextLine()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 FrameManager::missingScanlines() const Int32 FrameManager::missingScanlines() const
{ {
if (myLastY == ystart() + myY) if (myLastY == myYStart + myY)
return 0; return 0;
else { else {
return myHeight - myY; return myHeight - myY;
@ -117,28 +114,8 @@ Int32 FrameManager::missingScanlines() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::onSetVsync() void FrameManager::onSetVsync()
{ {
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG if (myState == State::waitForVsyncEnd) setState(State::waitForFrameStart);
(cout << "vsync " << !myVsync << " -> " << myVsync << ": state " << int(myState) << " @ " << myLineInState << "\n").flush(); else setState(State::waitForVsyncEnd);
#endif
switch (myState)
{
case State::waitForVsyncStart:
case State::waitForFrameStart:
if (myVsync) setState(State::waitForVsyncEnd);
break;
case State::waitForVsyncEnd:
if (!myVsync) setState(State::waitForFrameStart);
break;
case State::frame:
if (myVsync) setState(State::waitForVsyncEnd);
break;
default:
throw runtime_error("frame manager: invalid state");
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -146,21 +123,14 @@ 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;
switch (myState) { switch (myState) {
case State::waitForFrameStart: case State::waitForFrameStart:
if (myFramePending) finalizeFrame(); finalizeFrame();
notifyFrameStart(); notifyFrameStart();
myVblankManager.start();
myFramePending = true;
myVsyncLines = 0; myVsyncLines = 0;
break; break;
@ -204,6 +174,7 @@ void FrameManager::finalizeFrame()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::handleJitter(Int32 scanlineDifference) void FrameManager::handleJitter(Int32 scanlineDifference)
{ {
/*
if ( if (
(uInt32)abs(scanlineDifference) < Metrics::minDeltaForJitter || (uInt32)abs(scanlineDifference) < Metrics::minDeltaForJitter ||
!myJitterEnabled || !myJitterEnabled ||
@ -211,16 +182,13 @@ void FrameManager::handleJitter(Int32 scanlineDifference)
) return; ) return;
myVblankManager.setJitter(scanlineDifference); myVblankManager.setJitter(scanlineDifference);
*/
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: kill this with fire once frame manager refactoring is complete // TODO: kill this with fire once frame manager refactoring is complete
void FrameManager::onLayoutChange() void FrameManager::onLayoutChange()
{ {
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "TV mode switched to " << int(layout()) << "\n").flush();
#endif // TIA_FRAMEMANAGER_DEBUG_LOG
switch (layout()) switch (layout())
{ {
case FrameLayout::ntsc: case FrameLayout::ntsc:
@ -242,23 +210,6 @@ void FrameManager::onLayoutChange()
myFrameLines = Metrics::vsync + myVblankLines + myKernelLines + myOverscanLines; myFrameLines = Metrics::vsync + myVblankLines + myKernelLines + myOverscanLines;
if (myFixedHeight == 0) if (myFixedHeight == 0)
myHeight = myKernelLines + Metrics::visibleOverscan; myHeight = myKernelLines + Metrics::visibleOverscan;
myVblankManager.setVblankLines(myVblankLines);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::onSetVblank()
{
#ifdef TIA_FRAMEMANAGER_DEBUG_LOG
(cout << "vblank change " << !myVblank << " -> " << myVblank << "@" << myLineInState << "\n").flush();
#endif // TIA_FRAMEMANAGER_DEBUG_LOG
if (myState == State::waitForFrameStart) {
if (myVblankManager.setVblankDuringVblank(myVblank, myTotalFrames <= Metrics::initialGarbageFrames)) {
setState(State::frame);
}
} else
myVblankManager.setVblank(myVblank);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -271,9 +222,11 @@ void FrameManager::setFixedHeight(uInt32 height)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::enableJitter(bool enabled) void FrameManager::enableJitter(bool enabled)
{ {
/*
myJitterEnabled = enabled; myJitterEnabled = enabled;
if (!enabled) myVblankManager.setJitter(0); if (!enabled) myVblankManager.setJitter(0);
*/
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -284,14 +237,11 @@ void FrameManager::updateIsRendering() {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameManager::onSave(Serializer& out) const bool FrameManager::onSave(Serializer& out) const
{ {
if (!myVblankManager.save(out)) return false;
out.putInt(uInt32(myState)); out.putInt(uInt32(myState));
out.putInt(myLineInState); out.putInt(myLineInState);
out.putInt(myVsyncLines); out.putInt(myVsyncLines);
out.putInt(myY); out.putInt(myY);
out.putInt(myLastY); out.putInt(myLastY);
out.putBool(myFramePending);
out.putInt(myVblankLines); out.putInt(myVblankLines);
out.putInt(myKernelLines); out.putInt(myKernelLines);
@ -311,14 +261,11 @@ bool FrameManager::onSave(Serializer& out) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameManager::onLoad(Serializer& in) bool FrameManager::onLoad(Serializer& in)
{ {
if (!myVblankManager.load(in)) return false;
myState = State(in.getInt()); myState = State(in.getInt());
myLineInState = in.getInt(); myLineInState = in.getInt();
myVsyncLines = in.getInt(); myVsyncLines = in.getInt();
myY = in.getInt(); myY = in.getInt();
myLastY = in.getInt(); myLastY = in.getInt();
myFramePending = in.getBool();
myVblankLines = in.getInt(); myVblankLines = in.getInt();
myKernelLines = in.getInt(); myKernelLines = in.getInt();

View File

@ -19,7 +19,6 @@
#define TIA_FRAME_MANAGER #define TIA_FRAME_MANAGER
#include "AbstractFrameManager.hxx" #include "AbstractFrameManager.hxx"
#include "VblankManager.hxx"
#include "TIAConstants.hxx" #include "TIAConstants.hxx"
#include "bspf.hxx" #include "bspf.hxx"
@ -30,7 +29,7 @@ class FrameManager: public AbstractFrameManager {
public: public:
void setJitterFactor(uInt8 factor) override { myVblankManager.setJitterFactor(factor); } void setJitterFactor(uInt8 factor) override { }
bool jitterEnabled() const override { return myJitterEnabled; } bool jitterEnabled() const override { return myJitterEnabled; }
@ -46,14 +45,12 @@ class FrameManager: public AbstractFrameManager {
Int32 missingScanlines() const override; Int32 missingScanlines() const override;
void setYstart(uInt32 ystart) override { myVblankManager.setYstart(ystart); } void setYstart(uInt32 ystart) override { myYStart = ystart; }
uInt32 ystart() const override { return myVblankManager.ystart(); } uInt32 ystart() const override { return myYStart; }
void setLayout(FrameLayout mode) override { layout(mode); } void setLayout(FrameLayout mode) override { layout(mode); }
void onSetVblank() override;
void onSetVsync() override; void onSetVsync() override;
void onNextLine() override; void onNextLine() override;
@ -93,13 +90,10 @@ class FrameManager: public AbstractFrameManager {
private: private:
VblankManager myVblankManager;
State myState; State myState;
uInt32 myLineInState; uInt32 myLineInState;
uInt32 myVsyncLines; uInt32 myVsyncLines;
uInt32 myY, myLastY; uInt32 myY, myLastY;
bool myFramePending;
uInt32 myVblankLines; uInt32 myVblankLines;
uInt32 myKernelLines; uInt32 myKernelLines;
@ -107,6 +101,7 @@ class FrameManager: public AbstractFrameManager {
uInt32 myFrameLines; uInt32 myFrameLines;
uInt32 myHeight; uInt32 myHeight;
uInt32 myFixedHeight; uInt32 myFixedHeight;
uInt32 myYStart;
bool myJitterEnabled; bool myJitterEnabled;