1
0
mirror of https://frontier.innolan.net/github/AmigaExamples.git synced 2025-11-23 23:55:15 +00:00

Clean up scroll_text

This commit is contained in:
alpine9000
2016-04-02 19:56:59 +11:00
parent a6e8f3c1b6
commit a86c373eea
6 changed files with 96 additions and 272 deletions

View File

@ -25,7 +25,7 @@ out/%.bin: ../assets/%.png
out/simple_image.o: constants.i macros.i
out/blittext.o: constants.i macros.i
out/blitchar.o: constants.i macros.i
out/blit.o: constants.i macros.i
out/main.o: $(IMAGEDATA) constants.i macros.i Makefile link.script.x palette.pal
out/init.o: constants.i Makefile

View File

@ -29,10 +29,10 @@ BlitFillColor:
move.w d1,d4
btst d3,d0 ; is the color's bit set in this plane?
beq .zero
move.w #BLIT_DEST|$FF,d5 ; yes ? all ones
move.w #BC0F_DEST|$FF,d5 ; yes ? all ones
bra .doblit
.zero
move.w #BLIT_DEST|$0,d5 ; no ? all zeros
move.w #BC0F_DEST|$0,d5 ; no ? all zeros
.doblit
WaitBlitter
@ -55,12 +55,11 @@ BlitFillColor:
BlitScroll:
;; kills a0,a1,d0,d1,d2
;; a0 - dest
;; a1 - source
;; d0 - shift pixels
;; d1 - height
;; d2 - ypos
;; a0 - dest bitplane pointer
;; a1 - source bitplane pointer
;; d0 - number of shift pixels to left shift
;; d1 - height in pixels
;; d2 - y position
movem.l d0-d2/a0-a1,-(sp)
add.l d1,d2 ;point to end of data for descending mode
@ -70,30 +69,23 @@ BlitScroll:
WaitBlitter
if 0
move.w #$1002,BLTCON1(a6)
move.w #$1000|BLIT_SRCB|BLIT_SRCC|BLIT_DEST|$ca,BLTCON0(a6)
else
lsl.w #6,d0
lsl.w #6,d0
move.w #$2,d3
or.w d0,d3
move.w d3,BLTCON1(a6)
move.w #BLIT_SRCB|BLIT_SRCC|BLIT_DEST|$ca,d3
or.w d0,d3
move.w d3,BLTCON0(a6)
endif
swap d0 ; lsl.l #ASHIFTSHIFT,d0
lsr.l #4,d0 ;
ori.w #BC1F_DESC,d0 ; BLTCON1 value. shift and descending mode
move.w d0,BLTCON1(a6)
and.w #$f000,d0 ; keep the shift, remove the rest
ori.w #BC0F_SRCB|BC0F_SRCC|BC0F_DEST|$ca,d0 ; BLTCON0 value. shift, dma and logic function
move.w d0,BLTCON0(a6)
move.w #$ffff,BLTADAT(a6); preload source mask so only BLTA?WM mask is used
move.w #0,BLTBMOD(a6)
move.w #0,BLTCMOD(a6)
move.w #0,BLTDMOD(a6)
move.l a1,BLTBPTH(a6)
move.l a1,BLTCPTH(a6)
move.l a0,BLTDPTH(a6)
move.w #$0000,BLTAFWM(a6)
move.w #$ffff,BLTALWM(a6)
move.w #0,BLTBMOD(a6) ; no modulo, blitting full width data
move.w #0,BLTCMOD(a6) ;
move.w #0,BLTDMOD(a6) ;
move.l a1,BLTBPTH(a6) ; source
move.l a1,BLTCPTH(a6) ; background
move.l a0,BLTDPTH(a6) ; dest
move.w #$0000,BLTAFWM(a6) ; A DMA is disabled, but the channel is still used in the logic function
move.w #$ffff,BLTALWM(a6) ; we use it for masking
move.w #$ffff,BLTADAT(a6) ; preload source mask so only BLTA?WM mask is used
mulu.w #SCREEN_BIT_DEPTH,d1
lsl.w #6,d1

View File

@ -9,9 +9,9 @@ BLIT_WIDTH_BYTES equ BLIT_WIDTH_WORDS*2
FONTMAP_WIDTH_BYTES equ 32
if MASKED_FONT==1
BLTCON0_VALUE equ BLIT_SRCA|BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM
BLTCON0_VALUE equ BC0F_SRCA|BC0F_SRCB|BC0F_SRCC|BC0F_DEST|BLIT_LF_MINTERM
else
BLTCON0_VALUE equ BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM
BLTCON0_VALUE equ BC0F_SRCB|BC0F_SRCC|BC0F_DEST|BLIT_LF_MINTERM
endif
BlitChar8:

View File

@ -1,150 +0,0 @@
include "includes.i"
xdef DrawText8
BLIT_LF_MINTERM equ $ca ; cookie cut
BLIT_WIDTH_WORDS equ 2 ; blit 2 words to allow shifting
BLIT_WIDTH_BYTES equ 4
FONTMAP_WIDTH_BYTES equ 32
DrawText8:
;; a0 - bitplane
;; a1 - text
;; d0 - xpos
;; d1 - ypos
movem.l d0-d7/a0-a4,-(sp)
WaitBlitter
;; blitter config that is shared for every character
if MASKED_FONT==1
move.w #BLIT_SRCA|BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM,d6 ; BLTCON0 value (masked version)
move.w #FONTMAP_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTAMOD(a6) ; A modulo (only used for masked version)
else
move.w #BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM,d6 ; BLTCON0 value
endif
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.l #fontMask,d7 ; font mask pointer
move.w #FONTMAP_WIDTH_BYTES*SCREEN_BIT_DEPTH*FONT_HEIGHT,d3 ; bytes per font line
.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
bsr DrawChar8 ; draw it
add.l #FONT_WIDTH,d0 ; increment the x position
bra .loop
.done:
movem.l (sp)+,d0-d7/a0-a4
rts
DrawChar8:
;; kills d2,d4,d5,a1,a2,a4
;; d0 - xpos
;; d1 - ypos bytes
;; d2* - char
;; d3 - bytes per font line
;; d6 - bltcon0 value
;; a4* - bitplane
;; a5 - #font
;; d7 - #fontMask
sub.w #'!',d2 ; index = char - '!'
move.w d2,d5
lsr.w #5,d5 ; char / 32 = fontmap line
andi.w #$1f,d2 ; char index in line (char index - start of line index)
add.l #1,d5 ; while we have a weird font image, '!' starts on second line
move.l a5,a1 ; #font
if 1
mulu.w d3,d5 ; d5 *= #FONTMAP_WIDTH_BYTES*SCREEN_BIT_DEPTH*FONT_HEIGHT
else
move.w d5,d3
lsl.w #7,d3 ; d5 *= FONTMAP_WIDTH_BYTES*SCREEN_BIT_DEPTH
move.w d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
add.l d3,d5
endif
if MASKED_FONT==1
move.l d7,a2 ; #fontMask
add.w d5,a2 ; add y offset in lines to fontMask address
endif
add.w d5,a1 ; add y offset in lines to font address
add.w d2,a1 ; add offset into font
if MASKED_FONT==1
add.l d2,a2 ; add offset into mask
endif
.blitChar8:
;; kills a4,d2,d4,d5
;; d0 - xpos
;; d1 - ypos bytes
;; d2.0 - odd character = 1, even character = 0
;; d3 - bytes per font line
;; d6 - bltcon0 value
;; a4 - display
;; a1 - object
;; a2 - mask
move.l d0,d4 ; xpos
move.l d0,d5 ; xpos
lsr.w #3,d4 ; d4 = xpos bytes
WaitBlitter
btst #0,d2 ; check if odd or even char
beq .evenChar ;
.oddChar
subq #8,d5 ; 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
bra .continue
.evenChar:
move.w #$FF00,BLTAFWM(a6) ; select the first character in the word
.continue:
;; this shift will give us the bits to shift (bits 0-3) in bits (12-15) of d5
swap d5 ; d5 << 12
lsr.l #4,d5 ;
move.w d5,BLTCON1(A6) ; set the shift bits 12-15, bits 00-11 cleared
if MASKED_FONT==1
move.l a2,BLTAPTH(a6) ; mask bitplane
endif
move.l a1,BLTBPTH(a6) ; source bitplane
or.w d6,d5 ; d5 = BLTCON0 value
move.w d5,BLTCON0(a6) ; set minterm, dma channel and shift
add.l d4,a4 ; dest += XPOS_BYTES
add.l d1,a4 ; dest += YPOS_BYTES
move.l a4,BLTCPTH(a6) ; background top left corner
move.l a4,BLTDPTH(a6) ; destination top left corner
move.w #(FONT_HEIGHT*SCREEN_BIT_DEPTH)<<6|(BLIT_WIDTH_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
rts
font:
incbin "out/font8x8.bin"
fontMask:
incbin "out/font8x8-mask.bin"

View File

@ -2,8 +2,8 @@
include "../include/vector.i"
include "../include/beambits.i"
include "../include/bplconbits.i"
include "../include/blitter.i"
include "hardware/dmabits.i"
include "hardware/intbits.i"
include "hardware/blit.i"
include "constants.i"
include "macros.i"

View File

@ -40,27 +40,19 @@ Entry:
move.w #SCREEN_HEIGHT,d1
move.w #0,d2 ; ypos
jsr BlitFillColor
WaitBlitter
jsr Init ; enable the playfield
MainLoop:
jsr WaitVerticalBlank
jsr InstallPalette
;; jsr GreyPalette
;; move.w #$500,COLOR00(a6)
jsr SwitchBuffers
move.l #NUM_LINES-1,d3
.loop:
bsr UpdateLine
dbra d3,.loop
jsr SwitchBuffers
bra MainLoop
@ -68,10 +60,10 @@ MainLoop:
UpdateLine:
;; d3 - line number
movem.l d0-a6,-(sp)
lea.l textlut,a2
lea.l textLookupTable,a2
move.l d3,d4
mulu.w #16,d4
add.l d4,a2 ; index into LUT
mulu.w #16,d4 ; #16 is size of lookup table entry
add.l d4,a2 ; address of line's entry in the textLookupTable
cmp.l #8,8(a2)
bne .shift
@ -79,44 +71,73 @@ UpdateLine:
move.l #BITPLANE_WIDTH-16,d0 ; xpos
move.l onscreen,a0
move.l #FONT_HEIGHT+1,d1 ; ypos
move.l d3,d4
mulu.w d3,d1
bsr GetNextChar
jsr BlitChar8
move.l #0,8(a2)
.shift:
move.l offscreen,a0 ; dest
move.l onscreen,a1 ; src
move.l #FONT_HEIGHT,d1 ; height
move.l #FONT_HEIGHT+1,d2 ; ypos
mulu.w d3,d2
Test:
move.l d3,d4 ; line number
;; move.l #1,d0
move.l 12(a2),d0
jsr BlitScroll
;; add.l #1,8(a2)
add.l d0,8(a2)
bsr GetNextChar
mulu.w d3,d1 ; y pos
jsr BlitChar8
move.l #0,8(a2) ; reset shift counter
.shift:
move.l offscreen,a0 ; dest
move.l onscreen,a1 ; src
move.l #FONT_HEIGHT,d1 ; height
move.l #FONT_HEIGHT+1,d2 ; ypos
mulu.w d3,d2
move.l 12(a2),d0 ; bits to shift per frame
jsr BlitScroll ; scroll line
add.l d0,8(a2) ; current shift counter += bits to shift per frame
movem.l (sp)+,d0-a6
rts
GetNextChar:
;; d4 - line number
;; a2 - address of textLookupTable entry
;; d2 (out) - next char
movem.l a3,-(sp)
move.l (a2),a3 ; address of next char
cmp.b #0,(a3) ; check for null termination
bne .moreText
.wrapText:
move.l 4(a2),(a2) ; reset current char pointer to reset value
.moreText:
add.l #1,(a2) ; increment current char pointer
sub.l d2,d2 ; clear d2
move.b (a3),d2 ; d2 (out) = next char
movem.l (sp)+,a3
rts
charbuffer:
dc.b 0
dc.b 0
Level3InterruptHandler:
movem.l d0-a6,-(sp)
lea CUSTOM,a6
.checkVerticalBlank:
move.w INTREQR(a6),d0
and.w #INTF_VERTB,d0
beq.s .checkCopper
shiftcounter:
dc.l 8
textlut:
dc.l text1
dc.l text2
dc.l 8
dc.l 1
dc.l text3
dc.l text4
dc.l 8
dc.l 2
dc.l text5
.verticalBlank:
move.w #INTF_VERTB,INTREQ(a6) ; clear interrupt bit
.checkCopper:
move.w INTREQR(a6),d0
and.w #INTF_COPER,d0
beq.s .interruptComplete
.copperInterrupt:
move.w #INTF_COPER,INTREQ(a6) ; clear interrupt bit
.interruptComplete:
movem.l (sp)+,d0-a6
rte
textLookupTable:
dc.l text1 ; line 1 - current char pointer
dc.l text2 ; line 1 - reset to this address on null
dc.l 8 ; line 1 - current shift counter
dc.l 1 ; line 1 - bits to shift per frame (scroll speed)
dc.l text3 ; line 2 - current char pointer
dc.l text4 ; line 2 - reset to this address on null
dc.l 8 ; line 2 - current shift counter
dc.l 2 ; line 2 - bits to shift per frame (scroll speed)
dc.l text5 ; etc
dc.l text4
dc.l 8
dc.l 4
@ -249,46 +270,6 @@ endText:
dc.b 0
align 4
GetNextChar:
movem.l a2-a3,-(sp)
lea.l textlut,a2
mulu.w #16,d4 ;
add.l d4,a2 ; index into LUT
move.l (a2),a3 ; address of next char
cmp.b #0,(a3)
bne .moreText
.wrapText:
move.l 4(a2),(a2)
.moreText:
sub.l d2,d2
move.l (a2),a3
move.b (a3),d2
add.l #1,(a2)
movem.l (sp)+,a2-a3
rts
Level3InterruptHandler:
movem.l d0-a6,-(sp)
lea CUSTOM,a6
.checkVerticalBlank:
move.w INTREQR(a6),d0
and.w #INTF_VERTB,d0
beq.s .checkCopper
.verticalBlank:
move.w #INTF_VERTB,INTREQ(a6) ; clear interrupt bit
.checkCopper:
move.w INTREQR(a6),d0
and.w #INTF_COPER,d0
beq.s .interruptComplete
.copperInterrupt:
move.w #INTF_COPER,INTREQ(a6) ; clear interrupt bit
.interruptComplete:
movem.l (sp)+,d0-a6
rte
copperList:
copperListBplPtr:
@ -304,6 +285,7 @@ copperListBplPtr:
dc.w BPL5PTH,0
dc.w BPL6PTL,0
dc.w BPL6PTH,0
dc.w COLOR01,$fff
dc.w $3507,$fffe
dc.w COLOR01,$0f0
dc.w $3e07,$fffe