static int HighCacheA[41+1]; // caches for high layers\r
static int HighCacheB[41+1];\r
static int HighCacheS[80+1]; // and sprites\r
-static int HighPreSpr[80*2+1]; // slightly preprocessed sprites\r
+int HighPreSpr[80*2+1]; // slightly preprocessed sprites\r
int *HighCacheS_ptr;\r
\r
#define MAX_LINE_SPRITES 30\r
-static unsigned char HighLnSpr[240][2 + MAX_LINE_SPRITES]; // sprite_count, tile_count, [spritep]...\r
+unsigned char HighLnSpr[240][2 + MAX_LINE_SPRITES]; // sprite_count, tile_count, [spritep]...\r
\r
int rendstatus = 0;\r
int DrawScanline = 0;\r
#ifdef _ASM_DRAW_C\r
void DrawWindow(int tstart, int tend, int prio, int sh);\r
void BackFill(int reg7, int sh);\r
-void DrawSprite(int *sprite, int sh, int as);\r
+void DrawAllSprites(int *hcache, int prio, int sh);\r
void DrawTilesFromCache(int *hc, int sh, int rlim);\r
void DrawSpritesFromCache(int *hc, int prio, int sh);\r
void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);\r
// Index + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size\r
// Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
\r
-static void PrepareSprites(int full)\r
+void PrepareSprites(int full)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
int u,link=0;\r
}\r
}\r
\r
+#ifndef _ASM_DRAW_C\r
static void DrawAllSprites(int *hcache, int prio, int sh)\r
{\r
int rs = rendstatus, scan = DrawScanline;\r
\r
// --------------------------------------------\r
\r
-#ifndef _ASM_DRAW_C\r
static void BackFill(int reg7, int sh)\r
{\r
unsigned int back;\r
.extern DrawScanline\r
.extern HighSprZ\r
.extern rendstatus\r
+.extern HighPreSpr\r
.extern DrawLineDest\r
.extern DrawStripInterlace\r
.extern HighCacheS_ptr\r
\r
+.equ PDRAW_SPRITES_MOVED, (1<<0)\r
+.equ PDRAW_WND_DIFF_PRIO, (1<<1)\r
+.equ PDRAW_ACC_SPRITES, (1<<2)\r
+.equ PDRAW_DIRTY_SPRITES, (1<<4)\r
+.equ PDRAW_PLANE_HI_PRIO, (1<<6)\r
+.equ PDRAW_SHHI_DONE, (1<<7)\r
+.equ MAX_LINE_SPRITES, 30\r
\r
@ helper\r
.macro TilePixel pat lsrr offs\r
mov r0, #0\r
ldreq r2, [r1]\r
str r0, [r6] @ terminate the cache list\r
- orreq r2, r2, #0x40 @ had a layer with all hi-prio tiles\r
+ orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles\r
streq r2, [r1]\r
\r
ldmfd sp!, {r4-r11,lr}\r
mov r0, #0\r
ldreq r2, [r1]\r
str r0, [r6] @ terminate the cache list\r
- orreq r2, r2, #0x40 @ had a layer with all hi-prio tiles\r
+ orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles\r
streq r2, [r1]\r
\r
ldmfd sp!, {r4-r11,lr}\r
.dtfc_check_rendflags:\r
ldr r1, =rendstatus\r
ldr r2, [r1]\r
- tst r2, #0xc0\r
+ tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)\r
beq .dtfc_loop\r
bic r8, r8, #1 @ sh/hi mode off\r
- tst r2, #0x80\r
+ tst r2, #PDRAW_SHHI_DONE\r
bne .dtfc_loop @ already processed\r
- orr r2, r2, #0x80\r
+ orr r2, r2, #PDRAW_SHHI_DONE\r
str r2, [r1]\r
\r
add r1, r11,#8\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
\r
-.global DrawSpritesFromCache @ int *hc, int maxwidth, int prio, int sh\r
+.global DrawSpritesFromCache @ int *hc, int prio_unused, int sh\r
\r
DrawSpritesFromCache:\r
stmfd sp!, {r4-r11,lr}\r
mov r12,#0xf\r
.endif\r
ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
- mov r6, r3, lsl #31\r
+ mov r6, r2, lsl #31\r
orr r6, r6, #1<<30\r
\r
mov r10, r0\r
\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
-@ + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size\r
+.global DrawAllSprites @ int *hcache, int prio, int sh\r
+\r
+DrawAllSprites:\r
+ ldr r3, =rendstatus\r
+ ldr r12,[r3]\r
+ tst r12,#(PDRAW_ACC_SPRITES|PDRAW_SPRITES_MOVED)\r
+ beq das_no_prep\r
+ stmfd sp!, {r0,r2,lr}\r
+ and r0, r12,#PDRAW_DIRTY_SPRITES\r
+ bic r12,r12,#(PDRAW_ACC_SPRITES|PDRAW_SPRITES_MOVED)\r
+ str r12,[r3]\r
+ bl PrepareSprites\r
+ ldmfd sp!, {r0,r2,lr}\r
+\r
+das_no_prep:\r
+ ldr r12,=HighCacheS_ptr\r
+ ldr r3, =DrawScanline\r
+ ldr r1, =HighLnSpr\r
+ str r0, [r12]\r
+ ldr r12,[r3]\r
+ mov r3, #(MAX_LINE_SPRITES+2)\r
+ mla r1, r12, r3, r1\r
+ mov r12,#0\r
+ ldr r3, [r1]\r
+ ands r3, r3, #0x7f\r
+ streq r12,[r0]\r
+ bxeq lr\r
+\r
+ @ time to do some real work\r
+ stmfd sp!, {r4-r11,lr}\r
+ ldr r4, =rendstatus\r
+ mov r12,#0xff\r
+ ldr r4, [r4]\r
+ strb r12,[r1,#1] @ end marker\r
+ add r10,r1, #2\r
+ add r10,r10,r3 @ r10=HighLnSpr end\r
+\r
+ mov r8, r2, lsl #4\r
+ tst r4, #PDRAW_ACC_SPRITES\r
+ orrne r8, r8, #1\r
+ str r8, [sp, #-4] @ no calls after this point\r
+\r
+.if OVERRIDE_HIGHCOL\r
+ ldr r11,=HighCol\r
+ mov r12,#0xf\r
+ ldr r11,[r11]\r
+.else\r
+ ldr r11,=HighCol\r
+ mov r12,#0xf\r
+.endif\r
+ ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
+\r
+@ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size\r
@ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
\r
-.global DrawSprite @ unsigned int *sprite, int sh, int acc_sprites\r
+DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites\r
+ @ draw next sprite\r
+ ldrb r0, [r10,#-1]!\r
+ ldr r1, =HighPreSpr\r
+ mov r8, #0\r
+ cmp r0, #0xff\r
+ ldreq r4, =HighCacheS_ptr\r
+ ldreq r4, [r4]\r
+ streq r8, [r4]\r
+ ldmeqfd sp!, {r4-r11,pc}\r
+ ldr r8, [sp, #-4]\r
+ and r0, r0, #0x7f\r
+ add r0, r1, r0, lsl #3\r
\r
-DrawSprite:\r
- stmfd sp!, {r4-r9,r11,lr}\r
+@ stmfd sp!, {r4-r9,r11,lr}\r
+@ orr r8, r2, r1, lsl #4\r
\r
- orr r8, r2, r1, lsl #4\r
ldr r3, [r0] @ sprite[0]\r
ldr r7, =DrawScanline\r
mov r6, r3, lsr #28\r
\r
.dspr_continue:\r
@ cache some stuff to avoid mem access\r
-.if OVERRIDE_HIGHCOL\r
- ldr r11,=HighCol\r
- mov r12,#0xf\r
- ldr r11,[r11]\r
-.else\r
- ldr r11,=HighCol\r
- mov r12,#0xf\r
-.endif\r
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
-\r
mov r5, r5, lsl #4 @ delta<<=4; // Delta of address\r
and r4, r9, #0x6000\r
orr r9, r9, r4, lsl #16\r
\r
.dspr_loop:\r
subs r6, r6, #1 @ width--\r
- ldmeqfd sp!, {r4-r9,r11,pc}@ return\r
+ beq DrawSprite\r
adds r0, r0, #8 @ sx+=8\r
add r8, r8, r5 @ tile+=delta\r
\r
.dspr_loop_enter:\r
ble .dspr_loop @ sx <= 0\r
cmp r0, #328\r
- ldmgefd sp!, {r4-r9,r11,pc}@ return\r
+ bge DrawSprite\r
\r
mov r8, r8, lsl #17\r
mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address\r
\r
and r0, r9, #(1<<27) @ as\r
teqne r0, #(1<<27) @ (code&0x8000) && !as\r
- ldmnefd sp!, {r4-r9,r11,pc}\r
+ bne DrawSprite\r
b .dspr_continue @ draw anyway if accurate sprites enabled\r
\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
@ fetch the first code now\r
ldrh r7, [lr, r12]\r
\r
- ands r6, r6, #2 @ we care about bit 1 only\r
+ ands r6, r6, #PDRAW_WND_DIFF_PRIO\r
orr r6, r6, r2\r
\r
eoreq r8, r2, r7, lsr #15 @ do prio bits differ?\r
eors r6, r6, #1 @ sh is 0\r
ldr r12,[r12]\r
mov lr, #0xff\r
- tstne r12,#(1<<2) @ and PDRAW_ACC_SPRITES\r
+ tstne r12,#PDRAW_ACC_SPRITES\r
\r
.if OVERRIDE_HIGHCOL\r
ldr r1, =HighCol\r
eors r6, r6, #1 @ sh is 0\r
ldr r12,[r12]\r
mov lr, #0xff\r
- tstne r12,#(1<<2) @ and PDRAW_ACC_SPRITES\r
+ tstne r12,#PDRAW_ACC_SPRITES\r
movne lr, #0x3f\r
\r
.if OVERRIDE_HIGHCOL\r