From 8409b6596dc3fea005681c12cad791551f816195 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 23 Jan 2021 14:29:07 +0200 Subject: [PATCH] Blitter + copper wait workaround (until copper rewrite) --- blitter.cpp | 4 ++-- custom.cpp | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/blitter.cpp b/blitter.cpp index c7dc8bb2..01c63bca 100644 --- a/blitter.cpp +++ b/blitter.cpp @@ -427,7 +427,7 @@ static void blitter_interrupt(int hpos, int done) send_interrupt (6, (4 + 1) * CYCLE_UNIT); if (debug_dma) record_dma_event (DMA_EVENT_BLITIRQ, hpos, vpos); - blitter_done_notify(hpos); + blitter_done_notify(blitline); } static void blitter_done (int hpos) @@ -439,7 +439,7 @@ static void blitter_done (int hpos) } blt_info.blit_finald = 0; blitter_interrupt (hpos, 1); - blitter_done_notify (hpos); + blitter_done_notify(blitline); event2_remevent (ev2_blitter); unset_special (SPCFLAG_BLTNASTY); if (log_blitter & 1) diff --git a/custom.cpp b/custom.cpp index 60e352a4..cbc28786 100644 --- a/custom.cpp +++ b/custom.cpp @@ -7592,23 +7592,16 @@ static void compute_spcflag_copper (int hpos) set_special (SPCFLAG_COPPER); } -void blitter_done_notify (int hpos) +static void blitter_done_notify_wakeup(uae_u32 temp) { - bool nextline = false; - if (cop_state.state != COP_bltwait) return; int vp_wait = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); int vp = vpos; - hpos += 3; + int hpos = current_hpos() + 1; hpos &= ~1; - if (hpos >= maxhpos) { - hpos -= maxhpos; - vp++; - nextline = true; - } cop_state.hpos = hpos; cop_state.vpos = vp; @@ -7623,7 +7616,7 @@ void blitter_done_notify (int hpos) record_copper_blitwait(cop_state.ip - 4, hpos, vp); #endif - if (dmaen(DMA_COPPER) && vp_wait >= cop_state.vcmp && !nextline) { + if (dmaen(DMA_COPPER) && vp_wait >= cop_state.vcmp) { copper_enabled_thisline = 1; set_special(SPCFLAG_COPPER); } else { @@ -7631,6 +7624,17 @@ void blitter_done_notify (int hpos) } } + +void blitter_done_notify(int blitline) +{ + if (cop_state.state != COP_bltwait) + return; + + // Blitline check is a hack! + // Copper emulation is not correct and new blitter emulation needs this workaround. + event2_newevent_xx(-1, (blitline ? 4 : 2) * CYCLE_UNIT, 0, blitter_done_notify_wakeup); +} + void do_copper (void) { int hpos = current_hpos (); -- 2.47.3