Wait for A2 VBL before VideoRefreshScreen()

- stops tearing
Moved WaitForVerticalBlank() before StretchBlt()
- window is updated after StretchBlt(), not after GdiFlush()
Still get juddery animation.
This commit is contained in:
tomcw 2019-08-26 09:26:54 +01:00
parent 521a09e75a
commit 27284dad2b
2 changed files with 15 additions and 2 deletions

View File

@ -352,12 +352,24 @@ static void ContinueExecution(void)
const UINT dwClksPerFrame = NTSC_GetCyclesPerFrame();
if (g_dwCyclesThisFrame >= dwClksPerFrame)
{
#if 0
g_dwCyclesThisFrame -= dwClksPerFrame;
if (g_bFullSpeed)
VideoRedrawScreenDuringFullSpeed(g_dwCyclesThisFrame);
else
VideoRefreshScreen(); // Just copy the output of our Apple framebuffer to the system Back Buffer
#else
if (g_nVideoClockVert >= 192)
{
g_dwCyclesThisFrame %= dwClksPerFrame;
if (g_bFullSpeed)
VideoRedrawScreenDuringFullSpeed(g_dwCyclesThisFrame);
else
VideoRefreshScreen(); // Just copy the output of our Apple framebuffer to the system Back Buffer
}
#endif
MB_EndOfVideoFrame();
}
@ -1533,7 +1545,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
LogFileOutput("Init: SysClk_InitTimer(), res=%d\n", bSpeechOK ? 1:0);
}
#endif
#if 0
#if 1
DDInit(); // For WaitForVerticalBlank()
#endif

View File

@ -603,6 +603,8 @@ void VideoRefreshScreen ( uint32_t uRedrawWholeScreenVideoMode /* =0*/, bool bRe
int wdest = g_nViewportCX;
int hdest = g_nViewportCY;
if (!bRedrawWholeScreen && g_lpDD) g_lpDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
SetStretchBltMode(hFrameDC, COLORONCOLOR);
StretchBlt(
hFrameDC,
@ -614,7 +616,6 @@ void VideoRefreshScreen ( uint32_t uRedrawWholeScreenVideoMode /* =0*/, bool bRe
SRCCOPY);
}
//if (g_lpDD) g_lpDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
GdiFlush();
}