From a75555d21cd771331b9910d17891d40cb27b3be2 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 20 Jul 2014 10:23:23 +0100 Subject: [PATCH] Simplified ContinueExecution(): video refresh part. --- source/Applewin.cpp | 49 ++++++++++++++++++--------------------------- source/Video.cpp | 26 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 1c317a6f..f2165c12 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -238,47 +238,36 @@ void ContinueExecution(void) emulmsec_frac %= CLKS_PER_MS; } + // DETERMINE WHETHER THE SCREEN WAS UPDATED THIS CLOCKTICK + static BOOL anyupdates = 0; + VideoCheckPage(0); // force=0 + anyupdates |= VideoHasRefreshed(); // Only called from here. Returns & clears 'hasrefreshed' flag + // if (g_dwCyclesThisFrame >= dwClksPerFrame) { g_dwCyclesThisFrame -= dwClksPerFrame; + VideoUpdateFlash(); - // DETERMINE WHETHER THE SCREEN WAS UPDATED THIS CLOCKTICK - VideoCheckPage(0); // force=0 - const BOOL screenupdated = VideoHasRefreshed(); // Only called from here. Clears & returns 'hasrefreshed' flag. - - if (g_nAppMode != MODE_LOGO) + static BOOL lastupdates[2] = {0,0}; + if (!anyupdates && !lastupdates[0] && !lastupdates[1] && VideoApparentlyDirty()) { - VideoUpdateFlash(); - - static BOOL anyupdates = 0; - static DWORD lastcycles = 0; - static BOOL lastupdates[2] = {0,0}; - - anyupdates |= screenupdated; - - // - - lastcycles = cumulativecycles; - if ((!anyupdates) && (!lastupdates[0]) && (!lastupdates[1]) && VideoApparentlyDirty()) + VideoCheckPage(1); // force=1 + static DWORD lasttime = 0; + DWORD currtime = GetTickCount(); + if ((!g_bFullSpeed) || + (currtime-lasttime >= (DWORD)(g_bGraphicsMode ? 100 : 25))) { - VideoCheckPage(1); // force=1 - static DWORD lasttime = 0; - DWORD currtime = GetTickCount(); - if ((!g_bFullSpeed) || - (currtime-lasttime >= (DWORD)(g_bGraphicsMode ? 100 : 25))) - { - VideoRefreshScreen(); - lasttime = currtime; - } + VideoRefreshScreen(); + lasttime = currtime; } - - lastupdates[1] = lastupdates[0]; - lastupdates[0] = anyupdates; - anyupdates = 0; } + lastupdates[1] = lastupdates[0]; + lastupdates[0] = anyupdates; + anyupdates = 0; + MB_EndOfVideoFrame(); } diff --git a/source/Video.cpp b/source/Video.cpp index 44c4b479..61a4a094 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -2438,8 +2438,34 @@ void _Video_SetupBanks( bool bBank2 ) } //=========================================================================== + +// NB. Can get "big" 1000+ms times: these occur during disk loading when the emulator is at full-speed. + +//#define DEBUG_REFRESH_TIMINGS + +#if defined(_DEBUG) && defined(DEBUG_REFRESH_TIMINGS) +static void DebugRefresh(char uDebugFlag) +{ + static DWORD uLastRefreshTime = 0; + + const DWORD uTimeBetweenRefreshes = uLastRefreshTime ? emulmsec - uLastRefreshTime : 0; + uLastRefreshTime = emulmsec; + + if (!uTimeBetweenRefreshes) + return; // 1st time in func + + char szStr[100]; + sprintf(szStr, "Time between refreshes = %d ms %c\n", uTimeBetweenRefreshes, (uDebugFlag==0)?' ':uDebugFlag); + OutputDebugString(szStr); +} +#endif + VideoUpdateFuncPtr_t VideoRefreshScreen () { +#if defined(_DEBUG) && defined(DEBUG_REFRESH_TIMINGS) + DebugRefresh(0); +#endif + // CHECK EACH CELL FOR CHANGED BYTES. REDRAW PIXELS FOR THE CHANGED BYTES // IN THE FRAME BUFFER. MARK CELLS IN WHICH REDRAWING HAS TAKEN PLACE AS // DIRTY.