mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
renderer patch for DBZ - Buyuu Retsuden
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@240 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
7969166ef6
commit
7a7c6476f3
2 changed files with 130 additions and 60 deletions
70
Pico/Draw.c
70
Pico/Draw.c
|
@ -46,7 +46,7 @@ struct TileStrip
|
|||
void DrawWindow(int tstart, int tend, int prio, int sh);
|
||||
void BackFill(int reg7, int sh);
|
||||
void DrawSprite(int *sprite, int **hc, int sh);
|
||||
void DrawTilesFromCache(int *hc, int sh);
|
||||
void DrawTilesFromCache(int *hc, int sh, int rlim);
|
||||
void DrawSpritesFromCache(int *hc, int sh);
|
||||
void DrawLayer(int plane, int *hcache, int maxcells, int sh);
|
||||
void FinalizeLineBGR444(int sh);
|
||||
|
@ -579,7 +579,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache
|
|||
|
||||
// --------------------------------------------
|
||||
|
||||
static void DrawTilesFromCache(int *hc, int sh)
|
||||
static void DrawTilesFromCache(int *hc, int sh, int rlim)
|
||||
{
|
||||
int code, addr, dx;
|
||||
int pal;
|
||||
|
@ -611,7 +611,7 @@ static void DrawTilesFromCache(int *hc, int sh)
|
|||
|
||||
if (sh)
|
||||
{
|
||||
while((code=*hc++)) {
|
||||
while ((code=*hc++)) {
|
||||
unsigned char *zb;
|
||||
// Get tile address/2:
|
||||
addr=(code&0x7ff)<<4;
|
||||
|
@ -624,6 +624,7 @@ static void DrawTilesFromCache(int *hc, int sh)
|
|||
if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
|
||||
|
||||
pal=((code>>9)&0x30);
|
||||
if (rlim-dx < 0) goto last_cut_tile;
|
||||
|
||||
if (code&0x0800) TileFlip(dx,addr,pal);
|
||||
else TileNorm(dx,addr,pal);
|
||||
|
@ -632,7 +633,7 @@ static void DrawTilesFromCache(int *hc, int sh)
|
|||
else
|
||||
{
|
||||
short blank=-1; // The tile we know is blank
|
||||
while((code=*hc++)) {
|
||||
while ((code=*hc++)) {
|
||||
int zero;
|
||||
if((short)code == blank) continue;
|
||||
// Get tile address/2:
|
||||
|
@ -641,11 +642,48 @@ static void DrawTilesFromCache(int *hc, int sh)
|
|||
dx=(code>>16)&0x1ff;
|
||||
|
||||
pal=((code>>9)&0x30);
|
||||
if (rlim-dx < 0) goto last_cut_tile;
|
||||
|
||||
if (code&0x0800) zero=TileFlip(dx,addr,pal);
|
||||
else zero=TileNorm(dx,addr,pal);
|
||||
|
||||
if(zero) blank=(short)code;
|
||||
if (zero) blank=(short)code;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
last_cut_tile:
|
||||
{
|
||||
unsigned int t, pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
||||
unsigned char *pd = HighCol+dx;
|
||||
if (!pack) return;
|
||||
if (code&0x0800)
|
||||
{
|
||||
switch (rlim-dx+8)
|
||||
{
|
||||
case 7: t=pack&0x00000f00; if (t) pd[6]=(unsigned char)(pal|(t>> 8)); // "break" is left out intentionally
|
||||
case 6: t=pack&0x000000f0; if (t) pd[5]=(unsigned char)(pal|(t>> 4));
|
||||
case 5: t=pack&0x0000000f; if (t) pd[4]=(unsigned char)(pal|(t ));
|
||||
case 4: t=pack&0xf0000000; if (t) pd[3]=(unsigned char)(pal|(t>>28));
|
||||
case 3: t=pack&0x0f000000; if (t) pd[2]=(unsigned char)(pal|(t>>24));
|
||||
case 2: t=pack&0x00f00000; if (t) pd[1]=(unsigned char)(pal|(t>>20));
|
||||
case 1: t=pack&0x000f0000; if (t) pd[0]=(unsigned char)(pal|(t>>16));
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (rlim-dx+8)
|
||||
{
|
||||
case 7: t=pack&0x00f00000; if (t) pd[6]=(unsigned char)(pal|(t>>20));
|
||||
case 6: t=pack&0x0f000000; if (t) pd[5]=(unsigned char)(pal|(t>>24));
|
||||
case 5: t=pack&0xf0000000; if (t) pd[4]=(unsigned char)(pal|(t>>28));
|
||||
case 4: t=pack&0x0000000f; if (t) pd[3]=(unsigned char)(pal|(t ));
|
||||
case 3: t=pack&0x000000f0; if (t) pd[2]=(unsigned char)(pal|(t>> 4));
|
||||
case 2: t=pack&0x00000f00; if (t) pd[1]=(unsigned char)(pal|(t>> 8));
|
||||
case 1: t=pack&0x0000f000; if (t) pd[0]=(unsigned char)(pal|(t>>12));
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1246,23 +1284,23 @@ static int DrawDisplay(int sh)
|
|||
if (win&0x80) { if (Scanline>=edge) hvwind=1; }
|
||||
else { if (Scanline< edge) hvwind=1; }
|
||||
|
||||
if(!hvwind) { // we might have a vertical window here
|
||||
if (!hvwind) { // we might have a vertical window here
|
||||
win=pvid->reg[0x11];
|
||||
edge=win&0x1f;
|
||||
if(win&0x80) {
|
||||
if(!edge) hvwind=1;
|
||||
if (win&0x80) {
|
||||
if (!edge) hvwind=1;
|
||||
else if(edge < (maxcells>>1)) hvwind=2;
|
||||
} else {
|
||||
if(!edge);
|
||||
if (!edge);
|
||||
else if(edge < (maxcells>>1)) hvwind=2;
|
||||
else hvwind=1;
|
||||
}
|
||||
}
|
||||
|
||||
DrawLayer(1, HighCacheB, maxcells, sh);
|
||||
if(hvwind == 1)
|
||||
if (hvwind == 1)
|
||||
DrawWindow(0, maxcells>>1, 0, sh); // HighCacheAW
|
||||
else if(hvwind == 2) {
|
||||
else if (hvwind == 2) {
|
||||
// ahh, we have vertical window
|
||||
DrawLayer(0, HighCacheA, (win&0x80) ? edge<<1 : maxcells, sh);
|
||||
DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh); // HighCacheW
|
||||
|
@ -1270,14 +1308,14 @@ static int DrawDisplay(int sh)
|
|||
DrawLayer(0, HighCacheA, maxcells, sh);
|
||||
DrawAllSprites(HighCacheS, maxw, 0, sh);
|
||||
|
||||
if(HighCacheB[0]) DrawTilesFromCache(HighCacheB, sh);
|
||||
if(hvwind == 1)
|
||||
if (HighCacheB[0]) DrawTilesFromCache(HighCacheB, sh, 328);
|
||||
if (hvwind == 1)
|
||||
DrawWindow(0, maxcells>>1, 1, sh);
|
||||
else if(hvwind == 2) {
|
||||
if(HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh);
|
||||
else if (hvwind == 2) {
|
||||
if(HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, (win&0x80) ? edge<<4 : 0);
|
||||
DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 1, sh);
|
||||
} else
|
||||
if(HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh);
|
||||
if (HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, 328);
|
||||
DrawAllSprites(HighCacheS, maxw, 1, sh);
|
||||
|
||||
#if 0
|
||||
|
|
120
Pico/Draw.s
120
Pico/Draw.s
|
@ -69,7 +69,7 @@
|
|||
streqb r4, [r1,#\offs]
|
||||
.endm
|
||||
|
||||
@ TileNorm (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: register with helper pattern 0xf, touches r3 high bits
|
||||
@ TileNormShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: register with helper pattern 0xf, touches r3 high bits
|
||||
.macro TileNormShHP
|
||||
TilePixelShHP 12, 0 @ #0x0000f000
|
||||
TilePixelShHP 8, 1 @ #0x00000f00
|
||||
|
@ -81,7 +81,7 @@
|
|||
TilePixelShHP 16, 7 @ #0x000f0000
|
||||
.endm
|
||||
|
||||
@ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
|
||||
@ TileFlipShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
|
||||
.macro TileFlipShHP
|
||||
TilePixelShHP 16, 0 @ #0x000f0000
|
||||
TilePixelShHP 20, 1 @ #0x00f00000
|
||||
|
@ -364,16 +364,17 @@ DrawLayer:
|
|||
beq .DrawStrip_SingleColor @ tileline singlecolor
|
||||
|
||||
tst r9, #0x0800
|
||||
beq .DrawStrip_TileNorm
|
||||
bne .DrawStrip_TileFlip
|
||||
|
||||
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
|
||||
TileFlip r0
|
||||
b .dsloop
|
||||
|
||||
.DrawStrip_TileNorm:
|
||||
TileNorm r0
|
||||
b .dsloop
|
||||
|
||||
.DrawStrip_TileFlip:
|
||||
TileFlip r0
|
||||
b .dsloop
|
||||
|
||||
.DrawStrip_SingleColor:
|
||||
and r4, r2, #0xf
|
||||
orr r4, r3, r4
|
||||
|
@ -527,16 +528,17 @@ DrawLayer:
|
|||
beq .DrawStrip_vs_SingleColor @ tileline singlecolor
|
||||
|
||||
tst r9, #0x0800
|
||||
beq .DrawStrip_vs_TileNorm
|
||||
bne .DrawStrip_vs_TileFlip
|
||||
|
||||
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
|
||||
TileFlip r0
|
||||
b .dsloop_vs
|
||||
|
||||
.DrawStrip_vs_TileNorm:
|
||||
TileNorm r0
|
||||
b .dsloop_vs
|
||||
|
||||
.DrawStrip_vs_TileFlip:
|
||||
TileFlip r0
|
||||
b .dsloop_vs
|
||||
|
||||
.DrawStrip_vs_SingleColor:
|
||||
and r4, r2, #0xf
|
||||
orr r4, r3, r4
|
||||
|
@ -663,7 +665,7 @@ BackFill:
|
|||
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
|
||||
.global DrawTilesFromCache @ int *hc, int sh
|
||||
.global DrawTilesFromCache @ int *hc, int sh, int rlim
|
||||
|
||||
DrawTilesFromCache:
|
||||
stmfd sp!, {r4-r8,r11,lr}
|
||||
|
@ -674,7 +676,8 @@ DrawTilesFromCache:
|
|||
mov r12,#0xf
|
||||
|
||||
mvn r5, #0 @ r5=prevcode=-1
|
||||
movs r8, r1
|
||||
ands r8, r1, #1
|
||||
orr r8, r8, r2, lsl #1
|
||||
bne .dtfc_check_rendflags
|
||||
|
||||
@ scratch: r4, r7
|
||||
|
@ -682,8 +685,8 @@ DrawTilesFromCache:
|
|||
ldr r6, [r0], #4 @ read code
|
||||
movs r1, r6, lsr #16 @ r1=dx;
|
||||
ldmeqfd sp!, {r4-r8,r11,pc} @ dx is never zero, this must be a terminator, return
|
||||
bic r1, r1, #0xfe00
|
||||
add r1, r11, r1 @ r1=pdest
|
||||
bic r4, r1, #0xfe00
|
||||
add r1, r11, r4 @ r1=pdest
|
||||
|
||||
mov r7, r6, lsl #16
|
||||
cmp r5, r7, lsr #16
|
||||
|
@ -701,7 +704,10 @@ DrawTilesFromCache:
|
|||
ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
||||
|
||||
.dtfc_samecode:
|
||||
tst r8, r8
|
||||
rsbs r4, r4, r8, lsr #1
|
||||
bmi .dtfc_cut_tile
|
||||
|
||||
tst r8, #1
|
||||
bne .dtfc_shadow
|
||||
|
||||
tst r2, r2
|
||||
|
@ -711,16 +717,17 @@ DrawTilesFromCache:
|
|||
beq .dtfc_SingleColor @ tileline singlecolor
|
||||
|
||||
tst r5, #0x0800
|
||||
beq .dtfc_TileNorm
|
||||
bne .dtfc_TileFlip
|
||||
|
||||
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
|
||||
TileFlip r12
|
||||
b .dtfc_loop
|
||||
|
||||
.dtfc_TileNorm:
|
||||
TileNorm r12
|
||||
b .dtfc_loop
|
||||
|
||||
.dtfc_TileFlip:
|
||||
TileFlip r12
|
||||
b .dtfc_loop
|
||||
|
||||
.dtfc_SingleColor:
|
||||
and r4, r2, #0xf
|
||||
orr r4, r3, r4
|
||||
|
@ -742,16 +749,17 @@ DrawTilesFromCache:
|
|||
beq .dtfc_SingleColor @ tileline singlecolor
|
||||
|
||||
tst r5, #0x0800
|
||||
beq .dtfc_TileNormShHP
|
||||
bne .dtfc_TileFlipShHP
|
||||
|
||||
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
|
||||
TileFlipShHP
|
||||
b .dtfc_loop
|
||||
|
||||
.dtfc_TileNormShHP:
|
||||
TileNormShHP
|
||||
b .dtfc_loop
|
||||
|
||||
.dtfc_TileFlipShHP:
|
||||
TileFlipShHP
|
||||
b .dtfc_loop
|
||||
|
||||
.dtfc_shadow_blank:
|
||||
ldrb r4, [r1] @ 1ci
|
||||
ldrb r12,[r1,#1]
|
||||
|
@ -788,13 +796,32 @@ DrawTilesFromCache:
|
|||
mov r12, #0xf
|
||||
b .dtfc_loop
|
||||
|
||||
.dtfc_cut_tile:
|
||||
add r4, r4, #7 @ 0-6
|
||||
mov r4, r4, lsl #2
|
||||
mov r12,#0xf<<28
|
||||
mov r12,r12,asr r4
|
||||
mov r2, r2, ror #16
|
||||
tst r5, #0x0800 @ flipped?
|
||||
mvnne r12,r12
|
||||
and r2, r2, r12
|
||||
mov r2, r2, ror #16
|
||||
mov r12,#0xf
|
||||
tst r8, #1
|
||||
bne .dtfc_shadow
|
||||
tst r2, r2
|
||||
beq .dtfc_loop
|
||||
tst r5, #0x0800
|
||||
beq .dtfc_TileNorm
|
||||
b .dtfc_TileFlip
|
||||
|
||||
@ check if we have detected layer covered with hi-prio tiles:
|
||||
.dtfc_check_rendflags:
|
||||
ldr r1, =rendstatus
|
||||
ldr r2, [r1]
|
||||
tst r2, #0xc0
|
||||
beq .dtfc_loop
|
||||
mov r8, #0 @ sh/hi mode off
|
||||
bic r8, r8, #1 @ sh/hi mode off
|
||||
tst r2, #0x80
|
||||
bne .dtfc_loop @ already processed
|
||||
orr r2, r2, #0x80
|
||||
|
@ -903,16 +930,17 @@ DrawSpritesFromCache:
|
|||
beq .dsfc_SingleColor @ tileline singlecolor
|
||||
|
||||
tst r9, #0x10000
|
||||
beq .dsfc_TileNorm
|
||||
bne .dsfc_TileFlip
|
||||
|
||||
@ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
|
||||
TileFlip r12
|
||||
b .dsfc_inloop
|
||||
|
||||
.dsfc_TileNorm:
|
||||
TileNorm r12
|
||||
b .dsfc_inloop
|
||||
|
||||
.dsfc_TileFlip:
|
||||
TileFlip r12
|
||||
b .dsfc_inloop
|
||||
|
||||
.dsfc_SingleColor:
|
||||
tst r0, #1 @ not aligned?
|
||||
and r4, r2, #0xf
|
||||
|
@ -931,16 +959,17 @@ DrawSpritesFromCache:
|
|||
beq .dsfc_singlec_sh
|
||||
|
||||
tst r9, #0x10000
|
||||
beq .dsfc_TileNorm_sh
|
||||
bne .dsfc_TileFlip_sh
|
||||
|
||||
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
|
||||
TileFlipSh
|
||||
b .dsfc_inloop
|
||||
|
||||
.dsfc_TileNorm_sh:
|
||||
TileNormSh
|
||||
b .dsfc_inloop
|
||||
|
||||
.dsfc_TileFlip_sh:
|
||||
TileFlipSh
|
||||
b .dsfc_inloop
|
||||
|
||||
.dsfc_singlec_sh:
|
||||
cmp r2, #0xe0000000
|
||||
bcc .dsfc_SingleColor @ normal singlecolor tileline (carry inverted in ARM)
|
||||
|
@ -1047,17 +1076,18 @@ DrawSprite:
|
|||
beq .dspr_SingleColor @ tileline singlecolor
|
||||
|
||||
tst r9, #0x0800
|
||||
beq .dspr_TileNorm
|
||||
bne .dspr_TileFlip
|
||||
|
||||
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
|
||||
TileFlip r12
|
||||
b .dspr_loop
|
||||
|
||||
@ scratch: r4, r7
|
||||
.dspr_TileNorm:
|
||||
TileNorm r12
|
||||
b .dspr_loop
|
||||
|
||||
.dspr_TileFlip:
|
||||
TileFlip r12
|
||||
b .dspr_loop
|
||||
|
||||
.dspr_SingleColor:
|
||||
and r4, r2, #0xf
|
||||
orr r4, r3, r4
|
||||
|
@ -1076,16 +1106,17 @@ DrawSprite:
|
|||
beq .dspr_singlec_sh
|
||||
|
||||
tst r9, #0x0800
|
||||
beq .dspr_TileNorm_sh
|
||||
bne .dspr_TileFlip_sh
|
||||
|
||||
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
|
||||
TileFlipSh
|
||||
b .dspr_loop
|
||||
|
||||
.dspr_TileNorm_sh:
|
||||
TileNormSh
|
||||
b .dspr_loop
|
||||
|
||||
.dspr_TileFlip_sh:
|
||||
TileFlipSh
|
||||
b .dspr_loop
|
||||
|
||||
.dspr_singlec_sh:
|
||||
cmp r2, #0xe0000000
|
||||
bcc .dspr_SingleColor @ normal tileline
|
||||
|
@ -1213,16 +1244,17 @@ DrawWindow:
|
|||
beq .dw_SingleColor @ tileline singlecolor
|
||||
|
||||
tst r9, #0x0800
|
||||
beq .dw_TileNorm
|
||||
bne .dw_TileFlip
|
||||
|
||||
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
|
||||
TileFlip r0
|
||||
b .dwloop
|
||||
|
||||
.dw_TileNorm:
|
||||
TileNorm r0
|
||||
b .dwloop
|
||||
|
||||
.dw_TileFlip:
|
||||
TileFlip r0
|
||||
b .dwloop
|
||||
|
||||
.dw_SingleColor:
|
||||
and r4, r0, r2 @ #0x0000000f
|
||||
orr r4, r3, r4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue