From ad12a8e6d29876d7d196a6d6f208ae64f90e32c5 Mon Sep 17 00:00:00 2001 From: tomcw Date: Thu, 24 May 2018 21:34:26 +0100 Subject: [PATCH] Fix for #555: . Start video rendering from screen position -1 (ie. 1 DHGR pixel offscreen) . Allows 559th DHGR vertical column to be visible . But now an HGR HCOLOR=2 vertical line at column 0 is only 1 DHGR pixel wide Also: . Fix TEXT80 to be aligned with DHGR . Fix FLASH in TEXT80 (inverse aux bits needed to be masked with 0x7f) --- source/NTSC.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/source/NTSC.cpp b/source/NTSC.cpp index 70578e6d..42d35096 100644 --- a/source/NTSC.cpp +++ b/source/NTSC.cpp @@ -658,6 +658,9 @@ inline void updateFramebufferMonitorDoubleScanline( uint16_t signal, bgra_t *pTa #endif //=========================================================================== + +// NB. g_nLastColumnPixelNTSC = bits.b13 will be superseded by these parent funcs which use bits.b14: +// . updateScreenDoubleHires80(), updateScreenDoubleLores80(), updateScreenText80() inline void updatePixels( uint16_t bits ) { if (g_nColorBurstPixels < 2) @@ -683,7 +686,7 @@ inline void updatePixels( uint16_t bits ) /* #7 of 7 */ g_pFuncUpdateBnWPixel(bits & 1); bits >>= 1; g_pFuncUpdateBnWPixel(bits & 1); - g_nLastColumnPixelNTSC=bits& 1 ; bits >>= 1; + g_nLastColumnPixelNTSC = bits & 1; } else { @@ -708,7 +711,7 @@ inline void updatePixels( uint16_t bits ) /* #7 of 7 */ g_pFuncUpdateHuePixel(bits & 1); bits >>= 1; // 0000 0000 0000 0abc g_pFuncUpdateHuePixel(bits & 1); - g_nLastColumnPixelNTSC=bits& 1 ; bits >>= 1; // 0000 0000 0000 00ab + g_nLastColumnPixelNTSC = bits & 1; } } @@ -723,7 +726,7 @@ inline void updateVideoScannerHorzEOL() if (g_nColorBurstPixels < 2) { // NOTE: This writes out-of-bounds for a 560x384 framebuffer - g_pFuncUpdateBnWPixel(0); + g_pFuncUpdateBnWPixel(g_nLastColumnPixelNTSC); g_pFuncUpdateBnWPixel(0); g_pFuncUpdateBnWPixel(0); g_pFuncUpdateBnWPixel(0); @@ -731,7 +734,7 @@ inline void updateVideoScannerHorzEOL() else { // NOTE: This writes out-of-bounds for a 560x384 framebuffer - g_pFuncUpdateHuePixel(g_nLastColumnPixelNTSC); // BUGFIX: ARCHON: green fringe on end of line + g_pFuncUpdateHuePixel(g_nLastColumnPixelNTSC); g_pFuncUpdateHuePixel(0); g_pFuncUpdateHuePixel(0); g_pFuncUpdateHuePixel(0); @@ -1154,8 +1157,6 @@ void updateScreenDoubleHires40 (long cycles6502) // wsUpdateVideoHires0 //=========================================================================== void updateScreenDoubleHires80 (long cycles6502 ) // wsUpdateVideoDblHires { - uint16_t bits; - if (g_nVideoMixed && g_nVideoClockVert >= VIDEO_SCANNER_Y_MIXED) { g_pFuncUpdateTextScreen( cycles6502 ); @@ -1180,10 +1181,10 @@ void updateScreenDoubleHires80 (long cycles6502 ) // wsUpdateVideoDblHires uint8_t m = pMain[0]; uint8_t a = pAux [0]; - bits = ((m & 0x7f) << 7) | (a & 0x7f); - bits = (bits << 1) | g_nLastColumnPixelNTSC; // TC: needed else colours are wrong phase + uint16_t bits = ((m & 0x7f) << 7) | (a & 0x7f); + bits = (bits << 1) | g_nLastColumnPixelNTSC; updatePixels( bits ); - g_nLastColumnPixelNTSC = (bits >> 14) & 3; + g_nLastColumnPixelNTSC = (bits >> 14) & 1; } } updateVideoScannerHorzEOL(); @@ -1256,12 +1257,10 @@ void updateScreenDoubleLores80 (long cycles6502) // wsUpdateVideoDblLores uint16_t aux = hi >> (((1 - (g_nVideoClockHorz & 1)) * 2) + 3); uint16_t bits = (main << 7) | (aux & 0x7f); updatePixels( bits ); - g_nLastColumnPixelNTSC = (bits >> 14) & 3; - + g_nLastColumnPixelNTSC = (bits >> 14) & 1; } } updateVideoScannerHorzEOL(); - } } @@ -1273,7 +1272,7 @@ void updateScreenSingleHires40 (long cycles6502) g_pFuncUpdateTextScreen( cycles6502 ); return; } - + for (; cycles6502 > 0; --cycles6502) { uint16_t addr = updateVideoScannerAddressHGR(); @@ -1393,8 +1392,10 @@ void updateScreenText80 (long cycles6502) if ((0 == g_nVideoCharSet) && 0x40 == (a & 0xC0)) // Flash only if mousetext not active aux ^= g_nTextFlashMask; - uint16_t bits = (main << 7) | aux; + uint16_t bits = (main << 7) | (aux & 0x7f); + bits = (bits << 1) | g_nLastColumnPixelNTSC; // GH#555: Align TEXT80 chars with DHGR updatePixels( bits ); + g_nLastColumnPixelNTSC = (bits >> 14) & 1; } } updateVideoScannerHorzEOL(); @@ -1628,7 +1629,11 @@ 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 + sizeof(bgra_t) * GetFrameBufferWidth() * ((GetFrameBufferHeight() - 1) - y - GetFrameBufferBorderHeight()) + (sizeof(bgra_t) * GetFrameBufferBorderWidth())); + { + uint32_t offset = sizeof(bgra_t) * GetFrameBufferWidth() * ((GetFrameBufferHeight() - 1) - y - GetFrameBufferBorderHeight()) + (sizeof(bgra_t) * GetFrameBufferBorderWidth()); + offset -= sizeof(bgra_t); // GH#555: Start 1 RGBA pixel before frame to account for g_nLastColumnPixelNTSC + g_pScanLines[y] = (bgra_t*) (g_pFramebufferbits + offset); + } g_pVideoAddress = g_pScanLines[0];