From ebc8f7d5be62574efecc071e338b0cbdf1c9f90d Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Tue, 13 Feb 2018 21:51:46 -0600 Subject: [PATCH] improved 'normal' blitter mode, fixes flicker in PP Hammer and Spindizzy Worlds --- src/blitter.cpp | 33 +++++++++++++++++---------------- src/custom.cpp | 21 ++++++++++----------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/blitter.cpp b/src/blitter.cpp index 87900f0..6a71911 100755 --- a/src/blitter.cpp +++ b/src/blitter.cpp @@ -59,8 +59,8 @@ uae_u32 blit_masktable[BLITTER_MAX_WORDS]; enum blitter_states bltstate; static long int blit_cyclecounter; -// blitter_slowdown doesn't work at the moment -//static int blit_slowdown; +// blitter_slowdown used to cause gfx glitches in Shadow of the Beast but works now +static int blit_slowdown; static long blit_firstline_cycles; static long blit_first_cycle; @@ -545,14 +545,14 @@ void blitter_handler(void) return; } -// blitter_slowdown doesn't work at the moment -// if (blit_slowdown > 0 && !currprefs.immediate_blits) { -// eventtab[ev_blitter].active = 1; -// eventtab[ev_blitter].oldcycles = get_cycles (); -// eventtab[ev_blitter].evtime = blit_slowdown * CYCLE_UNIT + get_cycles (); /* wait a little */ -// blit_slowdown = -1; -// return; -// } + // blitter_slowdown used to cause gfx glitches in Shadow of the Beast but works now + if (!currprefs.immediate_blits && blit_slowdown > 0) { + eventtab[ev_blitter].active = 1; + eventtab[ev_blitter].oldcycles = get_cycles (); + eventtab[ev_blitter].evtime = blit_slowdown * CYCLE_UNIT + get_cycles (); /* wait a little */ + blit_slowdown = -1; + return; + } blitter_doit(); } @@ -670,10 +670,12 @@ void do_blitter(void) } bltstate = BLT_init; -// blitter_slowdown doesn't work at the moment -// blit_slowdown = 0; + // blitter_slowdown used to cause gfx glitches in Shadow of the Beast but works now + if (!blitter_in_partial_mode && !currprefs.immediate_blits) { + blit_slowdown = 0; + } - if (dmaen(DMA_BLITPRI)) + if (dmaen(DMA_BLITPRI)) setnasty(); else unset_special (SPCFLAG_BLTNASTY); @@ -848,9 +850,9 @@ int blitnasty (void) return ccnt; } -// blitter_slowdown doesn't work at the moment (causes gfx glitches in Shadow of the Beast) +// blitter_slowdown used to cause gfx glitches in Shadow of the Beast but works now /* very approximate emulation of blitter slowdown caused by bitplane DMA */ -/* + void blitter_slowdown (int ddfstrt, int ddfstop, int totalcycles, int freecycles) { static int oddfstrt, oddfstop, ototal, ofree; @@ -874,4 +876,3 @@ void blitter_slowdown (int ddfstrt, int ddfstop, int totalcycles, int freecycles return; blit_slowdown += slow; } -*/ diff --git a/src/custom.cpp b/src/custom.cpp index 3d7edad..6a1b987 100755 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -470,16 +470,16 @@ static const int fetchstarts[] = { 3,2,1,0, 4,3,2,0, 5,4,3,0 }; static const int fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 }; static int cycle_diagram_table[3][3][9][32]; -// blitter_slowdown doesn't work at the moment (causes gfx glitches in Shadow of the Beast) -//static int cycle_diagram_free_cycles[3][3][9]; -//static int cycle_diagram_total_cycles[3][3][9]; +// blitter_slowdown used to cause gfx glitches in Shadow of the Beast but works now +static int cycle_diagram_free_cycles[3][3][9]; +static int cycle_diagram_total_cycles[3][3][9]; static int *curr_diagram; static int cycle_sequences[3 * 8] = { 2,1,2,1,2,1,2,1, 4,2,3,1,4,2,3,1, 8,4,6,2,7,3,5,1 }; static _INLINE_ void create_cycle_diagram_table(void) { int fm, res, cycle, planes, v; - int fetch_start, max_planes/*, freecycles*/; + int fetch_start, max_planes, freecycles; int *cycle_sequence; for (fm = 0; fm <= 2; fm++) { @@ -489,7 +489,7 @@ static _INLINE_ void create_cycle_diagram_table(void) cycle_sequence = &cycle_sequences[(max_planes - 1) * 8]; max_planes = 1 << max_planes; for (planes = 0; planes <= 8; planes++) { -// freecycles = 0; + freecycles = 0; for (cycle = 0; cycle < 32; cycle++) cycle_diagram_table[fm][res][planes][cycle] = -1; if (planes <= max_planes) { @@ -498,13 +498,13 @@ static _INLINE_ void create_cycle_diagram_table(void) v = cycle_sequence[cycle & 7]; } else { v = 0; -// freecycles++; + freecycles++; } cycle_diagram_table[fm][res][planes][cycle] = v; } } -// cycle_diagram_free_cycles[fm][res][planes] = freecycles; -// cycle_diagram_total_cycles[fm][res][planes] = fetch_start; + cycle_diagram_free_cycles[fm][res][planes] = freecycles; + cycle_diagram_total_cycles[fm][res][planes] = fetch_start; } } } @@ -3848,13 +3848,12 @@ static void hsync_handler (void) fetch_audio(); } -/* blitter_slowdown doesn't work at the moment (causes gfx glitches in Shadow of the Beast) - if (bltstate != BLT_done && dmaen (DMA_BITPLANE) && diwstate == DIW_waiting_stop) { + //blitter_slowdown used to cause gfx glitches in Shadow of the Beast but works now + if (!blitter_in_partial_mode && !currprefs.immediate_blits && bltstate != BLT_done && dmaen (DMA_BITPLANE) && diwstate == DIW_waiting_stop) { blitter_slowdown (thisline_decision.plfleft, thisline_decision.plfright - (16 << fetchmode), cycle_diagram_total_cycles[fetchmode][res_bplcon0][planes_bplcon0], cycle_diagram_free_cycles[fetchmode][res_bplcon0][planes_bplcon0]); } -*/ /* In theory only an equality test is needed here - but if a program goes haywire with the VPOSW register, it can cause us to miss this,