From: Toni Wilen Date: Thu, 18 Aug 2022 18:22:39 +0000 (+0300) Subject: INTENA/INTREQ timing update. IPL state included in DMA debugger. X-Git-Tag: 41000~158 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=26ce210812d8fc463c43fcdf979c70b3048a438e;p=francis%2Fwinuae.git INTENA/INTREQ timing update. IPL state included in DMA debugger. --- diff --git a/custom.cpp b/custom.cpp index a183c1c9..e083f4b1 100644 --- a/custom.cpp +++ b/custom.cpp @@ -181,6 +181,7 @@ static uae_u8 color_regs_genlock[256]; static uae_u16 cregs[256]; uae_u16 intena, intreq; +static uae_u16 intena2, intreq2; uae_u16 dmacon; uae_u16 adkcon; /* used by audio code */ uae_u16 last_custom_value; @@ -7670,8 +7671,8 @@ int intlev(void) } return lvl; } - uae_u16 imask = intreq & intena; - if (!(imask && (intena & 0x4000))) + uae_u16 imask = intreq2 & intena2; + if (!(imask && (intena2 & 0x4000))) return -1; if (imask & (0x4000 | 0x2000)) // 13 14 return 6; @@ -7723,18 +7724,19 @@ static void rethink_intreq(void) devices_rethink(); } -static void intreq_checks(uae_u16 old) +static void intreq_checks(uae_u16 oldreq, uae_u16 newreq) { - if ((old & 0x0800) && !(intreq & 0x0800)) { + if ((oldreq & 0x0800) && !(newreq & 0x0800)) { serial_rbf_clear(); } } static void doint_delay_do_ext(uae_u32 v) { - uae_u16 old = intreq; + uae_u16 old = intreq2; setclr(&intreq, (1 << v) | 0x8000); - intreq_checks(old); + setclr(&intreq2, (1 << v) | 0x8000); + intreq_checks(old, intreq2); doint(); } @@ -7763,9 +7765,9 @@ void INTREQ_INT(int num, int delay) static void doint_delay_do_intreq(uae_u32 v) { - uae_u16 old = intreq; - setclr(&intreq, v); - intreq_checks(old); + uae_u16 old = intreq2; + setclr(&intreq2, v); + intreq_checks(old, intreq2); doint(); } @@ -7783,6 +7785,8 @@ static void doint_delay_intreq(uae_u16 v) static void doint_delay_do_intena(uae_u32 v) { + setclr(&intena2, v); + doint(); } @@ -7812,7 +7816,8 @@ static void INTREQ_nodelay(uae_u16 v) { uae_u16 old = intreq; setclr(&intreq, v); - intreq_checks(old); + intreq2 = intreq; + intreq_checks(old, intreq); doint(); } @@ -7820,7 +7825,8 @@ void INTREQ_f(uae_u16 v) { uae_u16 old = intreq; setclr(&intreq, v); - intreq_checks(old); + intreq2 = intreq; + intreq_checks(old, intreq); } bool INTREQ_0(uae_u16 v) @@ -7828,10 +7834,6 @@ bool INTREQ_0(uae_u16 v) uae_u16 old = intreq; setclr(&intreq, v); - //write_log("%04x %04x -> %04x %08x\n", v, old, intreq, M68K_GETPC); - - intreq_checks(old); - if (old != intreq) { doint_delay_intreq(v); } @@ -9812,7 +9814,7 @@ static void do_copper_fetch(int hpos, uae_u16 id) } } #ifdef DEBUGGER - if (debug_copper && !cop_state.ignore_next) { + if (debug_copper && cop_state.ignore_next <= 0) { uaecptr next = 0xffffffff; if (reg == 0x88) { next = cop1lc; @@ -10044,16 +10046,15 @@ static void update_copper(int until_hpos) // Wait finished, request IR1. case COP_wait: { + if (copper_cant_read(hpos, CYCLE_PIPE_COPPER | 0x04)) { + goto next; + } #ifdef DEBUGGER if (debug_dma) record_dma_event(DMA_EVENT_COPPERWAKE, hpos, vpos); if (debug_copper) record_copper(cop_state.ip - 4, 0xffffffff, cop_state.ir[0], cop_state.ir[1], hpos, vpos); #endif - if (copper_cant_read(hpos, CYCLE_PIPE_COPPER | 0x04)) { - goto next; - } - cop_state.state = COP_read1; } break; @@ -10087,18 +10088,17 @@ static void update_copper(int until_hpos) if (!coppercomp(hpos, false)) { cop_state.ignore_next = 1; - -#ifdef DEBUGGER - if (debug_dma && cop_state.ignore_next > 0) - record_dma_event(DMA_EVENT_COPPERSKIP, hpos, vpos); - if (debug_copper) - record_copper(cop_state.ip - 4, 0xffffffff, cop_state.ir[0], cop_state.ir[1], hpos, vpos); -#endif - } else { cop_state.ignore_next = -1; } +#ifdef DEBUGGER + if (debug_dma && cop_state.ignore_next > 0) + record_dma_event(DMA_EVENT_COPPERSKIP, hpos, vpos); + if (debug_copper) + record_copper(cop_state.ip - 4, 0xffffffff, cop_state.ir[0], cop_state.ir[1], hpos, vpos); +#endif + cop_state.state = COP_read1; break; @@ -13102,6 +13102,8 @@ void custom_cpuchange(void) // after CPU mode changes intreq = intreq | 0x8000; intena = intena | 0x8000; + intreq2 = intreq; + intena2 = intena; } @@ -13206,8 +13208,8 @@ void custom_reset(bool hardreset, bool keyboardreset) memset(spr, 0, sizeof spr); dmacon = 0; - intreq = 0; - intena = 0; + intreq = intreq2 = 0; + intena = intena2 = 0; copcon = 0; DSKLEN (0, 0); @@ -14221,6 +14223,9 @@ uae_u8 *restore_custom(uae_u8 *src) bitplane_dma_change(dmacon); vdiw_change(vdiwstate == diw_states::DIW_waiting_stop); + intreq2 = intreq; + intena2 = intena; + current_colors.extra = 0; if (isbrdblank(-1, bplcon0, bplcon3)) { current_colors.extra |= 1 << CE_BORDERBLANK; diff --git a/debug.cpp b/debug.cpp index a0ca1130..7e16b10f 100644 --- a/debug.cpp +++ b/debug.cpp @@ -1930,6 +1930,19 @@ void record_dma_hsync(int lasthpos) #endif } +void record_dma_ipl(int hpos, int vpos) +{ + struct dma_rec *dr; + + if (!dma_record[0]) + return; + if (hpos >= NR_DMA_REC_HPOS || vpos >= NR_DMA_REC_VPOS) + return; + dr = &dma_record[dma_record_toggle][vpos * NR_DMA_REC_HPOS + hpos]; + dr->intlev = regs.intmask; + dr->ipl = regs.ipl_pin; +} + void record_dma_event(uae_u32 evt, int hpos, int vpos) { struct dma_rec *dr; @@ -1940,6 +1953,22 @@ void record_dma_event(uae_u32 evt, int hpos, int vpos) return; dr = &dma_record[dma_record_toggle][vpos * NR_DMA_REC_HPOS + hpos]; dr->evt |= evt; + dr->ipl = regs.ipl_pin; +} + +void record_dma_event_data(uae_u32 evt, int hpos, int vpos, uae_u32 data) +{ + struct dma_rec *dr; + + if (!dma_record[0]) + return; + if (hpos >= NR_DMA_REC_HPOS || vpos >= NR_DMA_REC_VPOS) + return; + dr = &dma_record[dma_record_toggle][vpos * NR_DMA_REC_HPOS + hpos]; + dr->evt |= evt; + dr->evtdata = data; + dr->evtdataset = true; + dr->ipl = regs.ipl_pin; } void record_dma_replace(int hpos, int vpos, int type, int extra) @@ -1997,6 +2026,7 @@ void record_dma_write(uae_u16 reg, uae_u32 dat, uae_u32 addr, int hpos, int vpos dr->type = type; dr->extra = extra; dr->intlev = regs.intmask; + dr->ipl = regs.ipl_pin; dr->size = 2; last_dma_rec = dr; debug_mark_refreshed(dr->addr); @@ -2103,11 +2133,13 @@ void record_dma_read(uae_u16 reg, uae_u32 addr, int hpos, int vpos, int type, in dr->type = type; dr->extra = extra; dr->intlev = regs.intmask; + dr->ipl = regs.ipl_pin; + last_dma_rec = dr; debug_mark_refreshed(dr->addr); } -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) +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, uae_u32 *split, int *iplp) { int longsize = dr->size; bool got = false; @@ -2134,6 +2166,12 @@ static bool get_record_dma_info(struct dma_rec *dr, int hpos, int vpos, TCHAR *l if (l6) l6[0] = 0; + if (split) { + if ((dr->evt & DMA_EVENT_CPUINS) && dr->evtdataset) { + *split = dr->evtdata; + } + } + if (dr->type != 0 || dr->reg != 0xffff || dr->evt) got = true; @@ -2198,7 +2236,23 @@ static bool get_record_dma_info(struct dma_rec *dr, int hpos, int vpos, TCHAR *l } else { _tcscpy(srtext, sr); } - _stprintf (l1, _T("[%02X %3d]"), hpos, hpos); + int ipl = 0; + if (iplp) { + ipl = *iplp; + if (dr->ipl > 0) { + ipl = dr->ipl; + } else if (dr->ipl < 0) { + ipl = 0; + } + *iplp = ipl; + } + if (ipl >= 0) { + _stprintf(l1, _T("[%02X %d]"), hpos, ipl); + } else if (ipl == -2) { + _stprintf(l1, _T("[%02X -]"), hpos); + } else { + _stprintf(l1, _T("[%02X ]"), hpos); + } if (l4) { _tcscpy(l4, _T(" ")); } @@ -2400,6 +2454,7 @@ static void decode_dma_record (int hpos, int vpos, int toggle, bool logfile) maxh = maxh2; } } + int ipl = -2; while (h < maxh) { int cols = (logfile ? 16 : 8); TCHAR l1[200]; @@ -2416,8 +2471,9 @@ static void decode_dma_record (int hpos, int vpos, int toggle, bool logfile) l6[0] = 0; for (i = 0; i < cols && h < maxh; i++, h++, dr++) { TCHAR l1l[16], l2l[16], l3l[16], l4l[16], l5l[16], l6l[16]; + uae_u32 split = 0xffffffff; - get_record_dma_info(dr, h, vpos, l1l, l2l, l3l, l4l, l5l, l6l); + get_record_dma_info(dr, h, vpos, l1l, l2l, l3l, l4l, l5l, l6l, &split, &ipl); TCHAR *p = l1 + _tcslen(l1); _stprintf(p, _T("%9s "), l1l); @@ -2431,6 +2487,39 @@ static void decode_dma_record (int hpos, int vpos, int toggle, bool logfile) _stprintf(p, _T("%9s "), l5l); p = l6 + _tcslen(l6); _stprintf(p, _T("%9s "), l6l); + + if (split != 0xffffffff) { + if (split < 0x10000) { + struct instr *dp = table68k + split; + if (dp->mnemo == i_ILLG) { + split = 0x4AFC; + dp = table68k + split; + } + struct mnemolookup *lookup; + for (lookup = lookuptab; lookup->mnemo != dp->mnemo; lookup++) + ; + const TCHAR *opcodename = lookup->friendlyname; + if (!opcodename) { + opcodename = lookup->name; + } + TCHAR *ptrs[7]; + ptrs[0] = &l1[_tcslen(l1)]; + ptrs[1] = &l2[_tcslen(l2)]; + ptrs[2] = &l3[_tcslen(l3)]; + ptrs[3] = &l4[_tcslen(l4)]; + ptrs[4] = &l5[_tcslen(l5)]; + ptrs[5] = &l6[_tcslen(l6)]; + for (int i = 0; i < 6; i++) { + if (!opcodename[i]) { + break; + } + TCHAR *p = ptrs[i]; + p[-1] = opcodename[i]; + } + } else { + l1[_tcslen(l1) - 1] = '*'; + } + } } if (logfile) { write_dlog(_T("%s\n"), l1); @@ -5922,7 +6011,7 @@ 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, l1, l2, l3, l4, NULL, NULL)) { + if (get_record_dma_info(dr, hp, vp, l1, l2, l3, l4, NULL, NULL, NULL, NULL)) { console_out_f(_T(" - %02X %s %s %s\n"), hp, l2, l3, l4); } hp++; diff --git a/include/debug.h b/include/debug.h index 2de18823..6b55b72c 100644 --- a/include/debug.h +++ b/include/debug.h @@ -224,9 +224,11 @@ struct dma_rec uae_u16 size; uae_u32 addr; uae_u32 evt; + uae_u32 evtdata; + bool evtdataset; uae_s16 type; uae_u16 extra; - uae_s8 intlev; + uae_s8 intlev, ipl; uae_u16 cf_reg, cf_dat, cf_addr; int ciareg; int ciamask; @@ -268,6 +270,7 @@ extern struct dma_rec *last_dma_rec; #define DMA_EVENT_CIAB_IRQ 0x10000000 #define DMA_EVENT_CPUSTOP 0x20000000 #define DMA_EVENT_CPUSTOPIPL 0x40000000 +#define DMA_EVENT_CPUINS 0x80000000 #define DMARECORD_REFRESH 1 @@ -288,11 +291,13 @@ extern void record_dma_read_value_wide(uae_u64 v, bool quad); extern void record_dma_replace(int hpos, int vpos, int type, int extra); extern void record_dma_reset(void); extern void record_dma_event(uae_u32 evt, int hpos, int vpos); +extern void record_dma_event_data(uae_u32 evt, int hpos, int vpos, uae_u32 data); extern void record_dma_clear(int hpos, int vpos); extern bool record_dma_check(int hpos, int vpos); 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 record_dma_ipl(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); diff --git a/newcpu.cpp b/newcpu.cpp index d33d894b..c1784150 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -3332,6 +3332,10 @@ static void ExceptionX (int nr, uaecptr address, uaecptr oldpc) uaecptr pc = m68k_getpc(); regs.exception = nr; regs.loop_mode = 0; + + if (debug_dma) { + record_dma_event_data(DMA_EVENT_CPUINS, current_hpos(), vpos, 0x20000); + } if (cpu_tracer) { cputrace.state = nr; } @@ -3416,7 +3420,7 @@ static int get_ipl(void) static void do_interrupt (int nr) { if (debug_dma) - record_dma_event (DMA_EVENT_CPUIRQ, current_hpos (), vpos); + record_dma_event(DMA_EVENT_CPUIRQ, current_hpos (), vpos); if (inputrecord_debug & 2) { if (input_record > 0) @@ -4400,10 +4404,15 @@ void doint(void) if (!ppc_interrupt(intlev())) return; } +#endif + int il = intlev(); + regs.ipl_pin = il; +#ifdef DEBUGGER + if (debug_dma) { + record_dma_ipl(current_hpos(), vpos); + } #endif if (m68k_interrupt_delay) { - int il = intlev(); - regs.ipl_pin = il; if (regs.ipl_pin > 0) { set_special(SPCFLAG_INT); } @@ -4834,6 +4843,9 @@ static void m68k_run_1_ce (void) } r->instruction_pc = m68k_getpc (); + if (debug_dma) { + record_dma_event_data(DMA_EVENT_CPUINS, current_hpos(), vpos, r->opcode); + } (*cpufunctbl[r->opcode])(r->opcode); if (!regs.loop_mode)