From ee6d8ac0118b9b76dfc3dea15ea63b223875d9be Mon Sep 17 00:00:00 2001 From: Sour Date: Wed, 1 Apr 2020 23:19:20 -0400 Subject: [PATCH] Debugger: Event Viewer - Display dot on current pixel --- Core/EventManager.cpp | 14 ++++++++++++-- Core/EventManager.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Core/EventManager.cpp b/Core/EventManager.cpp index f1ca6545..cd3d22dc 100644 --- a/Core/EventManager.cpp +++ b/Core/EventManager.cpp @@ -129,12 +129,17 @@ void EventManager::DrawEvent(DebugEventInfo &evt, bool drawBackground, uint32_t color |= 0xFF000000; } + uint32_t y = std::min((evt.Scanline + 1) * 2, _scanlineCount * 2); + uint32_t x = evt.Cycle * 2; + DrawDot(x, y, color, drawBackground, buffer); +} + +void EventManager::DrawDot(uint32_t x, uint32_t y, uint32_t color, bool drawBackground, uint32_t* buffer) +{ int iMin = drawBackground ? -2 : 0; int iMax = drawBackground ? 3 : 1; int jMin = drawBackground ? -2 : 0; int jMax = drawBackground ? 3 : 1; - uint32_t y = std::min((evt.Scanline + 1) * 2, _scanlineCount * 2); - uint32_t x = evt.Cycle * 2; for(int i = iMin; i <= iMax; i++) { for(int j = jMin; j <= jMax; j++) { @@ -168,6 +173,7 @@ uint32_t EventManager::TakeEventSnapshot(EventViewerDisplayOptions options) _snapshot = _debugEvents; _snapshotScanline = scanline; + _snapshotCycle = cycle; if(options.ShowPreviousFrameEvents && scanline != 0) { for(DebugEventInfo &evt : _prevDebugEvents) { uint32_t evtKey = (evt.Scanline << 9) + evt.Cycle; @@ -222,6 +228,10 @@ void EventManager::GetDisplayBuffer(uint32_t *buffer, EventViewerDisplayOptions for(DebugEventInfo &evt : _snapshot) { DrawEvent(evt, false, buffer, options); } + + //Draw dot over current pixel + DrawDot(_snapshotCycle * 2, _snapshotScanline * 2, 0xFF990099, true, buffer); + DrawDot(_snapshotCycle * 2, _snapshotScanline * 2, 0xFFFF00FF, false, buffer); } void EventManager::DrawPixel(uint32_t *buffer, int32_t x, uint32_t y, uint32_t color) diff --git a/Core/EventManager.h b/Core/EventManager.h index b5dbe172..61ed36bd 100644 --- a/Core/EventManager.h +++ b/Core/EventManager.h @@ -24,12 +24,14 @@ private: vector _snapshot; uint16_t _snapshotScanline = 0; + uint16_t _snapshotCycle = 0; SimpleLock _lock; uint32_t _scanlineCount = 262; uint16_t *_ppuBuffer = nullptr; void DrawEvent(DebugEventInfo &evt, bool drawBackground, uint32_t *buffer, EventViewerDisplayOptions &options); + void DrawDot(uint32_t x, uint32_t y, uint32_t color, bool drawBackground, uint32_t* buffer); void DrawNtscBorders(uint32_t *buffer); void DrawPixel(uint32_t *buffer, int32_t x, uint32_t y, uint32_t color);