From: Toni Wilen Date: Sun, 23 Apr 2023 16:19:22 +0000 (+0300) Subject: ECS superhires sprite attachment weird behavior partially emulated X-Git-Tag: 5.0.0~63 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=6fd01d2715cf55b7f4c1df9fb31efb0f39e006c7;p=francis%2Fwinuae.git ECS superhires sprite attachment weird behavior partially emulated --- diff --git a/custom.cpp b/custom.cpp index dc702822..b71f833b 100644 --- a/custom.cpp +++ b/custom.cpp @@ -5608,7 +5608,7 @@ static void record_sprite(int num, int sprxp, uae_u16 *data, uae_u16 *datb, unsi /* We have 8 bits per pixel in spixstate, two for every sprite pair. The low order bit records whether the attach bit was set for this pair. */ - if (attachment && !ecsshres ()) { + if (attachment) { uae_u32 state = 0x01010101 << (num & ~1); uae_u8 *stb1 = spixstate.stb + word_offs; for (int i = 0; i < width; i += 8) { @@ -14841,7 +14841,7 @@ static int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int n case 0x1A4: case 0x1A6: case 0x1A8: case 0x1AA: case 0x1AC: case 0x1AE: case 0x1B0: case 0x1B2: case 0x1B4: case 0x1B6: case 0x1B8: case 0x1BA: case 0x1BC: case 0x1BE: - COLOR_WRITE (hpos, value & 0xFFF, (addr & 0x3E) / 2); + COLOR_WRITE(hpos, value & 0xFFF, (addr & 0x3E) / 2); break; case 0x120: case 0x124: case 0x128: case 0x12C: case 0x130: case 0x134: case 0x138: case 0x13C: diff --git a/drawing.cpp b/drawing.cpp index 304e508a..91ec019c 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -1867,7 +1867,49 @@ static uae_u8 render_sprites(int pos, int dualpf, uae_u8 apixel, int aga) #define PUTBPIX(x) buf[dpix] = (x); -STATIC_INLINE uae_u32 shsprite(int dpix, uae_u32 spix_val, uae_u32 v, int add, int spr) +static uae_u8 sh_render_sprites(int pos, int dualpf, uae_u8 apixel, int aga) +{ + struct spritepixelsbuf *spb = &spritepixels[pos]; + unsigned int v = spb->data; + int *shift_lookup = dualpf ? (bpldualpfpri ? dblpf_ms2 : dblpf_ms1) : dblpf_ms; + int maskshift, plfmask; + + if (exthblank) { + return 0; + } + if (extborder && ce_is_borderblank(colors_for_drawing.extra)) { + return 0; + } + + maskshift = shift_lookup[apixel]; + plfmask = (plf_sprite_mask >> maskshift) >> maskshift; + v &= ~plfmask; + if (pos >= sprite_playfield_start && pos < sprite_end && v != 0) { + uae_u32 col; + uae_u32 v1 = v & 255; + int offs; + if (v1 == 0) + offs = 4 + sprite_offs[v >> 8]; + else + offs = sprite_offs[v1]; + v >>= offs * 2; + v &= 15; + col = (v >> 0) & 3; + if (!col) { + col = (v >> 2) & 3; + } + // not correct + if ((spb->flags & 1) && (spb->stdata & (3 << offs))) { + int col1 = (v >> 0) & 3; + int col2 = (v >> 2) & 3; + col = col1 | col2; + } + return col; + } + return 0; +} + +static uae_u32 shsprite(int dpix, uae_u32 spix_val, uae_u32 v, int add, int spr) { uae_u8 sprcol1, sprcol2, off; uae_u16 scol; @@ -1880,16 +1922,17 @@ STATIC_INLINE uae_u32 shsprite(int dpix, uae_u32 spix_val, uae_u32 v, int add, i if (spb->flags & 2) { sdpix -= add; } - sprcol1 = render_sprites(sdpix, bpldualpf, spix_val, 0) & 3; - sprcol2 = render_sprites(sdpix + add, bpldualpf, spix_val, 0) & 3; - off = sprcol2 * 4 + sprcol1 + 16; + int mask = 3; + sprcol1 = sh_render_sprites(sdpix, bpldualpf, spix_val, 0); + sprcol2 = sh_render_sprites(sdpix + add, bpldualpf, spix_val, 0); + off = (sprcol2 & mask) * 4 + (sprcol1 & mask) + 16; if ((dpix & add)) { - if (!sprcol2) { + if (!(sprcol2 & mask)) { return v; } scol = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2; } else { - if (!sprcol1) { + if (!(sprcol1 & mask)) { return v; } scol = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;