From 20b8515b7b3f226bf81917b3cafd4e685893508b Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 10 Nov 2019 23:52:29 +0000 Subject: [PATCH] Full-speed: Only redraw video screen during VBl (support VBl in full-speed) --- source/Applewin.cpp | 2 +- source/Video.cpp | 21 ++++++--------------- source/Video.h | 3 +-- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 84cfabe7..9670fe70 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -357,7 +357,7 @@ static void ContinueExecution(void) // const UINT dwClksPerFrame = NTSC_GetCyclesPerFrame(); - if (g_dwCyclesThisFrame >= dwClksPerFrame && !VideoGetVblBar()) + if (g_dwCyclesThisFrame >= dwClksPerFrame && !VideoGetVblBar(g_dwCyclesThisFrame)) { g_dwCyclesThisFrame -= dwClksPerFrame; diff --git a/source/Video.cpp b/source/Video.cpp index 4440ec30..7f9b83ac 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -873,24 +873,15 @@ WORD VideoGetScannerAddress(DWORD nCycles, VideoScanner_e videoScannerAddr /*= V //=========================================================================== -// TODO: Consider replacing simply with: return g_nVideoClockVert < kVDisplayableScanLines -// - will this work in full-speed mode? bool VideoGetVblBar(const DWORD uExecutedCycles) { - // get video scanner position - int nCycles = CpuGetCyclesThisVideoFrame(uExecutedCycles); + if (g_bFullSpeed) + { + // Ensure that NTSC video-scanner gets updated during full-speed: + // so that video-dependent Apple II code doesn't hang & video screen can be redraw during VBL + NTSC_VideoClockResync(CpuGetCyclesThisVideoFrame(uExecutedCycles)); + } - // calculate video parameters according to display standard - const int kScanLines = g_bVideoScannerNTSC ? kNTSCScanLines : kPALScanLines; - const int kScanCycles = kScanLines * kHClocks; - nCycles %= kScanCycles; - - // VBL' - return nCycles < kVDisplayableScanLines * kHClocks; -} - -bool VideoGetVblBar(void) -{ return g_nVideoClockVert < kVDisplayableScanLines; } diff --git a/source/Video.h b/source/Video.h index 0bb88578..3a06ec56 100644 --- a/source/Video.h +++ b/source/Video.h @@ -188,8 +188,7 @@ void VideoReinitialize (bool bInitVideoScannerAddress = true); void VideoResetState (); enum VideoScanner_e {VS_FullAddr, VS_PartialAddrV, VS_PartialAddrH}; WORD VideoGetScannerAddress(DWORD nCycles, VideoScanner_e videoScannerAddr = VS_FullAddr); -bool VideoGetVblBar(DWORD uExecutedCycles); -bool VideoGetVblBar(void); +bool VideoGetVblBar(const DWORD uExecutedCycles); bool VideoGetSW80COL(void); bool VideoGetSWDHIRES(void);