Fix video tearing by only updating during the Apple II VBL (#711)

This commit is contained in:
tomcw 2019-11-03 15:05:28 +00:00
parent d92eca5068
commit 4ad0923399
4 changed files with 14 additions and 3 deletions

View File

@ -356,7 +356,7 @@ static void ContinueExecution(void)
//
const UINT dwClksPerFrame = NTSC_GetCyclesPerFrame();
if (g_dwCyclesThisFrame >= dwClksPerFrame)
if (g_dwCyclesThisFrame >= dwClksPerFrame && !VideoGetVblBar())
{
g_dwCyclesThisFrame -= dwClksPerFrame;

View File

@ -2003,8 +2003,12 @@ void NTSC_VideoInit( uint8_t* pFramebuffer ) // wsVideoInit
//===========================================================================
void NTSC_VideoReinitialize( DWORD cyclesThisFrame, bool bInitVideoScannerAddress )
{
_ASSERT(cyclesThisFrame < g_videoScanner6502Cycles);
if (cyclesThisFrame >= g_videoScanner6502Cycles) cyclesThisFrame = 0; // error
if (cyclesThisFrame >= g_videoScanner6502Cycles)
{
// Possible, since ContinueExecution() loop waits until: cycles > g_videoScanner6502Cycles && VBL
cyclesThisFrame %= g_videoScanner6502Cycles;
}
g_nVideoClockVert = (uint16_t) (cyclesThisFrame / VIDEO_SCANNER_MAX_HORZ);
g_nVideoClockHorz = cyclesThisFrame % VIDEO_SCANNER_MAX_HORZ;

View File

@ -874,6 +874,7 @@ 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
@ -888,6 +889,11 @@ bool VideoGetVblBar(const DWORD uExecutedCycles)
return nCycles < kVDisplayableScanLines * kHClocks;
}
bool VideoGetVblBar(void)
{
return g_nVideoClockVert < kVDisplayableScanLines;
}
//===========================================================================
#define MAX_DRAW_DEVICES 10

View File

@ -189,6 +189,7 @@ 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 VideoGetSW80COL(void);
bool VideoGetSWDHIRES(void);