From 7813a0e7fd4b0f86ef7038fac163913f1de80c9e Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 18 Mar 2026 18:42:57 +0200 Subject: [PATCH] Fix sprite autoscale detection --- drawing.cpp | 67 +++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 27a565b5..b6c229b9 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -2737,26 +2737,6 @@ static void sprwrite_64(int reg, uae_u64 v) } else { s->dataa64 = v; spr_arm(s, 1); -#if AUTOSCALE_SPRITES - /* get upper and lower sprite position if brdsprt enabled */ - if ((s->dataa64 || s->datab64) && bordersprite) { - if (this_line->linear_vpos < plffirstline_total) { - plffirstline_total = this_line->linear_vpos; - } - if (this_line->linear_vpos > plflastline_total) { - plflastline_total = this_line->linear_vpos; - } - int x = s->xpos;; - if (diwfirstword_total > x && x >= (48 << RES_MAX)) { - diwfirstword_total = x; - diwfirstword_total <<= 2; - } - if (diwlastword_total < x + 16 && x <= (448 << RES_MAX)) { - diwlastword_total = x + 16; - diwlastword_total <<= 2; - } -#endif - } } } @@ -2792,26 +2772,6 @@ static void sprwrite(int reg, uae_u32 v) return; } spr_arm(s, 1); -#if AUTOSCALE_SPRITES - /* get upper and lower sprite position if brdsprt enabled */ - if ((s->dataa || s->datab) && bordersprite) { - if (this_line->linear_vpos < plffirstline_total) { - plffirstline_total = this_line->linear_vpos; - } - if (this_line->linear_vpos > plflastline_total) { - plflastline_total = this_line->linear_vpos; - } - int x = s->xpos;; - if (diwfirstword_total > x && x >= (48 << RES_MAX)) { - diwfirstword_total = x; - diwfirstword_total <<= 2; - } - if (diwlastword_total < x + 16 && x <= (448 << RES_MAX)) { - diwlastword_total = x + 16; - diwlastword_total <<= 2; - } - } -#endif } } else { if (second) { @@ -4573,6 +4533,24 @@ static uae_u8 denise_render_sprites2(uae_u8 apixel, uae_u32 vs) return 0; } +static void autoscale_sprites(void) +{ +#if AUTOSCALE_SPRITES + if (diwfirstword_total > internal_pixel_cnt && internal_pixel_cnt > (48 << RES_MAX)) { + diwfirstword_total = internal_pixel_cnt; + } + if (diwlastword_total < internal_pixel_cnt && internal_pixel_cnt < (448 << RES_MAX)) { + diwlastword_total = internal_pixel_cnt; + } + if (this_line->linear_vpos < plffirstline_total) { + plffirstline_total = this_line->linear_vpos; + } + if (this_line->linear_vpos > plflastline_total) { + plflastline_total = this_line->linear_vpos; + } +#endif +} + static void get_shres_spr_pix(uae_u32 sv0, uae_u32 sv1, uae_u32 *dpix0, uae_u32 *dpix1) { uae_u16 v; @@ -4623,6 +4601,7 @@ static uae_u32 denise_render_sprites_aga(int add) { uae_u32 v = 0; uae_u32 d = 0; + bool asp = false; int sidx = 0; while (dprspts[sidx]) { struct denise_spr *sp = dprspts[sidx]; @@ -4641,6 +4620,8 @@ static uae_u32 denise_render_sprites_aga(int add) if (denise_sprfmode64) { if (!sp->dataas64 && !sp->databs64) { d |= 1 << num; + } else if (num > 0) { + asp = true; } sp->pix = ((sp->dataas64 >> 63) & 1) << 0; sp->pix |= ((sp->databs64 >> 63) & 1) << 1; @@ -4649,6 +4630,8 @@ static uae_u32 denise_render_sprites_aga(int add) } else { if (!sp->dataas && !sp->databs) { d |= 1 << num; + } else if (num > 0) { + asp = true; } sp->pix = ((sp->dataas >> 31) & 1) << 0; sp->pix |= ((sp->databs >> 31) & 1) << 1; @@ -4661,6 +4644,10 @@ static uae_u32 denise_render_sprites_aga(int add) if (d) { spr_disarms(d); } + if (asp && !denise_blank_active && !sprites_hidden) { + // only sprites 1-7 + autoscale_sprites(); + } return v; } -- 2.47.3