Factor out ystart detection.

This commit is contained in:
Christian Speckner 2017-10-11 16:04:47 +02:00
parent 12afce8c0d
commit dc5c68bb80
4 changed files with 22 additions and 7 deletions

View File

@ -59,6 +59,7 @@
#include "FrameLayout.hxx"
#include "frame-manager/FrameManager.hxx"
#include "frame-manager/FrameLayoutDetector.hxx"
#include "frame-manager/YStartDetector.hxx"
#ifdef DEBUGGER_SUPPORT
#include "Debugger.hxx"
@ -144,7 +145,20 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
// Don't forget to reset the SC progress bars again
myOSystem.settings().setValue("fastscbios", fastscbios);
// TODO: move! move! move! (temporary for testing)
YStartDetector ystartDetector;
ystartDetector.setLayout(frameLayoutDetector.detectedLayout());
myTIA->setFrameManager(&ystartDetector);
mySystem->reset();
for (int i = 0; i < 80; i++) myTIA->update();
myTIA->setFrameManager(myFrameManager.get());
(cout << "detected ystart value: " << ystartDetector.detectedYStart() << std::endl).flush();
}
myConsoleInfo.DisplayFormat = myDisplayFormat + autodetected;
// Set up the correct properties used when toggling format

View File

@ -40,7 +40,7 @@ void FrameLayoutDetector::onReset()
{
myState = State::waitForVsyncStart;
myNtscFrames = myPalFrames = 0;
myLinesWaitingForVsync = 0;
myLinesWaitingForVsyncToStart = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -62,14 +62,14 @@ void FrameLayoutDetector::onNextLine()
// We start counting the number of "lines spent while waiting for vsync start" from
// the "ideal" frame size (corrected by the three scanlines spent in vsync).
if (myCurrentFrameTotalLines > frameLines - 3 || myTotalFrames == 0)
myLinesWaitingForVsync++;
myLinesWaitingForVsyncToStart++;
if (myLinesWaitingForVsync > Metrics::waitForVsync) setState(State::waitForVsyncEnd);
if (myLinesWaitingForVsyncToStart > Metrics::waitForVsync) setState(State::waitForVsyncEnd);
break;
case State::waitForVsyncEnd:
if (++myLinesWaitingForVsync > Metrics::waitForVsync) setState(State::waitForVsyncStart);
if (++myLinesWaitingForVsyncToStart > Metrics::waitForVsync) setState(State::waitForVsyncStart);
break;
@ -84,7 +84,7 @@ void FrameLayoutDetector::setState(State state)
if (state == myState) return;
myState = state;
myLinesWaitingForVsync = 0;
myLinesWaitingForVsyncToStart = 0;
switch (myState) {
case State::waitForVsyncEnd:

View File

@ -96,7 +96,7 @@ class FrameLayoutDetector: public AbstractFrameManager {
* We count the number of scanlines we spend waiting for vsync to be
* toggled. If a threshold is exceeded, we force the transition.
*/
uInt32 myLinesWaitingForVsync;
uInt32 myLinesWaitingForVsyncToStart;
};

View File

@ -4,7 +4,8 @@ MODULE_OBJS := \
src/emucore/tia/frame-manager/FrameManager.o \
src/emucore/tia/frame-manager/VblankManager.o \
src/emucore/tia/frame-manager/AbstractFrameManager.o \
src/emucore/tia/frame-manager/FrameLayoutDetector.o
src/emucore/tia/frame-manager/FrameLayoutDetector.o \
src/emucore/tia/frame-manager/YStartDetector.o
MODULE_DIRS += \
src/emucore/tia/frame-manager