From 3878f9dcded1f4a19d71ce7672b6f51309b4bd7d Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Thu, 26 May 2016 14:20:29 +1000 Subject: [PATCH] blittext optimisations --- 028.bs/assets/background.png | Bin 2518 -> 2583 bytes 028.bs/blittext.s | 229 ++++++++++++++++++++++++++--------- 028.bs/counter.s | 20 ++- 028.bs/game1.s | 8 ++ 028.bs/player.s | 9 +- 5 files changed, 205 insertions(+), 61 deletions(-) diff --git a/028.bs/assets/background.png b/028.bs/assets/background.png index 1888aeccb93fbf19ceeb18b386121b2d1b31f64f..64cf228f5c40f294558bc3bd3afda83a68ef7e86 100644 GIT binary patch delta 1517 zcmbV~`#+Nl0LI_vDn4V|y5VMR%gQ^FRfA zTfB}XUU4aov4hsmz#a;PQUl@--5n^* z51y9>R}4iN6%LiWojg0q4jYN>^IthUtLNucjH=S~<{T&bx;TRdCerQQ2M!MZ)$ti; zK;CQPL3GniL0BmI&IJ?Yw4P}iIo}k5{}|U(qDA>WR?W&cSDVdvuKBWNTRbof7{o1` zqGHQTGWm90;B=N*rw|@jraJV~Z8Z-M(OE*KtZWwfA(i?j6$_2x=K zICtvsGtYq_@m67o5f!_(`>Kv3)VfoE+oh0BdA2#`1BHu^%+kj4SfxH6IBKbvy@J>F zUO3qJb_e6VuDEvXzQJ@;+tRIgidypx{&6o1_>|S=V>5$m?g_IcN6_?93$HIXne&89 z%Ro2qaPxrM3i#VbG~bf6J06%}>YL?rvg@@<2a$~=@m9Zq08V=Isf#&X>aIq)mw`$r zWglZvTa5h{*dJ`h6W(0QvM*8xj{qcU-~trw+NpT)25D_B0x8mLpu=dE9r3qvawk9G;!FJGdH|Zp^bQF{u%ELl)l3AG zgU^1<9qVWrntuIS)_ziBU^}2o@o=~nz6jFcvjtSSFGBuN#ca&Bt9n^wu)t-k+k-(g z3wpqyv-lKD$b0nUr~hv<3>SNQdna@aN#>{Os5E{t_ey@+xzV1!V?I@m6@wFTXy@ne z_HX2Z5gMmYu#ZDlDPsm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{!tt`XRo%axW8EFs*Z7Hu$*wphF;!0oE`knC39<`G7#T zwL;(;-3!k{6Xulpks2$o=G$eGHni`RPS?aHm1tz-Er98fC5lmapYL=OdIiGO)f~x- za6(goBP4Pu7e^AnIdc9;Aev=zFHaNEAD`b!uQ9qX zG-+eBcpZ9Lz|?eg#W{iokl7MGO$~m`hKS6QJTbo0L$Ie}b zN5p0?*47iLD{@fwnrP+lL|xr&yaRx7Nh#?!-%tS89GT7v8Wi__TH?I&^)0NbbS~2$ zWLQA`A-{jA?y^H*uMWlP1rZg}Cgn-jD(9q2pC%AgVFbB1Oj)}p48Pz21;_gZ<+d9C z6G;D_YB=hg&Q852ldVx(eT=uCW3;UU19!VD%gq<5;vYfNn@#t#)2VCy6WOjMTRtp) z_A}C(Ddvr7N8NEp{!e{bYf_ptPPglEs?!Fmnxi(G-yyJgm>Z3O)T!Z2Sg03TmcDqy zl@~r|yrGq;CT6)kT9%O*5pjFE;q7ji71L16qT z!duL~?TrZ}IeRimky{8cm1kxptNBY0pIIX5GS>WB`PR*RPXtCBdhYFhz0DLm7hBQ5 zYD)q355<}D_U(xwU7ajzPF{# z%&g;MTbuzj-dKP2u*{HlajtZ@?2E{zeT_XYa6^1OOYT0}^NI2>v+i1wzajz|Zixyf l?2WC4T?!_9UA!ewqmWGPqwWUNVrjrmygg5PG`dA(`~x&h!uS9H diff --git a/028.bs/blittext.s b/028.bs/blittext.s index beb6a55..9cff802 100644 --- a/028.bs/blittext.s +++ b/028.bs/blittext.s @@ -16,94 +16,205 @@ DrawText8: ;; a1 - text ;; d0 - xpos ;; d1 - ypos - movem.l d0-d4/a1-a4,-(sp) + movem.l d0-d3/a1-a2,-(sp) WaitBlitter ;; blitter config that is shared for every character - move.w #BC0F_SRCB|BC0F_SRCC|BC0F_DEST|BLIT_LF_MINTERM,d4 ; BLTCON0 value + move.w #BC0F_SRCB|BC0F_SRCC|BC0F_DEST|BLIT_LF_MINTERM,d3 ; BLTCON0 value move.w #FONTMAP_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTBMOD(a6) ; B modulo move.w #_BITPLANE_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTCMOD(a6) ; C modulo move.w #_BITPLANE_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTDMOD(a6) ; D modulo - mulu.w #_BITPLANE_WIDTH_BYTES*_SCREEN_BIT_DEPTH,d1 ; ypos bytes move.w #$0000,BLTALWM(a6) ; mask out extra word used for shifting move.w #$ffff,BLTADAT(a6) ; preload source mask so only BLTA?WM mask is used - move.l a1,a3 ; character pointer + move.l #font,a5 ; font pointer - ;; move.w #FONTMAP_WIDTH_BYTES*_SCREEN_BIT_DEPTH*FONT_HEIGHT,d3 ; bytes per font line + move.l a0,a2 ; bitplane pointer + mulu.w #_BITPLANE_WIDTH_BYTES*_SCREEN_BIT_DEPTH,d1 ; d1 = ypos bytes + adda.w d1,a2 ; dest += YPOS_BYTES + move.w d0,d1 ; xpos + lsr.w #3,d1 ; d2 = xpos bytes + adda.w d1,a2 ; dest += XPOS_BYTES + .loop: - clr.l d2 - move.b (a3)+,d2 ; get next character - cmp.b #0,d2 ; 0 terminates the string - beq .done - move.l a0,a4 ; bitplane pointer - - move.l a5,a1 ; #font + moveq #0,d1 + move.b (a1)+,d1 ; get next character + cmp.b #0,d1 ; 0 terminates the string + beq .done ; finished! + lsl.w #2,d1 ; font atlas index = char * 4 + move.l d0,d2 ; xpos - sub.w #' ',d2 ; index = char - ' ' - move.w d2,d3 - - - andi.w #$1f,d2 ; char index in line (char index - start of line index) - adda.w d2,a1 ; add offset into font - - add.w #1<<5,d3 ; while we have a weird font image, ' ' starts on second line - ;; lsr.w #5,d3 ; char / 32 = fontmap line - ;; lsl.w #5,d3 ; d3 *= #FONTMAP_WIDTH_BYTES*_SCREEN_BIT_DEPTH*FONT_HEIGHT - andi.w #$e0,d3 - lsl.w #5,d3 - adda.w d3,a1 ; add y offset in lines to font address - - move.w d0,d3 ; xpos - lsr.w #3,d3 ; d3 = xpos bytes - adda.w d3,a4 ; dest += XPOS_BYTES - adda.w d1,a4 ; dest += YPOS_BYTES - - move.l d0,d3 ; xpos - WaitBlitter - btst #0,d2 ; check if odd or even char + btst #2,d1 ; check if odd or even char beq .evenChar ; .oddChar - subq #8,d3 ; offset the x position for the odd character + subq #8,d2 ; offset the x position for the odd character move.w #$00FF,BLTAFWM(a6) ; select the second (odd) character in the word - subq #1,a4 ; move the destination pointer left by one byte + subq #1,a2 ; move the destination pointer left by one byte + move.l a2,BLTCPTH(a6) ; background top left corner + move.l a2,BLTDPTH(a6) ; destination top left corner + addq #1,a2 bra .continue .evenChar: move.w #$FF00,BLTAFWM(a6) ; select the first character in the word + move.l a2,BLTCPTH(a6) ; background top left corner + move.l a2,BLTDPTH(a6) ; destination top left corner .continue: - - ;; this shift will give us the bits to shift (bits 0-3) in bits (12-15) of d3 - swap d3 ; d3 << 12 - lsr.l #4,d3 ; - - move.w d3,BLTCON1(A6) ; set the shift bits 12-15, bits 00-11 cleared - move.l a1,BLTBPTH(a6) ; source bitplane - or.w d4,d3 ; d3 = BLTCON0 value - move.w d3,BLTCON0(a6) ; set minterm, dma channel and shift - move.l a4,BLTCPTH(a6) ; background top left corner - move.l a4,BLTDPTH(a6) ; destination top left corner + ;; this shift will give us the bits to shift (bits 0-3) in bits (12-15) of d2 + swap d2 ; d2 << 12 + lsr.l #4,d2 ; + move.w d2,BLTCON1(A6) ; set the shift bits 12-15, bits 00-11 cleared + move.l fontAtlas(pc,d1.w),BLTBPTH(a6) ; source bitplane + or.w d3,d2 ; d2 = BLTCON0 value + move.w d2,BLTCON0(a6) ; set minterm, dma channel and shift move.w #(FONT_HEIGHT*_SCREEN_BIT_DEPTH)<<6|(BLIT_WIDTH_WORDS),BLTSIZE(a6) ;rectangle size, starts blit add.l #FONT_WIDTH,d0 ; increment the x position + addq #1,a2 ; increment the dest buffer pointer bra .loop .done: - movem.l (sp)+,d0-d4/a1-a4 + movem.l (sp)+,d0-d3/a1-a2 rts -DrawChar8: - ;; kills d2,d3,a1,a2,a4 - ;; d0 - xpos - ;; d1 - ypos bytes - ;; d2* - char - ;; d4 - bltcon0 value - ;; a4* - bitplane - ;; a5 - #font - rts -font: +CharAddress: macro + dc.l font+(((\1)/FONTMAP_WIDTH_BYTES)*(FONT_HEIGHT*FONTMAP_WIDTH_BYTES*_SCREEN_BIT_DEPTH))+((\1)-(((\1)/FONTMAP_WIDTH_BYTES)*FONTMAP_WIDTH_BYTES)) + endm + + +fontAtlas: + CharAddress 0 + CharAddress 1 + CharAddress 2 + CharAddress 3 + CharAddress 4 + CharAddress 5 + CharAddress 6 + CharAddress 7 + CharAddress 8 + CharAddress 9 + CharAddress 10 + CharAddress 11 + CharAddress 12 + CharAddress 13 + CharAddress 14 + CharAddress 15 + CharAddress 16 + CharAddress 17 + CharAddress 18 + CharAddress 19 + CharAddress 20 + CharAddress 21 + CharAddress 22 + CharAddress 23 + CharAddress 24 + CharAddress 25 + CharAddress 26 + CharAddress 27 + CharAddress 28 + CharAddress 29 + CharAddress 30 + CharAddress 31 + CharAddress 32 + CharAddress 33 + CharAddress 34 + CharAddress 35 + CharAddress 36 + CharAddress 37 + CharAddress 38 + CharAddress 39 + CharAddress 40 + CharAddress 41 + CharAddress 42 + CharAddress 43 + CharAddress 44 + CharAddress 45 + CharAddress 46 + CharAddress 47 + CharAddress 48 + CharAddress 49 + CharAddress 50 + CharAddress 51 + CharAddress 52 + CharAddress 53 + CharAddress 54 + CharAddress 55 + CharAddress 56 + CharAddress 57 + CharAddress 58 + CharAddress 59 + CharAddress 60 + CharAddress 61 + CharAddress 62 + CharAddress 63 + CharAddress 64 + CharAddress 65 + CharAddress 66 + CharAddress 67 + CharAddress 68 + CharAddress 69 + CharAddress 70 + CharAddress 71 + CharAddress 72 + CharAddress 73 + CharAddress 74 + CharAddress 75 + CharAddress 76 + CharAddress 77 + CharAddress 78 + CharAddress 79 + CharAddress 80 + CharAddress 81 + CharAddress 82 + CharAddress 83 + CharAddress 84 + CharAddress 85 + CharAddress 86 + CharAddress 87 + CharAddress 88 + CharAddress 89 + CharAddress 90 + CharAddress 91 + CharAddress 92 + CharAddress 93 + CharAddress 94 + CharAddress 95 + CharAddress 96 + CharAddress 97 + CharAddress 98 + CharAddress 99 + CharAddress 100 + CharAddress 101 + CharAddress 102 + CharAddress 103 + CharAddress 104 + CharAddress 105 + CharAddress 106 + CharAddress 107 + CharAddress 108 + CharAddress 109 + CharAddress 110 + CharAddress 111 + CharAddress 112 + CharAddress 113 + CharAddress 114 + CharAddress 115 + CharAddress 116 + CharAddress 117 + CharAddress 118 + CharAddress 119 + CharAddress 120 + CharAddress 121 + CharAddress 122 + CharAddress 123 + CharAddress 124 + CharAddress 125 + CharAddress 126 + CharAddress 127 + +font: incbin "out/font8x8.bin" - + diff --git a/028.bs/counter.s b/028.bs/counter.s index 46becae..e818179 100644 --- a/028.bs/counter.s +++ b/028.bs/counter.s @@ -3,7 +3,8 @@ xdef IncrementCounter xdef DecrementCounter xdef RenderNumber5 - xdef RenderNumber4 + xdef RenderNumber4 + xdef RenderNumber2 RenderCounter: ;; d0.w x position @@ -26,6 +27,23 @@ RenderNumber4: jsr DrawText8 rts +RenderNumber2: + ;; d0.l number + ;; d1.w x position + move.l d1,d3 + move.l #2,d2 + bsr ToAscii + move.l a0,a1 + lea panel,a0 + move.w #20,d1 + move.w d3,d0 + jsr DrawText8 + rts + + +test: + dc.b "HELLO" + dc.b 0 RenderNumber5: ;; d0.l number diff --git a/028.bs/game1.s b/028.bs/game1.s index 85e600c..cb03a3f 100644 --- a/028.bs/game1.s +++ b/028.bs/game1.s @@ -93,6 +93,7 @@ Reset: move.w #PANEL_PLAYER1_X,d0 jsr RenderCounter move.l playerXColumnLastSafe,playerXColumn + jsr PreRenderColumnsRemaining jsr RenderPlayerScore move.l startForegroundMapPtr,foregroundMapPtr @@ -228,6 +229,13 @@ GameLoop: bsr RenderNextForegroundFrame jsr RenderNextBackgroundFrame + if 0 + jsr RenderPlayerScore + move.w #$0f0,COLOR00(a6) + jsr RenderPlayerScore + move.w #$0,COLOR00(a6) + endif + cmp.w #0,pathwayClearPending beq .dontClearPathway jsr ClearPathway diff --git a/028.bs/player.s b/028.bs/player.s index d02794a..223f18f 100644 --- a/028.bs/player.s +++ b/028.bs/player.s @@ -10,6 +10,7 @@ xdef SetupSpriteData xdef ScrollSprites xdef RenderPlayerScore + xdef PreRenderColumnsRemaining xdef deadSprite ; used in items xdef UpdatePlayerFallingAnimation xdef InstallPlayerColorPalette @@ -573,8 +574,14 @@ UpdatePlayerScore: RenderPlayerScore: jsr RenderScore move.l playerXColumn,d0 + move.w #PANEL_COLUMNS_REMAINING_X+(8*3),d1 + jsr RenderNumber2 + rts + +PreRenderColumnsRemaining: + move.l playerXColumn,d0 move.w #PANEL_COLUMNS_REMAINING_X,d1 - jsr RenderNumber5 + jsr RenderNumber5 rts