From d63a31a043a8a89c4b3de08798f2c6cc3f010f35 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 14 Jan 2023 14:08:42 +0000 Subject: [PATCH] NTSC: only use accessors to get internal video clock vert/horz values --- source/Debugger/Debug.cpp | 6 +++--- source/Debugger/Debugger_Display.cpp | 2 +- source/NTSC.cpp | 15 ++++++++++----- source/NTSC.h | 7 +++---- source/Video.cpp | 6 +++--- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index ab800d01..fa09f72a 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -1350,7 +1350,7 @@ int CheckBreakpointsVideo() if (pBP->eSource != BP_SRC_VIDEO_SCANNER) continue; - uint16_t vert = NTSC_GetVideoVForDebugger(); // update video scanner's vert/horz position - needed for when in fullspeed (GH#1164) + uint16_t vert = NTSC_GetVideoVertForDebugger(); // update video scanner's vert/horz position - needed for when in fullspeed (GH#1164) if (_CheckBreakpointValue(pBP, vert)) { bBreakpointHit = BP_HIT_VIDEO_POS; @@ -7893,7 +7893,7 @@ void OutputTraceLine () if (g_bTraceFileWithVideoScanner) { uint16_t vert, horz; - NTSC_GetVideoHVForDebugger(vert, horz); // update video scanner's vert/horz position - needed for when in fullspeed (GH#1164) + NTSC_GetVideoVertHorzForDebugger(vert, horz); // update video scanner's vert/horz position - needed for when in fullspeed (GH#1164) uint32_t data; int dataSize; @@ -8519,7 +8519,7 @@ void DebugContinueStepping(const bool bCallerWillUpdateDisplay/*=false*/) stopReason = (g_LBR == LBR_UNDEFINED) ? StrFormat("Interrupt occurred (LBR unknown)") : StrFormat("Interrupt occurred at $%04X", g_LBR); else if (g_bDebugBreakpointHit & BP_HIT_VIDEO_POS) - stopReason = StrFormat("Video scanner position matches at vpos=$%04X", NTSC_GetVideoVForDebugger()); + stopReason = StrFormat("Video scanner position matches at vpos=$%04X", NTSC_GetVideoVertForDebugger()); else if (g_bDebugBreakpointHit & BP_DMA_TO_IO_MEM) stopReason = StrFormat("HDD DMA to I/O memory or ROM at $%04X", g_DebugBreakOnDMAIO.memoryAddr); else if (g_bDebugBreakpointHit & BP_DMA_FROM_IO_MEM) diff --git a/source/Debugger/Debugger_Display.cpp b/source/Debugger/Debugger_Display.cpp index a3b4c59d..2b7412e0 100644 --- a/source/Debugger/Debugger_Display.cpp +++ b/source/Debugger/Debugger_Display.cpp @@ -3232,7 +3232,7 @@ static void DrawVideoScannerValue(int line, int vert, int horz, bool isVisible) static void DrawVideoScannerInfo(int line) { uint16_t v, h; - NTSC_GetVideoHVForDebugger(v, h); // update video scanner's vert/horz position - needed for when in fullspeed (GH#1164) + NTSC_GetVideoVertHorzForDebugger(v, h); // update video scanner's vert/horz position - needed for when in fullspeed (GH#1164) if (g_videoScannerDisplayInfo.isHorzReal) { diff --git a/source/NTSC.cpp b/source/NTSC.cpp index 41eae4a8..c5bc5fde 100644 --- a/source/NTSC.cpp +++ b/source/NTSC.cpp @@ -69,8 +69,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Globals (Public) ___________________________________________________ - uint16_t g_nVideoClockVert = 0; // 9-bit: VC VB VA V5 V4 V3 V2 V1 V0 = 0 .. 262 - uint16_t g_nVideoClockHorz = 0; // 6-bit: H5 H4 H3 H2 H1 H0 = 0 .. 64, 25 >= visible (NB. final hpos is 2 cycles long, so a line is 65 cycles) + static uint16_t g_nVideoClockVert = 0; // 9-bit: VC VB VA V5 V4 V3 V2 V1 V0 = 0 .. 262 + static uint16_t g_nVideoClockHorz = 0; // 6-bit: H5 H4 H3 H2 H1 H0 = 0 .. 64, 25 >= visible (NB. final hpos is 2 cycles long, so a line is 65 cycles) // Globals (Private) __________________________________________________ static int g_nVideoCharSet = 0; @@ -1940,7 +1940,12 @@ uint16_t NTSC_VideoGetScannerAddress ( const ULONG uExecutedCycles ) return addr; } -void NTSC_GetVideoHVForDebugger(uint16_t& vert, uint16_t& horz) +uint16_t NTSC_GetVideoVert(void) +{ + return g_nVideoClockVert; +} + +void NTSC_GetVideoVertHorzForDebugger(uint16_t& vert, uint16_t& horz) { ResetCyclesExecutedForDebugger(); // if in full-speed, then reset cycles so that CpuCalcCycles() doesn't ASSERT NTSC_VideoGetScannerAddress(0); @@ -1948,10 +1953,10 @@ void NTSC_GetVideoHVForDebugger(uint16_t& vert, uint16_t& horz) horz = g_nVideoClockHorz; } -uint16_t NTSC_GetVideoVForDebugger(void) +uint16_t NTSC_GetVideoVertForDebugger(void) { uint16_t vert, horz; - NTSC_GetVideoHVForDebugger(vert, horz); + NTSC_GetVideoVertHorzForDebugger(vert, horz); return vert; } diff --git a/source/NTSC.h b/source/NTSC.h index aad683d8..f4bcc079 100644 --- a/source/NTSC.h +++ b/source/NTSC.h @@ -3,8 +3,6 @@ #include "Video.h" // NB. needed by GCC (for fwd enum declaration) // Globals (Public) -extern uint16_t g_nVideoClockVert; -extern uint16_t g_nVideoClockHorz; extern uint32_t g_nChromaSize; // Prototypes (Public) ________________________________________________ @@ -14,8 +12,9 @@ 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); -void NTSC_GetVideoHVForDebugger(uint16_t& vert, uint16_t& horz); -uint16_t NTSC_GetVideoVForDebugger(void); +uint16_t NTSC_GetVideoVert(void); +void NTSC_GetVideoVertHorzForDebugger(uint16_t& vert, uint16_t& horz); +uint16_t NTSC_GetVideoVertForDebugger(void); void NTSC_Destroy(void); void NTSC_VideoInit(uint8_t *pFramebuffer); void NTSC_VideoReinitialize(DWORD cyclesThisFrame, bool bInitVideoScannerAddress); diff --git a/source/Video.cpp b/source/Video.cpp index d6e47f60..860e599d 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -156,7 +156,7 @@ void Video::VideoReinitialize(bool bInitVideoScannerAddress) NTSC_VideoInitAppleType(); NTSC_SetVideoStyle(); NTSC_SetVideoTextMode( g_uVideoMode & VF_80COL ? 80 : 40 ); - NTSC_SetVideoMode( g_uVideoMode ); // Pre-condition: g_nVideoClockHorz (derived from g_dwCyclesThisFrame) + NTSC_SetVideoMode( g_uVideoMode ); VideoSwitchVideocardPalette(RGB_GetVideocard(), GetVideoType()); } @@ -455,7 +455,7 @@ bool Video::VideoGetVblBarEx(const DWORD dwCyclesThisFrame) NTSC_VideoClockResync(dwCyclesThisFrame); } - return g_nVideoClockVert < kVDisplayableScanLines; + return NTSC_GetVideoVert() < kVDisplayableScanLines; } // Called when *inside* CpuExecute() @@ -467,7 +467,7 @@ bool Video::VideoGetVblBar(const DWORD uExecutedCycles) NTSC_VideoClockResync(CpuGetCyclesThisVideoFrame(uExecutedCycles)); } - return g_nVideoClockVert < kVDisplayableScanLines; + return NTSC_GetVideoVert() < kVDisplayableScanLines; } //===========================================================================