From: Toni Wilen Date: Sun, 12 Sep 2021 15:42:55 +0000 (+0300) Subject: Custom chipset WIP updates. X-Git-Tag: 4900~71 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=71d715fc7b5621fcff3b235a4824fd60e6e85dc5;p=francis%2Fwinuae.git Custom chipset WIP updates. --- diff --git a/akiko.cpp b/akiko.cpp index f9f8cf37..19262867 100644 --- a/akiko.cpp +++ b/akiko.cpp @@ -2301,7 +2301,7 @@ void restore_akiko_finish (void) void restore_akiko_final(void) { - if (!currprefs.cs_cd32cd) + if (!currprefs.cs_cd32cd || !akiko_inited) return; write_comm_pipe_u32(&requests, 0x0102, 1); // pause write_comm_pipe_u32(&requests, 0x0105, 1); // set mute diff --git a/audio.cpp b/audio.cpp index 9869b64f..1a133b76 100644 --- a/audio.cpp +++ b/audio.cpp @@ -49,10 +49,13 @@ #define DEBUG_AUDIO_HACK 0 #define DEBUG_CHANNEL_MASK 15 #define TEST_AUDIO 0 +#define TEST_MISSED_DMA 0 #define PERIOD_MIN 4 #define PERIOD_MIN_NONCE 60 +#define PERIOD_LOW 124 + int audio_channel_mask = 15; volatile bool cd_audio_mode_changed; @@ -121,6 +124,9 @@ struct audio_channel_data bool pbufldl; int drhpos; bool dat_written; +#if TEST_MISSED_DMA + bool dat_loaded; +#endif uaecptr lc, pt; int state; int per; @@ -1456,6 +1462,12 @@ static void newsample (int nr, sample8_t sample) } } +static void setdsr(uae_u32 v) +{ + struct audio_channel_data* cdp = audio_channel + v; + cdp->dsr = true; +} + static void setdr(int nr, bool startup) { struct audio_channel_data *cdp = audio_channel + nr; @@ -1469,15 +1481,20 @@ static void setdr(int nr, bool startup) if (debugchannel(nr) && cdp->wlen <= 2) write_log(_T("DR%d=%d LEN=%d/%d PT=%08X PC=%08X\n"), nr, cdp->dr, cdp->wlen, cdp->len, cdp->pt, M68K_GETPC); #endif - cdp->dr = true; cdp->drhpos = current_hpos(); if (!startup && cdp->wlen == 1) { - cdp->dsr = true; + if (!currprefs.cachesize && (cdp->per < PERIOD_LOW * CYCLE_UNIT || currprefs.cpu_compatible)) { + event2_newevent_xx(-1, 1 * CYCLE_UNIT, nr, setdsr); + } else { + setdsr(nr); + } #if DEBUG_AUDIO > 0 if (debugchannel(nr)) write_log(_T("DSR%d=1 PT=%08X PC=%08X\n"), nr, cdp->pt, M68K_GETPC); #endif + } else { + cdp->dr = true; } } else { #if DEBUG_AUDIO > 0 @@ -1522,6 +1539,13 @@ static void loaddat (int nr, bool modper) #endif cdp->dat2 = cdp->dat; } + +#if TEST_MISSED_DMA + if (!cdp->dat_loaded) { + write_log("Missed DMA %d\n", nr); + } + cdp->dat_loaded = false; +#endif } static void loaddat (int nr) { @@ -2328,13 +2352,16 @@ void AUDxDAT (int nr, uae_u16 v, uaecptr addr) #endif cdp->dat = v; cdp->dat_written = true; +#if TEST_MISSED_DMA + cdp->dat_loaded = true; +#endif #if TEST_AUDIO > 0 if (debugchannel (nr) && cdp->have_dat) write_log (_T("%d: audxdat 1=%04x 2=%04x but old dat not yet used\n"), nr, cdp->dat, cdp->dat2); cdp->have_dat = true; #endif // AUDxLEN is processed after 2 cycle delay - if (!currprefs.cachesize && (cdp->per < 124 * CYCLE_UNIT || currprefs.cpu_compatible)) { + if (!currprefs.cachesize && (cdp->per < PERIOD_LOW * CYCLE_UNIT || currprefs.cpu_compatible)) { event2_newevent_xx(-1, 2 * CYCLE_UNIT, nr | (chan_ena ? 0x100 : 0), audxdat_func); } else { audxdat_func(nr | (chan_ena ? 0x100 : 0)); diff --git a/blitter.cpp b/blitter.cpp index cbb6575d..5a5626a0 100644 --- a/blitter.cpp +++ b/blitter.cpp @@ -58,7 +58,8 @@ static int blit_ch; static bool shifter_skip_b, shifter_skip_y; static bool shifter_skip_b_old, shifter_skip_y_old; static uae_u16 bltcon0_old, bltcon1_old; -static bool shifter[4], shifter_out, shifter_first; +static bool shifter[4], shifter_out; +static int shifter_first; static bool blitline_c, blitfill_c; static int blitter_delayed_debug; @@ -441,10 +442,11 @@ static void blitter_end(void) blt_info.blitter_dangerous_bpl = 0; } -static void blitter_done_all(void) +static void blitter_done_all(int hpos) { blt_info.blit_main = 0; blt_info.blit_finald = 0; + blt_info.finishhpos = (hpos + 1) % maxhpos; blitter_interrupt(); blitter_done_notify(blitline); if (!blt_info.blit_queued && !blt_info.blit_finald) { @@ -467,7 +469,7 @@ STATIC_INLINE void chipmem_agnus_wput2 (uaecptr addr, uae_u32 w) debug_putpeekdma_chipram(addr, w, MW_MASK_BLITTER_D_N, 0x000, 0x054); chipmem_wput_indirect(addr, w); } - last_custom_value1 = w; + regs.chipset_latch_rw = w; } } @@ -672,7 +674,7 @@ static void blitter_line_read(void) // B (normally not enabled) record_dma_blit(0x72, 0, bltbpt, last_blitter_hpos); blt_info.bltbdat = chipmem_wget_indirect(bltbpt); - last_custom_value1 = blt_info.bltbdat; + regs.chipset_latch_rw = blt_info.bltbdat; record_dma_blit_val(blt_info.bltbdat); bltbpt += blt_info.bltbmod; } @@ -680,7 +682,7 @@ static void blitter_line_read(void) // C record_dma_blit(0x70, 0, bltcpt, last_blitter_hpos); blt_info.bltcdat = chipmem_wget_indirect(bltcpt); - last_custom_value1 = blt_info.bltcdat; + regs.chipset_latch_rw = blt_info.bltcdat; record_dma_blit_val(blt_info.bltcdat); } } @@ -692,7 +694,7 @@ static void blitter_line_write(void) /* D-channel state has no effect on linedraw, but C must be enabled or nothing is drawn! */ if (bltcon0 & 0x200) { chipmem_wput_indirect(bltdpt, blt_info.bltddat); - last_custom_value1 = blt_info.bltddat; + regs.chipset_latch_rw = blt_info.bltddat; } } @@ -809,14 +811,14 @@ static void actually_do_blit (void) blt_info.blit_main = 0; } -static void blitter_doit (void) +static void blitter_doit (int hpos) { if (blt_info.vblitsize == 0 || (blitline && blt_info.hblitsize != 2)) { - blitter_done_all(); + blitter_done_all(hpos); return; } actually_do_blit(); - blitter_done_all(); + blitter_done_all(hpos); } static int makebliteventtime(int delay) @@ -829,7 +831,7 @@ static int makebliteventtime(int delay) return delay; } -void blitter_handler (uae_u32 data) +void blitter_handler(uae_u32 data) { static int blitter_stuck; @@ -849,7 +851,7 @@ void blitter_handler (uae_u32 data) blit_slowdown = -1; return; } - blitter_doit(); + blitter_doit(-1); } #ifdef CPUEMU_13 @@ -1035,6 +1037,13 @@ static int get_current_channel(void) if (shifter[1] && (bltcon0 & 0x400)) { return 2; } + // D is disabled if position A is non-zero, even if A is disabled. + if (shifter[0]) { + return 0; + } + if (shifter_first >= 0) { + return 0; + } // D only if A, B and C is not currently active if (ddat1use) { // idle fill cycle: 3 = D, 4 = idle @@ -1165,8 +1174,8 @@ static int blitter_next_cycle(void) shifter[0] = shifter_out; } - if (shifter_first) { - shifter_first = false; + if (shifter_first > 0) { + shifter_first = -1; shifter[0] = true; blitfc = !!(bltcon1 & 0x4); } else { @@ -1183,6 +1192,7 @@ static int blitter_next_cycle(void) out = shifter[3]; } } + shifter_out = out; if (blit_cyclecounter > 0 && blitchanged) { @@ -1228,7 +1238,7 @@ static void blitter_dodma_new(int ch, int hpos, bool addmod) record_dma_blit(reg, 0, bltapt, hpos); blt_info.bltadat = dat = chipmem_wget_indirect(bltapt); record_dma_blit_val(dat); - last_custom_value1 = blt_info.bltadat; + regs.chipset_latch_rw = blt_info.bltadat; addr = &bltapt; mod = blit_modadda; alloc_cycle_blitter(hpos, &bltapt, 1); @@ -1239,7 +1249,7 @@ static void blitter_dodma_new(int ch, int hpos, bool addmod) record_dma_blit(reg, 0, bltbpt, hpos); blt_info.bltbdat = dat = chipmem_wget_indirect(bltbpt); record_dma_blit_val(dat); - last_custom_value1 = blt_info.bltbdat; + regs.chipset_latch_rw = blt_info.bltbdat; addr = &bltbpt; mod = blit_modaddb; if (blitdesc) @@ -1256,7 +1266,7 @@ static void blitter_dodma_new(int ch, int hpos, bool addmod) record_dma_blit(reg, 0, bltcpt, hpos); blt_info.bltcdat = dat = chipmem_wget_indirect(bltcpt); record_dma_blit_val(dat); - last_custom_value1 = blt_info.bltcdat; + regs.chipset_latch_rw = blt_info.bltcdat; addr = &bltcpt; mod = blit_modaddc; alloc_cycle_blitter(hpos, &bltcpt, 3); @@ -1281,7 +1291,7 @@ static bool blitter_idle_cycle_register_write(uaecptr addr, uae_u32 v) return false; addr &= 0x1fe; if (v == 0xffffffff) { - v = last_custom_value1; + v = regs.chipset_latch_rw; } if (addr == 0x40) { bltcon0 = v; @@ -1332,7 +1342,7 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va return false; } if (dmaen(DMA_BLITTER)) { - blitter_doit(); + blitter_doit(hpos); } return false; } @@ -1417,7 +1427,7 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va record_dma_blit(0x70, 0, bltcpt, hpos); blt_info.bltcdat = chipmem_wget_indirect(bltcpt); - last_custom_value1 = blt_info.bltcdat; + regs.chipset_latch_rw = blt_info.bltcdat; record_dma_blit_val(blt_info.bltcdat); alloc_cycle_blitter(hpos, &bltcpt, 3); @@ -1444,7 +1454,7 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va blt_info.blitzero = 0; } chipmem_wput_indirect(bltdpt, blt_info.bltddat); - last_custom_value1 = blt_info.bltddat; + regs.chipset_latch_rw = blt_info.bltddat; alloc_cycle_blitter(hpos, &bltdpt, 4); blitlinepixel = 0; } else { @@ -1516,7 +1526,7 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va cycle_line_pipe[offset] = CYCLE_PIPE_BLITTER; blitter_pipe[offset] = cycle_line_pipe[offset] | 4 | BLITTER_PIPELINE_ADDMOD | BLITTER_PIPELINE_LASTD; if (currprefs.chipset_mask & CSMASK_AGA) { - blitter_done_all(); + blitter_done_all(hpos); } blt_info.blit_finald = 0; if (!blt_info.blit_queued) { @@ -1528,7 +1538,7 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va if (blt_info.blit_main) { blit_cyclecounter++; if (blit_cyclecounter == 0) { - shifter_first = true; + shifter_first = 1; blitter_next_cycle(); } int c = get_current_channel(); @@ -1587,7 +1597,7 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va blitter_done_except_d(); } } else { - blitter_done_all(); + blitter_done_all(hpos); } } @@ -1657,7 +1667,7 @@ static void blitter_force_finish(bool state) } else { actually_do_blit(); } - blitter_done_all(); + blitter_done_all(-1); dmacon = odmacon; } @@ -1715,6 +1725,7 @@ static bool waitingblits (void) static void blitter_start_init (void) { + shifter_first = 0; blt_info.blit_queued = 0; blit_faulty = 0; blt_info.blitzero = 1; @@ -1820,7 +1831,7 @@ void do_blitter(int hpos, int copper, uaecptr pc) if (blitter_cycle_exact) { if (immediate_blits) { if (dmaen(DMA_BLITTER)) { - blitter_doit(); + blitter_doit(-1); } return; } @@ -1846,7 +1857,7 @@ void do_blitter(int hpos, int copper, uaecptr pc) if (blt_info.vblitsize == 0 || (blitline && blt_info.hblitsize != 2)) { if (dmaen(DMA_BLITTER)) { - blitter_done_all(); + blitter_done_all(-1); } return; } @@ -1857,7 +1868,7 @@ void do_blitter(int hpos, int copper, uaecptr pc) if (immediate_blits) { if (dmaen(DMA_BLITTER)) { - blitter_doit(); + blitter_doit(-1); } return; } @@ -1873,7 +1884,7 @@ void blitter_check_start (void) blt_info.blit_main = 1; blitter_start_init(); if (immediate_blits) { - blitter_doit(); + blitter_doit(-1); } } } diff --git a/custom.cpp b/custom.cpp index 6b0d9a6b..2ddb6cc2 100644 --- a/custom.cpp +++ b/custom.cpp @@ -177,8 +177,7 @@ static uae_u16 cregs[256]; uae_u16 intena, intreq; uae_u16 dmacon; uae_u16 adkcon; /* used by audio code */ -uae_u32 last_custom_value1; -uae_u16 last_custom_value2; +uae_u16 last_custom_value; static bool dmacon_bpl; static uae_u32 cop1lc, cop2lc, copcon; @@ -188,10 +187,10 @@ static uae_u32 cop1lc, cop2lc, copcon; * 0x00 0 HCB * 0x01 1 HC1 (HSTART) * 0x09 9 VR1 -* 0x12 18 SHS (Horizontal blank start) +* 0x12 18 SHS (Horizontal sync start) * 0x1a 26 VER1 PAL * 0x1b 27 VER1 NTSC -* 0x23 35 RHS (Horizontal blank end) +* 0x23 35 RHS (Horizontal sync end) * 0x73 115 VR2 * 0x84 132 CEN (HCENTER) * 0x8c 140 VER2 PAL @@ -455,6 +454,7 @@ enum copper_states { COP_read1, COP_read2, COP_bltwait, + COP_bltwait2, COP_wait_in2, COP_skip_in2, COP_wait1, @@ -586,6 +586,7 @@ static bool speedup_first; static void events_dmal(int); static uae_u16 dmal, dmal_hpos; +static uae_u16 dmal_htotal_mask; static bool dmal_ce; /* The number of bits left from the last fetched words. @@ -2042,8 +2043,8 @@ static bool fetch(int nr, int fm, int hpos, bool addmodulo) } #endif fetched_aga[nr] = fetched[nr] = v; - last_custom_value1 = v; - last_custom_value2 = (uae_u16)last_custom_value1; + regs.chipset_latch_rw = v; + last_custom_value = (uae_u16)regs.chipset_latch_rw; break; } #ifdef AGA @@ -2067,8 +2068,8 @@ static bool fetch(int nr, int fm, int hpos, bool addmodulo) record_dma_read_value_wide(fetched_aga[nr], false); } #endif - last_custom_value1 = (uae_u32)fetched_aga[nr]; - last_custom_value2 = (uae_u16)last_custom_value1; + regs.chipset_latch_rw = (uae_u32)fetched_aga[nr]; + last_custom_value = (uae_u16)regs.chipset_latch_rw; fetched[nr] = (uae_u16)fetched_aga[nr]; break; } @@ -2102,8 +2103,8 @@ static bool fetch(int nr, int fm, int hpos, bool addmodulo) record_dma_read_value_wide(fetched_aga[nr], true); } #endif - last_custom_value1 = (uae_u32)fetched_aga[nr]; - last_custom_value2 = (uae_u16)last_custom_value1; + regs.chipset_latch_rw = (uae_u32)fetched_aga[nr]; + last_custom_value = (uae_u16)regs.chipset_latch_rw; fetched[nr] = (uae_u16)fetched_aga[nr]; break; } @@ -4601,6 +4602,7 @@ static void reset_decisions_scanline_start(void) ddfstop_hpos = -1; last_diw_hpos = 0; last_diw_hpos2 = 0; + blt_info.finishhpos = -1; /* Default to no bitplane DMA overriding sprite DMA */ plfstrt_sprite = 0x100; @@ -5394,7 +5396,8 @@ static void init_hz(bool checkvposw) vblank_hz_lace = clk / ((maxvpos + 0.5) * (maxhpos + 0.5)); } - if (beamcon0 & 0x80) { + dmal_htotal_mask = 0xffff; + if (beamcon0 & 0x0080) { // programmable scanrates (ECS Agnus) if (vtotal >= MAXVPOS) { vtotal = MAXVPOS - 1; @@ -5404,6 +5407,13 @@ static void init_hz(bool checkvposw) htotal = MAXHPOS - 1; } maxhpos = htotal + 1; + + if (maxhpos < DMAL_FIRST_HPOS) { + dmal_htotal_mask = 0; + } else if (maxhpos < DMAL_FIRST_HPOS + 6 * 2) { + int cnt = (maxhpos - DMAL_FIRST_HPOS) / 2; + dmal_htotal_mask = (1 << cnt) - 1; + } } // after vsync, it seems earlier possible visible line is vsync+3. @@ -5768,8 +5778,12 @@ static uae_u16 DENISEID(int *missing) return 0xFFFF; } -static bool blit_busy(void) +static bool blit_busy(int hpos, bool dmaconr) { + // DMACONR latch load takes 1 cycle. Copper sees it immediately. + if (dmaconr && blt_info.finishhpos == hpos) { + return true; + } if (!blt_info.blit_main && !blt_info.blit_finald) { return false; } @@ -5803,7 +5817,7 @@ STATIC_INLINE uae_u16 DMACONR(int hpos) decide_line(hpos); decide_fetch_safe(hpos); dmacon &= ~(0x4000 | 0x2000); - dmacon |= (blit_busy() ? 0x4000 : 0x0000) | (blt_info.blitzero ? 0x2000 : 0); + dmacon |= (blit_busy(hpos, true) ? 0x4000 : 0x0000) | (blt_info.blitzero ? 0x2000 : 0); return dmacon; } STATIC_INLINE uae_u16 INTENAR(void) @@ -5972,7 +5986,6 @@ static void VPOSW(uae_u16 v) static void VHPOSW(uae_u16 v) { int oldvpos = vpos; - bool changed = false; #if 0 if (M68K_GETPC < 0xf00000 || 1) write_log (_T("VHPOSW %04X PC=%08x\n"), v, M68K_GETPC); @@ -5983,7 +5996,7 @@ static void VHPOSW(uae_u16 v) int chp = current_hpos_safe() - 4; int hp = v & 0xff; if (chp >= 0x21 && chp <= 0x29 && hp == 0x2d) { - hack_delay_shift = 4; + hack_delay_shift = 0; record_color_change(chp, 0, COLOR_CHANGE_HSYNC_HACK | 6); thisline_changed = 1; } @@ -5992,7 +6005,7 @@ static void VHPOSW(uae_u16 v) v >>= 8; vpos &= 0xff00; vpos |= v; - if (vpos != oldvpos && !changed) { + if (vpos != oldvpos) { vposw_change++; } if (vpos < oldvpos) { @@ -6868,9 +6881,9 @@ static void BPLxDAT_next(uae_u32 v) flush_display(fetchmode); fetched[num] = vv; if ((fmode & 3) == 3) { - fetched_aga[num] = ((uae_u64)last_custom_value2 << 48) | ((uae_u64)vv << 32) | (vv << 16) | vv; + fetched_aga[num] = ((uae_u64)last_custom_value << 48) | ((uae_u64)vv << 32) | (vv << 16) | vv; } else if ((fmode & 3) == 2) { - fetched_aga[num] = (last_custom_value2 << 16) | vv; + fetched_aga[num] = (last_custom_value << 16) | vv; } else if ((fmode & 3) == 1) { fetched_aga[num] = (vv << 16) | vv; } else { @@ -7004,7 +7017,6 @@ static void FNULL(uae_u16 v) static void BLTADAT(int hpos, uae_u16 v) { maybe_blit(hpos, 0); - blt_info.bltadat = v; } /* @@ -7015,25 +7027,51 @@ static void BLTADAT(int hpos, uae_u16 v) static void BLTBDAT(int hpos, uae_u16 v) { maybe_blit(hpos, 0); - int shift = bltcon1 >> 12; - - if (bltcon1 & 2) + if (bltcon1 & 2) { blt_info.bltbhold = (((uae_u32)v << 16) | blt_info.bltbold) >> (16 - shift); - else + } else { blt_info.bltbhold = (((uae_u32)blt_info.bltbold << 16) | v) >> shift; - + } blt_info.bltbdat = v; blt_info.bltbold = v; } -static void BLTCDAT(int hpos, uae_u16 v) { maybe_blit(hpos, 0); blt_info.bltcdat = v; reset_blit(0); } - -static void BLTAMOD(int hpos, uae_u16 v) { maybe_blit(hpos, 1); blt_info.bltamod = (uae_s16)(v & 0xFFFE); reset_blit(0); } -static void BLTBMOD(int hpos, uae_u16 v) { maybe_blit(hpos, 1); blt_info.bltbmod = (uae_s16)(v & 0xFFFE); reset_blit(0); } -static void BLTCMOD(int hpos, uae_u16 v) { maybe_blit(hpos, 1); blt_info.bltcmod = (uae_s16)(v & 0xFFFE); reset_blit(0); } -static void BLTDMOD(int hpos, uae_u16 v) { maybe_blit(hpos, 1); blt_info.bltdmod = (uae_s16)(v & 0xFFFE); reset_blit(0); } - -static void BLTCON0(int hpos, uae_u16 v) { maybe_blit (hpos, 2); bltcon0 = v; reset_blit(1); } +static void BLTCDAT(int hpos, uae_u16 v) +{ + maybe_blit(hpos, 0); + blt_info.bltcdat = v; + reset_blit(0); +} +static void BLTAMOD(int hpos, uae_u16 v) +{ + maybe_blit(hpos, 1); + blt_info.bltamod = (uae_s16)(v & 0xFFFE); + reset_blit(0); +} +static void BLTBMOD(int hpos, uae_u16 v) +{ + maybe_blit(hpos, 1); + blt_info.bltbmod = (uae_s16)(v & 0xFFFE); + reset_blit(0); +} +static void BLTCMOD(int hpos, uae_u16 v) +{ + maybe_blit(hpos, 1); + blt_info.bltcmod = (uae_s16)(v & 0xFFFE); + reset_blit(0); +} +static void BLTDMOD(int hpos, uae_u16 v) +{ + maybe_blit(hpos, 1); + blt_info.bltdmod = (uae_s16)(v & 0xFFFE); + reset_blit(0); +} +static void BLTCON0(int hpos, uae_u16 v) +{ + maybe_blit (hpos, 2); + bltcon0 = v; + reset_blit(1); +} /* The next category is "Most useless hardware register". * And the winner is... */ static void BLTCON0L(int hpos, uae_u16 v) @@ -7048,7 +7086,6 @@ static void BLTCON1(int hpos, uae_u16 v) { bltcon1 = v; reset_blit(2); } - static void BLTAFWM(int hpos, uae_u16 v) { maybe_blit(hpos, 2); blt_info.bltafwm = v; @@ -7059,7 +7096,6 @@ static void BLTALWM(int hpos, uae_u16 v) { blt_info.bltalwm = v; reset_blit(0); } - static void BLTAPTH(int hpos, uae_u16 v) { maybe_blit(hpos, 0); @@ -7352,7 +7388,7 @@ static void SPRxDATA(int hpos, uae_u16 v, int num) if ((fmode & 4) && get_bitplane_dma_rel(hpos, -1)) { sprite_get_bpl_data(hpos, s, &s->data[0]); } else { - s->data[0] = last_custom_value2; + s->data[0] = last_custom_value; } } } @@ -7366,7 +7402,7 @@ static void SPRxDATB(int hpos, uae_u16 v, int num) if ((fmode & 4) && get_bitplane_dma_rel(hpos, -1)) { sprite_get_bpl_data(hpos, s, &s->datb[0]); } else { - s->datb[0] = last_custom_value2; + s->datb[0] = last_custom_value; } } } @@ -8079,7 +8115,7 @@ static void do_copper_fetch(int hpos, uae_u8 id) debug_getpeekdma_chipram(cop_state.ip, MW_MASK_COPPER, 0x8c, cop_state.last_strobe == 2 ? 0x84 : 0x80); } #endif - cop_state.ir[0] = last_custom_value1 = last_custom_value2 = chipmem_wget_indirect(cop_state.ip); + cop_state.ir[0] = regs.chipset_latch_rw = last_custom_value = chipmem_wget_indirect(cop_state.ip); #ifdef DEBUGGER if (debug_dma) { record_dma_read_value(cop_state.ir[0]); @@ -8162,7 +8198,7 @@ static void do_copper_fetch(int hpos, uae_u8 id) debug_getpeekdma_chipram(cop_state.ip, MW_MASK_COPPER, 0x1fe, 0x1fe); } #endif - cop_state.ir[0] = last_custom_value1 = last_custom_value2 = chipmem_wget_indirect(cop_state.ip); + cop_state.ir[0] = regs.chipset_latch_rw = last_custom_value = chipmem_wget_indirect(cop_state.ip); #ifdef DEBUGGER if (debug_dma) { record_dma_read_value(cop_state.ir[0]); @@ -8183,7 +8219,7 @@ static void do_copper_fetch(int hpos, uae_u8 id) debug_getpeekdma_chipram(cop_state.ip, MW_MASK_COPPER, 0x8c, cop_state.last_strobe == 2 ? 0x84 : 0x80); } #endif - cop_state.ir[0] = last_custom_value1 = last_custom_value2 = chipmem_wget_indirect(cop_state.ip); + cop_state.ir[0] = regs.chipset_latch_rw = last_custom_value = chipmem_wget_indirect(cop_state.ip); #ifdef DEBUGGER if (debug_dma) { record_dma_read_value(cop_state.ir[0]); @@ -8309,7 +8345,7 @@ static void do_copper_fetch(int hpos, uae_u8 id) #endif cop_state.ignore_next = 0; } - last_custom_value1 = last_custom_value2 = cop_state.ir[1]; + regs.chipset_latch_rw = last_custom_value = cop_state.ir[1]; check_copper_stop(); break; @@ -8358,7 +8394,7 @@ static int coppercomp(int hpos, bool blitwait) if ((cop_state.ir[1] & 0x8000) == 0) { decide_blitter(hpos); - if (blit_busy()) { + if (blit_busy(-1, false)) { if (blitwait) { /* We need to wait for the blitter. */ cop_state.state = COP_bltwait; @@ -8595,7 +8631,7 @@ next: static void compute_spcflag_copper(void) { - if (!dmaen(DMA_COPPER) || cop_state.state == COP_stop || cop_state.state == COP_waitforever || cop_state.state == COP_bltwait || nocustom()) + if (!dmaen(DMA_COPPER) || cop_state.state == COP_stop || cop_state.state == COP_waitforever || cop_state.state == COP_bltwait || cop_state.state == COP_bltwait2 || nocustom()) return; if (cop_state.state == COP_wait1) { int vp = vpos & (((cop_state.ir[1] >> 8) & 0x7F) | 0x80); @@ -8610,11 +8646,11 @@ static void compute_spcflag_copper(void) static void blitter_done_notify_wakeup(uae_u32 temp) { - if (cop_state.state != COP_bltwait) { + if (cop_state.state != COP_bltwait2) { return; } // blitter_done_notify() might be called too early, wait a bit if blitter is still busy. - if (blit_busy()) { + if (blit_busy(-1, false)) { event2_newevent_xx(-1, 1 * CYCLE_UNIT, 0, blitter_done_notify_wakeup); return; } @@ -8639,6 +8675,7 @@ void blitter_done_notify(int blitline) if (cop_state.state != COP_bltwait) { return; } + cop_state.state = COP_bltwait2; event2_newevent_xx(-1, 1 * CYCLE_UNIT, 0, blitter_done_notify_wakeup); } @@ -8683,7 +8720,7 @@ static void cursorsprite(void) static uae_u16 sprite_fetch(struct sprite *s, uaecptr pt, int hpos, int slot, int mode) { - uae_u16 data = last_custom_value1; + uae_u16 data = regs.chipset_latch_rw; #if CYCLE_CONFLICT_LOGGING if ((hpos & 1) != (SPR_FIRST_HPOS & 1)) { @@ -8700,7 +8737,7 @@ static uae_u16 sprite_fetch(struct sprite *s, uaecptr pt, int hpos, int slot, in debug_getpeekdma_chipram(pt, MW_MASK_SPR_0 << num, num * 8 + 0x140 + mode * 4 + slot * 2, num * 4 + 0x120); } #endif - data = last_custom_value1 = chipmem_wget_indirect(pt); + data = regs.chipset_latch_rw = chipmem_wget_indirect(pt); alloc_cycle(hpos, CYCLE_SPRITE); return data; } @@ -9412,6 +9449,10 @@ static void vsync_handler_render(void) config_check_vsync(); } + vsync_rendered = false; + frame_shown = false; + frame_rendered = false; + if (quit_program > 0) { /* prevent possible infinite loop at wait_cycles().. */ ad->framecnt = 0; @@ -9420,10 +9461,6 @@ static void vsync_handler_render(void) return; } - vsync_rendered = false; - frame_shown = false; - frame_rendered = false; - if (vblank_hz_mult > 0) { vblank_hz_state ^= 1; } else { @@ -9753,7 +9790,7 @@ static void dmal_emu(uae_u32 v) } #endif } - last_custom_value1 = last_custom_value2 = dat; + regs.chipset_latch_rw = last_custom_value = dat; AUDxDAT(nr, dat, pt); } else { uae_u16 dat = 0; @@ -9784,7 +9821,7 @@ static void dmal_emu(uae_u32 v) } #endif } - last_custom_value1 = last_custom_value2 = dat; + regs.chipset_latch_rw = last_custom_value = dat; DSKDAT(dat); } } else { @@ -9816,8 +9853,9 @@ static void dmal_func(uae_u32 v) static void dmal_func2(uae_u32 v) { while (dmal) { - if (dmal & 3) + if (dmal & 3) { dmal_emu(dmal_hpos + ((dmal & 2) ? 1 : 0)); + } dmal_hpos += 2; dmal >>= 2; } @@ -9846,26 +9884,40 @@ static void events_dmal(int hpos) } } -static void events_dmal_hsync(void) +static void events_dmal_hsync2(uae_u32 v) { + int dmal_first = DMAL_FIRST_HPOS - v; // 3 disk + 4 audio - if (dmal) - write_log (_T("DMAL error!? %04x\n"), dmal); + if (dmal) { + write_log(_T("DMAL error!? %04x\n"), dmal); + } dmal = audio_dmal(); dmal <<= (3 * 2); dmal |= disk_dmal(); + dmal &= dmal_htotal_mask; dmal_alloc_mask = dmal; - if (!dmal) + if (!dmal) { return; + } dmal_hpos = 0; if (currprefs.cpu_memory_cycle_exact) { for (int i = 0; i < 3 * 2 + 4 * 2; i += 2) { if (dmal & (3 << i)) { - alloc_cycle_ext(i + DMAL_FIRST_HPOS, CYCLE_MISC); + alloc_cycle_ext(DMAL_FIRST_HPOS + i, CYCLE_MISC); } } } - events_dmal(DMAL_FIRST_HPOS); + events_dmal(dmal_first); +} + +static void events_dmal_hsync(void) +{ + if (currprefs.cpu_compatible) { + int delay = REFRESH_FIRST_HPOS + 1; + event2_newevent2(delay, delay, events_dmal_hsync2); + } else { + events_dmal_hsync2(0); + } } static void lightpen_trigger_func(uae_u32 v) @@ -10857,7 +10909,7 @@ void vsync_event_done(void) } // this prepares for new line -static void hsync_handler_post (bool onvsync) +static void hsync_handler_post(bool onvsync) { #ifdef CPUEMU_13 if (1 || currprefs.cpu_memory_cycle_exact || currprefs.blitter_cycle_exact) { @@ -10878,12 +10930,12 @@ static void hsync_handler_post (bool onvsync) CIAB_tod_handler(18); } else if (ciahsyncs) { CIA_hsync_posthandler(true, ciahsyncs); - if (beamcon0 & (0x80 | 0x100)) { + if (beamcon0 & 0x0100) { if (hsstop < (maxhpos & ~1) && hsstrt < maxhpos) { - CIAB_tod_handler(hsstop); + CIAB_tod_handler(hsstrt); } } else { - CIAB_tod_handler(18); + CIAB_tod_handler(18); // hsync start } } @@ -11113,7 +11165,7 @@ static void hsync_handler_post (bool onvsync) } - events_dmal_hsync (); + events_dmal_hsync(); #if 0 // AF testing stuff static int cnt = 0; @@ -11405,6 +11457,7 @@ void custom_reset(bool hardreset, bool keyboardreset) vs_state = false; vs_state_hw = false; vs_state_on = false; + dmal_htotal_mask = 0xffff; memset(custom_storage, 0, sizeof(custom_storage)); if (!currprefs.cs_dipagnus) { vb_start_line = 1; @@ -11833,9 +11886,9 @@ writeonly: * * AGA: * Can also return last CPU accessed value - * Remembers old last_custom_value1 + * Remembers old regs.chipset_latch_rw */ - v = last_custom_value1; + v = regs.chipset_latch_rw; SET_LINE_CYCLEBASED; if (!noput) { int r, c, bmdma; @@ -11868,18 +11921,18 @@ writeonly: bmdma = bitplane_dma_access(hpos, 0); if (aga_mode) { if (bmdma || (c > CYCLE_REFRESH && c < CYCLE_CPU)) { - v = last_custom_value1; + v = regs.chipset_latch_rw; } else if (c == CYCLE_CPU) { v = regs.db; } else { - v = last_custom_value1 >> ((addr & 2) ? 0 : 16); + v = regs.chipset_latch_rw >> ((addr & 2) ? 0 : 16); } } else { if (bmdma || (c > CYCLE_REFRESH && c < CYCLE_CPU)) { - v = last_custom_value1; + v = regs.chipset_latch_rw; } else { // refresh checked because refresh cycles do not always - // set last_custom_value1 for performance reasons. + // set regs.chipset_latch_rw for performance reasons. v = 0xffff; } } @@ -12445,7 +12498,7 @@ uae_u8 *restore_custom(uae_u8 *src) currprefs.ntscmode = changed_prefs.ntscmode = i & 1; } fmode = RW; /* 1FC FMODE */ - last_custom_value1 = last_custom_value2 = RW;/* 1FE ? */ + last_custom_value = RW; /* 1FE ? */ bplcon0_saved = bplcon0; bplcon1_saved = bplcon1; @@ -12651,7 +12704,7 @@ uae_u8 *save_custom(int *len, uae_u8 *dstptr, int full) SW(0); /* 1F8 */ SW(0x8000 | (currprefs.ntscmode ? 1 : 0)); /* 1FA (re-used for NTSC) */ SW(fmode); /* 1FC FMODE */ - SW (last_custom_value1); /* 1FE */ + SW (last_custom_value); /* 1FE */ *len = dst - dstbak; return dstbak; @@ -13132,10 +13185,6 @@ void do_copper(void) update_copper(hpos); } -#define SETIFCHIP \ - if (addr < 0xd80000) \ - last_custom_value1 = v; - uae_u32 wait_cpu_cycle_read(uaecptr addr, int mode) { uae_u32 v = 0; @@ -13149,7 +13198,7 @@ uae_u32 wait_cpu_cycle_read(uaecptr addr, int mode) int reg = 0x1000; if (mode == -3) { reg |= 2; - v = last_custom_value1; + v = regs.chipset_latch_rw; } else if (mode < 0) { reg |= 4; } else if (mode > 0) { @@ -13190,7 +13239,6 @@ uae_u32 wait_cpu_cycle_read(uaecptr addr, int mode) #endif regs.chipset_latch_rw = regs.chipset_latch_read = v; - SETIFCHIP; x_do_cycles_post(CYCLE_UNIT, v); @@ -13247,7 +13295,6 @@ uae_u32 wait_cpu_cycle_read_ce020(uaecptr addr, int mode) #endif regs.chipset_latch_rw = regs.chipset_latch_read = v; - SETIFCHIP; x_do_cycles_post(CYCLE_UNIT, v); @@ -13291,7 +13338,6 @@ void wait_cpu_cycle_write(uaecptr addr, int mode, uae_u32 v) } regs.chipset_latch_rw = regs.chipset_latch_write = v; - SETIFCHIP; x_do_cycles_post(CYCLE_UNIT, v); @@ -13329,7 +13375,6 @@ void wait_cpu_cycle_write_ce020(uaecptr addr, int mode, uae_u32 v) } regs.chipset_latch_rw = regs.chipset_latch_write = v; - SETIFCHIP; // chipset buffer latches the write, CPU does // not need to wait for the chipset cycle to finish. diff --git a/debug.cpp b/debug.cpp index 0e93057f..28a58e24 100644 --- a/debug.cpp +++ b/debug.cpp @@ -21,6 +21,7 @@ #include "newcpu.h" #include "cpu_prefetch.h" #include "debug.h" +#include "disasm.h" #include "debugmem.h" #include "cia.h" #include "xwin.h" @@ -59,6 +60,7 @@ int debugger_active; static int debug_rewind; static int memwatch_triggered; static int inside_debugger; +int debugger_used; int memwatch_access_validator; int memwatch_enabled; int debugging; @@ -111,11 +113,13 @@ void deactivate_debugger (void) void activate_debugger (void) { + disasm_init(); if (isfullscreen() > 0) return; debugger_load_libraries(); + debugger_used = 1; inside_debugger = 1; debug_pc = 0xffffffff; trace_mode = 0; diff --git a/disasm.cpp b/disasm.cpp index cb93162a..6dc305d9 100644 --- a/disasm.cpp +++ b/disasm.cpp @@ -10,6 +10,135 @@ #include "debugmem.h" #include "disasm.h" +int disasm_flags = DISASM_FLAG_LC_MNEMO | DISASM_FLAG_LC_REG | DISASM_FLAG_LC_SIZE | DISASM_FLAG_LC_HEX | DISASM_FLAG_CC | DISASM_FLAG_EA | DISASM_FLAG_VAL | DISASM_FLAG_WORDS; +int disasm_min_words = 5; +int disasm_max_words = 16; +TCHAR disasm_hexprefix[3] = { '$', 0 }; + +static TCHAR disasm_areg, disasm_dreg; +static TCHAR disasm_pcreg[3], disasm_fpreg[3]; + +void disasm_init(void) +{ + _tcscpy(disasm_pcreg, _T("PC")); + _tcscpy(disasm_fpreg, _T("FP")); + if (disasm_flags & DISASM_FLAG_LC_REG) { + _tcscpy(disasm_pcreg, _T("pc")); + _tcscpy(disasm_fpreg, _T("fp")); + } + disasm_areg = (disasm_flags & DISASM_FLAG_LC_REG) ? 'a' : 'A'; + disasm_dreg = (disasm_flags & DISASM_FLAG_LC_REG) ? 'd' : 'D'; + +} + +static void disasm_lc_mnemo(TCHAR *s) +{ + if (!(disasm_flags & DISASM_FLAG_LC_MNEMO) && !(disasm_flags & DISASM_FLAG_LC_SIZE)) { + return; + } + if ((disasm_flags & DISASM_FLAG_LC_MNEMO) && (disasm_flags & DISASM_FLAG_LC_SIZE)) { + to_lower(s, -1); + return; + } + TCHAR *s2 = _tcschr(s, '.'); + if (s2) { + if (disasm_flags & DISASM_FLAG_LC_SIZE) { + to_lower(s2, -1); + } + if (disasm_flags & DISASM_FLAG_LC_MNEMO) { + s2[0] = 0; + to_lower(s, -1); + s2[0] = '.'; + } + } else { + if (disasm_flags & DISASM_FLAG_LC_MNEMO) { + to_lower(s, -1); + return; + } + } +} + +static const TCHAR *disasm_lc_size(const TCHAR *s) +{ + static TCHAR tmp[32]; + if (disasm_flags & DISASM_FLAG_LC_SIZE) { + _tcscpy(tmp, s); + to_lower(tmp, -1); + return tmp; + } + return s; +} + +static const TCHAR *disasm_lc_reg(const TCHAR *s) +{ + static TCHAR tmp[32]; + if (disasm_flags & DISASM_FLAG_LC_REG) { + _tcscpy(tmp, s); + to_lower(tmp, -1); + return tmp; + } + return s; +} + +static const TCHAR *disasm_lc_hex2(const TCHAR *s, bool noprefix) +{ + static TCHAR tmp[32]; + bool copied = false; + if (disasm_flags & DISASM_FLAG_LC_HEX) { + const TCHAR *s2 = _tcschr(s, 'X'); + if (s2) { + _tcscpy(tmp, s); + copied = true; + tmp[s2 - s] = 'x'; + for (;;) { + s2 = _tcschr(tmp, 'X'); + if (!s2) { + break; + } + tmp[0] = 'x'; + } + } + } + if (!noprefix) { + if (disasm_hexprefix[0] != '$' || disasm_hexprefix[1] != 0 || s[0] != '$') { + if (!copied) { + _tcscpy(tmp, s); + copied = true; + } + const TCHAR *s2 = _tcschr(tmp, '%'); + if (s2) { + int len = _tcslen(disasm_hexprefix); + if (s2 > tmp && s2[-1] == '$') { + len--; + s2--; + } + if (len < 0) { + memmove(tmp + (s2 - tmp), tmp + (s2 - tmp) - len, (_tcslen(tmp + (s2 - tmp) - len) + 1) * sizeof(TCHAR)); + } else { + if (len > 0) { + memmove(tmp + (s2 - tmp) + len, s2, (_tcslen(s2) + 1) * sizeof(TCHAR)); + } + memcpy(tmp + (s2 - tmp), disasm_hexprefix, _tcslen(disasm_hexprefix) * sizeof(TCHAR)); + } + } + return tmp; + } + } + if (copied) { + return tmp; + } + return s; +} + +static const TCHAR *disasm_lc_hex(const TCHAR *s) +{ + return disasm_lc_hex2(s, false); +} +static const TCHAR *disasm_lc_nhex(const TCHAR *s) +{ + return disasm_lc_hex2(s, true); +} + struct cpum2c m2cregs[] = { { 0, 31, _T("SFC") }, @@ -68,10 +197,16 @@ static void showea_val(TCHAR *buffer, uae_u16 opcode, uaecptr addr, int size) struct mnemolookup *lookup; struct instr *table = &table68k[opcode]; +#if UAE if (addr >= 0xe90000 && addr < 0xf00000) goto skip; if (addr >= 0xdff000 && addr < 0xe00000) goto skip; +#endif + + if (!(disasm_flags & DISASM_FLAG_VAL)) { + goto skip; + } for (lookup = lookuptab; lookup->mnemo != table->mnemo; lookup++) ; @@ -231,7 +366,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name if ((dp & 0x30) == 0x20) { // BD SIZE = 2 (WORD) disp = (uae_s32)(uae_s16)get_iword_debug(pc); if (buffer) { - _stprintf(p, _T("$%04x,"), (uae_s16)disp); + _stprintf(p, disasm_lc_hex(_T("$%04X,")), (uae_s16)disp); p += _tcslen(p); } pc += 2; @@ -239,7 +374,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name } else if ((dp & 0x30) == 0x30) { // BD SIZE = 3 (LONG) disp = get_ilong_debug(pc); if (buffer) { - _stprintf(p, _T("$%08x,"), disp); + _stprintf(p, disasm_lc_hex(_T("$%08X,")), disp); p += _tcslen(p); } pc += 4; @@ -276,14 +411,14 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name if ((dp & 0x03) == 0x02) { outer = (uae_s32)(uae_s16)get_iword_debug(pc); if (buffer) { - _stprintf(p, _T("$%04x,"), (uae_s16)outer); + _stprintf(p, disasm_lc_hex(_T("$%04X,")), (uae_s16)outer); p += _tcslen(p); } pc += 2; } else if ((dp & 0x03) == 0x03) { outer = get_ilong_debug(pc); if (buffer) { - _stprintf(p, _T("$%08x,"), outer); + _stprintf(p, disasm_lc_hex(_T("$%08X,")), outer); p += _tcslen(p); } pc += 4; @@ -306,7 +441,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name addr = base + outer; if (buffer) { - _stprintf(p, _T(" == $%08x"), addr); + _stprintf(p, disasm_lc_hex(_T(" == $%08X")), addr); p += _tcslen(p); } @@ -323,7 +458,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name } } regstr[0] = 0; - _stprintf(regstr, _T(",%c%d.%c"), dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W'); + _stprintf(regstr, _T(",%c%d.%c"), dp & 0x8000 ? disasm_areg : disasm_dreg, (int)r, dp & 0x800 ? 'L' : 'W'); addr = base + (uae_s32)((uae_s8)disp8) + dispreg; if (buffer) { if (pcrel) { @@ -358,47 +493,50 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi buffer[0] = 0; switch (mode){ case Dreg: - _stprintf (buffer, _T("D%d"), reg); + _stprintf(buffer, _T("%c%d"), disasm_dreg, reg); if (actualea) *actualea = 0; break; case Areg: - _stprintf (buffer, _T("A%d"), reg); + _stprintf(buffer, _T("%c%d"), disasm_areg, reg); if (actualea) *actualea = 0; break; case Aind: - _stprintf (buffer, _T("(A%d)"), reg); + _stprintf(buffer, _T("(%c%d)"), disasm_areg, reg); addr = regs.regs[reg + 8]; showea_val(buffer, opcode, addr, size); break; case Aipi: - _stprintf (buffer, _T("(A%d)+"), reg); + _stprintf(buffer, _T("(%c%d)+"), disasm_areg, reg); addr = regs.regs[reg + 8]; showea_val(buffer, opcode, addr, size); break; case Apdi: - _stprintf (buffer, _T("-(A%d)"), reg); + _stprintf(buffer, _T("-(%c%d)"), disasm_areg, reg); addr = regs.regs[reg + 8] - datasizes[size]; showea_val(buffer, opcode, addr, size); break; case Ad16: { - TCHAR offtxt[8]; + TCHAR offtxt[32]; disp16 = get_iword_debug (pc); pc += 2; if (disp16 < 0) - _stprintf (offtxt, _T("-$%04x"), -disp16); + _stprintf (offtxt, disasm_lc_hex(_T("-$%04X")), -disp16); else - _stprintf (offtxt, _T("$%04x"), disp16); + _stprintf (offtxt, disasm_lc_hex(_T("$%04X")), disp16); addr = m68k_areg (regs, reg) + disp16; - _stprintf (buffer, _T("(A%d,%s) == $%08x"), reg, offtxt, addr); + _stprintf(buffer, _T("(%c%d,%s)"), disasm_areg, reg, offtxt); + if (disasm_flags & DISASM_FLAG_VAL) { + _stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(" == $%08X")), addr); + } showea_val(buffer, opcode, addr, size); } break; case Ad8r: { TCHAR name[10]; - _stprintf(name, _T("A%d"), reg); + _stprintf(name, _T("%c%d"), disasm_areg, reg); addr = ShowEA_disp(&pc, m68k_areg(regs, reg), buffer, name, false); showea_val(buffer, opcode, addr, size); } @@ -406,24 +544,28 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi case PC16: disp16 = get_iword_debug (pc); pc += 2; addr += (uae_s16)disp16; - _stprintf (buffer, _T("(PC,$%04x) == $%08x"), disp16 & 0xffff, addr); + _stprintf(buffer, _T("(%s"), disasm_pcreg); + _stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(",$%04X)")), disp16 & 0xffff); + if (disasm_flags & DISASM_FLAG_VAL) { + _stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(" == $%08X")), addr); + } showea_val(buffer, opcode, addr, size); break; case PC8r: { - addr = ShowEA_disp(&pc, addr, buffer, _T("PC"), true); + addr = ShowEA_disp(&pc, addr, buffer, disasm_pcreg, true); showea_val(buffer, opcode, addr, size); } break; case absw: addr = (uae_s32)(uae_s16)get_iword_debug (pc); - _stprintf (buffer, _T("$%04x"), (uae_u16)addr); + _stprintf (buffer, disasm_lc_hex(_T("$%04X")), (uae_u16)addr); pc += 2; showea_val(buffer, opcode, addr, size); break; case absl: addr = get_ilong_debug (pc); - _stprintf (buffer, _T("$%08x"), addr); + _stprintf (buffer, disasm_lc_hex(_T("$%08X")), addr); pc += 4; showea_val(buffer, opcode, addr, size); break; @@ -432,15 +574,15 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi *actualea = 0; switch (size){ case sz_byte: - _stprintf (buffer, _T("#$%02x"), (get_iword_debug (pc) & 0xff)); + _stprintf (buffer, disasm_lc_hex(_T("#$%02X")), (get_iword_debug (pc) & 0xff)); pc += 2; break; case sz_word: - _stprintf (buffer, _T("#$%04x"), (get_iword_debug (pc) & 0xffff)); + _stprintf (buffer, disasm_lc_hex(_T("#$%04X")), (get_iword_debug (pc) & 0xffff)); pc += 2; break; case sz_long: - _stprintf(buffer, _T("#$%08x"), (get_ilong_debug(pc))); + _stprintf(buffer, disasm_lc_hex(_T("#$%08X")), (get_ilong_debug(pc))); pc += 4; break; case sz_single: @@ -468,7 +610,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi break; } case sz_packed: - _stprintf(buffer, _T("#$%08x%08x%08x"), get_ilong_debug(pc), get_ilong_debug(pc + 4), get_ilong_debug(pc + 8)); + _stprintf(buffer, disasm_lc_hex(_T("#$%08X%08X%08X")), get_ilong_debug(pc), get_ilong_debug(pc + 4), get_ilong_debug(pc + 8)); pc += 12; break; default: @@ -477,7 +619,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi break; case imm0: offset = (uae_s32)(uae_s8)get_iword_debug (pc); - _stprintf (buffer, _T("#$%02x"), (uae_u32)(offset & 0xff)); + _stprintf (buffer, disasm_lc_hex(_T("#$%02X")), (uae_u32)(offset & 0xff)); addr = pc + 2 + offset; if ((opcode & 0xf000) == 0x6000) { showea_val(buffer, opcode, addr, 1); @@ -489,7 +631,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi case imm1: offset = (uae_s32)(uae_s16)get_iword_debug (pc); buffer[0] = 0; - _stprintf (buffer, _T("#$%04x"), (uae_u32)(offset & 0xffff)); + _stprintf (buffer, disasm_lc_hex(_T("#$%04X")), (uae_u32)(offset & 0xffff)); addr = pc + offset; if ((opcode & 0xf000) == 0x6000) { showea_val(buffer, opcode, addr, 2); @@ -500,7 +642,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi break; case imm2: offset = (uae_s32)get_ilong_debug (pc); - _stprintf (buffer, _T("#$%08x"), (uae_u32)offset); + _stprintf (buffer, disasm_lc_hex(_T("#$%08X")), (uae_u32)offset); addr = pc + offset; if ((opcode & 0xf000) == 0x6000) { showea_val(buffer, opcode, addr, 4); @@ -511,7 +653,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi break; case immi: offset = (uae_s32)(uae_s8)(reg & 0xff); - _stprintf (buffer, _T("#$%02x"), (uae_u8)offset); + _stprintf (buffer, disasm_lc_hex(_T("#$%02X")), (uae_u8)offset); addr = pc + offset; if (actualea) *actualea = 0; @@ -732,8 +874,9 @@ static const TCHAR *movemregs[] = _T("FPIAR") }; -static void addmovemreg (TCHAR *out, int *prevreg, int *lastreg, int *first, int reg, int fpmode) +static void addmovemreg(TCHAR *out, int *prevreg, int *lastreg, int *first, int reg, int fpmode) { + TCHAR s[10]; TCHAR *p = out + _tcslen (out); if (*prevreg < 0) { *prevreg = reg; @@ -741,13 +884,21 @@ static void addmovemreg (TCHAR *out, int *prevreg, int *lastreg, int *first, int return; } if (reg < 0 || fpmode == 2 || (*prevreg) + 1 != reg || (reg & 8) != ((*prevreg & 8))) { - _stprintf (p, _T("%s%s"), (*first) ? _T("") : _T("/"), movemregs[*lastreg]); + _tcscpy(s, movemregs[*lastreg]); + if (disasm_flags & DISASM_FLAG_LC_REG) { + to_lower(s, -1); + } + _stprintf (p, _T("%s%s"), (*first) ? _T("") : _T("/"), s); p = p + _tcslen (p); if (*lastreg != *prevreg) { + _tcscpy(s, movemregs[*prevreg]); + if (disasm_flags & DISASM_FLAG_LC_REG) { + to_lower(s, -1); + } if ((*lastreg) + 2 == reg) { - _stprintf(p, _T("/%s"), movemregs[*prevreg]); + _stprintf(p, _T("/%s"), s); } else if ((*lastreg) != (*prevreg)) { - _stprintf(p, _T("-%s"), movemregs[*prevreg]); + _stprintf(p, _T("-%s"), s); } } *lastreg = reg; @@ -756,7 +907,7 @@ static void addmovemreg (TCHAR *out, int *prevreg, int *lastreg, int *first, int *prevreg = reg; } -static bool movemout (TCHAR *out, uae_u16 mask, int mode, int fpmode, bool dst) +static bool movemout(TCHAR *out, uae_u16 mask, int mode, int fpmode, bool dst) { unsigned int dmask, amask; int prevreg = -1, lastreg = -1, first = 1; @@ -800,7 +951,7 @@ static bool movemout (TCHAR *out, uae_u16 mask, int mode, int fpmode, bool dst) return dataout; } -static void disasm_size (TCHAR *instrname, struct instr *dp) +static void disasm_size(TCHAR *instrname, struct instr *dp) { int size = dp->size; if (dp->unsized) { @@ -810,29 +961,29 @@ static void disasm_size (TCHAR *instrname, struct instr *dp) int m = dp->mnemo; if (dp->suse && dp->smode == immi && (m == i_MOVE || m == i_ADD || m == i_ADDA || m == i_SUB || m == i_SUBA)) { - _tcscat(instrname, _T("Q")); + _tcscat(instrname, disasm_lc_size(_T("Q"))); if (m == i_MOVE) size = -1; } // EXT.B -> EXTB.L if (m == i_EXT && dp->size == sz_byte) { - _tcscat(instrname,_T("B")); + _tcscat(instrname, disasm_lc_size(_T("B"))); size = sz_long; } switch (size) { case sz_byte: - _tcscat (instrname, _T(".B ")); + _tcscat(instrname, disasm_lc_size(_T(".B "))); break; case sz_word: - _tcscat (instrname, _T(".W ")); + _tcscat(instrname, disasm_lc_size(_T(".W "))); break; case sz_long: - _tcscat (instrname, _T(".L ")); + _tcscat(instrname, disasm_lc_size(_T(".L "))); break; default: - _tcscat (instrname, _T(" ")); + _tcscat(instrname, disasm_lc_size(_T(" "))); break; } } @@ -1515,7 +1666,7 @@ static void resolve_if_jmp(TCHAR *s, uae_u32 addr) if (opcode == 0x4ef9) { // JMP x.l TCHAR *p = s + _tcslen(s); uae_u32 addr2 = get_long_debug(addr + 2); - _stprintf(p, _T(" == $%08x "), addr2); + _stprintf(p, disasm_lc_hex(_T(" == $%08X ")), addr2); showea_val(p + _tcslen(p), opcode, addr2, 4); TCHAR txt[256]; bool ext; @@ -1535,13 +1686,13 @@ static bool mmu_op30_helper_get_fc(uae_u16 extra, TCHAR *out) _stprintf(out, _T("#%d"), extra & 7); return true; case 0x0008: - _stprintf(out, _T("D%d"), extra & 7); + _stprintf(out, _T("%c%d"), disasm_dreg, extra & 7); return true; case 0x0000: if (extra & 1) { - _tcscpy(out, _T("DFC")); + _tcscpy(out, disasm_lc_reg(_T("DFC"))); } else { - _tcscpy(out, _T("SFC")); + _tcscpy(out, disasm_lc_reg(_T("SFC"))); } return true; default: @@ -1614,12 +1765,13 @@ static uaecptr disasm_mmu030(uaecptr pc, uae_u16 opcode, uae_u16 extra, struct i if (fd) _tcscat(instrname, _T("FD")); _tcscat(instrname, _T(" ")); + disasm_lc_mnemo(instrname); if (!rw) { pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr2, actualea, safemode); _tcscat(instrname, _T(",")); } - _tcscat(instrname, r); + _tcscat(instrname, disasm_lc_reg(r)); if (rw) { _tcscat(instrname, _T(",")); pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr2, actualea, safemode); @@ -1643,25 +1795,32 @@ static uaecptr disasm_mmu030(uaecptr pc, uae_u16 opcode, uae_u16 extra, struct i case 0x02: // PLOAD R if (mmu_op30_invea(opcode)) break; - _stprintf(instrname, _T("PLOAD%c %s,"), mode == 0 ? 'W' : 'R', fc); + _stprintf(instrname, _T("PLOAD%c"), mode == 0 ? 'W' : 'R'); + disasm_lc_mnemo(instrname); + _stprintf(instrname + _tcslen(instrname), _T(" %s,"), fc); pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr2, actualea, safemode); break; case 0x04: // PFLUSHA if (fc_bits) break; _tcscpy(instrname, _T("PFLUSHA")); + disasm_lc_mnemo(instrname); break; case 0x10: // FC if (!mmu_op30_helper_get_fc(extra, fc)) break; - _stprintf(instrname, _T("PFLUSH %s,%d"), fc, fc_mask); + _tcscpy(instrname, _T("PFLUSH")); + disasm_lc_mnemo(instrname); + _stprintf(instrname + _tcslen(instrname), _T(" %s,%d"), fc, fc_mask); break; case 0x18: // FC + EA if (mmu_op30_invea(opcode)) break; if (!mmu_op30_helper_get_fc(extra, fc)) break; - _stprintf(instrname, _T("PFLUSH %s,%d"), fc, fc_mask); + _tcscpy(instrname, _T("PFLUSH")); + disasm_lc_mnemo(instrname); + _stprintf(instrname + _tcslen(instrname), _T(" %s,%d"), fc, fc_mask); _tcscat(instrname, _T(",")); pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr2, actualea, safemode); break; @@ -1683,13 +1842,18 @@ static uaecptr disasm_mmu030(uaecptr pc, uae_u16 opcode, uae_u16 extra, struct i break; if (!level && a) break; - _stprintf(instrname, _T("PTEST%c %s,"), rw ? 'R' : 'W', fc); + _stprintf(instrname, _T("PTEST%c"), rw ? 'R' : 'W'); + disasm_lc_mnemo(instrname); + _stprintf(instrname + _tcslen(instrname), _T(" %s,"), fc); pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr2, actualea, safemode); _stprintf(instrname + _tcslen(instrname), _T(",#%d"), level); if (a) - _stprintf(instrname + _tcslen(instrname), _T(",A%d"), areg); + _stprintf(instrname + _tcslen(instrname), _T(",%c%d"), disasm_areg, areg); break; } + default: + disasm_lc_mnemo(instrname); + break; } return pc; } @@ -1772,7 +1936,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b } symbolpos = buf; - buf = buf_out (buf, &bufsize, _T("%08X "), pc); + buf = buf_out (buf, &bufsize, disasm_lc_nhex(_T("%08X ")), pc); if (segid) { buf = buf_out(buf, &bufsize, _T("%s "), segout); @@ -1781,10 +1945,10 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b add_disasm_word(&pc, &bufpc, &bufpcsize, 2); if (lookup->friendlyname) - _tcscpy (instrname, lookup->friendlyname); + _tcscpy(instrname, lookup->friendlyname); else - _tcscpy (instrname, lookup->name); - ccpt = _tcsstr (instrname, _T("cc")); + _tcscpy(instrname, lookup->name); + ccpt = _tcsstr(instrname, _T("cc")); if (ccpt != 0) { if ((opcode & 0xf000) == 0xf000) { if (lookup->mnemo == i_FBcc) { @@ -1794,9 +1958,13 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b } } else { _tcsncpy(ccpt, ccnames[dp->cc], 2); + if (dp->cc == 0) { + _tcscpy(ccpt, _T("BRA")); + } } } - disasm_size (instrname, dp); + disasm_lc_mnemo(instrname); + disasm_size(instrname, dp); if (lookup->mnemo == i_MOVEC2 || lookup->mnemo == i_MOVE2C) { uae_u16 imm = extra; @@ -1809,7 +1977,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b if (m2cregs[j].regno == creg) break; } - _stprintf(regs, _T("%c%d"), r >= 8 ? 'A' : 'D', r >= 8 ? r - 8 : r); + _stprintf(regs, _T("%c%d"), r >= 8 ? disasm_areg : disasm_dreg, r >= 8 ? r - 8 : r); if (m2cregs[j].regname) cname = m2cregs[j].regname; if (lookup->mnemo == i_MOVE2C) { @@ -1832,38 +2000,39 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b if (!(extra & 0x0800)) { instrname[1] = 'M'; instrname[2] = 'P'; + disasm_lc_mnemo(instrname); } add_disasm_word(&pc, &bufpc, &bufpcsize, 2); pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &seaddr2, &actualea_src, safemode); p = instrname + _tcslen(instrname); - _stprintf(p, (extra & 0x8000) ? _T(",A%d") : _T(",D%d"), (extra >> 12) & 7); + _stprintf(p, _T(",%c%d"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7); } else if (lookup->mnemo == i_CAS) { TCHAR *p = instrname + _tcslen(instrname); - _stprintf(p, _T("D%d,D%d,"), extra & 7, (extra >> 6) & 7); + _stprintf(p, _T("%c%d,%c%d,"), disasm_dreg, extra & 7, disasm_dreg, (extra >> 6) & 7); add_disasm_word(&pc, &bufpc, &bufpcsize, 2); pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &deaddr2, &actualea_dst, safemode); } else if (lookup->mnemo == i_CAS2) { TCHAR *p = instrname + _tcslen(instrname); uae_u16 extra2 = get_word_debug(pc + 2); - _stprintf(p, _T("D%d:D%d,D%d,D%d,(%c%d):(%c%d)"), - extra & 7, extra2 & 7, (extra >> 6) & 7, (extra2 >> 6) & 7, - (extra & 0x8000) ? 'A' : 'D', (extra >> 12) & 7, - (extra2 & 0x8000) ? 'A' : 'D', (extra2 >> 12) & 7); + _stprintf(p, _T("%c%d:%c%d,%c%d,%c%d,(%c%d):(%c%d)"), + disasm_dreg, extra & 7, disasm_dreg, extra2 & 7, disasm_dreg, (extra >> 6) & 7, disasm_dreg, (extra2 >> 6) & 7, + (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7, + (extra2 & 0x8000) ? disasm_dreg : disasm_dreg, (extra2 >> 12) & 7); add_disasm_word(&pc, &bufpc, &bufpcsize, 4); } else if (lookup->mnemo == i_ORSR || lookup->mnemo == i_ANDSR || lookup->mnemo == i_EORSR) { pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, &seaddr2, &actualea_src, safemode); - _tcscat(instrname, dp->size == sz_byte ? _T(",CCR") : _T(",SR")); + _tcscat(instrname, dp->size == sz_byte ? disasm_lc_reg(_T(",CCR")) : disasm_lc_reg(_T(",SR"))); } else if (lookup->mnemo == i_MVR2USP) { pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, &seaddr2, &actualea_src, safemode); - _tcscat(instrname, _T(",USP")); + _tcscat(instrname, disasm_lc_reg(_T(",USP"))); } else if (lookup->mnemo == i_MVUSP2R) { - _tcscat(instrname, _T("USP,")); + _tcscat(instrname, disasm_lc_reg(_T("USP,"))); pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, &seaddr2, &actualea_src, safemode); } else if (lookup->mnemo == i_MV2SR) { pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, &seaddr2, &actualea_src, safemode); - _tcscat(instrname, dp->size == sz_byte ? _T(",CCR") : _T(",SR")); + _tcscat(instrname, dp->size == sz_byte ? disasm_lc_reg(_T(",CCR")) : disasm_lc_reg(_T(",SR"))); } else if (lookup->mnemo == i_MVSR2) { - _tcscat(instrname, dp->size == sz_byte ? _T("CCR,") : _T("SR,")); + _tcscat(instrname, dp->size == sz_byte ? disasm_lc_reg(_T("CCR,")) : disasm_lc_reg(_T("SR,"))); pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, &seaddr2, &actualea_src, safemode); } else if (lookup->mnemo == i_MVMEL) { uae_u16 mask = extra; @@ -1892,22 +2061,23 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b instrname[5] = instrname[4]; instrname[4] = 'L'; } + disasm_lc_mnemo(instrname); pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &seaddr2, &actualea_src, safemode); p = instrname + _tcslen(instrname); if (extra & 0x0400) - _stprintf(p, _T(",D%d:D%d"), extra & 7, (extra >> 12) & 7); + _stprintf(p, _T(",%c%d:%c%d"), disasm_dreg, extra & 7, disasm_dreg, (extra >> 12) & 7); else - _stprintf(p, _T(",D%d"), (extra >> 12) & 7); + _stprintf(p, _T(",%c%d"), disasm_dreg, (extra >> 12) & 7); } else if (lookup->mnemo == i_MOVES) { TCHAR *p; add_disasm_word(&pc, &bufpc, &bufpcsize, 2); if (!(extra & 0x0800)) { pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &deaddr2, &actualea_dst, safemode); p = instrname + _tcslen(instrname); - _stprintf(p, _T(",%c%d"), (extra & 0x8000) ? 'A' : 'D', (extra >> 12) & 7); + _stprintf(p, _T(",%c%d"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7); } else { p = instrname + _tcslen(instrname); - _stprintf(p, _T("%c%d,"), (extra & 0x8000) ? 'A' : 'D', (extra >> 12) & 7); + _stprintf(p, _T("%c%d,"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7); pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &seaddr2, &actualea_src, safemode); } } else if (lookup->mnemo == i_BFEXTS || lookup->mnemo == i_BFEXTU || @@ -1922,42 +2092,42 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b if (lookup->mnemo == i_BFEXTS || lookup->mnemo == i_BFEXTU || lookup->mnemo == i_BFFFO || lookup->mnemo == i_BFINS) reg = (extra >> 12) & 7; if (lookup->mnemo == i_BFINS) - _stprintf(p, _T("D%d,"), reg); + _stprintf(p, _T("%c%d,"), disasm_dreg, reg); pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &seaddr2, &actualea_src, safemode); _tcscat(instrname, _T(" {")); p = instrname + _tcslen(instrname); if (extra & 0x0800) - _stprintf(p, _T("D%d"), (extra >> 6) & 7); + _stprintf(p, _T("%c%d"), disasm_dreg, (extra >> 6) & 7); else _stprintf(p, _T("%d"), (extra >> 6) & 31); _tcscat(instrname, _T(":")); p = instrname + _tcslen(instrname); if (extra & 0x0020) - _stprintf(p, _T("D%d"), extra & 7); + _stprintf(p, _T("%c%d"), disasm_dreg, extra & 7); else _stprintf(p, _T("%d"), extra & 31); _tcscat(instrname, _T("}")); p = instrname + _tcslen(instrname); if (lookup->mnemo == i_BFFFO || lookup->mnemo == i_BFEXTS || lookup->mnemo == i_BFEXTU) - _stprintf(p, _T(",D%d"), reg); + _stprintf(p, _T(",%c%d"), disasm_dreg, reg); } else if (lookup->mnemo == i_CPUSHA || lookup->mnemo == i_CPUSHL || lookup->mnemo == i_CPUSHP || lookup->mnemo == i_CINVA || lookup->mnemo == i_CINVL || lookup->mnemo == i_CINVP) { if ((opcode & 0xc0) == 0xc0) - _tcscat(instrname, _T("BC")); + _tcscat(instrname, disasm_lc_reg(_T("BC"))); else if (opcode & 0x80) - _tcscat(instrname, _T("IC")); + _tcscat(instrname, disasm_lc_reg(_T("IC"))); else if (opcode & 0x40) - _tcscat(instrname, _T("DC")); + _tcscat(instrname, disasm_lc_reg(_T("DC"))); else _tcscat(instrname, _T("?")); if (lookup->mnemo == i_CPUSHL || lookup->mnemo == i_CPUSHP || lookup->mnemo == i_CINVL || lookup->mnemo == i_CINVP) { TCHAR *p = instrname + _tcslen(instrname); - _stprintf(p, _T(",(A%d)"), opcode & 7); + _stprintf(p, _T(",(%c%d)"), disasm_areg, opcode & 7); } } else if (lookup->mnemo == i_MOVE16) { TCHAR *p = instrname + _tcslen(instrname); if (opcode & 0x20) { - _stprintf(p, _T("(A%d)+,(A%d)+"), opcode & 7, (extra >> 12) & 7); + _stprintf(p, _T("(%c%d)+,(%c%d)+"), disasm_areg, opcode & 7, disasm_areg, (extra >> 12) & 7); add_disasm_word(&pc, &bufpc, &bufpcsize, 2); } else { uae_u32 addr = get_long_debug(pc); @@ -1966,16 +2136,16 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b switch ((opcode >> 3) & 3) { case 0: - _stprintf(p, _T("(A%d)+,$%08x"), ay, addr); + _stprintf(p, _T("(%c%d)+,$%08x"), disasm_areg, ay, addr); break; case 1: - _stprintf(p, _T("$%08x,(A%d)+"), addr, ay); + _stprintf(p, _T("$%08x,(%c%d)+"), addr, disasm_areg, ay); break; case 2: - _stprintf(p, _T("(A%d),$%08x"), ay, addr); + _stprintf(p, _T("(%c%d),$%08x"), disasm_areg, ay, addr); break; case 3: - _stprintf(p, _T("$%08x,(A%d)"), addr, ay); + _stprintf(p, _T("$%08x,(%c%d)"), addr, disasm_areg, ay); break; } } @@ -1984,15 +2154,19 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b _tcscat(instrname, _T(",")); pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &deaddr2, &actualea_dst, safemode); extra = get_word_debug(pc); - _stprintf(instrname + _tcslen(instrname), _T(",#$%04x"), extra); + _stprintf(instrname + _tcslen(instrname), disasm_lc_hex(_T(",#$%04X")), extra); add_disasm_word(&pc, &bufpc, &bufpcsize, 2); } else if (lookup->mnemo == i_LPSTOP) { if (extra == 0x01c0) { uae_u16 extra2 = get_word_debug(pc + 2); - _stprintf(instrname, _T("LPSTOP #$%04x"), extra2); + _tcscpy(instrname, _T("LPSTOP")); + disasm_lc_mnemo(instrname); + _stprintf(instrname + _tcslen(instrname), disasm_lc_hex(_T(" #$%04X")), extra2); add_disasm_word(&pc, &bufpc, &bufpcsize, 4); } else { - _stprintf(instrname, _T("ILLG #$%04x"), extra); + _tcscpy(instrname, _T("ILLG")); + disasm_lc_mnemo(instrname); + _stprintf(instrname + _tcslen(instrname), disasm_lc_hex(_T(" #$%04X")), extra); add_disasm_word(&pc, &bufpc, &bufpcsize, 2); } } else if (lookup->mnemo == i_CALLM) { @@ -2023,7 +2197,9 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b if ((extra & 0xfc00) == 0x5c00) { // FMOVECR (=i_FPP with source specifier = 7) fpdata fp; fpu_get_constant(&fp, extra & 0x7f); - _stprintf(instrname, _T("FMOVECR.X #0x%02x [%s],FP%d"), extra & 0x7f, fpp_print(&fp, 0), (extra >> 7) & 7); + _tcscpy(instrname, _T("FMOVECR.X")); + disasm_lc_mnemo(instrname); + _stprintf(instrname + _tcslen(instrname), _T(" #0x%02x [%s],%s%d"), extra & 0x7f, fpp_print(&fp, 0), disasm_fpreg, (extra >> 7) & 7); } else if ((extra & 0x8000) == 0x8000) { // FMOVEM or FMOVE control register int dr = (extra >> 13) & 1; int mode; @@ -2035,6 +2211,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b regmask = extra & 0xff; // FMOVEM FPx fpmode = 1; _tcscpy(instrname, _T("FMOVEM.X ")); + disasm_lc_mnemo(instrname); } else { mode = 0; regmask = (extra >> 10) & 7; // FMOVEM or FMOVE control @@ -2042,11 +2219,12 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b _tcscpy(instrname, _T("FMOVEM.L ")); if (regmask == 1 || regmask == 2 || regmask == 4) _tcscpy(instrname, _T("FMOVE.L ")); + disasm_lc_mnemo(instrname); } p = instrname + _tcslen(instrname); if (dr) { if (mode & 1) - _stprintf(p, _T("D%d"), dreg); + _stprintf(p, _T("%c%d"), disasm_dreg, dreg); else movemout(p, regmask, dp->dmode, fpmode, false); _tcscat(instrname, _T(",")); @@ -2063,7 +2241,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b _tcscat(p, _T("/")); entry = true; p = instrname + _tcslen(instrname); - _stprintf(p, _T("#$%08x"), get_ilong_debug(pc)); + _stprintf(p, disasm_lc_hex(_T("#$%08X")), get_ilong_debug(pc)); add_disasm_word(&pc, &bufpc, &bufpcsize, 4); } } @@ -2072,7 +2250,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b } p = instrname + _tcslen(instrname); if (mode & 1) - _stprintf(p, _T(",D%d"), dreg); + _stprintf(p, _T(",%c%d"), disasm_dreg, dreg); else movemout(p, regmask, dp->dmode, fpmode, true); } @@ -2080,19 +2258,21 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b if (fpuopcodes[ins]) { _tcscpy(instrname, fpuopcodes[ins]); } else { - _stprintf(instrname, _T("F?%02X"), ins); + _stprintf(instrname, _T("%s?%02X"), disasm_lc_reg(_T("F")), ins); } + disasm_lc_mnemo(instrname); if ((extra & (0x8000 | 0x4000 | 0x2000)) == (0x4000 | 0x2000)) { // FMOVE to memory/data register int kfactor = extra & 0x7f; _tcscpy(instrname, _T("FMOVE.")); _tcscat(instrname, fpsizes[size]); + disasm_lc_mnemo(instrname); _tcscat(instrname, _T(" ")); p = instrname + _tcslen(instrname); - _stprintf(p, _T("FP%d,"), (extra >> 7) & 7); + _stprintf(p, _T("%s%d,"), disasm_fpreg, (extra >> 7) & 7); pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, fpsizeconv[size], instrname, &deaddr2, &actualea_dst, safemode); p = instrname + _tcslen(instrname); if (size == 7) { - _stprintf(p, _T(" {D%d}"), (kfactor >> 4)); + _stprintf(p, _T(" {%c%d}"), disasm_dreg, (kfactor >> 4)); } else if (kfactor) { if (kfactor & 0x40) kfactor |= ~0x3f; @@ -2101,19 +2281,21 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b } else if ((extra & (0x8000 | 0x2000)) == 0) { if (extra & 0x4000) { // source is EA _tcscat(instrname, _T(".")); - _tcscat(instrname, fpsizes[size]); + _tcscat(instrname, disasm_lc_size(fpsizes[size])); _tcscat(instrname, _T(" ")); pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, fpsizeconv[size], instrname, &seaddr2, &actualea_src, safemode); } else { // source is FPx p = instrname + _tcslen(instrname); - _stprintf(p, _T(".X FP%d"), (extra >> 10) & 7); + _tcscat(p, disasm_lc_reg(_T(".X"))); + p = instrname + _tcslen(instrname); + _stprintf(p, _T(" %s%d"), disasm_fpreg, (extra >> 10) & 7); } p = instrname + _tcslen(instrname); if ((extra & 0x4000) || (((extra >> 7) & 7) != ((extra >> 10) & 7))) - _stprintf(p, _T(",FP%d"), (extra >> 7) & 7); + _stprintf(p, _T(",%s%d"), disasm_fpreg, (extra >> 7) & 7); if (ins >= 0x30 && ins < 0x38) { // FSINCOS p = instrname + _tcslen(instrname); - _stprintf(p, _T(",FP%d"), extra & 7); + _stprintf(p, _T(",%s%d"), disasm_fpreg, extra & 7); } } if (ins >= 0x40 && currprefs.fpu_model >= 68881 && fpuopcodes[ins]) { @@ -2124,9 +2306,11 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b pc = disasm_mmu030(pc, opcode, extra, dp, instrname, &seaddr2, &actualea_src, safemode); } else if ((opcode & 0xf000) == 0xa000) { _tcscpy(instrname, _T("A-LINE")); + disasm_lc_mnemo(instrname); } else { if (lookup->mnemo == i_FBcc && (opcode & 0x1f) == 0 && extra == 0) { _tcscpy(instrname, _T("FNOP")); + disasm_lc_mnemo(instrname); add_disasm_word(&pc, &bufpc, &bufpcsize, 2); } else { if (dp->suse) { @@ -2157,17 +2341,22 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b if (lookup->mnemo == i_RTE || lookup->mnemo == i_RTR) { a += 2; } - _stprintf(eas, _T(" == $%08x"), get_ilong_debug(a)); + if (disasm_flags & DISASM_FLAG_EA) { + _stprintf(eas, disasm_lc_hex(_T(" == $%08X")), get_ilong_debug(a)); + } _tcscat(instrname, eas); } } } - for (i = 0; i < (pc - oldpc) / 2; i++) { - buf = buf_out (buf, &bufsize, _T("%04x "), get_word_debug (oldpc + i * 2)); + if (disasm_flags & DISASM_FLAG_WORDS) { + for (i = 0; i < (pc - oldpc) / 2 && i < disasm_max_words; i++) { + buf = buf_out(buf, &bufsize, disasm_lc_nhex(_T("%04X ")), get_word_debug(oldpc + i * 2)); + } + while (i++ < disasm_min_words) { + buf = buf_out(buf, &bufsize, _T(" ")); + } } - while (i++ < 5) - buf = buf_out (buf, &bufsize, _T(" ")); if (illegal) buf = buf_out (buf, &bufsize, _T("[ ")); @@ -2181,31 +2370,37 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b *deaddr = pc; if ((opcode & 0xf000) == 0xf000) { if (currprefs.fpu_model) { + buf = buf_out(buf, &bufsize, disasm_lc_hex(_T(" == $%08X")), addr2); if (fpp_cond(dp->cc)) { - buf = buf_out(buf, &bufsize, _T(" == $%08x (T)"), addr2); + buf = buf_out(buf, &bufsize, _T(" (T)")); } else { - buf = buf_out(buf, &bufsize, _T(" == $%08x (F)"), addr2); + buf = buf_out(buf, &bufsize, _T(" (F)")); } } } else { if (dp->mnemo == i_Bcc || dp->mnemo == i_DBcc) { - if (cctrue(dp->cc)) { - buf = buf_out(buf, &bufsize, _T(" == $%08x (T)"), addr2); - } else { - buf = buf_out(buf, &bufsize, _T(" == $%08x (F)"), addr2); - } - } else { + buf = buf_out(buf, &bufsize, disasm_lc_hex(_T(" == $%08X")), addr2); if (cctrue(dp->cc)) { buf = buf_out(buf, &bufsize, _T(" (T)")); } else { buf = buf_out(buf, &bufsize, _T(" (F)")); } + } else { + if (disasm_flags & DISASM_FLAG_CC) { + if (cctrue(dp->cc)) { + buf = buf_out(buf, &bufsize, _T(" (T)")); + } else { + buf = buf_out(buf, &bufsize, _T(" (F)")); + } + } } } } else if ((opcode & 0xff00) == 0x6100) { /* BSR */ if (deaddr) *deaddr = pc; - buf = buf_out (buf, &bufsize, _T(" == $%08x"), seaddr2); + if (disasm_flags & DISASM_FLAG_EA) { + buf = buf_out(buf, &bufsize, disasm_lc_hex(_T(" == $%08X")), seaddr2); + } } buf = buf_out (buf, &bufsize, _T("\n")); diff --git a/drawing.cpp b/drawing.cpp index 37ee9dc7..565bd5de 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -3378,7 +3378,7 @@ static void do_color_changes(line_draw_func worker_border, line_draw_func worker int shift = (hsync_shift_hack << lores_shift) * vidinfo->drawbuffer.pixbytes; if (shift) { int firstpos = visible_left_border * vidinfo->drawbuffer.pixbytes; - int lastpos = (visible_right_border - visible_left_border) * vidinfo->drawbuffer.pixbytes; + int lastpos = (visible_left_border + vidinfo->drawbuffer.inwidth) * vidinfo->drawbuffer.pixbytes; memmove(xlinebuffer + firstpos, xlinebuffer + firstpos + shift, lastpos - firstpos - shift); memset(xlinebuffer + lastpos - shift, 0, shift); } @@ -3658,20 +3658,21 @@ static void center_image (void) } } #endif - } else if (vidinfo->drawbuffer.extrawidth > 0 || currprefs.gfx_overscanmode == OVERSCANMODE_EXTREME) { - // extreme wide mode - visible_left_border = (hsync_end_left_border * 2 + 1) << currprefs.gfx_resolution; } else if (ew == -1) { // wide mode - visible_left_border = (hsync_end_left_border * 2) << currprefs.gfx_resolution; + int hs = hsync_end_left_border * 2; + if (currprefs.gfx_overscanmode >= OVERSCANMODE_BROADCAST) { + hs++; + } + visible_left_border = hs << currprefs.gfx_resolution; if (visible_left_border + w < max_diwlastword) { visible_left_border += (max_diwlastword - (visible_left_border + w) - 1) / 2; } if (ew > 0) { visible_left_border -= (ew / 2) << currprefs.gfx_resolution; } - if (visible_left_border < ((hsync_end_left_border * 2) << currprefs.gfx_resolution)) { - visible_left_border = (hsync_end_left_border * 2) << currprefs.gfx_resolution; + if (visible_left_border < (hs << currprefs.gfx_resolution)) { + visible_left_border = hs << currprefs.gfx_resolution; } } else if (ew < -1) { // normal diff --git a/include/blitter.h b/include/blitter.h index 8ef4afc0..3d110b18 100644 --- a/include/blitter.h +++ b/include/blitter.h @@ -25,11 +25,12 @@ struct bltinfo { int blitter_dangerous_bpl; int blit_main, blit_finald, blit_pending; int blit_queued; + int finishhpos; }; extern struct bltinfo blt_info; -extern void check_is_blit_dangerous (uaecptr *bplpt, int planes, int words); +extern void check_is_blit_dangerous(uaecptr *bplpt, int planes, int words); extern uae_u16 bltsize; extern uae_u16 bltcon0, bltcon1; @@ -37,18 +38,18 @@ extern uae_u32 bltapt, bltbpt, bltcpt, bltdpt; extern uae_u32 bltptx; extern int bltptxpos, bltptxc; -extern void maybe_blit (int, int); -extern void reset_blit (int); -extern int blitnasty (void); -extern void blitter_handler (uae_u32); -extern void build_blitfilltable (void); -extern void do_blitter (int, int, uaecptr); +extern void maybe_blit(int, int); +extern void reset_blit(int); +extern int blitnasty(void); +extern void blitter_handler(uae_u32); +extern void build_blitfilltable(void); +extern void do_blitter(int, int, uaecptr); extern void decide_blitter(int hpos); extern bool decide_blitter_maybe_write(int hpos, uaecptr addr, uae_u32 v); -extern void blitter_done_notify (int); -extern void blitter_slowdown (int, int, int, int); -extern void blitter_check_start (void); -extern void blitter_reset (void); +extern void blitter_done_notify(int); +extern void blitter_slowdown(int, int, int, int); +extern void blitter_check_start(void); +extern void blitter_reset(void); extern void blitter_debugdump(void); extern bool blit_steal_cycle(int hpos); @@ -58,8 +59,8 @@ typedef void blitter_func(uaecptr, uaecptr, uaecptr, uaecptr, struct bltinfo *); #define BLITTER_MAX_WORDS 2048 -extern blitter_func * const blitfunc_dofast[256]; -extern blitter_func * const blitfunc_dofast_desc[256]; +extern blitter_func *const blitfunc_dofast[256]; +extern blitter_func *const blitfunc_dofast_desc[256]; extern uae_u32 blit_masktable[BLITTER_MAX_WORDS]; #endif /* UAE_BLITTER_H */ diff --git a/include/debug.h b/include/debug.h index 85413322..4fb3c932 100644 --- a/include/debug.h +++ b/include/debug.h @@ -34,6 +34,7 @@ extern int debug_bpl_mask, debug_bpl_mask_one; extern int debugger_active; extern int debug_illegal; extern uae_u64 debug_illegal_mask; +extern int debugger_used; extern void debug (void); extern void debugger_change (int mode); diff --git a/include/disasm.h b/include/disasm.h index 1744ed98..4ed91a9d 100644 --- a/include/disasm.h +++ b/include/disasm.h @@ -5,7 +5,22 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b void sm68k_disasm(TCHAR *instrname, TCHAR *instrcode, uaecptr addr, uaecptr *nextpc, uaecptr lastpc); uae_u32 REGPARAM2 op_illg_1(uae_u32 opcode); uae_u32 REGPARAM2 op_unimpl_1(uae_u32 opcode); +void disasm_init(void); extern struct cpum2c m2cregs[]; extern const TCHAR *fpuopcodes[]; -extern const TCHAR *fpsizes[]; \ No newline at end of file +extern const TCHAR *fpsizes[]; + +extern int disasm_flags; +extern int disasm_min_words; +extern int disasm_max_words; +extern TCHAR disasm_hexprefix[3]; + +#define DISASM_FLAG_LC_MNEMO 1 +#define DISASM_FLAG_LC_REG 2 +#define DISASM_FLAG_LC_HEX 8 +#define DISASM_FLAG_LC_SIZE 16 +#define DISASM_FLAG_CC 32 +#define DISASM_FLAG_EA 64 +#define DISASM_FLAG_VAL 128 +#define DISASM_FLAG_WORDS 256 diff --git a/include/memory.h b/include/memory.h index dfdc25d5..6aa98f25 100644 --- a/include/memory.h +++ b/include/memory.h @@ -456,8 +456,6 @@ extern uaecptr expamem_z3_pointer_real, expamem_z3_pointer_uae; extern uae_u32 expamem_z3_highram_real, expamem_z3_highram_uae; extern uae_u32 expamem_board_size; -extern uae_u32 last_custom_value1; - /* Default memory access functions */ extern void dummy_put (uaecptr addr, int size, uae_u32 val); diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index fbec533e..0f848f8d 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -104,6 +104,8 @@ #include "fsdb.h" #include "uae/time.h" #include "specialmonitors.h" +#include "debug.h" +#include "disasm.h" const static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2L, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } }; @@ -5538,6 +5540,42 @@ static void resetgui(void) resetgui_pending = false; } +static void target_load_debugger_config(void) +{ + int size; + + disasm_flags = DISASM_FLAG_LC_MNEMO | DISASM_FLAG_LC_REG | DISASM_FLAG_LC_SIZE | DISASM_FLAG_LC_HEX | DISASM_FLAG_CC | DISASM_FLAG_EA | DISASM_FLAG_VAL | DISASM_FLAG_WORDS; + disasm_min_words = 5; + disasm_max_words = 16; + disasm_hexprefix[0] = '$'; + disasm_hexprefix[1] = 0; + + UAEREG *fkey = regcreatetree(NULL, _T("Debugger")); + if (fkey) { + regqueryint(fkey, _T("Disasm_flags"), &disasm_flags); + regqueryint(fkey, _T("Disasm_min_words"), &disasm_min_words); + regqueryint(fkey, _T("Disasm_max_words"), &disasm_max_words); + size = sizeof(disasm_hexprefix) / sizeof(TCHAR); + regquerystr(fkey, _T("Hex_prefix"), disasm_hexprefix, &size); + regclosetree(fkey); + } +} + +static void target_save_debugger_config(void) +{ + if (!debugger_used) { + return; + } + UAEREG *fkey = regcreatetree(NULL, _T("Debugger")); + if (fkey) { + regsetint(fkey, _T("Disasm_flags"), disasm_flags); + regsetint(fkey, _T("Disasm_min_words"), disasm_min_words); + regsetint(fkey, _T("Disasm_max_words"), disasm_max_words); + regsetstr(fkey, _T("Hex_prefix"), disasm_hexprefix); + regclosetree(fkey); + } +} + static void WIN32_HandleRegistryStuff (void) { RGBFTYPE colortype = RGBFB_NONE; @@ -5678,6 +5716,7 @@ static void WIN32_HandleRegistryStuff (void) associate_init_extensions (); read_rom_list (); load_keyring (NULL, NULL); + target_load_debugger_config(); } #if WINUAEPUBLICBETA > 0 @@ -7106,6 +7145,7 @@ end: closeIPC (globalipc); shmem_serial_delete(); write_disk_history (); + target_save_debugger_config(); timeend (); #ifdef AVIOUTPUT AVIOutput_Release ();