Debugger: Event Viewer - Display dot on current pixel

This commit is contained in:
Sour 2020-04-01 23:19:20 -04:00
parent d400842e98
commit ee6d8ac011
2 changed files with 14 additions and 2 deletions

View file

@ -129,12 +129,17 @@ void EventManager::DrawEvent(DebugEventInfo &evt, bool drawBackground, uint32_t
color |= 0xFF000000; color |= 0xFF000000;
} }
uint32_t y = std::min<uint32_t>((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 iMin = drawBackground ? -2 : 0;
int iMax = drawBackground ? 3 : 1; int iMax = drawBackground ? 3 : 1;
int jMin = drawBackground ? -2 : 0; int jMin = drawBackground ? -2 : 0;
int jMax = drawBackground ? 3 : 1; int jMax = drawBackground ? 3 : 1;
uint32_t y = std::min<uint32_t>((evt.Scanline + 1) * 2, _scanlineCount * 2);
uint32_t x = evt.Cycle * 2;
for(int i = iMin; i <= iMax; i++) { for(int i = iMin; i <= iMax; i++) {
for(int j = jMin; j <= jMax; j++) { for(int j = jMin; j <= jMax; j++) {
@ -168,6 +173,7 @@ uint32_t EventManager::TakeEventSnapshot(EventViewerDisplayOptions options)
_snapshot = _debugEvents; _snapshot = _debugEvents;
_snapshotScanline = scanline; _snapshotScanline = scanline;
_snapshotCycle = cycle;
if(options.ShowPreviousFrameEvents && scanline != 0) { if(options.ShowPreviousFrameEvents && scanline != 0) {
for(DebugEventInfo &evt : _prevDebugEvents) { for(DebugEventInfo &evt : _prevDebugEvents) {
uint32_t evtKey = (evt.Scanline << 9) + evt.Cycle; uint32_t evtKey = (evt.Scanline << 9) + evt.Cycle;
@ -222,6 +228,10 @@ void EventManager::GetDisplayBuffer(uint32_t *buffer, EventViewerDisplayOptions
for(DebugEventInfo &evt : _snapshot) { for(DebugEventInfo &evt : _snapshot) {
DrawEvent(evt, false, buffer, options); 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) void EventManager::DrawPixel(uint32_t *buffer, int32_t x, uint32_t y, uint32_t color)

View file

@ -24,12 +24,14 @@ private:
vector<DebugEventInfo> _snapshot; vector<DebugEventInfo> _snapshot;
uint16_t _snapshotScanline = 0; uint16_t _snapshotScanline = 0;
uint16_t _snapshotCycle = 0;
SimpleLock _lock; SimpleLock _lock;
uint32_t _scanlineCount = 262; uint32_t _scanlineCount = 262;
uint16_t *_ppuBuffer = nullptr; uint16_t *_ppuBuffer = nullptr;
void DrawEvent(DebugEventInfo &evt, bool drawBackground, uint32_t *buffer, EventViewerDisplayOptions &options); 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 DrawNtscBorders(uint32_t *buffer);
void DrawPixel(uint32_t *buffer, int32_t x, uint32_t y, uint32_t color); void DrawPixel(uint32_t *buffer, int32_t x, uint32_t y, uint32_t color);