vdp rendering, fix handling of palettes 0-2 color 14 in sprite drawing

This commit is contained in:
kub 2020-12-12 14:59:09 +01:00
parent dda72beae4
commit 08bbe7f816
2 changed files with 71 additions and 21 deletions

View file

@ -187,6 +187,14 @@ TileFlipMaker(TileFlip, pix_just_write)
#ifndef _ASM_DRAW_C #ifndef _ASM_DRAW_C
// draw low prio sprite non-s/h pixels in s/h mode
#define pix_nonsh(x) \
if (t == 0xe) pd[x]=(pal|t)&~0x80; /* disable shadow for color 14 (hw bug?) */ \
else if (t) pd[x]=pal|t
TileNormMaker(TileNormNonSH, pix_nonsh)
TileFlipMaker(TileFlipNonSH, pix_nonsh)
// draw sprite pixels, process operator colors // draw sprite pixels, process operator colors
#define pix_sh(x) \ #define pix_sh(x) \
if (t) { \ if (t) { \
@ -824,6 +832,9 @@ static void DrawSprite(int *sprite, int sh, int w)
if (sh && (code&0x6000) == 0x6000) { if (sh && (code&0x6000) == 0x6000) {
if(code&0x0800) fTileFunc=TileFlipSH_markop; if(code&0x0800) fTileFunc=TileFlipSH_markop;
else fTileFunc=TileNormSH_markop; else fTileFunc=TileNormSH_markop;
} else if (sh) {
if(code&0x0800) fTileFunc=TileFlipNonSH;
else fTileFunc=TileNormNonSH;
} else { } else {
if(code&0x0800) fTileFunc=TileFlip; if(code&0x0800) fTileFunc=TileFlip;
else fTileFunc=TileNorm; else fTileFunc=TileNorm;
@ -1556,26 +1567,23 @@ void PicoDoHighPal555_8bit(int sh, int line, struct PicoEState *est)
// otherwise intensity difference between this and s/h will be wrong // otherwise intensity difference between this and s/h will be wrong
t = PXCONV(t); t = PXCONV(t);
t |= (t >> 4) & PXMASKL; t |= (t >> 4) & PXMASKL;
dpal[i] = dpal[0xc0/2 + i] = t; dpal[i] = t;
} }
// norm: xxx0, sh: 0xxx, hi: 0xxx + 7 // norm: xxx0, sh: 0xxx, hi: 0xxx + 7
if (sh) if (sh)
{ {
// shadowed pixels // shadowed pixels
for (i = 0; i < 0x40 / 2; i++) for (i = 0; i < 0x40 / 2; i++) {
dpal[0xc0/2 + i] = dpal[i];
dpal[0x80/2 + i] = (dpal[i] >> 1) & PXMASKH; dpal[0x80/2 + i] = (dpal[i] >> 1) & PXMASKH;
}
// hilighted pixels // hilighted pixels
for (i = 0; i < 0x40 / 2; i++) { for (i = 0; i < 0x40 / 2; i++) {
t = ((dpal[i] >> 1) & PXMASKH) + PXMASKH; t = ((dpal[i] >> 1) & PXMASKH) + PXMASKH;
t |= (t >> 4) & PXMASKL; t |= (t >> 4) & PXMASKL;
dpal[0x40/2 + i] = t; dpal[0x40/2 + i] = t;
} }
// shadowed pixels in color 14 always appear normal (hw bug?)
unsigned short *hpal = est->HighPal;
hpal[0x80 + 0x0e] = hpal[0x0e];
hpal[0x80 + 0x1e] = hpal[0x1e];
hpal[0x80 + 0x2e] = hpal[0x2e];
} }
} }
@ -1611,11 +1619,6 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
t |= (t >> 4) & PXMASKL; t |= (t >> 4) & PXMASKL;
dpal[0x40/2 + i] = t; dpal[0x40/2 + i] = t;
} }
// shadowed pixels in color 14 always appear normal (hw bug?)
unsigned short *hpal = est->HighPal;
hpal[0x80 + 0x0e] = hpal[0x0e];
hpal[0x80 + 0x1e] = hpal[0x1e];
hpal[0x80 + 0x2e] = hpal[0x2e];
} }
} }

View file

@ -69,6 +69,45 @@
@ shadow/hilight mode @ shadow/hilight mode
@
.macro TilePixelNonSH pat lsrr offs
.if !\lsrr
ands r4, \pat, r2
.else
ands r4, \pat, r2, lsr #\lsrr
.endif
beq 0f
cmp r4, #0xe
orr r4, r3, r4
biceq r4, #0x80
strb r4, [r1,#\offs]
0:
.endm
@ TileNormNonSH (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
.macro TileNormNonSH pat
TilePixelNonSH \pat, 12, 0 @ #0x0000f000
TilePixelNonSH \pat, 8, 1 @ #0x00000f00
TilePixelNonSH \pat, 4, 2 @ #0x000000f0
TilePixelNonSH \pat, 0, 3 @ #0x0000000f
TilePixelNonSH \pat, 28, 4 @ #0xf0000000
TilePixelNonSH \pat, 24, 5 @ #0x0f000000
TilePixelNonSH \pat, 20, 6 @ #0x00f00000
TilePixelNonSH \pat, 16, 7 @ #0x000f0000
.endm
@ TileFlipNonSH (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
.macro TileFlipNonSH pat
TilePixelNonSH \pat, 16, 0 @ #0x000f0000
TilePixelNonSH \pat, 20, 1 @ #0x00f00000
TilePixelNonSH \pat, 24, 2 @ #0x0f000000
TilePixelNonSH \pat, 28, 3 @ #0xf0000000
TilePixelNonSH \pat, 0, 4 @ #0x0000000f
TilePixelNonSH \pat, 4, 5 @ #0x000000f0
TilePixelNonSH \pat, 8, 6 @ #0x00000f00
TilePixelNonSH \pat, 12, 7 @ #0x0000f000
.endm
@ this one is for hi priority layer @ this one is for hi priority layer
.macro TilePixelShHP lsrr offs .macro TilePixelShHP lsrr offs
.if !\lsrr .if !\lsrr
@ -1260,6 +1299,9 @@ DrawSprite:
cmp r12, r9, lsr #28 cmp r12, r9, lsr #28
beq .dspr_shadow beq .dspr_shadow
tst r9, #0x80000000
bne .dspr_shnonsh
cmp r2, r2, ror #4 cmp r2, r2, ror #4
beq .dspr_SingleColor @ tileline singlecolor beq .dspr_SingleColor @ tileline singlecolor
@ -1293,6 +1335,20 @@ DrawSprite:
strneb r4, [r1], #1 strneb r4, [r1], #1
b .dspr_loop b .dspr_loop
.dspr_shnonsh:
tst r9, #0x0800
bne .dspr_TileFlipNonSH
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
@ scratch: r4, r7
.dspr_TileNormNonSH:
TileNormNonSH r12
b .dspr_loop
.dspr_TileFlipNonSH:
TileFlipNonSH r12
b .dspr_loop
.dspr_shadow: .dspr_shadow:
cmp r2, r2, ror #4 cmp r2, r2, ror #4
beq .dspr_singlec_sh beq .dspr_singlec_sh
@ -1567,15 +1623,6 @@ PicoDoHighPal555:
stmia r4!, {r1,r6} stmia r4!, {r1,r6}
bne .fl_loopcpRGB555_sh bne .fl_loopcpRGB555_sh
@ fixup shadowed color 14 in palette 0,1,2 (always normal)
sub r4, r3, #0x40*2
ldrh r1, [r4, #0x0e*2] @ 0x0e, 0x1e, 0x2e
ldrh r5, [r4, #0x1e*2]
ldrh r6, [r4, #0x2e*2]
strh r1, [r3, #0x4e*2] @ 0x8e, 0x9e, 0xae
strh r5, [r3, #0x5e*2]
strh r6, [r3, #0x6e*2]
mov r0, #1 mov r0, #1
PicoDoHighPal555_end: PicoDoHighPal555_end:
ldmfd sp!, {r4-r10,pc} ldmfd sp!, {r4-r10,pc}