X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=Pico%2FDraw.s;h=e31ba0baa6911ad14782bf7823d97d4b6051c6af;hb=69996cb7c62468cd97842e35bdd2b74006a28dba;hp=91a647c2dd5da7103b504a16d42f03f29e445c37;hpb=740da8c60b40ec09256e438f849f766b150d29d9;p=picodrive.git diff --git a/Pico/Draw.s b/Pico/Draw.s index 91a647c..e31ba0b 100644 --- a/Pico/Draw.s +++ b/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 @@ -211,9 +211,9 @@ @ int cells; // 0x14 @ }; -@ int DrawLayer(int plane, int *hcache, int maxcells, int sh) +@ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells); -.global DrawLayer @ int plane, int *hcache, int maxcells, int sh +.global DrawLayer DrawLayer: stmfd sp!, {r4-r11,lr} @@ -221,10 +221,11 @@ DrawLayer: ldr r11, =(Pico+0x22228) @ Pico.video mov r8, #1 - ldrb r7, [r11, #16] @ ??hh??ww + ldrb r7, [r11, #16] @ ??vv??hh mov r6, r1 @ hcache - orr r9, r2, r3, lsl #31 @ r9=maxcells|(sh<<31) + orr r9, r3, r0, lsl #30 + orr r9, r9, r2, lsl #8 @ r9=sh[31]|cellskip[15:8]|maxcells[7:0] (tmp) mov r1, r7, lsl #4 orr r1, r1, #0x00ff @@ -244,7 +245,7 @@ DrawLayer: sub r5, r5, #1 @ r5=xmask @ Find name table: - tst r0, r0 + ands r0, r0, #1 ldreqb r12, [r11, #2] ldrneb r12, [r11, #4] @@ -309,11 +310,15 @@ DrawLayer: orrne r10,r10, #1<<23 @ r10=(cells<<24|sh<<23|hi_not_empty<<22|had_output<<21|ty) movne r3, #0x40 @ default to shadowed pal on sh mode - mvn r9, #0 @ r9=prevcode=-1 - cmp r7, #8 addne r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll + and r9, r9, #0xff00 + add r8, r8, r9, lsr #8 @ tilex+=cellskip + add r7, r7, r9, lsr #5 @ dx+=cellskip<<3; + sub r10,r10,r9, lsl #16 @ cells-=cellskip + mvn r9, #0 @ r9=prevcode=-1 + @ cache some stuff to avoid mem access ldr r11,=HighCol mov r0, #0xf @@ -364,16 +369,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 @@ -431,7 +437,7 @@ DrawLayer: rsb r8, r3, #0 mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3 bic r8, r8, #0xff000000 - orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|tilex[15:0]) + orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|tilex[23:0]) ldr r4, =Scanline orr r5, r1, r10, lsl #24 @@ -442,24 +448,28 @@ DrawLayer: add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1 mov r10,r9, lsl #16 - tst r0, r0 + tst r0, #1 orrne r10,r10, #0x8000 tst r9, #1<<31 mov r3, #0 orr r10,r10, #0xff000000 @ will be adjusted on entering loop - orrne r10,r10, #1<<23 @ r10=(cells[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0]) + orrne r10,r10, #1<<23 @ r10=(cell[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0]) movne r3, #0x40 @ default to shadowed pal on sh mode - mvn r9, #0 @ r9=prevcode=-1 + cmp r7, #8 + subne r10,r10, #0x01000000 @ have hscroll, start with negative cell + + and r9, r9, #0xff00 + add r8, r8, r9, lsr #8 @ tilex+=cellskip + add r7, r7, r9, lsr #5 @ dx+=cellskip<<3; + add r10,r10,r9, lsl #16 @ cell+=cellskip + mvn r9, #0 @ r9=prevcode=-1 @ cache some stuff to avoid mem access ldr r11,=HighCol mov r0, #0xf add r1, r11, r7 @ r1=pdest - cmp r7, #8 - subne r10,r10, #0x01000000 @ have hscroll, start with negative cell - @ r4 & r7 are scratch in this loop .dsloop_vs_subr1: @@ -527,16 +537,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 +674,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 +685,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 +694,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 +713,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 +726,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 +758,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 +805,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 +939,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 +968,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 +1085,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 +1115,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 +1253,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