From: Toni Wilen Date: Sat, 29 Nov 2025 11:16:17 +0000 (+0200) Subject: Always 64-bit shifter in AGA, disabled for now. X-Git-Tag: 6020~46 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=822d7421fd6a722c15c0a8b547d1daed9822e61f;p=francis%2Fwinuae.git Always 64-bit shifter in AGA, disabled for now. --- diff --git a/drawing.cpp b/drawing.cpp index 1eae8fd9..8eb5d0f1 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -40,6 +40,8 @@ #include "gfxboard.h" #define ENABLE_MULTITHREADED_DENISE 1 +#define FMODE64_HACK 0 + extern int multithread_enabled; #define MULTITHREADED_DENISE (ENABLE_MULTITHREADED_DENISE && multithread_enabled != 0) @@ -411,6 +413,9 @@ static int linear_denise_frame_hbstrt, linear_denise_frame_hbstop; static int denise_visible_lines, denise_visible_lines_counted; static uae_u16 hbstrt_denise_reg, hbstop_denise_reg; static uae_u16 fmode_denise, denise_bplfmode, denise_sprfmode; +#if FMODE64_HACK +static int denise_bplfmode_max; +#endif static bool denise_sprfmode64, denise_bplfmode64; static int bpldat_fmode; static int fetchmode_size_denise, fetchmode_mask_denise; @@ -450,6 +455,9 @@ static uae_u16 clxcon_bpl_match_55, clxcon_bpl_match_aa; static int aga_delayed_color_idx; static uae_u16 aga_delayed_color_val, aga_delayed_color_con2, aga_delayed_color_con3; static int aga_unalign0, aga_unalign1, bpl1dat_unalign, reswitch_unalign; +#if 0 +static int bplcon0_res_unalign, bplcon0_res_unalign_res; +#endif static uae_u8 loaded_pix, loaded_pixs[4]; static int hresolution, hresolution_inv, hresolution_add; static bool denise_sprite_blank_active; @@ -3162,21 +3170,6 @@ static void expand_bplcon1(uae_u16 v) check_lts_request(); } -static void expand_bplcon0_early(uae_u16 v) -{ - if (!aga_mode) { - int ores = denise_res; - int nres = GET_RES_DENISE(v); - if (ores == RES_LORES && nres == RES_HIRES) { - if (ecs_denise) { - reswitch_unalign = 3; - } else { - reswitch_unalign = 3; - } - } - } -} - int gethresolution(void) { return hresolution; @@ -3203,6 +3196,50 @@ static void setlasthamcolor(void) } } +static void expand_bplcon0_early(uae_u16 v) +{ + if (!aga_mode) { + + int ores = denise_res; + int nres = GET_RES_DENISE(v); + if (ores == RES_LORES && nres == RES_HIRES) { + if (ecs_denise) { + reswitch_unalign = 3; + } else { + reswitch_unalign = 3; + } + } + + } else { + +#if 0 + // shres resolution change in AGA is 1 lores pixel earlier + if (denise_res != GET_RES_DENISE(v)) { + bplcon0_res_unalign = true; + bplcon0_res_unalign_res = GET_RES_DENISE(v); + aga_unalign0 += 2; + aga_unalign1 += 2; + } +#endif + + } +} + +#if 0 +static void expand_bplcon0_unaligned(void) +{ + bplcon0_res_unalign = false; + denise_res = bplcon0_res_unalign_res; + denise_res_size = 1 << denise_res; + sethresolution(); + setbplmode(); + update_fmode(); + update_specials(); + update_sprres(); + check_lts_request(); +} +#endif + static void expand_bplcon0(uae_u16 v) { uae_u16 old = bplcon0_denise; @@ -3219,11 +3256,14 @@ static void expand_bplcon0(uae_u16 v) bplcon0_denise = v; - if (denise_res != GET_RES_DENISE(bplcon0_denise) || denise_planes != GET_PLANES(bplcon0_denise)) { + if (denise_res != GET_RES_DENISE(bplcon0_denise)) { + lts_request = true; + } + + if (denise_planes != GET_PLANES(bplcon0_denise)) { lts_request = true; } - int ores = denise_res; denise_res = GET_RES_DENISE(bplcon0_denise); denise_res_size = 1 << denise_res; sethresolution(); @@ -3252,6 +3292,17 @@ static void expand_bplcon0(uae_u16 v) check_lts_request(); } +#if FMODE64_HACK +static uae_u64 make6416(uae_u32 v) +{ + return ((uae_u64)v << 48) | ((uae_u64)v << 32) | ((uae_u64)v << 16) | ((uae_u64)v); +} +static uae_u64 make6432(uae_u32 v) +{ + return ((uae_u64)v << 32) | ((uae_u64)v); +} +#endif + static void expand_fmode(uae_u16 v) { if (!aga_mode) { @@ -3264,11 +3315,38 @@ static void expand_fmode(uae_u16 v) denise_xposmask <<= 2; denise_xposmask |= hresolution == RES_SUPERHIRES ? 3 : (hresolution == RES_HIRES ? 2 : 0); + int fm = denise_bplfmode; denise_bplfmode = (v & 3) == 3 ? 2 : (v & 3) == 0 ? 0 : 1; +#if FMODE64_HACK + if (fm != denise_bplfmode) { + if (!denise_bplfmode_max) { + if (fm < 2) { + for (int i = 0; i < MAX_PLANES; i++) { + if (fm == 1) { + bplxdat_64[i] = make6432(bplxdat[i]); + bplxdat2_64[i] = make6432(bplxdat2[i]); + bplxdat3_64[i] = make6432(bplxdat3[i]); + } else { + bplxdat_64[i] = make6416(bplxdat[i]); + bplxdat2_64[i] = make6416(bplxdat2[i]); + bplxdat3_64[i] = make6416(bplxdat3[i]); + } + } + } + lts_request = true; + } + denise_bplfmode_max = 2; + } +#endif v >>= 2; denise_sprfmode = (v & 3) == 3 ? 2 : (v & 3) == 0 ? 0 : 1; denise_sprfmode64 = denise_sprfmode == 2; denise_bplfmode64 = denise_bplfmode == 2; +#if FMODE64_HACK + if (denise_bplfmode_max) { + denise_bplfmode64 = true; + } +#endif update_fmode(); check_lts_request(); } @@ -3573,6 +3651,14 @@ static void hstart_new(void) } #endif } +#if FMODE64_HACK + if (denise_bplfmode_max > 0) { + denise_bplfmode_max--; + if (!denise_bplfmode_max) { + select_lts(); + } + } +#endif } static void do_exthblankon_ecs(void) @@ -3923,7 +4009,15 @@ static void expand_drga(struct denise_rga *rd) case 0x110: if (denise_bplfmode64) { +#if FMODE64_HACK + if (denise_bplfmode < 2) { + bplxdat_64[0] = denise_bplfmode == 0 ? make6416(rd->v) : make6432(rd->v); + } else { + bplxdat_64[0] = rd->v64; + } +#else bplxdat_64[0] = rd->v64; +#endif } else { bplxdat[0] = rd->v; } @@ -3941,10 +4035,21 @@ static void expand_drga(struct denise_rga *rd) case 0x11a: case 0x11c: case 0x11e: - if (denise_bplfmode64) { - bplxdat_64[(rd->rga - 0x110) / 2] = rd->v64; - } else { - bplxdat[(rd->rga - 0x110) / 2] = rd->v; + { + int num = (rd->rga - 0x110) / 2; + if (denise_bplfmode64) { +#if FMODE64_HACK + if (denise_bplfmode < 2) { + bplxdat_64[num] = denise_bplfmode == 0 ? make6416(rd->v) : make6432(rd->v);; + } else { + bplxdat_64[num] = rd->v64; + } +#else + bplxdat_64[num] = rd->v64; +#endif + } else { + bplxdat[num] = rd->v; + } } break; @@ -5951,6 +6056,10 @@ static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, in #include "linetoscr_aga_fm0.cpp" #include "linetoscr_aga_fm1.cpp" #include "linetoscr_aga_fm2.cpp" +#if FMODE64_HACK +#include "linetoscr_aga_fm0_64.cpp" +#include "linetoscr_aga_fm1_64.cpp" +#endif #include "linetoscr_aga_fm0_genlock.cpp" #include "linetoscr_aga_fm1_genlock.cpp" #include "linetoscr_aga_fm2_genlock.cpp" @@ -6030,6 +6139,11 @@ static void select_lts(void) lts = linetoscr_aga_funcs[idx]; } } else { +#if FMODE64_HACK + if (denise_bplfmode_max && bpldat_fmode < 2) { + idx += 3 * 2 * 5 * 4 * 2 * 3 * 3; + } +#endif lts = linetoscr_aga_funcs[idx]; } } @@ -6167,6 +6281,11 @@ static void lts_unaligned_aga(int cnt, int cnt_next, int h) aga_delayed_color_idx = -1; } bplmode = bplmode_new; +#if 0 + if (bplcon0_res_unalign) { + expand_bplcon0_unaligned(); + } +#endif } if (h) { @@ -6313,6 +6432,7 @@ static void lts_unaligned_aga(int cnt, int cnt_next, int h) gpix = spix; } } + dtbuf[h][ipix] = dpix_val; dtgbuf[h][ipix] = gpix; @@ -6500,6 +6620,7 @@ static void lts_unaligned_ecs(int cnt, int cnt_next, int h) gpix = spix; } } + dtbuf[h][ipix] = dpix_val; dtgbuf[h][ipix] = gpix; diff --git a/genlinetoscr.cpp b/genlinetoscr.cpp index eab071de..7c4fc402 100644 --- a/genlinetoscr.cpp +++ b/genlinetoscr.cpp @@ -13,9 +13,12 @@ #include #include +static bool FMODE64_HACK = false; + static FILE *outfile; static int outfile_indent = 0; static int aga, outres, res, planes, modes, bplfmode, sprres, oddeven, ecsshres, genlock, ntsc, filtered, modetype; +static int bplfmode64; static int isbuf2 = 0; static int maxplanes = 8; static char funcnames[500000], funcnamesf[500000]; @@ -250,7 +253,7 @@ static void gen_getbpl(int num, int maxplanes) } int p = planes < maxplanes ? planes : maxplanes; - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("loaded_pix = getbpl%d_64();", p); } else if (bplfmode == 1) { outf("loaded_pix = getbpl%d_32(); ", p); @@ -268,7 +271,7 @@ static void gen_shiftbpl(int maxplanes) } int p = planes < maxplanes ? planes : maxplanes; - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("shiftbpl%d_64();", p); } else { outf("shiftbpl%d();", p); @@ -289,7 +292,7 @@ static void gen_shiftbpl_hr(int maxplanes) add = 4; } if (add == 4) { - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("shiftbpl%d_64();", p); } else { outf("shiftbpl%d();", p); @@ -298,7 +301,7 @@ static void gen_shiftbpl_hr(int maxplanes) outf("bplshiftcnt[0] += %d;", add); outf("if (bplshiftcnt[0] >= 4) {"); outf("bplshiftcnt[0] = 0;"); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("shiftbpl%de_64();", p); } else { outf("shiftbpl%de();", p); @@ -308,7 +311,7 @@ static void gen_shiftbpl_hr(int maxplanes) outf("bplshiftcnt[1] += %d;", add); outf("if (bplshiftcnt[1] >= 4) {"); outf("bplshiftcnt[1] = 0;"); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("shiftbpl%do_64();", p); } else { outf("shiftbpl%do();", p); @@ -319,7 +322,7 @@ static void gen_shiftbpl_hr(int maxplanes) outf("bplshiftcnt[0] += %d;", add); outf("if (bplshiftcnt[0] >= 4) {"); outf("bplshiftcnt[0] = 0;"); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("shiftbpl%d_64();", p); } else { outf("shiftbpl%d();", p); @@ -425,7 +428,7 @@ static void gen_copybpl_lines(int oddeven) for (int i = 1; i <= 8; i++) { if (planes >= i) { if (oddeven == 0 || (oddeven == 1 && (i & 1)) || (oddeven == 2 && !(i & 1))) { - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("bplxdat3_64[%d] = bplxdat2_64[%d];", i - 1, i - 1); } else { outf("bplxdat3[%d] = bplxdat2[%d];", i - 1, i - 1); @@ -450,14 +453,14 @@ static void gen_copybpl(void) if (oddeven) { // bitplane shifter shifting outf("if (bpldat_copy[0] && (denise_hcounter_cmp & %d) == bplcon1_shift[0]) { ", ((16 << bplfmode) >> res) - 1); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("copybpl%de_64();", planes); } else { outf("copybpl%de();", planes); } outf("}"); outf("if (bpldat_copy[1] && (denise_hcounter_cmp & %d) == bplcon1_shift[1]) {", ((16 << bplfmode) >> res) - 1); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("copybpl%do_64();", planes); } else { outf("copybpl%do();", planes); @@ -466,7 +469,7 @@ static void gen_copybpl(void) } else { // bitplane shifter shifting outf("if (bpldat_copy[0] && (denise_hcounter_cmp & %d) == bplcon1_shift[0]) { ", ((16 << bplfmode) >> res) - 1); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("copybpl%d_64();", planes); } else { outf("copybpl%d();", planes); @@ -490,7 +493,7 @@ static void gen_copybpl_hr(int add) if (oddeven) { // bitplane shifter shifting outf("if (bpldat_copy[0] && ((cmp | %d) & %d) == bplcon1_shift_full_masked[0]) { ", add, (((16 << bplfmode) >> res) << 2) - 1); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("copybpl%de_64();", planes); } else { outf("copybpl%de();", planes); @@ -501,7 +504,7 @@ static void gen_copybpl_hr(int add) } outf("}"); outf("if (bpldat_copy[1] && ((cmp | %d) & %d) == bplcon1_shift_full_masked[1]) {", add, (((16 << bplfmode) >> res) << 2) - 1); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("copybpl%do_64();", planes); } else { outf("copybpl%do();", planes); @@ -514,7 +517,7 @@ static void gen_copybpl_hr(int add) } else { // bitplane shifter shifting outf("if (bpldat_copy[0] && ((cmp | %d) & %d) == bplcon1_shift_full_masked[0]) { ", add, (((16 << bplfmode) >> res) << 2) - 1); - if (bplfmode == 2) { + if (bplfmode == 2 || bplfmode64) { outf("copybpl%d_64();", planes); } else { outf("copybpl%d();", planes); @@ -910,9 +913,10 @@ static int gen_head(void) { char funcname[200]; - sprintf(funcname, "lts_%s_%s_%s%d_p%d_i%s_d%s%s%s%s%s", + sprintf(funcname, "lts_%s_%s%s_%s%d_p%d_i%s_d%s%s%s%s%s", aga ? "aga" : "ecs", bplfmode == 0 ? "fm0" : (bplfmode == 1 ? "fm1" : "fm2"), + bplfmode64 ? "_64" : "", modes == 0 ? "n" : (modes == 1 ? "dpf" : (modes == 2 ? "ehb" : (modes == 4 ? "kehb" : "ham"))), oddeven ? 1 : 0, planes, @@ -1484,51 +1488,63 @@ int main (int argc, char *argv[]) ntsc = -1; modetype = 0; - for (bplfmode = 0; bplfmode < 3; bplfmode++) { + for (bplfmode64 = 0; bplfmode64 < 2; bplfmode64++) { - char tmp[100]; - sprintf(tmp, "../../linetoscr_aga_fm%d.cpp", bplfmode); - set_outfile(tmp); + for (bplfmode = 0; bplfmode < 3; bplfmode++) { - for (outres = 0; outres < 3; outres++) { - for (res = 0; res < 3; res++) { - for (int spr = 0; spr < 2; spr++) { - sprres = spr == 0 ? -1 : 0; - for (planes = 2; planes <= 8; planes += 2) { - for (modes = 0; modes < 5; modes++) { - for (oddeven = 0; oddeven < 2; oddeven++) { - modetype = gen_head(); - if (modetype) { - gen_start(); - gen_init(); - gen_pix_aga(); - gen_end(); - } else { - gen_null(); - } - gen_tail(); - filtered = 1; - modetype = gen_head(); - if (modetype) { - gen_start(); - gen_init(); - gen_pix_aga(); - gen_end(); - } else { - gen_null(); + if (bplfmode64 && bplfmode >= 2) { + continue; + } + if (bplfmode64 && !FMODE64_HACK) { + continue; + } + + char tmp[100]; + sprintf(tmp, "../../linetoscr_aga_fm%d%s.cpp", bplfmode, bplfmode64 ? "_64" : ""); + set_outfile(tmp); + + for (outres = 0; outres < 3; outres++) { + for (res = 0; res < 3; res++) { + for (int spr = 0; spr < 2; spr++) { + sprres = spr == 0 ? -1 : 0; + for (planes = 2; planes <= 8; planes += 2) { + for (modes = 0; modes < 5; modes++) { + for (oddeven = 0; oddeven < 2; oddeven++) { + modetype = gen_head(); + if (modetype) { + gen_start(); + gen_init(); + gen_pix_aga(); + gen_end(); + } else { + gen_null(); + } + gen_tail(); + filtered = 1; + modetype = gen_head(); + if (modetype) { + gen_start(); + gen_init(); + gen_pix_aga(); + gen_end(); + } else { + gen_null(); + } + gen_tail(); + filtered = 0; } - gen_tail(); - filtered = 0; } } } } } + } } write_funcs("linetoscr_aga_funcs"); + bplfmode64 = 0; genlock = 1; for (bplfmode = 0; bplfmode < 3; bplfmode++) {