X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FDraw.s;h=5074a637a92314a11f4773b66c6ffb25ecb67670;hb=b2305d080dcd60b0da0065c29f6a3c3b6762e8f5;hp=dca251d2bda3020293d60a3d09abc87c118ace4c;hpb=e352c3af64cb2e812f6821ffdf90fccb3cbf40b7;p=picodrive.git diff --git a/Pico/Draw.s b/Pico/Draw.s index dca251d..5074a63 100644 --- a/Pico/Draw.s +++ b/Pico/Draw.s @@ -25,7 +25,6 @@ .equ PDRAW_DIRTY_SPRITES, (1<<4) .equ PDRAW_PLANE_HI_PRIO, (1<<6) .equ PDRAW_SHHI_DONE, (1<<7) -.equ MAX_LINE_SPRITES, 30 @ helper .macro TilePixel pat lsrr offs @@ -947,26 +946,19 @@ DrawTilesFromCache: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -.global DrawSpritesSHi @ int prio_unused, int sh +.global DrawSpritesSHi @ unsigned char *sprited DrawSpritesSHi: - ldr r3, =DrawScanline - ldr r2, =HighLnSpr - ldr r12,[r3] - mov r3, #(MAX_LINE_SPRITES+2) - mla r2, r12, r3, r2 - ldr r3, [r2] + ldr r3, [r0] + mov r12,#0xff ands r3, r3, #0x7f bxeq lr stmfd sp!, {r4-r11,lr} - mov r12,#0xff - strb r12,[r2,#1] @ set end marker - add r10,r2, #2 + strb r12,[r0,#2] @ set end marker + add r10,r0, #3 @ r10=HighLnSpr end add r10,r10,r3 @ r10=HighLnSpr end - str r1, [sp, #-4] @ no calls after this point - .if OVERRIDE_HIGHCOL ldr r11,=HighCol mov r12,#0xf @@ -982,7 +974,7 @@ DrawSpriteSHi: @ draw next sprite ldrb r0, [r10,#-1]! ldr r1, =HighPreSpr - ldr r8, [sp, #-4] +@ ldr r8, [sp, #-4] cmp r0, #0xff ldmeqfd sp!, {r4-r11,pc} @ end of list and r0, r0, #0x7f @@ -994,12 +986,12 @@ DrawSpriteSHi: mov r9, r9, lsl #16 mov r3, r9, lsr #31 @ priority mov r9, r9, lsr #16 - orr r9, r9, r8, lsl #31 @ r9=code|sh[31] +@ orr r9, r9, r8, lsl #31 @ r9=code|sh[31] @@ sh is always on here now and r4, r9, #0x6000 orr r9, r9, r4, lsl #16 - orr r9, r9, #0x10000000 @ r9=scc1 ???? ... (s=shadow/hilight, cc=pal) + orr r9, r9, #0x90000000 @ r9=scc1 ???? ... (s=shadow/hilight, cc=pal) cmp r12,r9, lsr #28 @ sh/hi with pal3? - cmpne r3, #1 @ if not, is hi prio + cmpne r3, #1 @ if not, is ir hi prio? bne DrawSpriteSHi @ non-operator low sprite, already drawn ldr r3, [r0] @ sprite[0] @@ -1030,8 +1022,6 @@ DrawSpriteSHi: add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address mov r5, r5, lsl #4 @ delta<<=4; // Delta of address - - orrs r3, r9, r9, lsl #4 mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30); add r6, r6, #1 @ inc now @@ -1136,44 +1126,34 @@ DrawSpriteSHi: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -.global DrawAllSprites @ int prio, int sh +.global DrawAllSprites @ unsigned char *sprited, int prio, int sh DrawAllSprites: ldr r3, =rendstatus - orr r1, r1, r0, lsl #1 + orr r1, r2, r1, lsl #1 ldr r12,[r3] - tst r12,#(PDRAW_ACC_SPRITES|PDRAW_SPRITES_MOVED) + tst r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED) beq das_no_prep - stmfd sp!, {r1,lr} + stmfd sp!, {r0,r1,lr} and r0, r12,#PDRAW_DIRTY_SPRITES - bic r12,r12,#(PDRAW_ACC_SPRITES|PDRAW_SPRITES_MOVED) + bic r12,r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED) str r12,[r3] bl PrepareSprites - ldmfd sp!, {r1,lr} + ldmfd sp!, {r0,r1,lr} das_no_prep: - ldr r3, =DrawScanline - ldr r2, =HighLnSpr - ldr r12,[r3] - mov r3, #(MAX_LINE_SPRITES+2) - mla r2, r12, r3, r2 - ldr r3, [r2] + ldr r3, [r0] ands r3, r3, #0x7f bxeq lr @ time to do some real work stmfd sp!, {r4-r11,lr} - ldr r4, =rendstatus mov r12,#0xff - ldr r4, [r4] - strb r12,[r2,#1] @ set end marker - add r10,r2, #2 + strb r12,[r0,#2] @ set end marker + add r10,r0, #3 add r10,r10,r3 @ r10=HighLnSpr end - mov r8, r1, lsl #4 - tst r4, #PDRAW_ACC_SPRITES - orrne r8, r8, #1 - str r8, [sp, #-4] @ no calls after this point + str r1, [sp, #-4] @ no calls after this point .if OVERRIDE_HIGHCOL ldr r11,=HighCol @@ -1196,7 +1176,7 @@ DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites mov r2, r0, lsr #7 cmp r0, #0xff ldmeqfd sp!, {r4-r11,pc} @ end of list - cmp r2, r8, lsr #5 + cmp r2, r8, lsr #1 bne DrawSprite @ wrong priority and r0, r0, #0x7f add r0, r1, r0, lsl #3 @@ -1220,7 +1200,7 @@ DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites mov r2, r9, asr #16 @ r2=sx mov r9, r9, lsl #16 mov r9, r9, lsr #16 - orr r9, r9, r8, lsl #27 @ r9=code|sh[31]|as[27] + orr r9, r9, r8, lsl #31 @ r9=code|sh[31] tst r9, #0x1000 movne r4, r5, lsl #3 @@ -1242,11 +1222,10 @@ DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites mov r5, r5, lsl #4 @ delta<<=4; // Delta of address and r4, r9, #0x6000 orr r9, r9, r4, lsl #16 - orr r9, r9, #0x10000000 @ r9=scc1 a??? ... (s=shadow/hilight, cc=pal, a=acc_spr) + orrs r9, r9, #0x10000000 @ r9=scc1 ???? ... (s=shadow/hilight, cc=pal) - orrs r3, r9, r9, lsl #4 mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30); - orrmi r3, r3, #0x40 @ for shadow|as + orrmi r3, r3, #0x40 @ for sh/hi add r6, r6, #1 @ inc now adds r0, r2, #0 @ mov sx to r0 and set ZV flags @@ -1351,7 +1330,7 @@ DrawWindow: add r12, r12, r0, lsl #2 @ +starttile ldr r6, =rendstatus - ldr lr, =(Pico+0x10000) @ lr=Pico.vram + ldr lr, =(Pico+0x10000) @ lr=Pico.vram ldr r6, [r6] @ fetch the first code now @@ -1463,7 +1442,7 @@ DrawWindow: .dwloop_end: ldr r0, =rendstatus ldr r1, [r0] - and r6, r6, #2 + and r6, r6, #PDRAW_WND_DIFF_PRIO orr r1, r1, r6 str r1, [r0] @@ -1654,18 +1633,15 @@ FinalizeLineBGR444: orr \reg, \reg, r3 @ add blue back .endm -.global vidConvCpyRGB565 - -vidConvCpyRGB565: @ void *to, void *from, int pixels - stmfd sp!, {r4-r9,lr} - +@ trashes: r2-r9,r12,lr; r0,r1 are advanced +.macro vidConvCpyRGB565_local mov r12, r2, lsr #3 @ repeats mov lr, #0x001c0000 orr lr, lr, #0x01c @ lr == pattern 0x001c001c mov r8, #0x00030000 orr r8, r8, #0x003 -.loopRGB565: +0: ldmia r1!, {r4-r7} subs r12, r12, #1 convRGB565 r4 @@ -1677,44 +1653,51 @@ vidConvCpyRGB565: @ void *to, void *from, int pixels convRGB565 r7 str r7, [r0], #4 - bgt .loopRGB565 + bgt 0b +.endm + + +.global vidConvCpyRGB565 +vidConvCpyRGB565: @ void *to, void *from, int pixels + stmfd sp!, {r4-r9,lr} + vidConvCpyRGB565_local ldmfd sp!, {r4-r9,lr} bx lr +.global PicoDoHighPal555 @ int sh -.global FinalizeLineRGB555 @ int sh - -FinalizeLineRGB555: - stmfd sp!, {r4-r8,lr} +PicoDoHighPal555: + stmfd sp!, {r4-r9,lr} + mov r1, #0 ldr r8, =(Pico+0x22228) @ Pico.video - ldr r4, =HighPal - ldrb r7, [r8, #-0x1a] @ 0x2220e ~ dirtyPal - mov r6, r0 +PicoDoHighPal555_nopush: + str r1, [sp, #-8] @ is called from FinalizeLineRGB555? + + str r0, [sp, #-4] + ldr r0, =HighPal + mov r1, #0 - tst r7, r7 - beq .fl_noconvRGB555 - strb r1, [r8, #-0x1a] + strb r1, [r8, #-0x1a] @ 0x2220e ~ dirtyPal + sub r1, r8, #0x128 @ r1=Pico.cram - mov r0, r4 mov r2, #0x40 - bl vidConvCpyRGB565 + vidConvCpyRGB565_local -.fl_noconvRGB555: - mov r3, r4 - tst r6, r6 - beq .fl_noshRGB555 - tst r7, r7 - beq .fl_noshRGB555 + ldr r0, [sp, #-4] + tst r0, r0 + beq PicoDoHighPal555_end + + ldr r3, =HighPal @ shadowed pixels: mov r12, #0x008e - orr r12,r12,#0x7300 - orr r12,r12,r12,lsl #16 add r4, r3, #0x40*2 + orr r12,r12,#0x7300 add r5, r3, #0xc0*2 + orr r12,r12,r12,lsl #16 mov lr, #0x40/4 .fl_loopcpRGB555_sh: ldmia r3!, {r1,r6} @@ -1734,13 +1717,33 @@ FinalizeLineRGB555: str r1, [r4], #4 subs lr, lr, #1 bne .fl_loopcpRGB555_hi + mov r0, #1 - sub r3, r3, #0x40*2 - mov r6, #1 +PicoDoHighPal555_end: + ldr r1, [sp, #-8] + tst r1, r1 + ldmeqfd sp!, {r4-r9,pc} + + ldr r8, =(Pico+0x22228) @ Pico.video + b FinalizeLineRGB555_pal_done + + +.global FinalizeLineRGB555 @ int sh + +FinalizeLineRGB555: + stmfd sp!, {r4-r9,lr} + ldr r8, =(Pico+0x22228) @ Pico.video + + ldrb r2, [r8, #-0x1a] @ 0x2220e ~ dirtyPal + mov r1, #1 + tst r2, r2 + bne PicoDoHighPal555_nopush + +FinalizeLineRGB555_pal_done: + ldr r3, =HighPal -.fl_noshRGB555: ldr r12,=rendstatus - eors r6, r6, #1 @ sh is 0 + eors r0, r0, #1 @ sh is 0 ldr r12,[r12] mov lr, #0xff tstne r12,#PDRAW_ACC_SPRITES @@ -1812,12 +1815,12 @@ FinalizeLineRGB555: stmia r0!, {r4,r5,r8,r12} bne .fl_loopRGB555 - ldmfd sp!, {r4-r8,lr} + ldmfd sp!, {r4-r9,lr} bx lr .fl_32scale_RGB555: - stmfd sp!, {r9,r10} + stmfd sp!, {r10} mov r9, #0x3900 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007 orr r9, r9, #0x00e7 @@ -1878,8 +1881,8 @@ FinalizeLineRGB555: stmia r0!, {r4,r5,r6,r8,r10} bne .fl_loop32scale_RGB555 - ldmfd sp!, {r9,r10} - ldmfd sp!, {r4-r8,lr} + ldmfd sp!, {r10} + ldmfd sp!, {r4-r9,lr} bx lr .if UNALIGNED_DRAWLINEDEST @@ -1925,7 +1928,7 @@ FinalizeLineRGB555: strh r8, [r0], #2 - ldmfd sp!, {r4-r8,lr} + ldmfd sp!, {r4-r9,lr} bx lr @@ -1991,8 +1994,8 @@ FinalizeLineRGB555: strh r4, [r0], #2 - ldmfd sp!, {r9,r10} - ldmfd sp!, {r4-r8,lr} + ldmfd sp!, {r10} + ldmfd sp!, {r4-r9,lr} bx lr .endif @ UNALIGNED_DRAWLINEDEST