Z80 Routines:Graphic:Bub4font

From WikiTI
(Redirected from Routines:Graphic:Bub4font)
Jump to: navigation, search
; dwedit's bub_font routine modified with 
; harper maddox's 4*4 galaxy font (expanded)
; by guillaume h.
; june 2004

; displayable characters go from $20 (space) to $5A (Z)
; they include : capital letters, digits, and some punctuation

;  !"#$%&'()*+,-./
; 0123456789:;<=>?
; @ABCDEFGHIJKLMNO
; PQRSTUVWXYZ


; remarks :
;   $24 is "power 4" in ti's font, but a dollar sign in normal ascii
;      in this font, it's gonna be a block, because drawing a dollar sign
;      because drawing one in 4*4 is hard..

; $5B is a space right now, it is a theta in ti's ascii and a '['
; in normal ascii

FONT_HEIGHT equ 4

appvputs
 ld a,(hl)
 inc hl
 or a
 ret z
 push hl
 call appvputmap
 pop hl
 jr appvputs

appvputmap
 sub $20
 ld l,a
 srl l
 ld h,0
 add hl,hl
 add hl,hl  ; multiplication by 4 = FONT_HEIGHT
 ld de,fontdata
 add hl,de
 ld de,bytes4
 ld b,FONT_HEIGHT
 and 1
 jr z,unshiftedchar
shiftedcharloop:
 ld a,(hl)
 add a,a
 add a,a
 add a,a
 add a,a
 ld (de),a
 inc hl
 inc de
 djnz shiftedcharloop
 jr fontskip
unshiftedchar:
 ld a,(hl)
 and %11110000
 ld (de),a
 inc hl
 inc de
 djnz unshiftedchar
fontskip:
 ld ix,bytes4
 ld hl,(pencol)
 ld a,l
 ld l,h
 inc l
 ld bc,256*FONT_HEIGHT+1
 call largesprite      ; or any sprite routine that fits
 ;advance
 ld hl,pencol
 ld a,(hl)
 add a,6
 ld (hl),a
 ld c,%00001000
findwidthloop:
 dec (hl)
 ld a,c
 add a,a
 ret z
 ld c,a
 ld de,bytes4
 ld b,FONT_HEIGHT
findwidthloop2:
 ld a,(de)
 and c
 ret nz
 inc de
 djnz findwidthloop2
 jr findwidthloop	
	
bytes4:
 db 0,0,0,0

fontdata:
 db %00001000
 db %00001000 ; (space) !
 db %00000000
 db %00001000

 db %10100101
 db %10101111 ; " #
 db %00000101
 db %00001111

 db %11111010
 db %11110100 ; $ (block) %
 db %11111000
 db %11111010

 db %01001000 ; & '
 db %11101000
 db %10100000
 db %01010000

 db %01001000
 db %10000100 ; ( )
 db %10000100
 db %01001000

 db %00000000 ; * +
 db %10100100
 db %01001110
 db %10100100

 db %00000000
 db %00000000 ; , -
 db %01001110
 db %10000000

 db %00000001 ; . /
 db %00000010
 db %00000100
 db %10001000

 db %11101000 ;0  1
 db %10101000
 db %10101000
 db %11101000

 db %11101110 ; 2 3
 db %00100110
 db %11000010
 db %11101110

 db %10101110
 db %10101100 ; 4 5
 db %11100010
 db %00101110

 db %10001110 ; 6 7
 db %11100010
 db %10100010
 db %11100010

 db %11101110 ; 8 9
 db %11101010
 db %10101110
 db %11100010

 db %00000100
 db %10000000 ; : ;
 db %00000100
 db %10001000

 db %00000000
 db %01001110 ; < =
 db %10000000
 db %01001110

 db %00001110
 db %10000010 ; > ?
 db %01000000
 db %10000100

 db %01100100
 db %10101010
 db %11101110 ; @ A
 db %01101010

 db %11101100
 db %11101000
 db %10101000 ; B C
 db %11101100

 db %11001100
 db %10101100 ; D E
 db %10101000
 db %11001100

 db %11001110 ; F G
 db %11001000
 db %10001010
 db %10001110

 db %10101000
 db %10101000 ; H I
 db %11101000
 db %10101000

 db %00101010
 db %00101010 ; J K
 db %10101100
 db %11101010

 db %10001110
 db %10001110 ; L M
 db %10001010
 db %11001010

 db %11001110
 db %10101010 ; N O
 db %10101010
 db %10101110

 db %11101110 ; P Q
 db %10101010
 db %11101110
 db %10001110

 db %11101100
 db %10101000 ; R S
 db %11000100
 db %10101100

 db %11101010 ; T U
 db %01001010
 db %01001010
 db %01001110

 db %10101010
 db %10101010 ; V W
 db %10101110
 db %01001110

 db %10101010
 db %10101010
 db %01000100 ; X Y
 db %10100100

 db %11000000
 db %01000000 ; Z
 db %10000000
 db %11000000