From db4581b3808e5d9ee50512441e28ba3ecc2b68a7 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 3 Jul 2022 17:35:51 +0300 Subject: [PATCH] Blitter modifications while blitter is running compatibility with recent chipset emulation changes. --- blitter.cpp | 19 ++++++++----------- custom.cpp | 29 +++++++++++++---------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/blitter.cpp b/blitter.cpp index 0270587e..665036f4 100644 --- a/blitter.cpp +++ b/blitter.cpp @@ -81,7 +81,6 @@ uae_u32 blit_masktable[BLITTER_MAX_WORDS]; static int blit_cyclecounter, blit_waitcyclecounter; static int blit_maxcyclecounter, blit_slowdown, blit_totalcyclecounter; static int blit_misscyclecounter; -static int blit_copperstarted; #ifdef CPUEMU_13 static int blitter_cyclecounter; @@ -113,7 +112,7 @@ static uae_u16 debug_bltadat, debug_bltbdat, debug_bltcdat; #define BLITTER_MAX_PIPELINED_CYCLES 4 #define CYCLECOUNT_FINISHED -1000 -#define CYCLECOUNT_START 3 +#define CYCLECOUNT_START 4 /* Blitter Idle Cycle: @@ -1387,7 +1386,7 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va if (dmaen(DMA_BLITTER)) { blitter_doit(last_blitter_hpos); } - goto end; + goto end2; } if (log_blitter && blitter_delayed_debug) { @@ -1396,7 +1395,7 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va } if (!blitter_cycle_exact) { - goto end; + goto end2; } while (last_blitter_hpos < until_hpos) { @@ -1656,9 +1655,9 @@ static bool decide_blitter_maybe_write2(int until_hpos, uaecptr addr, uae_u32 va last_blitter_hpos++; bltptxpos = -1; } - -end: +end2: bltptxpos = -1; +end: if (hsync) { last_blitter_hpos = 0; } @@ -1866,6 +1865,7 @@ void do_blitter(int hpos, int copper, uaecptr pc) blit_maxcyclecounter = 0x7fffffff; blit_waitcyclecounter = 0; + last_blitter_hpos = hpos; if (blitter_cycle_exact) { if (immediate_blits) { @@ -1880,11 +1880,8 @@ void do_blitter(int hpos, int copper, uaecptr pc) blitter_hcounter = 0; blitter_vcounter = 0; blit_cyclecounter = -CYCLECOUNT_START; - blit_copperstarted = copper; - if (copper) { - blit_waitcyclecounter = 0; - } else { - blit_waitcyclecounter = 0; + if (!copper) { + blit_cyclecounter++; } blit_maxcyclecounter = blt_info.hblitsize * blt_info.vblitsize + 2; blt_info.blit_pending = 0; diff --git a/custom.cpp b/custom.cpp index 4be2634f..ca8f49f8 100644 --- a/custom.cpp +++ b/custom.cpp @@ -8472,20 +8472,23 @@ static void BLTALWM(int hpos, uae_u16 v) { blt_info.bltalwm = v; reset_blit(0); } +static void setblitx(int hpos, int n) +{ + bltptxpos = (hpos + 1) % maxhpos; + bltptxc = copper_access ? n : -n; +} static void BLTAPTH(int hpos, uae_u16 v) { maybe_blit(hpos, 0); bltptx = bltapt; - bltptxpos = hpos; - bltptxc = copper_access ? 1 : -1; + setblitx(hpos, 1); bltapt = (bltapt & 0xffff) | ((uae_u32)v << 16); } static void BLTAPTL(int hpos, uae_u16 v) { maybe_blit(hpos, 0); bltptx = bltapt; - bltptxpos = hpos; - bltptxc = copper_access ? 1 : -1; + setblitx(hpos, 1); bltapt = (bltapt & ~0xffff) | (v & 0xFFFE); } static void BLTBPTH(int hpos, uae_u16 v) @@ -8500,24 +8503,21 @@ static void BLTBPTL(int hpos, uae_u16 v) { maybe_blit(hpos, 0); bltptx = bltbpt; - bltptxpos = hpos; - bltptxc = copper_access ? 2 : -2; + setblitx(hpos, 2); bltbpt = (bltbpt & ~0xffff) | (v & 0xFFFE); } static void BLTCPTH(int hpos, uae_u16 v) { maybe_blit(hpos, 0); bltptx = bltcpt; - bltptxpos = hpos; - bltptxc = copper_access ? 3 : -3; + setblitx(hpos, 3); bltcpt = (bltcpt & 0xffff) | ((uae_u32)v << 16); } static void BLTCPTL(int hpos, uae_u16 v) { maybe_blit(hpos, 0); bltptx = bltcpt; - bltptxpos = hpos; - bltptxc = copper_access ? 3 : -3; + setblitx(hpos, 3); bltcpt = (bltcpt & ~0xffff) | (v & 0xFFFE); } static void BLTDPTH (int hpos, uae_u16 v) @@ -8531,10 +8531,8 @@ static void BLTDPTH (int hpos, uae_u16 v) write_log("Possible Copper Blitter wait bug detected COP=%08x\n", cop_state.ip); } } - bltptx = bltdpt; - bltptxpos = hpos; - bltptxc = copper_access ? 4 : -4; + setblitx(hpos, 4); bltdpt = (bltdpt & 0xffff) | ((uae_u32)v << 16); } static void BLTDPTL(int hpos, uae_u16 v) @@ -8550,8 +8548,7 @@ static void BLTDPTL(int hpos, uae_u16 v) } bltptx = bltdpt; - bltptxpos = hpos; - bltptxc = copper_access ? 4 : -4; + setblitx(hpos, 4); bltdpt = (bltdpt & ~0xffff) | (v & 0xFFFE); } @@ -14721,7 +14718,7 @@ static int dma_cycle(uaecptr addr, uae_u32 value, int *mode) decide_fetch_ce(hpos_next); int bpldma = bitplane_dma_access(hpos_old, 0); if (blt_info.blit_queued) { -#if 0 +#if 1 decide_blitter(hpos_next); #else // CPU write must be done at the same time with blitter idle cycles -- 2.47.3