@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
\r
-.global DrawSpritesFromCache @ int *hc, int prio_unused, int sh\r
+.global DrawSpritesSHi @ int prio_unused, int sh\r
+\r
+DrawSpritesSHi:\r
+ ldr r3, =DrawScanline\r
+ ldr r2, =HighLnSpr\r
+ ldr r12,[r3]\r
+ mov r3, #(MAX_LINE_SPRITES+2)\r
+ mla r2, r12, r3, r2\r
+ ldr r3, [r2]\r
+ ands r3, r3, #0x7f\r
+ bxeq lr\r
\r
-DrawSpritesFromCache:\r
stmfd sp!, {r4-r11,lr}\r
+ mov r12,#0xff\r
+ strb r12,[r2,#1] @ set end marker\r
+ add r10,r2, #2\r
+ add r10,r10,r3 @ r10=HighLnSpr end\r
+\r
+ str r1, [sp, #-4] @ no calls after this point\r
\r
- @ cache some stuff to avoid mem access\r
.if OVERRIDE_HIGHCOL\r
ldr r11,=HighCol\r
mov r12,#0xf\r
mov r12,#0xf\r
.endif\r
ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
- mov r6, r2, lsl #31\r
- orr r6, r6, #1<<30\r
\r
- mov r10, r0\r
\r
-.dsfc_loop:\r
- ldr r9, [r10], #4 @ read code\r
- bic r6, r6, #7 @ using pipeline\r
- tst r9, r9\r
- ldmeqfd sp!, {r4-r11,pc}\r
+DrawSpriteSHi:\r
+ @ draw next sprite\r
+ ldrb r0, [r10,#-1]!\r
+ ldr r1, =HighPreSpr\r
+ ldr r8, [sp, #-4]\r
+ cmp r0, #0xff\r
+ ldmeqfd sp!, {r4-r11,pc} @ end of list\r
+ and r0, r0, #0x7f\r
+ add r0, r1, r0, lsl #3\r
\r
- mov r4, r9, lsl #28\r
- orr r6, r6, r4, lsr #30\r
- add r6, r6, #1 @ r6=s1cc???? ... ?????www (s=shadow/hilight, cc=pal, w=width)\r
+ ldr r9, [r0, #4] @ sprite[1]\r
+ mov r2, r9, asr #16 @ r2=sx\r
\r
- and r5, r9, #3\r
- add r5, r5, #1 @ r5=delta\r
- tst r9, #0x10000\r
- rsbne r5, r5, #0 @ Flip X\r
- mov r5, r5, lsl #4\r
+ mov r9, r9, lsl #16\r
+ mov r3, r9, lsr #31 @ priority\r
+ mov r9, r9, lsr #16\r
+ orr r9, r9, r8, lsl #31 @ r9=code|sh[31]\r
+ and r4, r9, #0x6000\r
+ orr r9, r9, r4, lsl #16\r
+ orr r9, r9, #0x10000000 @ r9=scc1 ???? ... <code> (s=shadow/hilight, cc=pal)\r
+ cmp r12,r9, lsr #28 @ sh/hi with pal3?\r
+ cmpne r3, #1 @ if not, is hi prio\r
+ bne DrawSpriteSHi @ non-operator low sprite, already drawn\r
+\r
+ ldr r3, [r0] @ sprite[0]\r
+ ldr r7, =DrawScanline\r
+ mov r6, r3, lsr #28\r
+ sub r6, r6, #1 @ r6=width-1 (inc later)\r
+ mov r5, r3, lsr #24\r
+ and r5, r5, #7 @ r5=height\r
\r
- mov r2, r9, lsr #17\r
- mov r8, r2, lsl #1 @ tile=((unsigned int)code>>17)<<1;\r
+ mov r0, r3, lsl #16 @ r4=sy<<16 (tmp)\r
\r
- and r3, r9, #0x30 @ r3=pal=(code&0x30);\r
+ ldr r7, [r7]\r
+ sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy\r
\r
- bic r6, r6, #3<<28\r
- orr r6, r6, r3, lsl #24\r
+ tst r9, #0x1000\r
+ movne r0, r5, lsl #3\r
+ subne r0, r0, #1\r
+ subne r7, r0, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y\r
\r
- mov r0, r9, lsl #16\r
- mov r0, r0, asr #22 @ sx=(code<<16)>>22\r
- adds r0, r0, #0 @ set ZV\r
- b .dsfc_inloop_enter\r
+ add r8, r9, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down\r
+ tst r9, #0x0800\r
+ mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);\r
+ rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now\r
\r
-@ scratch: r4, r7\r
-.dsfc_inloop:\r
- sub r6, r6, #1\r
- tst r6, #7\r
- beq .dsfc_loop\r
- adds r0, r0, #8\r
- add r8, r8, r5\r
-\r
-.dsfc_inloop_enter:\r
- ble .dsfc_inloop\r
+ mov r8, r8, lsl #21\r
+ mov r8, r8, lsr #17\r
+ and r7, r7, #7\r
+ add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address\r
+\r
+ mov r5, r5, lsl #4 @ delta<<=4; // Delta of address\r
+\r
+ orrs r3, r9, r9, lsl #4\r
+ mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);\r
+\r
+ add r6, r6, #1 @ inc now\r
+ adds r0, r2, #0 @ mov sx to r0 and set ZV flags\r
+ b .dsprShi_loop_enter\r
+\r
+.dsprShi_loop:\r
+ subs r6, r6, #1 @ width--\r
+ beq DrawSpriteSHi\r
+ adds r0, r0, #8 @ sx+=8\r
+ add r8, r8, r5 @ tile+=delta\r
+\r
+.dsprShi_loop_enter:\r
+ ble .dsprShi_loop @ sx <= 0\r
cmp r0, #328\r
- bge .dsfc_loop\r
+ bge DrawSpriteSHi\r
\r
mov r8, r8, lsl #17\r
- mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address\r
+ mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address\r
\r
- ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+tile); // Get 8 pixels\r
- add r1, r11, r0 @ r1=pdest\r
+ ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+ add r1, r11, r0 @ r1=pdest\r
tst r2, r2\r
- beq .dsfc_inloop\r
+ beq .dsprShi_loop\r
\r
- cmp r12, r6, lsr #28\r
- beq .dsfc_shadow\r
+ cmp r12, r9, lsr #28\r
+ beq .dsprShi_shadow\r
\r
cmp r2, r2, ror #4\r
- beq .dsfc_SingleColor @ tileline singlecolor \r
+ beq .dsprShi_SingleColor @ tileline singlecolor \r
\r
- tst r9, #0x10000\r
- bne .dsfc_TileFlip\r
+ tst r9, #0x0800\r
+ bne .dsprShi_TileFlip\r
\r
- @ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
-.dsfc_TileNorm:\r
+ @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
+@ scratch: r4, r7\r
+.dsprShi_TileNorm:\r
TileNorm r12\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
-.dsfc_TileFlip:\r
+.dsprShi_TileFlip:\r
TileFlip r12\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
-.dsfc_SingleColor:\r
- tst r0, #1 @ not aligned?\r
+.dsprShi_SingleColor:\r
and r4, r2, #0xf\r
orr r4, r3, r4\r
orr r4, r4, r4, lsl #8\r
+ tst r0, #1 @ not aligned?\r
strneb r4, [r1], #1\r
streqh r4, [r1], #2\r
strh r4, [r1], #2\r
strh r4, [r1], #2\r
strh r4, [r1], #2\r
strneb r4, [r1], #1\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
-.dsfc_shadow:\r
- tst r9, #0x80000000\r
- beq .dsfc_shadow_lowpri\r
+.dsprShi_shadow:\r
+ tst r9, #0x8000\r
+ beq .dsprShi_shadow_lowpri\r
\r
cmp r2, r2, ror #4\r
- beq .dsfc_singlec_sh\r
+ beq .dsprShi_singlec_sh\r
\r
- tst r9, #0x10000\r
- bne .dsfc_TileFlip_sh\r
+ tst r9, #0x0800\r
+ bne .dsprShi_TileFlip_sh\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
-.dsfc_TileNorm_sh:\r
+.dsprShi_TileNorm_sh:\r
TileNormSh\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
-.dsfc_TileFlip_sh:\r
+.dsprShi_TileFlip_sh:\r
TileFlipSh\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
-.dsfc_singlec_sh:\r
+.dsprShi_singlec_sh:\r
cmp r2, #0xe0000000\r
- bcc .dsfc_SingleColor @ normal singlecolor tileline (carry inverted in ARM)\r
+ bcc .dsprShi_SingleColor @ normal singlecolor tileline (carry inverted in ARM)\r
tst r2, #0x10000000\r
- bne .dsfc_sh_sh\r
+ bne .dsprShi_sh_sh\r
TileSingleHi\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
-.dsfc_sh_sh:\r
+.dsprShi_sh_sh:\r
TileSingleSh\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
-.dsfc_shadow_lowpri:\r
- tst r9, #0x10000\r
- bne .dsfc_TileFlip_sh_lp\r
+.dsprShi_shadow_lowpri:\r
+ tst r9, #0x800\r
+ bne .dsprShi_TileFlip_sh_lp\r
\r
-.dsfc_TileNorm_sh_lp:\r
+.dsprShi_TileNorm_sh_lp:\r
TileNormSh_onlyop_lp\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
-.dsfc_TileFlip_sh_lp:\r
+.dsprShi_TileFlip_sh_lp:\r
TileFlipSh_onlyop_lp\r
- b .dsfc_inloop\r
+ b .dsprShi_loop\r
\r
.pool\r
\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
-.global DrawAllSprites @ int *hcache, int prio, int sh\r
+.global DrawAllSprites @ int prio, int sh\r
\r
DrawAllSprites:\r
ldr r3, =rendstatus\r
+ orr r1, r1, r0, lsl #1\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
+ stmfd sp!, {r1,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
+ ldmfd sp!, {r1,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 r2, =HighLnSpr\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
+ mla r2, r12, r3, r2\r
+ ldr r3, [r2]\r
ands r3, r3, #0x7f\r
- streq r12,[r0]\r
bxeq lr\r
\r
@ time to do some real work\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
+ strb r12,[r2,#1] @ set end marker\r
+ add r10,r2, #2\r
add r10,r10,r3 @ r10=HighLnSpr end\r
\r
- mov r8, r2, lsl #4\r
+ mov r8, r1, lsl #4\r
tst r4, #PDRAW_ACC_SPRITES\r
orrne r8, r8, #1\r
str r8, [sp, #-4] @ no calls after this point\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
+ mov r2, r0, lsr #7\r
+ cmp r0, #0xff\r
+ ldmeqfd sp!, {r4-r11,pc} @ end of list\r
+ cmp r2, r8, lsr #5\r
+ bne DrawSprite @ wrong priority\r
and r0, r0, #0x7f\r
add r0, r1, r0, lsl #3\r
\r
and r7, r7, #7\r
add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address\r
\r
- tst r9, #0x8000\r
- tsteq r9, #(1<<27)\r
- bne .dspr_cache @ if(code&0x8000) || as\r
- tst r9, #0x4000\r
- tstne r9, #0x2000\r
- tstne r9, #(1<<31)\r
- bne .dspr_cache @ (sh && pal == 0x30)\r
-\r
.dspr_continue:\r
@ cache some stuff to avoid mem access\r
mov r5, r5, lsl #4 @ delta<<=4; // Delta of address\r
and r4, r9, #0x6000\r
orr r9, r9, r4, lsl #16\r
- orrs r9, r9, #0x10000000 @ r9=scc1 a??? ... <code> (s=shadow/hilight, cc=pal, a=acc_spr)\r
+ orr r9, r9, #0x10000000 @ r9=scc1 a??? ... <code> (s=shadow/hilight, cc=pal, a=acc_spr)\r
\r
+ orrs r3, r9, r9, lsl #4\r
mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);\r
- orrmi r3, r3, #0x40 @ shadow by default\r
+ orrmi r3, r3, #0x40 @ for shadow|as\r
\r
add r6, r6, #1 @ inc now\r
adds r0, r2, #0 @ mov sx to r0 and set ZV flags\r
b .dspr_loop\r
\r
\r
-.dspr_cache:\r
- @ *HighCacheS_ptr++ = ((code&0x8000)<<16)|(tile<<16)|((code&0x0800)<<5)|((sx<<6)&0x0000ffc0)|pal|((sprite[0]>>16)&0xf);\r
- ldr r1, =HighCacheS_ptr\r
- mov r4, r8, lsl #16 @ tile\r
- tst r9, #0x0800\r
- orrne r4, r4, #0x10000 @ code&0x0800\r
- mov r0, r2, lsl #22\r
- orr r4, r4, r0, lsr #16 @ (sx<<6)&0x0000ffc0\r
- and r0, r9, #0x6000\r
- orr r4, r4, r0, lsr #9 @ (code>>9)&0x30\r
- mov r3, r3, lsl #12\r
- orr r4, r4, r3, lsr #28 @ (sprite[0]>>24)&0xf\r
-\r
- ldr r0, [r1]\r
- tst r9, #0x8000\r
- orrne r4, r4, #0x80000000 @ prio\r
-\r
- str r4, [r0], #4\r
- str r0, [r1]\r
-\r
- and r0, r9, #(1<<27) @ as\r
- teqne r0, #(1<<27) @ (code&0x8000) && !as\r
- bne DrawSprite\r
- b .dspr_continue @ draw anyway if accurate sprites enabled\r
-\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
.global DrawWindow @ int tstart, int tend, int prio, int sh // int *hcache\r