From 4a88569d800aa0ea4171df69dc27dac569a3e03f Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 2 Aug 2022 12:01:59 +0300 Subject: [PATCH] DMA debugger variable number of line lengths and scanlines supported. --- custom.cpp | 11 ++++- debug.cpp | 122 ++++++++++++++++++++++++++++++------------------ include/debug.h | 4 +- 3 files changed, 90 insertions(+), 47 deletions(-) diff --git a/custom.cpp b/custom.cpp index d5500908..40a7609e 100644 --- a/custom.cpp +++ b/custom.cpp @@ -11717,6 +11717,11 @@ static void set_hpos(void) maxhposeven = (maxhpos & 1) == 0; eventtab[ev_hsync].evtime = get_cycles() + HSYNCTIME; eventtab[ev_hsync].oldcycles = get_cycles(); +#ifdef DEBUGGER + if (debug_dma) { + record_dma_hsync(maxhpos); + } +#endif } // this finishes current line @@ -11775,6 +11780,11 @@ static void hsync_handler_pre(bool onvsync) vpos = 0; } if (onvsync) { +#ifdef DEBUGGER + if (debug_dma) { + record_dma_vsync(vpos); + } +#endif vpos = 0; vsync_counter++; } @@ -12768,7 +12778,6 @@ static void hsync_handler_post(bool onvsync) if (lol) { record_dma_event(DMA_EVENT_LOL, REFRESH_FIRST_HPOS + 2, vpos); } - record_dma_hsync(); } diff --git a/debug.cpp b/debug.cpp index 89903c29..91e2ec21 100644 --- a/debug.cpp +++ b/debug.cpp @@ -1441,8 +1441,9 @@ static void set_debug_colors(void) } static int cycles_toggle; +static int record_dma_maxhpos, record_dma_maxvpos; -static void debug_draw_cycles (uae_u8 *buf, int bpp, int line, int width, int height, uae_u32 *xredcolors, uae_u32 *xgreencolors, uae_u32 *xbluescolors) +static void debug_draw_cycles(uae_u8 *buf, int bpp, 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; @@ -1466,41 +1467,49 @@ static void debug_draw_cycles (uae_u8 *buf, int bpp, int line, int width, int he if (y < 0) return; - if (y > maxvpos) + if (y > record_dma_maxvpos) return; if (y >= height) return; - dx = width - xplus * ((maxhpos + 1) & ~1) - 16; + dx = width - xplus * ((record_dma_maxhpos + 1) & ~1) - 16; + bool ended = false; uae_s8 intlev = 0; - for (x = 0; x < maxhpos; x++) { + for (x = 0; x < record_dma_maxhpos; x++) { uae_u32 c = debug_colors[0].l[0]; xx = x * xplus + dx; dr = &dma_record[t][y * NR_DMA_REC_HPOS + x]; - 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 + if (dr->end) { + ended = true; + } + if (ended) { + 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 + } } } if (dr->intlev > intlev) intlev = dr->intlev; - putpixel (buf, bpp, xx + 4, c); - if (xplus) - putpixel (buf, bpp, xx + 4 + 1, c); - if (debug_dma >= 6) - putpixel (buf, bpp, xx + 4 + 2, c); + putpixel(buf, bpp, xx + 4, c); + if (xplus > 1) + putpixel(buf, bpp, xx + 4 + 1, c); + if (xplus > 2) + putpixel(buf, bpp, xx + 4 + 2, c); } putpixel (buf, bpp, dx + 0, 0); putpixel (buf, bpp, dx + 1, lc(intlevc[intlev])); @@ -1879,11 +1888,39 @@ void debug_mark_refreshed(uaecptr rp) rd->cnt = 0; } -void record_dma_hsync(void) +void record_dma_vsync(int vp) +{ + struct dma_rec *dr; + + if (!dma_record[0]) + return; + if (vp >= NR_DMA_REC_VPOS) + return; + + dr = &dma_record[dma_record_toggle][vp * NR_DMA_REC_HPOS]; + dr->end = true; + + cycles_toggle = cycles_toggle ? 0 : 1; +} + +void record_dma_hsync(int lasthpos) { - if (vpos == 0) { - cycles_toggle = cycles_toggle ? 0 : 1; + struct dma_rec *dr; + + if (!dma_record[0]) + return; + if (lasthpos >= NR_DMA_REC_HPOS || vpos >= NR_DMA_REC_VPOS) + return; + + dr = &dma_record[dma_record_toggle][vpos * NR_DMA_REC_HPOS + lasthpos]; + dr->end = true; + if (lasthpos > record_dma_maxhpos) { + record_dma_maxhpos = lasthpos; + } + if (vpos > record_dma_maxvpos) { + record_dma_maxvpos = vpos; } + #if 0 refcheck_count++; if (refcheck_count >= REFRESH_LINES / 8) { @@ -2070,7 +2107,7 @@ void record_dma_read(uae_u16 reg, uae_u32 addr, int hpos, int vpos, int type, in debug_mark_refreshed(dr->addr); } -static bool get_record_dma_info(struct dma_rec *dr, int hpos, int vpos, evt_t cycles, TCHAR *l1, TCHAR *l2, TCHAR *l3, TCHAR *l4, TCHAR *l5, TCHAR *l6) +static bool get_record_dma_info(struct dma_rec *dr, int hpos, int vpos, TCHAR *l1, TCHAR *l2, TCHAR *l3, TCHAR *l4, TCHAR *l5, TCHAR *l6) { int longsize = dr->size; bool got = false; @@ -2084,8 +2121,6 @@ static bool get_record_dma_info(struct dma_rec *dr, int hpos, int vpos, evt_t cy uae_u32 extraval; bool noval = false; - cycles += (vpos * maxhpos + hpos) * CYCLE_UNIT; - if (l1) l1[0] = 0; if (l2) @@ -2339,8 +2374,7 @@ static bool get_record_dma_info(struct dma_rec *dr, int hpos, int vpos, evt_t cy static void decode_dma_record (int hpos, int vpos, int toggle, bool logfile) { struct dma_rec *dr, *dr_start; - int h, i, maxh; - evt_t cycles; + int h, i, maxh = 0; if (!dma_record[0] || hpos < 0 || vpos < 0) return; @@ -2352,13 +2386,16 @@ static void decode_dma_record (int hpos, int vpos, int toggle, bool logfile) else console_out_f (_T("Line: %02X %3d HPOS %02X %3d:\n"), vpos, vpos, hpos, hpos); h = hpos; - dr += hpos; - maxh = hpos + (logfile ? maxhpos_short : 80); - if (maxh > maxhpos_short) - maxh = maxhpos_short; - cycles = vsync_cycles; - if (toggle) - cycles -= maxvpos * maxhpos_short * CYCLE_UNIT; + while (maxh < NR_DMA_REC_HPOS) { + if (dr->end) + break; + maxh++; + dr++; + } + dr = dr_start; + if (!logfile && maxh - h > 80) { + maxh = h + 80; + } while (h < maxh) { int cols = (logfile ? 16 : 8); TCHAR l1[200]; @@ -2376,12 +2413,7 @@ static void decode_dma_record (int hpos, int vpos, int toggle, bool logfile) for (i = 0; i < cols && h < maxh; i++, h++, dr++) { TCHAR l1l[16], l2l[16], l3l[16], l4l[16], l5l[16], l6l[16]; - get_record_dma_info(dr, h, vpos, cycles, l1l, l2l, l3l, l4l, l5l, l6l); - if (dr_start[3 + 2].evt & DMA_EVENT_LOL) { - if (maxh == maxhpos_short) { - maxh++; - } - } + get_record_dma_info(dr, h, vpos, l1l, l2l, l3l, l4l, l5l, l6l); TCHAR *p = l1 + _tcslen(l1); _stprintf(p, _T("%9s "), l1l); @@ -5885,11 +5917,11 @@ static void dma_disasm(int frames, int vp, int hp, int frames_end, int vp_end, i if (!dr) return; TCHAR l1[16], l2[16], l3[16], l4[16]; - if (get_record_dma_info(dr, hp, vp, 0, l1, l2, l3, l4, NULL, NULL)) { + if (get_record_dma_info(dr, hp, vp, l1, l2, l3, l4, NULL, NULL)) { console_out_f(_T(" - %02X %s %s %s\n"), hp, l2, l3, l4); } hp++; - if (hp >= maxhpos) { + if (dr->end) { hp = 0; vp++; if (vp >= maxvpos + 1) { diff --git a/include/debug.h b/include/debug.h index b881d4bf..2de18823 100644 --- a/include/debug.h +++ b/include/debug.h @@ -232,6 +232,7 @@ struct dma_rec int ciamask; bool ciarw; uae_u16 ciavalue; + bool end; }; extern struct dma_rec *last_dma_rec; @@ -289,7 +290,8 @@ extern void record_dma_reset(void); extern void record_dma_event(uae_u32 evt, int hpos, int vpos); extern void record_dma_clear(int hpos, int vpos); extern bool record_dma_check(int hpos, int vpos); -extern void record_dma_hsync(void); +extern void record_dma_hsync(int); +extern void record_dma_vsync(int); extern void record_cia_access(int r, int mask, uae_u16 value, bool rw, int hpos, int vpos); extern void debug_mark_refreshed(uaecptr); extern void debug_draw(uae_u8 *buf, int bpp, int line, int width, int height, uae_u32 *xredcolors, uae_u32 *xgreencolors, uae_u32 *xbluescolors); -- 2.47.3