From 737e5a4552299a0daf43cc18f7201da5fa8842de Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 13 Mar 2026 17:33:32 +0200 Subject: [PATCH] Full overlay visual DMA debugger --- debug.cpp | 67 +++++++++++++++++++++++++++++++++++-------------- drawing.cpp | 34 ++++++++++++++++++++++--- include/debug.h | 5 +++- 3 files changed, 83 insertions(+), 23 deletions(-) diff --git a/debug.cpp b/debug.cpp index c1066030..e4058c6a 100644 --- a/debug.cpp +++ b/debug.cpp @@ -246,7 +246,7 @@ static const TCHAR help[] = { _T(" dm Dump current address space map.\n") _T(" v [] []\n") _T(" Show DMA data (accurate only in cycle-exact mode).\n") - _T(" v [-1 to -4] = enable visual DMA debugger.\n") + _T(" v [-2 to -5] = enable visual DMA debugger.\n") _T(" vh [ ] \"Heat map\"\n") _T(" I Send custom event string\n") _T(" ? Hex ($ and 0x)/Bin (%)/Dec (!) converter and calculator.\n") @@ -1555,6 +1555,8 @@ static void set_debug_colors(void) set_dbg_color(DMARECORD_SPRITE, 0, 0xff, 0x00, 0xff, 8, _T("Sprite")); set_dbg_color(DMARECORD_DISK, 0, 0xff, 0xff, 0xff, 3, _T("Disk")); set_dbg_color(DMARECORD_CONFLICT, 0, 0xff, 0xb8, 0x40, 0, _T("Conflict")); + set_dbg_color(DMARECORD_DIW, 0, 0xcf, 0xcf, 0xcf, 0, _T("DIW")); + set_dbg_color(DMARECORD_DDF, 0, 0xcf, 0xcf, 0x4f, 0, _T("DDF")); for (int i = 0; i < DMARECORD_MAX; i++) { for (int j = 1; j < DMARECORD_SUBITEMS; j++) { @@ -1574,19 +1576,55 @@ static void set_debug_colors(void) static int cycles_toggle; +int get_dma_debug_color(struct dma_rec *dr, int line, uae_u32 *cp) +{ + int t = 0; + if (dr->reg != 0xffff && debug_colors[dr->type].enabled) { + uae_u32 c = 0; + // General DMA slots + c = debug_colors[dr->type].l[dr->extra & 7]; + + // Special cases + if (dr->cf_reg != 0xffff && ((cycles_toggle ^ line) & 1)) { + c = debug_colors[DMARECORD_CONFLICT].l[0]; + } else if (dr->extra > 0xF) { + // High bits of "extra" contain additional blitter state. + if (dr->extra & 0x10) + c = debug_colors[dr->type].l[4]; // blit fill, channels A-D + else if (dr->extra & 0x20) + c = debug_colors[dr->type].l[6]; // blit line, channels A-D + } + t = 1; + if ((dr->denise_evt_changed[0] | dr->denise_evt_changed[1]) & DENISE_EVENT_HDIW) { + c |= debug_colors[DMARECORD_DIW].l[0]; + t = 3; + } + if (dr->agnus_evt_changed & AGNUS_EVENT_VDIW) { + c |= debug_colors[DMARECORD_DIW].l[0]; + t = 2; + } + if (dr->agnus_evt_changed & AGNUS_EVENT_BPRUN) { + c |= debug_colors[DMARECORD_DDF].l[0]; + t = 2; + } + *cp = c; + } + return t; +} + static void debug_draw_cycles(uae_u8 *buf, uae_u8 *genlock, int line, int width, int height, uae_u32 *xredcolors, uae_u32 *xgreencolors, uae_u32 *xbluescolors) { int y, x, xx, dx, xplus, yplus; struct dma_rec *dr; static bool endline; - if (debug_dma >= 4) + if (debug_dma >= 5) yplus = 2; else yplus = 1; - if (debug_dma >= 5) + if (debug_dma >= 6) xplus = 3; - else if (debug_dma >= 3) + else if (debug_dma >= 4) xplus = 2; else xplus = 1; @@ -1631,21 +1669,7 @@ static void debug_draw_cycles(uae_u8 *buf, uae_u8 *genlock, int line, int width, if (ended || dr->tick != tick) { c = 0; } else { - if (dr->reg != 0xffff && debug_colors[dr->type].enabled) { - // General DMA slots - c = debug_colors[dr->type].l[dr->extra & 7]; - - // Special cases - if (dr->cf_reg != 0xffff && ((cycles_toggle ^ line) & 1)) { - c = debug_colors[DMARECORD_CONFLICT].l[0]; - } else if (dr->extra > 0xF) { - // High bits of "extra" contain additional blitter state. - if (dr->extra & 0x10) - c = debug_colors[dr->type].l[4]; // blit fill, channels A-D - else if (dr->extra & 0x20) - c = debug_colors[dr->type].l[6]; // blit line, channels A-D - } - } + get_dma_debug_color(dr, line, &c); } if (dr->intlev > intlev) intlev = dr->intlev; @@ -7443,11 +7467,16 @@ static bool debug_line (TCHAR *input) if (debug_dma && v1 >= 0 && v2 >= 0) { decode_dma_record(v2, v1, v3, cmd == 'v', nextcmd == 'l'); } else { + int ddma = debug_dma; if (debug_dma) { record_dma_reset(0); reset_drawing(); } + set_debug_colors(); debug_dma = v1 < 0 ? -v1 : 1; + if ((ddma == 2 && debug_dma != 2) || (ddma != 2 && debug_dma == 2)) { + reset_drawing(); + } console_out_f(_T("DMA debugger enabled, mode=%d.\n"), debug_dma); } } diff --git a/drawing.cpp b/drawing.cpp index 7dd044c3..f0af053e 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -1972,7 +1972,7 @@ bool drawing_can_lineoptimizations(void) currprefs.cs_color_burst || currprefs.gfx_grayscale || currprefs.monitoremu) { return false; } - if ((lightpen_active && currprefs.lightpen_crosshair) || debug_dma >= 2 || debug_heatmap >= 2) { + if ((lightpen_active && currprefs.lightpen_crosshair) || debug_dma >= 3 || debug_heatmap >= 2) { return false; } if (video_recording_active) { @@ -1984,7 +1984,7 @@ bool drawing_can_lineoptimizations(void) static void draw_frame_extras(struct vidbuffer *vb, int y_start, int y_end) { #ifdef DEBUGGER - if (debug_dma > 1 || debug_heatmap > 1) { + if (debug_dma > 2 || debug_heatmap > 1) { if (denise_lock()) { for (int i = 0; i < vb->outheight; i++) { int line = i; @@ -3598,6 +3598,9 @@ void denise_reset(bool hard) last_bpl_pix = 0; decode_specials = 0; decode_specials_debug = currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA ? 2 : (currprefs.display_calibration ? 1 : 0); + if (debug_dma == 2) { + decode_specials_debug |= 0x100; + } debug_special_hvsync = currprefs.gfx_overscanmode == OVERSCANMODE_ULTRA + 1; debug_special_csync = currprefs.gfx_overscanmode == OVERSCANMODE_ULTRA + 2; denise_csync_blanken = false; @@ -5565,9 +5568,10 @@ static uae_u32 filter_pixel(uae_u32 p1, uae_u32 p2) } // ultra extreme debug pixel patterns +static bool dmadebugtoggle; static uint32_t decode_denise_specials_debug(uint32_t v, int inc) { - if (decode_specials_debug > 1) { + if ((decode_specials_debug & 15) > 1) { int t = ((inc >> 1) + this_line->linear_vpos + 1) & 3; if (denise_blank_active2) { if (t == 0) { @@ -5604,6 +5608,30 @@ static uint32_t decode_denise_specials_debug(uint32_t v, int inc) } } } + if (debug_dma == 2 && debug_dma_ptr) { + uae_u32 cv = 0; + int t = 0; + if (dmadebugtoggle) { + t = get_dma_debug_color(debug_dma_ptr, this_line->linear_vpos, &cv); + if ((this_line->linear_vpos & 1) && dmadebugtoggle) { + if (t) { + v = cv; + } + } + if (t > 1) { + v = cv; + } + } + if (!(this_line->linear_vpos & 1)) { + dmadebugtoggle = false; + } + dmadebugtoggle = !dmadebugtoggle; + if (!t) { + //v >>= 1; + //v &= 0x7f7f7f7f; + } + } + *buf_d++ = v; return v; } diff --git a/include/debug.h b/include/debug.h index cc6854e8..d4b172f1 100644 --- a/include/debug.h +++ b/include/debug.h @@ -320,7 +320,9 @@ extern struct dma_rec *last_dma_rec; #define DMARECORD_UHRESBPL 9 #define DMARECORD_UHRESSPR 10 #define DMARECORD_CONFLICT 11 -#define DMARECORD_MAX 12 +#define DMARECORD_DIW 12 +#define DMARECORD_DDF 13 +#define DMARECORD_MAX 14 extern void record_dma_read(uae_u16 reg, uae_u32 addr, int type, int extra); extern void record_dma_write(uae_u16 reg, uae_u32 v, uae_u32 addr, int type, int extra); @@ -342,6 +344,7 @@ extern void record_dma_ipl_sample(void); extern void debug_mark_refreshed(uaecptr); extern void debug_draw(uae_u8 *buf, uae_u8 *genlock, int line, int width, int height, uae_u32 *xredcolors, uae_u32 *xgreencolors, uae_u32 *xbluescolors); extern struct dma_rec *record_dma_next_cycle(int hpos, int vpos, int vvpos); +extern int get_dma_debug_color(struct dma_rec *dr, int line, uae_u32 *cp); #define TRACE_SKIP_INS 1 #define TRACE_MATCH_PC 2 -- 2.47.3