From b246dcb2cf008a52289ad31f1b83f44611590c9c Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 4 Jun 2024 09:51:47 +0200 Subject: [PATCH] added check which ignores invalid frames (too many scanlines) during frame detection (fixes Tarzan) --- src/emucore/tia/frame-manager/FrameLayoutDetector.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx b/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx index 1fe79f651..5ae3be83b 100644 --- a/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx +++ b/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx @@ -181,12 +181,14 @@ void FrameLayoutDetector::onNextLine() if (myCurrentFrameTotalLines > frameLines - 3 || myTotalFrames == 0) ++myLinesWaitingForVsyncToStart; - if (myLinesWaitingForVsyncToStart > Metrics::waitForVsync) setState(State::waitForVsyncEnd); + if (myLinesWaitingForVsyncToStart > Metrics::waitForVsync) + setState(State::waitForVsyncEnd); break; case State::waitForVsyncEnd: - if (++myLinesWaitingForVsyncToStart > Metrics::waitForVsync) setState(State::waitForVsyncStart); + if (++myLinesWaitingForVsyncToStart > Metrics::waitForVsync) + setState(State::waitForVsyncStart); break; @@ -232,7 +234,10 @@ void FrameLayoutDetector::finalizeFrame() { notifyFrameComplete(); - if (myTotalFrames <= Metrics::initialGarbageFrames) return; + if (myTotalFrames <= Metrics::initialGarbageFrames) + return; + if (myCurrentFrameFinalLines > Metrics::frameLinesPAL + Metrics::waitForVsync) + return; // Calculate how close a frame is to PAL and NTSC based on scanlines. An odd scanline count // results into a penalty of 0.5 for PAL. The result is between 0.0 (<=262 scanlines) and