million-perfect-letters/src/ui.font.heavy.silk.a

187 lines
4.8 KiB
Plaintext

;license:MIT
;(c) 2020 by 4am
;
; font drawing routines for Heavy Silk pixel font
;
; Public functions:
; - DrawHeavySilkString
; - DrawHeavySilkBuffer
; - DrawHeavySilkBufferInverse
;
;------------------------------------------------------------------------------
; DrawHeavySilkString
;
; in: A/Y contains address of length-prefixed string (length 1..40,
; characters 0x20..0x5A only)
; $24 (HTAB) contains starting column (0..39)
; $25 (VTAB) contains textpage line (0..23)
; all characters are drawn on the same line
; HTAB is incremented for each character
; out: clobbers A/X/Y
; clobbers $FE/$FF
;------------------------------------------------------------------------------
DrawHeavySilkString
+ST16 $FE
ldy #0
lda ($FE),y
tax
inc $FE
bne +
inc $FF
+
+LD16 $FE
; /!\ execution falls through here to DrawHeavySilkBuffer
;------------------------------------------------------------------------------
; DrawHeavySilkBuffer
;
; in: A/Y contains address of character buffer (characters 0x20..0x5A only)
; X contains buffer length (1..40)
; $24 (HTAB) contains starting column (0..39)
; $25 (VTAB) contains textpage line (0..23)
; all characters are drawn on the same line
; HTAB is incremented for each character
; VTAB is NOT incremented
; out: clobbers A/X/Y
;------------------------------------------------------------------------------
DrawHeavySilkBuffer
+ST16 @loop+1
dex
lda VTAB
asl
asl
asl
tay
lda HGRLO, y
sta @hgrlo+1
lda HGRHI, y
clc
sta @row0+2
adc #$04
sta @row1+2
adc #$04
sta @row2+2
adc #$04
sta @row3+2
adc #$04
sta @row4+2
adc #$04
sta @row5+2
adc #$04
sta @row6+2
adc #$04
sta @row7+2
@hgrlo lda #$FD
clc
adc HTAB
sta @row0+1
sta @row1+1
sta @row2+1
sta @row3+1
sta @row4+1
sta @row5+1
sta @row6+1
sta @row7+1
@loop ldy $FDFD,x
lda HeavySilkRow0-$20,y
@row0 sta $FDFD,x
lda HeavySilkRow1-$20,y
@row1 sta $FDFD,x
lda HeavySilkRow2-$20,y
@row2 sta $FDFD,x
lda HeavySilkRow3-$20,y
@row3 sta $FDFD,x
lda HeavySilkRow4-$20,y
@row4 sta $FDFD,x
lda HeavySilkRow5-$20,y
@row5 sta $FDFD,x
lda HeavySilkRow6-$20,y
@row6 sta $FDFD,x
lda HeavySilkRow7-$20,y
@row7 sta $FDFD,x
inc HTAB
dex
bpl @loop
rts
;------------------------------------------------------------------------------
; DrawHeavySilkBufferInverse
;
; in: A/Y contains address of character buffer (characters 0x20..0x5A only)
; X contains buffer length (1..40)
; $24 (HTAB) contains starting column (0..39)
; $25 (VTAB) contains textpage line (0..23)
; all characters are drawn on the same line
; HTAB is incremented for each character
; VTAB is NOT incremented
; out: clobbers A/X/Y
;------------------------------------------------------------------------------
DrawHeavySilkBufferInverse
+ST16 @loop+1
dex
lda VTAB
asl
asl
asl
tay
lda HGRLO, y
sta @hgrlo+1
lda HGRHI, y
clc
sta @row0+2
adc #$04
sta @row1+2
adc #$04
sta @row2+2
adc #$04
sta @row3+2
adc #$04
sta @row4+2
adc #$04
sta @row5+2
adc #$04
sta @row6+2
adc #$04
sta @row7+2
@hgrlo lda #$FD
clc
adc HTAB
sta @row0+1
sta @row1+1
sta @row2+1
sta @row3+1
sta @row4+1
sta @row5+1
sta @row6+1
sta @row7+1
@loop ldy $FDFD,x
lda HeavySilkRow0-$20,y
eor #$7F
@row0 sta $FDFD,x
lda HeavySilkRow1-$20,y
eor #$7F
@row1 sta $FDFD,x
lda HeavySilkRow2-$20,y
eor #$7F
@row2 sta $FDFD,x
lda HeavySilkRow3-$20,y
eor #$7F
@row3 sta $FDFD,x
lda HeavySilkRow4-$20,y
eor #$7F
@row4 sta $FDFD,x
lda HeavySilkRow5-$20,y
eor #$7F
@row5 sta $FDFD,x
lda HeavySilkRow6-$20,y
eor #$7F
@row6 sta $FDFD,x
lda HeavySilkRow7-$20,y
eor #$7F
@row7 sta $FDFD,x
inc HTAB
dex
bpl @loop
rts