diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index b14f7835..561e33fb 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -6459,8 +6459,6 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, VideoUpdateFuncPtr_t pfUpdate ); Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags ) { - VideoSetForceFullRedraw(); - switch( iPage ) { case VIEW_PAGE_X: bVideoModeFlags |= _Video_SetupBanks( VideoGetSWPAGE2() ); break; // Page Current @@ -6474,7 +6472,7 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags ) MessageBoxA( NULL, "bVideoModeFlags = ZERO !?", "Information", MB_OK ); #endif g_bDebuggerViewingAppleOutput = bVideoModeFlags; - VideoRefreshScreen( bVideoModeFlags ); + VideoRefreshScreen( bVideoModeFlags, true ); return UPDATE_NOTHING; // intentional } @@ -8234,8 +8232,6 @@ void DebugContinueStepping () { if (nStepsTaken == 0x10000) // HACK_MAGIC_NUM VideoRedrawScreen(); -// else -// VideoRefreshScreen(); } } else diff --git a/source/Frame.cpp b/source/Frame.cpp index 2dd70442..c43380a4 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -623,8 +623,7 @@ static void DrawFrameWindow () else if (g_nAppMode == MODE_DEBUG) DebugDisplay(1); else - VideoRedrawScreen(0); // TODO: Presume this is correct with new fullscreen window mode - //VideoRedrawScreen(g_bIsFullScreen ? 1 : 0); // On WM_PAINT: delay 1 refresh before rendering full-screen + VideoRedrawScreen(); if (g_bPaintingWindow) EndPaint(g_hFrameWindow,&ps); diff --git a/source/NTSC.cpp b/source/NTSC.cpp index ce5538c6..a5248739 100644 --- a/source/NTSC.cpp +++ b/source/NTSC.cpp @@ -1729,6 +1729,8 @@ bool NTSC_VideoIsVbl () //=========================================================================== void NTSC_VideoUpdateCycles( long cycles6502 ) { + _ASSERT(cycles6502 < VIDEO_SCANNER_6502_CYCLES); // Use NTSC_VideoRedrawWholeScreen() instead + bool bRedraw = cycles6502 >= VIDEO_SCANNER_6502_CYCLES; // if( !g_bFullSpeed ) @@ -1774,3 +1776,28 @@ if(true) } } } + +//=========================================================================== +void NTSC_VideoRedrawWholeScreen( void ) +{ + // Save/restore current V/H positions - maybe not strictly necessary, but should be harmless + uint16_t currVideoClockVert = g_nVideoClockVert; + uint16_t currVideoClockHorz = g_nVideoClockHorz; + + // Need to reset V/H positions so that redraw occurs from the start of the frame & mixed-mode is rendered correctly + g_nVideoClockVert = 0; + g_nVideoClockHorz = 0; + + if (g_nVideoMixed) + { + g_pFuncUpdateGraphicsScreen(VIDEO_SCANNER_MAX_HORZ * VIDEO_SCANNER_Y_MIXED); // lines [0..159] + g_pFuncUpdateGraphicsScreen(VIDEO_SCANNER_6502_CYCLES - (VIDEO_SCANNER_MAX_HORZ * VIDEO_SCANNER_Y_MIXED)); // lines [160..191..261] + } + else + { + g_pFuncUpdateGraphicsScreen(VIDEO_SCANNER_6502_CYCLES); // lines [0..261] + } + + g_nVideoClockVert = currVideoClockVert; + g_nVideoClockHorz = currVideoClockHorz; +} diff --git a/source/NTSC.h b/source/NTSC.h index d01bd250..85900764 100644 --- a/source/NTSC.h +++ b/source/NTSC.h @@ -18,3 +18,4 @@ extern void NTSC_VideoInitChroma(); extern bool NTSC_VideoIsVbl(); extern void NTSC_VideoUpdateCycles( long cycles6502 ); + extern void NTSC_VideoRedrawWholeScreen( void ); diff --git a/source/Video.cpp b/source/Video.cpp index 191fca27..f1323742 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -247,6 +247,7 @@ static LPBYTE g_aSourceStartofLine[ MAX_SOURCE_Y ]; static LPBYTE g_pTextBank1; // Aux static LPBYTE g_pTextBank0; // Main +// TC (25/8/2016): TODO: Need to investigate the use of this global flag for 1.27 static /*bool*/ UINT g_VideoForceFullRedraw = 1; static LPBYTE framebufferaddr = (LPBYTE)0; @@ -1126,11 +1127,10 @@ void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame) //=========================================================================== -void VideoRedrawScreen (UINT uDelayRefresh /* =0 */) +void VideoRedrawScreen (void) { - g_VideoForceFullRedraw = 1; - - VideoRefreshScreen( g_uVideoMode, uDelayRefresh ); + // NB. Can't rely on g_uVideoMode being non-zero (ie. so it can double up as a flag) since 'non-mixed GR' mode == 0x00. + VideoRefreshScreen( g_uVideoMode, true ); } //=========================================================================== @@ -1168,23 +1168,20 @@ static void DebugRefresh(char uDebugFlag) } #endif -void VideoRefreshScreen ( int bVideoModeFlags, UINT uDelayRefresh /* =0 */ ) +void VideoRefreshScreen ( int bVideoModeFlags, bool bRedrawWholeScreen /* =false*/ ) { - static UINT uDelayRefreshCount = 0; - if (uDelayRefresh) uDelayRefreshCount = uDelayRefresh; - #if defined(_DEBUG) && defined(DEBUG_REFRESH_TIMINGS) DebugRefresh(0); #endif - if (bVideoModeFlags || g_nAppMode == MODE_PAUSED) + if (bRedrawWholeScreen || g_nAppMode == MODE_PAUSED) { // bVideoModeFlags set if: // . MODE_DEBUG : always // . MODE_RUNNING : called from VideoRedrawScreen(), eg. during full-speed - if (bVideoModeFlags) + if (bRedrawWholeScreen) NTSC_SetVideoMode( bVideoModeFlags ); - NTSC_VideoUpdateCycles( VIDEO_SCANNER_6502_CYCLES ); + NTSC_VideoRedrawWholeScreen(); } // NTSC_BEGIN @@ -1204,12 +1201,6 @@ void VideoRefreshScreen ( int bVideoModeFlags, UINT uDelayRefresh /* =0 */ ) if (hFrameDC) { - if (uDelayRefreshCount) - { - // Delay the refresh in full-screen mode (to allow screen-capabilities to take effect) - required for Win7 (and others?) - --uDelayRefreshCount; - } - else { int xDst = 0; int yDst = 0; @@ -1381,13 +1372,6 @@ bool VideoGetSWAltCharSet(void) //=========================================================================== -void VideoSetForceFullRedraw(void) -{ - g_VideoForceFullRedraw = 1; -} - -//=========================================================================== - void VideoSetSnapshot_v1(const UINT AltCharSet, const UINT VideoMode) { g_nAltCharSetOffset = !AltCharSet ? 0 : 256; diff --git a/source/Video.h b/source/Video.h index 8190b8fe..2c6a8ac7 100644 --- a/source/Video.h +++ b/source/Video.h @@ -171,8 +171,8 @@ void VideoInitialize (); void VideoRealizePalette (HDC); void VideoRedrawScreenDuringFullSpeed(DWORD dwCyclesThisFrame, bool bInit = false); void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame); -void VideoRedrawScreen (UINT uDelayRefresh = 0); -void VideoRefreshScreen (int bVideoFlags, UINT uDelayRefresh =0 ); +void VideoRedrawScreen (void); +void VideoRefreshScreen (int bVideoFlags, bool bRedrawWholeScreen = false); void VideoReinitialize (); void VideoResetState (); WORD VideoGetScannerAddress(bool* pbVblBar_OUT, const DWORD uExecutedCycles); @@ -187,8 +187,6 @@ bool VideoGetSWPAGE2(void); bool VideoGetSWTEXT(void); bool VideoGetSWAltCharSet(void); -void VideoSetForceFullRedraw(void); - void VideoSetSnapshot_v1(const UINT AltCharSet, const UINT VideoMode); void VideoSaveSnapshot(class YamlSaveHelper& yamlSaveHelper); void VideoLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);