Z80 Routines:Graphic:Bub font

From WikiTI
Revision as of 22:14, 28 March 2005 by Dwedit (Talk | contribs)

Jump to: navigation, search


A modified version which contains a 4x4 font is available at Routines:Graphic:Bub4font.

;Code by Dwedit.  Font based on TI's small font.
;This is a replacement for Vputs intended for the TI85, since the TI85
;does not have a textwrite flag.
;The font data is packed so that two characters are stored every 5 bytes.
;Feel free to replace largesprite with any other sprite routine

Appvputs:
	ld a,(hl)
	inc hl

	or a
	ret z
	push hl
		call appvputmap
	pop hl
	jr appvputs

appvputmap:
	sub 32
	ld l,a
	srl l
	ld h,0
	ld e,l
	ld d,h
	add hl,hl
	add hl,hl
	add hl,de
	ld de,fontdata
	add hl,de
	ld de,bytes5
	ld b,5
	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,bytes5
	ld hl,(pencol)
	ld a,l
	ld l,h
	inc l
	ld bc,$0501
	call ionlargesprite
	;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,bytes5
	ld b,5
findwidthloop2:
	ld a,(de)
	and c
	ret nz
	inc de
	djnz findwidthloop2
	jr findwidthloop

;You can also equate bytes5 to any area where there are 5 bytes of destroyable ram, such as op1.	
bytes5:
	.db 0,0,0,0,0
	
Fontdata:
 .db %00001000
 .db %00001000
 .db %00001000
 .db %00000000
 .db %00001000

 .db %10100101
 .db %10101111
 .db %10100101
 .db %00001111
 .db %00000101

 .db %01111010
 .db %10100010
 .db %01110100
 .db %00101000
 .db %11111010

 .db %01001000
 .db %10101000
 .db %01001000
 .db %10100000
 .db %01010000

 .db %01001000
 .db %10000100
 .db %10000100
 .db %10000100
 .db %01001000

 .db %10100000
 .db %01000100
 .db %11101110
 .db %01000100
 .db %10100000

 .db %00000000
 .db %00000000
 .db %01001110
 .db %01000000
 .db %10000000

 .db %00000010
 .db %00000010
 .db %00000100
 .db %00001000
 .db %10001000

 .db %01000100
 .db %10101100
 .db %10100100
 .db %10100100
 .db %01001110

 .db %11001100
 .db %00100010
 .db %01000100
 .db %10000010
 .db %11101100

 .db %10001110
 .db %10101000
 .db %11101100
 .db %00100010
 .db %00101100

 .db %01101110
 .db %10000010
 .db %11100100
 .db %10101000
 .db %11101000

 .db %11101110
 .db %10101010
 .db %11101110
 .db %10100010
 .db %11101100

 .db %00000000
 .db %10000100
 .db %00000000
 .db %10000100
 .db %00001000

 .db %00100000
 .db %01001110
 .db %10000000
 .db %01001110
 .db %00100000

 .db %10001100
 .db %01000010
 .db %00100100
 .db %01000000
 .db %10000100

 .db %11100100
 .db %00011010
 .db %11011110
 .db %10111010
 .db %01111010

 .db %11000110
 .db %10101000
 .db %11001000
 .db %10101000
 .db %11000110

 .db %11001110
 .db %10101000
 .db %10101100
 .db %10101000
 .db %11001110

 .db %11100110
 .db %10001000
 .db %11001010
 .db %10001010
 .db %10000110

 .db %10101110
 .db %10100100
 .db %11100100
 .db %10100100
 .db %10101110

 .db %00101010
 .db %00101010
 .db %00101100
 .db %10101010
 .db %11101010

 .db %10001010
 .db %10001110
 .db %10001110
 .db %10001010
 .db %11101010

 .db %11001110
 .db %10101010
 .db %10101010
 .db %10101010
 .db %10101110

 .db %11001110
 .db %10101010
 .db %11001010
 .db %10001110
 .db %10000110

 .db %11000110
 .db %10101000
 .db %11000100
 .db %10100010
 .db %10101100

 .db %11101010
 .db %01001010
 .db %01001010
 .db %01001010
 .db %01001110

 .db %10101010
 .db %10101010
 .db %10101010
 .db %01001110
 .db %01001010

 .db %10101010
 .db %10101010
 .db %01000100
 .db %10100100
 .db %10100100

 .db %11100100
 .db %00101010
 .db %01001110
 .db %10001010
 .db %11100100

 .db %10001100
 .db %10000100
 .db %01000100
 .db %00100100
 .db %00101100

 .db %01000000
 .db %10100000
 .db %00000000
 .db %00000000
 .db %00001110

 .db %10000000
 .db %01000110
 .db %00001010
 .db %00001010
 .db %00000110

 .db %10000000
 .db %11000110
 .db %10101000
 .db %10101000
 .db %11000110

 .db %00100000
 .db %01100100
 .db %10101010
 .db %10101100
 .db %01100110

 .db %01000110
 .db %10001010
 .db %11000110
 .db %10000010
 .db %10001100

 .db %10001000
 .db %11000000
 .db %10101000
 .db %10101000
 .db %10101000

 .db %00101000
 .db %00001000
 .db %00101010
 .db %10101100
 .db %01001010

 .db %11000000
 .db %01001010
 .db %01001110
 .db %01001010
 .db %01001010

 .db %00000000
 .db %11000100
 .db %10101010
 .db %10101010
 .db %10100100

 .db %00000000
 .db %11000110
 .db %10101010
 .db %11000110
 .db %10000010

 .db %00000000
 .db %10101100
 .db %11001000
 .db %10000100
 .db %10001100

 .db %10000000
 .db %11001010
 .db %10001010
 .db %10001010
 .db %01001110

 .db %00000000
 .db %10101010
 .db %10101010
 .db %01001110
 .db %01001010

 .db %00000000
 .db %10101010
 .db %01001010
 .db %01000100
 .db %10101000

 .db %00000110
 .db %11100100
 .db %00101000
 .db %01000100
 .db %11100110