Simplified ContinueExecution(): video refresh part.

This commit is contained in:
tomcw 2014-07-20 10:23:23 +01:00
parent 8637dfa7af
commit a75555d21c
2 changed files with 45 additions and 30 deletions

View File

@ -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();
}

View File

@ -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.