Slight improvements to text

This commit is contained in:
alpine9000 2016-03-27 12:06:45 +11:00
parent 10047f6043
commit cd9f89098f
8 changed files with 131 additions and 131 deletions

View File

@ -11,14 +11,14 @@ IMAGES=font.png
IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin))
VASM_EXTRA_ARGS=
#SYMBOL_INFO=-M
SYMBOL_INFO=-M
LINK_COMMANDLINE=vlink -T link.script.x -brawbin1 $< $(OBJS) $(SYMBOL_INFO) -o out/main.bin
include ../shared/base.mk
out/%.bin: ../assets/%.png
$(IMAGECON) --input $< $(IMAGECON_ARGS) --output-bitplanes --output-palette-asm --output-palette --output out/$* --colors=16 --use-palette palette.pal --full-color-palette-file --output-mask --transparent-color=0,0,0
$(IMAGECON) --input $< $(IMAGECON_ARGS) --output-bitplanes --output-grey-palette-asm --output-palette-asm --output-palette --output out/$* --colors=16 --use-palette palette.pal --full-color-palette-file --output-mask --transparent-color=0,0,0
out/main.o: $(IMAGEDATA) constants.i Makefile link.script.x palette.pal
out/init.o: constants.i Makefile

View File

@ -3,30 +3,30 @@
xdef BlitFillColor
BLIT_LF_MINTERM equ $ff
BLIT_DEST equ $100
BLIT_SRCC equ $200
BLIT_SRCB equ $400
BLIT_SRCA equ $800
BlitFillColor:
;; a0 - bitplane
;; d0 - color#
;; d1 - height
;; d2 - ypos
movem.l d0-a6,-(sp)
mulu.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d2
add.l d2,a0
move.b #0,d3 ; bitplane #
.loop:
move.w d1,d4
btst d3,d0 ; is the color's bit set in this plane?
beq .zero
move.l #BLIT_DEST|$FF,d2 ; yes ? all ones
move.w #BLIT_DEST|$FF,d5 ; yes ? all ones
bra .doblit
.zero
move.l #BLIT_DEST|$0,d2 ; no ? all zeros
move.w #BLIT_DEST|$0,d5 ; no ? all zeros
.doblit
jsr WaitBlitter
move.w #0,BLTCON1(A6)
move.w d2,BLTCON0(A6)
move.w d5,BLTCON0(A6)
move.w #SCREEN_WIDTH_BYTES*(SCREEN_BIT_DEPTH-1),BLTDMOD(a6)
move.l a0,BLTDPTH(a6)
@ -34,7 +34,7 @@ BlitFillColor:
ori.w #SCREEN_WIDTH_WORDS,d4
move.w d4,BLTSIZE(a6)
add.b #1,d3
add.l #SCREEN_WIDTH_BYTES,a0
add.w #SCREEN_WIDTH_BYTES,a0
cmp.b #SCREEN_BIT_DEPTH,d3 ; all planes for a single line done ?
bne .loop ; no ? do the next plane
jsr WaitBlitter

View File

@ -1,53 +1,89 @@
include "includes.i"
xdef DrawText
xdef DrawText8
;; BLTCON? configuration
;; http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node011C.html
;; blitter logic function minterm truth table
;; fill in D column for desired function
;; A(mask) B(bob) C(bg) D(dest)
;; - - - -
;; 0 0 0 0
;; 0 0 1 1
;; 0 1 0 0
;; 0 1 1 1
;; 1 0 0 0
;; 1 0 1 0
;; 1 1 0 1
;; 1 1 1 1
;; read D column from bottom up = 11001010 = $ca
;; this is used in the LF? bits
BLIT_LF_MINTERM equ $ca
BLIT_DEST equ $100
BLIT_SRCC equ $200
BLIT_SRCB equ $400
BLIT_SRCA equ $800
BLIT_ASHIFTSHIFT equ 12 ;Bit index of ASH? bits
BLIT_BOB_WIDTH equ 32 ; Must blit extra word to allow shifting
BLIT_BOB_HEIGHT equ 10
BLIT_BOB_WIDTH_BYTES equ BLIT_BOB_WIDTH/8
BLIT_BOB_WIDTH_WORDS equ BLIT_BOB_WIDTH/16
;; This will only work for 8 pixel wide fonts
BLIT_LF_MINTERM equ $ca ; cookie cut
BLIT_WIDTH_WORDS equ 2 ; blit 2 words to allow shifting
BLIT_WIDTH_BYTES equ 4
;; BlitText
DrawText8:
;; a0 - bitplane
;; a1 - text
;; d0 - xpos
;; d1 - ypos
movem.l d0/d2/a1,-(sp)
;; blitter config that is shared for every character
move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTAMOD(a6) ;A modulo
move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTBMOD(a6) ;B modulo
move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTCMOD(a6) ;C modulo
move.w #SCREEN_WIDTH_BYTES-BLIT_WIDTH_BYTES,BLTDMOD(a6) ;D modulo
.loop:
move.b (a1)+,d2 ; get next character
cmp.b #0,d2 ; 0 terminates the string
beq .done
jsr DrawChar8 ; draw it
add.w #FONT_WIDTH,d0 ; increment the x position
bra .loop
.done:
movem.l (sp)+,d0/d2/a1
rts
DrawChar8:
;; d0 - xpos
;; d1 - ypos
;; d3 - odd character
;; d2 - char
;; a0 - bitplane
movem.l d0-d5/a0-a2,-(sp)
move.w #'!',d4 ; fontmap offset
sub.w d4,d2 ; index = char - '!'
move.w d2,d5
lsr.w #5,d5 ; fontmap y offset
move.w d5,d4
lsl.w #5,d4 ; start of line
sub.w d4,d2 ;
add.w #1,d5 ; while we have a weird font image, '!' starts on second line
lea font,a1
lea fontMask,a2
mulu.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH*FONT_HEIGHT,d5
add.w d5,a2
add.w d5,a1
btst #0,d2 ; blitter does words only, so we need to know if its an odd or even character
beq .even ; then shift it into position with the blitter shift
.odd:
move.b #1,d3
bra .c1
.even:
move.b #0,d3
.c1
add.w d2,a1
add.w d2,a2
jsr BlitChar8
movem.l (sp)+,d0-d5/a0-a2
rts
BlitChar8:
;; kills a0,d0,d3
;; d0 - xpos
;; d1 - ypos
;; d3 - odd character = 1, even character = 0
;; a0 - display
;; a1 - object
;; a2 - mask
BlitText:
movem.l d0-a6,-(sp)
;; a2 - mask
jsr WaitBlitter
;; d0 = XPOS
;; d1 = YPOS
;; d3 = odd character
;; d4 = XPOS_BYTES
move.w d0,d4 ; d4 = XPOS
move.l d0,d4 ; d4 = XPOS
lsr.w #3,d4 ; d4 = XPOS_BYTES
cmp.b #1,d3
@ -56,7 +92,7 @@ BlitText:
sub.w #8,d0
move.w #$00FF,BLTAFWM(a6) ; no mask for first word
move.w #$0000,BLTALWM(a6) ; mask out last word
sub.l #1,a0
subq #1,a0
bra .continue
.evenChar:
move.w #$ff00,BLTAFWM(a6) ; no mask for first word
@ -71,13 +107,6 @@ BlitText:
ori.w #BLIT_SRCA|BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM,d0
move.w d0,BLTCON0(A6)
move.w #SCREEN_WIDTH_BYTES-BLIT_BOB_WIDTH_BYTES,BLTAMOD(a6) ;A modulo
move.w #SCREEN_WIDTH_BYTES-BLIT_BOB_WIDTH_BYTES,BLTBMOD(a6) ;B modulo
move.w #SCREEN_WIDTH_BYTES-BLIT_BOB_WIDTH_BYTES,BLTCMOD(a6) ;C modulo
move.w #SCREEN_WIDTH_BYTES-BLIT_BOB_WIDTH_BYTES,BLTDMOD(a6) ;D modulo
move.l a2,BLTAPTH(a6) ; mask bitplane
move.l a1,BLTBPTH(a6) ; bob bitplane
@ -85,69 +114,13 @@ BlitText:
mulu.w d1,d3 ; d3 = YPOS*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH
move.l a0,d0 ; d0 = #bitplanes
add.w d4,d0 ; d0 = #bitplanes+XPOS_BYTES
add.w d3,d0 ; d0 = #bitplanes+XPOS_BYTES+(YPOS*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH)
add.l d4,d0 ; d0 = #bitplanes+XPOS_BYTES
add.l d3,d0 ; d0 = #bitplanes+XPOS_BYTES+(YPOS*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH)
move.l d0,BLTCPTH(a6) ;background top left corner
move.l d0,BLTDPTH(a6) ;destination top left corner
move.w #(BLIT_BOB_HEIGHT*SCREEN_BIT_DEPTH)<<6|(BLIT_BOB_WIDTH_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
movem.l (sp)+,d0-a6
rts
DrawText:
;; a0 - bitplane
;; a1 - text
;; d0 - xpos
;; d1 - ypos
.loop:
clr.l d2
move.b (a1)+,d2
cmp.b #0,d2
beq .done
jsr DrawChar
add.l #FONT_WIDTH,d0
bra .loop
.done:
rts
DrawChar:
;; d0 - xpos
;; d1 - ypos
;; d2 - char
;; a0 - bitplane
movem.l d0-a6,-(sp)
move.l #'!',d4 ; fontmap offset
sub.l d4,d2 ; index = char - '!'
move.l d2,d5
lsr.l #5,d5 ; fontmap y offset
move.l d5,d4
lsl.l #5,d4 ; start of line
sub.l d4,d2 ;
add.l #1,d5 ; temp marker first line xx
lea font,a1
lea fontMask,a2
mulu.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH*BLIT_BOB_HEIGHT,d5
add.l d5,a2
add.l d5,a1
btst.l #0,d2
beq .even
.odd:
move.b #1,d3
bra .c1
.even:
move.b #0,d3
.c1
add.l d2,a1
add.l d2,a2
jsr BlitText
movem.l (sp)+,d0-a6
move.w #(FONT_HEIGHT*SCREEN_BIT_DEPTH)<<6|(BLIT_WIDTH_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
rts
font:

View File

@ -1,4 +1,5 @@
FONT_WIDTH equ 8
FONT_HEIGHT equ 10
SCREEN_WIDTH equ 320
SCREEN_HEIGHT equ 256
SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8)

View File

@ -2,6 +2,7 @@
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 "constants.i"

View File

@ -5,6 +5,7 @@
xdef onscreen
xdef offscreen
xdef copperListBplPtr
xdef Test
byteMap:
dc.l Entry
@ -28,39 +29,51 @@ Entry:
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_MASTER),DMACON(a6)
move.l onscreen,a0
move.l #4,d0 ; color#
move.l #4,d0 ; color#
move.w #SCREEN_HEIGHT,d1 ; height
move.w #0,d2 ; ypos
jsr BlitFillColor
move.l offscreen,a0
move.l #4,d0 ; color#
move.l #4,d0 ; color#
move.w #SCREEN_HEIGHT,d1 ; height
move.w #0,d2 ; ypos
jsr BlitFillColor
jsr Init ; enable the playfield
jsr Init ; enable the playfield
MainLoop:
jsr WaitVerticalBlank
jsr InstallPalette
.mainLoop:
move.l offscreen,a0
move.l #4,d0 ; color#
move.w #25,d1
move.l #4,d0 ; color#
move.w #FONT_HEIGHT,d1 ; height
move.l ypos,d2 ; ypos
jsr BlitFillColor
move.l ypos2,d2
jsr BlitFillColor
move.l direction,d0
add.l d0,xpos
move.l xpos,d0
move.l #15,d1
move.l ypos,d1 ; ypos
move.l offscreen,a0
lea text,a1
jsr DrawText
jsr DrawText8
move.l ypos2,d1
jsr DrawText8
jsr WaitVerticalBlank
jsr SwitchBuffers
cmp.l #SCREEN_WIDTH-((endText-text)*FONT_WIDTH),xpos
ble .notRightEdge
move.l direction,d0
muls.w #-1,d0
move.l d0,direction
bra .mainLoop
bra .notLeftEdge
.notRightEdge:
cmp.l #0,xpos
bne .notLeftEdge
@ -68,7 +81,9 @@ Entry:
muls.w #-1,d0
move.l d0,direction
.notLeftEdge:
bra .mainLoop
jsr GreyPalette
bra MainLoop
text:
dc.b "My first text on an Amiga!"
@ -77,9 +92,13 @@ endText:
align 4
xpos:
dc.l 0
ypos:
dc.l 1
ypos2:
dc.l SCREEN_HEIGHT-FONT_HEIGHT-1
direction:
dc.l 2
Level3InterruptHandler:
movem.l d0-a6,-(sp)
lea CUSTOM,a6
@ -90,7 +109,6 @@ Level3InterruptHandler:
.verticalBlank:
move.w #INTF_VERTB,INTREQ(a6) ; clear interrupt bit
.checkCopper:
move.w INTREQR(a6),d0
and.w #INTF_COPER,d0
@ -117,18 +135,20 @@ copperListBplPtr:
dc.w BPL5PTH,0
dc.w BPL6PTL,0
dc.w BPL6PTH,0
dc.w $106,$c00 ;AGA sprites, palette and dual playfield reset
dc.w $1FC,0 ;AGA sprites and burst reset
dc.l $fffffffe
dc.l $fffffffe
InstallPalette:
include "out/font-palette.s"
rts
GreyPalette:
include "out/font-grey.s"
rts
onscreen:
dc.l bitplanes1
offscreen:
dc.l bitplanes2
section .bss
bitplanes1:
ds.b IMAGESIZE+(512)

View File

@ -21,7 +21,7 @@ WaitVerticalBlank:
bne.b .loop
.loop2 move.l $dff004,d0
and.l #$1ff00,d0
cmp.l #303<<8,d0 ; wait for the scal line to pass (A4000 is fast!)
cmp.l #303<<8,d0 ; wait for the scan line to pass (A4000 is fast!)
beq.b .loop2
movem.l (sp)+,d0
rts

5
include/blitter.i Normal file
View File

@ -0,0 +1,5 @@
BLIT_DEST equ $100
BLIT_SRCC equ $200
BLIT_SRCB equ $400
BLIT_SRCA equ $800
BLIT_ASHIFTSHIFT equ 12 ;Bit index of ASH? bits