]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
ECS superhires sprite attachment weird behavior partially emulated
authorToni Wilen <twilen@winuae.net>
Sun, 23 Apr 2023 16:19:22 +0000 (19:19 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 23 Apr 2023 16:19:22 +0000 (19:19 +0300)
custom.cpp
drawing.cpp

index dc7028228061e45084af24addb77406b34050d9d..b71f833b5fe7a9e1263273519a4908e850ff92d6 100644 (file)
@@ -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:
index 304e508a195a4b5fb85a2ff61ef739611f7b75ec..91ec019c38cc28a10c9c106fe50791632b241d38 100644 (file)
@@ -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;