From a58f990ab838e24a8750a77621a09403528d44c0 Mon Sep 17 00:00:00 2001 From: tomcw Date: Tue, 11 Oct 2016 21:52:11 +0100 Subject: [PATCH] Fix PrintScreen for Color TV and B&W TV (fix #356) --- source/NTSC.cpp | 2 +- source/Video.cpp | 51 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/source/NTSC.cpp b/source/NTSC.cpp index f1190b20..beeee566 100644 --- a/source/NTSC.cpp +++ b/source/NTSC.cpp @@ -1623,7 +1623,7 @@ void NTSC_VideoInit( uint8_t* pFramebuffer ) // wsVideoInit updateMonochromeTables( 0xFF, 0xFF, 0xFF ); for (int y = 0; y < (VIDEO_SCANNER_Y_DISPLAY*2); y++) - g_pScanLines[y] = (bgra_t*)(g_pFramebufferbits + 4 * FRAMEBUFFER_W * ((FRAMEBUFFER_H - 1) - y - 18) + 80); + g_pScanLines[y] = (bgra_t*)(g_pFramebufferbits + sizeof(bgra_t) * FRAMEBUFFER_W * ((FRAMEBUFFER_H - 1) - y - BORDER_H) + (sizeof(bgra_t) * BORDER_W)); g_pVideoAddress = g_pScanLines[0]; diff --git a/source/Video.cpp b/source/Video.cpp index 798b8f96..4a0472d4 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -1168,6 +1168,31 @@ static void DebugRefresh(char uDebugFlag) } #endif +// TC: Hacky-fix for GH#341 - better to draw to the correct position in the framebuffer to start with! (in NTSC.cpp) +static void VideoFrameBufferAdjust(int& xSrc, int& ySrc, bool bInvertY=false) +{ + int dx=0, dy=0; + + if (g_eVideoType == VT_MONO_TV || g_eVideoType == VT_COLOR_TV) + { + // Adjust the src locations for the NTSC video modes + dx = 2; + dy = -1; + } + else if (g_eVideoType == VT_COLOR_MONITOR) + { + //if ((g_uVideoMode & VF_TEXT) == 0) // NB. Not sufficient, eg. ANSI STORY... + if ( NTSC_GetColorBurst() == true ) // ANSI STORY (end credits): split DGR/TEXT80/DGR on scanline + dx = 2; + } + + if (bInvertY) + dy -= dy; + + xSrc += dx; + ySrc += dy; +} + void VideoRefreshScreen ( int bVideoModeFlags, bool bRedrawWholeScreen /* =false*/ ) { #if defined(_DEBUG) && defined(DEBUG_REFRESH_TIMINGS) @@ -1214,21 +1239,7 @@ void VideoRefreshScreen ( int bVideoModeFlags, bool bRedrawWholeScreen /* =false int xSrc = BORDER_W; int ySrc = BORDER_H; - -#if 1 // TC: Hacky-fix for GH#341 - better to draw to the correct position in the framebuffer to start with! (in NTSC.cpp) - if (g_eVideoType == VT_MONO_TV || g_eVideoType == VT_COLOR_TV) - { - // Adjust the src locations for the NTSC video modes - xSrc += 2; - ySrc -= 1; - } - else if (g_eVideoType == VT_COLOR_MONITOR) - { - //if ((g_uVideoMode & VF_TEXT) == 0) - if ( NTSC_GetColorBurst() == true ) // ANSI STORY (end credits): split DGR/TEXT80/DGR on scanline - xSrc += 2; - } -#endif + VideoFrameBufferAdjust(xSrc, ySrc); // TC: Hacky-fix for GH#341 int xdest = GetFullScreenOffsetX(); int ydest = GetFullScreenOffsetY(); @@ -1757,8 +1768,14 @@ void Video_MakeScreenShot(FILE *pFile) // No need to use GetDibBits() since we already have http://msdn.microsoft.com/en-us/library/ms532334.aspx // @reference: "Storing an Image" http://msdn.microsoft.com/en-us/library/ms532340(VS.85).aspx pSrc = (uint32_t*) g_pFramebufferbits; - pSrc += BORDER_H * FRAMEBUFFER_W; // Skip top border - pSrc += BORDER_W; // Skip left border + + int xSrc = BORDER_W; + int ySrc = BORDER_H; + VideoFrameBufferAdjust(xSrc, ySrc, true); // TC: Hacky-fix for GH#341 & GH#356 + // Lines stored in reverse, so invert the y-adjust value + + pSrc += xSrc; // Skip left border + pSrc += ySrc * FRAMEBUFFER_W; // Skip top border if( g_iScreenshotType == SCREENSHOT_280x192 ) {