From 9df0ea1e21d7ba8cfbadc2cf1a74c0c30a61f7f6 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 2 Oct 2022 20:23:54 +0100 Subject: [PATCH] Video: fix floating bus in new function getVideoScannerAddressTXTorHGR(): . when 'in mixed mode && vert >= 160' return text (not hires) video memory --- source/Debugger/Debug.cpp | 7 +++-- source/Debugger/Debugger_Display.cpp | 2 +- source/NTSC.cpp | 44 ++++++++++++---------------- source/NTSC.h | 2 +- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index b4020ba5..ba4b24da 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -7801,15 +7801,16 @@ void OutputTraceLine () if (g_bTraceFileWithVideoScanner) { - uint16_t addr = NTSC_VideoGetScannerAddressForDebugger(); - BYTE data = mem[addr]; + uint32_t data; + int dataSize; + uint16_t addr = NTSC_GetScannerAddressAndData(data, dataSize); fprintf( g_hTraceFile, "%04X %04X %04X %02X %02X %02X %02X %04X %s %s\n", g_nVideoClockVert, g_nVideoClockHorz, addr, - data, + (uint8_t)data, // truncated (unsigned)regs.a, (unsigned)regs.x, (unsigned)regs.y, diff --git a/source/Debugger/Debugger_Display.cpp b/source/Debugger/Debugger_Display.cpp index a6184a71..f6bf0ab7 100644 --- a/source/Debugger/Debugger_Display.cpp +++ b/source/Debugger/Debugger_Display.cpp @@ -3231,7 +3231,7 @@ static void DrawVideoScannerValue(int line, int vert, int horz, bool isVisible) //=========================================================================== static void DrawVideoScannerInfo(int line) { - NTSC_VideoGetScannerAddressForDebugger(); // update g_nVideoClockHorz/g_nVideoClockVert + NTSC_UpdateVideoHVForDebugger(); // update g_nVideoClockHorz/g_nVideoClockVert int v = g_nVideoClockVert; int h = g_nVideoClockHorz; diff --git a/source/NTSC.cpp b/source/NTSC.cpp index 9c646de5..5dcd5aa9 100644 --- a/source/NTSC.cpp +++ b/source/NTSC.cpp @@ -319,8 +319,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA INLINE void updatePixels( uint16_t bits ); INLINE void updateVideoScannerHorzEOL(); INLINE void updateVideoScannerAddress(); - INLINE uint16_t getVideoScannerAddressTXT(); - INLINE uint16_t getVideoScannerAddressHGR(); static void initChromaPhaseTables(); static real initFilterChroma (real z); @@ -869,6 +867,19 @@ INLINE uint16_t getVideoScannerAddressHGR() return nAddress; } +//=========================================================================== +INLINE uint16_t getVideoScannerAddressTXTorHGR() +{ + const bool isTextAddr = ((g_nVideoMixed && g_nVideoClockVert >= VIDEO_SCANNER_Y_MIXED) || + (g_uNewVideoModeFlags & VF_TEXT) || + !(g_uNewVideoModeFlags & VF_HIRES)); + + if (isTextAddr) + return getVideoScannerAddressTXT(); + else + return getVideoScannerAddressHGR(); +} + //=========================================================================== INLINE uint16_t getVideoScannerAddressSHR() { @@ -1915,12 +1926,7 @@ uint16_t NTSC_VideoGetScannerAddress ( const ULONG uExecutedCycles ) g_nVideoClockVert = g_videoScannerMaxVert-1; } - uint16_t addr; - bool bHires = (GetVideo().GetVideoMode() & VF_HIRES) && !(GetVideo().GetVideoMode() & VF_TEXT); // SW_HIRES && !SW_TEXT - if( bHires ) - addr = getVideoScannerAddressHGR(); - else - addr = getVideoScannerAddressTXT(); + uint16_t addr = getVideoScannerAddressTXTorHGR(); g_nVideoClockVert = currVideoClockVert; g_nVideoClockHorz = currVideoClockHorz; @@ -1928,10 +1934,10 @@ uint16_t NTSC_VideoGetScannerAddress ( const ULONG uExecutedCycles ) return addr; } -uint16_t NTSC_VideoGetScannerAddressForDebugger(void) +void NTSC_UpdateVideoHVForDebugger(void) { ResetCyclesExecutedForDebugger(); // if in full-speed, then reset cycles so that CpuCalcCycles() doesn't ASSERT - return NTSC_VideoGetScannerAddress(0); + NTSC_VideoGetScannerAddress(0); } //=========================================================================== @@ -2722,11 +2728,9 @@ bool NTSC_IsVisible(void) // For debugger uint16_t NTSC_GetScannerAddressAndData(uint32_t& data, int& dataSize) { - uint16_t addr = 0; - if (g_uNewVideoModeFlags & VF_SHR) { - addr = getVideoScannerAddressSHR(); + uint16_t addr = getVideoScannerAddressSHR(); uint32_t* pAux = (uint32_t*)MemGetAuxPtr(addr); // 8 pixels (320 mode) / 16 pixels (640 mode) data = pAux[0]; dataSize = 4; @@ -2735,17 +2739,6 @@ uint16_t NTSC_GetScannerAddressAndData(uint32_t& data, int& dataSize) // - if ( (g_nVideoMixed && g_nVideoClockVert >= VIDEO_SCANNER_Y_MIXED) || - (g_uNewVideoModeFlags & VF_TEXT) || - !(g_uNewVideoModeFlags & VF_HIRES) ) - { - addr = getVideoScannerAddressTXT(); - } - else - { - addr = getVideoScannerAddressHGR(); - } - // Copy logic from NTSC_SetVideoMode() if (g_uNewVideoModeFlags & VF_TEXT) { @@ -2787,8 +2780,9 @@ uint16_t NTSC_GetScannerAddressAndData(uint32_t& data, int& dataSize) if (g_nVideoMixed && g_nVideoClockVert >= VIDEO_SCANNER_Y_MIXED && (g_uNewVideoModeFlags & VF_80COL)) dataSize = 2; - + uint16_t addr = getVideoScannerAddressTXTorHGR(); data = 0; + if (dataSize == 2) { uint8_t* pAux = MemGetAuxPtr(addr); diff --git a/source/NTSC.h b/source/NTSC.h index 6e64ea1b..6894cc7d 100644 --- a/source/NTSC.h +++ b/source/NTSC.h @@ -14,7 +14,7 @@ void NTSC_SetVideoTextMode(int cols); uint32_t* NTSC_VideoGetChromaTable(bool bHueTypeMonochrome, bool bMonitorTypeColorTV); void NTSC_VideoClockResync(const DWORD dwCyclesThisFrame); uint16_t NTSC_VideoGetScannerAddress(const ULONG uExecutedCycles); -uint16_t NTSC_VideoGetScannerAddressForDebugger(void); +void NTSC_UpdateVideoHVForDebugger(void); void NTSC_Destroy(void); void NTSC_VideoInit(uint8_t *pFramebuffer); void NTSC_VideoReinitialize(DWORD cyclesThisFrame, bool bInitVideoScannerAddress);