mirror of
https://frontier.innolan.net/github/AmigaExamples.git
synced 2026-09-11 23:11:37 +00:00
blittext optimisations
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
+170
-59
@@ -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"
|
||||
|
||||
|
||||
|
||||
|
||||
+19
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+8
-1
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user