streqb r4, [r1,#\offs]\r
.endm\r
\r
-@ TileNorm (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: register with helper pattern 0xf, touches r3 high bits\r
+@ TileNormShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: register with helper pattern 0xf, touches r3 high bits\r
.macro TileNormShHP\r
TilePixelShHP 12, 0 @ #0x0000f000\r
TilePixelShHP 8, 1 @ #0x00000f00\r
TilePixelShHP 16, 7 @ #0x000f0000\r
.endm\r
\r
-@ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf\r
+@ TileFlipShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf\r
.macro TileFlipShHP\r
TilePixelShHP 16, 0 @ #0x000f0000\r
TilePixelShHP 20, 1 @ #0x00f00000\r
beq .DrawStrip_SingleColor @ tileline singlecolor \r
\r
tst r9, #0x0800\r
- beq .DrawStrip_TileNorm\r
+ bne .DrawStrip_TileFlip\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern\r
- TileFlip r0\r
- b .dsloop\r
-\r
.DrawStrip_TileNorm:\r
TileNorm r0\r
b .dsloop\r
\r
+.DrawStrip_TileFlip:\r
+ TileFlip r0\r
+ b .dsloop\r
+\r
.DrawStrip_SingleColor:\r
and r4, r2, #0xf\r
orr r4, r3, r4\r
beq .DrawStrip_vs_SingleColor @ tileline singlecolor \r
\r
tst r9, #0x0800\r
- beq .DrawStrip_vs_TileNorm\r
+ bne .DrawStrip_vs_TileFlip\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern\r
- TileFlip r0\r
- b .dsloop_vs\r
-\r
.DrawStrip_vs_TileNorm:\r
TileNorm r0\r
b .dsloop_vs\r
\r
+.DrawStrip_vs_TileFlip:\r
+ TileFlip r0\r
+ b .dsloop_vs\r
+\r
.DrawStrip_vs_SingleColor:\r
and r4, r2, #0xf\r
orr r4, r3, r4\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
\r
-.global DrawTilesFromCache @ int *hc, int sh\r
+.global DrawTilesFromCache @ int *hc, int sh, int rlim\r
\r
DrawTilesFromCache:\r
stmfd sp!, {r4-r8,r11,lr}\r
mov r12,#0xf\r
\r
mvn r5, #0 @ r5=prevcode=-1\r
- movs r8, r1\r
+ ands r8, r1, #1\r
+ orr r8, r8, r2, lsl #1\r
bne .dtfc_check_rendflags\r
\r
@ scratch: r4, r7\r
ldr r6, [r0], #4 @ read code\r
movs r1, r6, lsr #16 @ r1=dx;\r
ldmeqfd sp!, {r4-r8,r11,pc} @ dx is never zero, this must be a terminator, return\r
- bic r1, r1, #0xfe00\r
- add r1, r11, r1 @ r1=pdest\r
+ bic r4, r1, #0xfe00\r
+ add r1, r11, r4 @ r1=pdest\r
\r
mov r7, r6, lsl #16\r
cmp r5, r7, lsr #16\r
ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
\r
.dtfc_samecode:\r
- tst r8, r8\r
+ rsbs r4, r4, r8, lsr #1\r
+ bmi .dtfc_cut_tile\r
+\r
+ tst r8, #1\r
bne .dtfc_shadow\r
\r
tst r2, r2\r
beq .dtfc_SingleColor @ tileline singlecolor \r
\r
tst r5, #0x0800\r
- beq .dtfc_TileNorm\r
+ bne .dtfc_TileFlip\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
- TileFlip r12\r
- b .dtfc_loop\r
-\r
.dtfc_TileNorm:\r
TileNorm r12\r
b .dtfc_loop\r
\r
+.dtfc_TileFlip:\r
+ TileFlip r12\r
+ b .dtfc_loop\r
+\r
.dtfc_SingleColor:\r
and r4, r2, #0xf\r
orr r4, r3, r4\r
beq .dtfc_SingleColor @ tileline singlecolor \r
\r
tst r5, #0x0800\r
- beq .dtfc_TileNormShHP\r
+ bne .dtfc_TileFlipShHP\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
- TileFlipShHP\r
- b .dtfc_loop\r
-\r
.dtfc_TileNormShHP:\r
TileNormShHP\r
b .dtfc_loop\r
\r
+.dtfc_TileFlipShHP:\r
+ TileFlipShHP\r
+ b .dtfc_loop\r
+\r
.dtfc_shadow_blank:\r
ldrb r4, [r1] @ 1ci\r
ldrb r12,[r1,#1]\r
mov r12, #0xf\r
b .dtfc_loop\r
\r
+.dtfc_cut_tile:\r
+ add r4, r4, #7 @ 0-6\r
+ mov r4, r4, lsl #2\r
+ mov r12,#0xf<<28\r
+ mov r12,r12,asr r4\r
+ mov r2, r2, ror #16\r
+ tst r5, #0x0800 @ flipped?\r
+ mvnne r12,r12\r
+ and r2, r2, r12\r
+ mov r2, r2, ror #16\r
+ mov r12,#0xf\r
+ tst r8, #1\r
+ bne .dtfc_shadow\r
+ tst r2, r2\r
+ beq .dtfc_loop\r
+ tst r5, #0x0800\r
+ beq .dtfc_TileNorm\r
+ b .dtfc_TileFlip\r
+\r
@ check if we have detected layer covered with hi-prio tiles:\r
.dtfc_check_rendflags:\r
ldr r1, =rendstatus\r
ldr r2, [r1]\r
tst r2, #0xc0\r
beq .dtfc_loop\r
- mov r8, #0 @ sh/hi mode off\r
+ bic r8, r8, #1 @ sh/hi mode off\r
tst r2, #0x80\r
bne .dtfc_loop @ already processed\r
orr r2, r2, #0x80\r
beq .dsfc_SingleColor @ tileline singlecolor \r
\r
tst r9, #0x10000\r
- beq .dsfc_TileNorm\r
+ bne .dsfc_TileFlip\r
\r
@ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
- TileFlip r12\r
- b .dsfc_inloop\r
-\r
.dsfc_TileNorm:\r
TileNorm r12\r
b .dsfc_inloop\r
\r
+.dsfc_TileFlip:\r
+ TileFlip r12\r
+ b .dsfc_inloop\r
+\r
.dsfc_SingleColor:\r
tst r0, #1 @ not aligned?\r
and r4, r2, #0xf\r
beq .dsfc_singlec_sh\r
\r
tst r9, #0x10000\r
- beq .dsfc_TileNorm_sh\r
+ bne .dsfc_TileFlip_sh\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
- TileFlipSh\r
- b .dsfc_inloop\r
-\r
.dsfc_TileNorm_sh:\r
TileNormSh\r
b .dsfc_inloop\r
\r
+.dsfc_TileFlip_sh:\r
+ TileFlipSh\r
+ b .dsfc_inloop\r
+\r
.dsfc_singlec_sh:\r
cmp r2, #0xe0000000\r
bcc .dsfc_SingleColor @ normal singlecolor tileline (carry inverted in ARM)\r
beq .dspr_SingleColor @ tileline singlecolor \r
\r
tst r9, #0x0800\r
- beq .dspr_TileNorm\r
+ bne .dspr_TileFlip\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
- TileFlip r12\r
- b .dspr_loop\r
-\r
@ scratch: r4, r7\r
.dspr_TileNorm:\r
TileNorm r12\r
b .dspr_loop\r
\r
+.dspr_TileFlip:\r
+ TileFlip r12\r
+ b .dspr_loop\r
+\r
.dspr_SingleColor:\r
and r4, r2, #0xf\r
orr r4, r3, r4\r
beq .dspr_singlec_sh\r
\r
tst r9, #0x0800\r
- beq .dspr_TileNorm_sh\r
+ bne .dspr_TileFlip_sh\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern\r
- TileFlipSh\r
- b .dspr_loop\r
-\r
.dspr_TileNorm_sh:\r
TileNormSh\r
b .dspr_loop\r
\r
+.dspr_TileFlip_sh:\r
+ TileFlipSh\r
+ b .dspr_loop\r
+\r
.dspr_singlec_sh:\r
cmp r2, #0xe0000000\r
bcc .dspr_SingleColor @ normal tileline\r
beq .dw_SingleColor @ tileline singlecolor \r
\r
tst r9, #0x0800\r
- beq .dw_TileNorm\r
+ bne .dw_TileFlip\r
\r
@ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern\r
- TileFlip r0\r
- b .dwloop\r
-\r
.dw_TileNorm:\r
TileNorm r0\r
b .dwloop\r
\r
+.dw_TileFlip:\r
+ TileFlip r0\r
+ b .dwloop\r
+\r
.dw_SingleColor:\r
and r4, r0, r2 @ #0x0000000f\r
orr r4, r3, r4\r