Difference between revisions of "Z80 Routines:Graphic:Bub4font"

From WikiTI
Jump to: navigation, search
 
m
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  ; dwedit's bub_font routine modified with  
+
[[Category:Z80 Routines:Graphic|Bub4font]]
; harper maddox's 4*4 galaxy font (expanded)
+
[[Category:Z80 Routines|Bub4font]]
; by guillaume h.
+
  <nowiki>
; june 2004
+
; dwedit's bub_font routine modified with  
+
; harper maddox's 4*4 galaxy font (expanded)
; displayable characters go from $20 (space) to $5A (Z)
+
; by guillaume h.
; they include : capital letters, digits, and some punctuation
+
; june 2004
+
 
;  !"#$%&'()*+,-./
+
; displayable characters go from $20 (space) to $5A (Z)
; 0123456789:;<=>?
+
; they include : capital letters, digits, and some punctuation
; @ABCDEFGHIJKLMNO
+
 
; PQRSTUVWXYZ
+
;  !"#$%&'()*+,-./
+
; 0123456789:;<=>?
; remarks :
+
; @ABCDEFGHIJKLMNO
;  $24 is "power 4" in ti's font, but a dollar sign in normal ascii
+
; PQRSTUVWXYZ
;      in this font, it's gonna be a block, because drawing a dollar sign
+
 
;      because drawing one in 4*4 is hard..
+
 
+
; remarks :
; $5B is a space right now, it is a theta in ti's ascii and a '['
+
;  $24 is "power 4" in ti's font, but a dollar sign in normal ascii
; 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..
FONT_HEIGHT equ 4
+
 
+
; $5B is a space right now, it is a theta in ti's ascii and a '['
appvputs
+
; in normal ascii
  ld a,(hl)
+
 
  inc hl  
+
FONT_HEIGHT equ 4
  or a
+
 
  ret z
+
appvputs
  push hl
+
ld a,(hl)
  call appvputmap
+
inc hl
  pop hl
+
or a
  jr appvputs
+
ret z
+
push hl
appvputmap
+
call appvputmap
  sub $20
+
pop hl
  ld l,a
+
jr appvputs
  srl l
+
 
  ld h,0
+
appvputmap
  add hl,hl
+
sub $20
  add hl,hl  ; multiplication by 4 = FONT_HEIGHT
+
ld l,a
  ld de,fontdata
+
srl l
  add hl,de
+
ld h,0
  ld de,bytes4
+
add hl,hl
  ld b,FONT_HEIGHT
+
add hl,hl  ; multiplication by 4 = FONT_HEIGHT
  and 1
+
ld de,fontdata
  jr z,unshiftedchar
+
add hl,de
shiftedcharloop:
+
ld de,bytes4
  ld a,(hl)
+
ld b,FONT_HEIGHT
  add a,a
+
and 1
  add a,a
+
jr z,unshiftedchar
  add a,a
+
shiftedcharloop:
  add a,a
+
ld a,(hl)
  ld (de),a
+
add a,a
  inc hl
+
add a,a
  inc de  
+
add a,a
  djnz shiftedcharloop
+
add a,a
  jr fontskip
+
ld (de),a
unshiftedchar:
+
inc hl
  ld a,(hl)
+
inc de
  and %11110000
+
djnz shiftedcharloop
  ld (de),a
+
jr fontskip
  inc hl
+
unshiftedchar:
  inc de
+
ld a,(hl)
  djnz unshiftedchar
+
and %11110000
fontskip:
+
ld (de),a
  ld ix,bytes4
+
inc hl
  ld hl,(pencol)
+
inc de
  ld a,l
+
djnz unshiftedchar
  ld l,h
+
fontskip:
  inc l
+
ld ix,bytes4
  ld bc,256*FONT_HEIGHT+1
+
ld hl,(pencol)
  call largesprite
+
ld a,l
 +
ld l,h
 +
inc l
 +
ld bc,256*FONT_HEIGHT+1
 +
call largesprite     ; or any sprite routine that fits
 
  ;advance
 
  ;advance
  ld hl,pencol
+
ld hl,pencol
  ld a,(hl)
+
ld a,(hl)
  add a,6
+
add a,6
  ld (hl),a
+
ld (hl),a
  ld c,%00001000
+
ld c,%00001000
findwidthloop:
+
findwidthloop:
  dec (hl)
+
dec (hl)
  ld a,c
+
ld a,c
  add a,a
+
add a,a
  ret z
+
ret z
  ld c,a
+
ld c,a
  ld de,bytes4
+
ld de,bytes4
  ld b,FONT_HEIGHT
+
ld b,FONT_HEIGHT
findwidthloop2:
+
findwidthloop2:
  ld a,(de)
+
ld a,(de)
  and c
+
and c
  ret nz
+
ret nz
  inc de
+
inc de
  djnz findwidthloop2
+
djnz findwidthloop2
  jr findwidthloop  
+
jr findwidthloop
+
bytes4:
+
bytes4:
  db 0,0,0,0
+
db 0,0,0,0
+
 
fontdata:
+
fontdata:
  db %00001000
+
db %00001000
  db %00001000 ; (space) !
+
db %00001000 ; (space) !
  db %00000000
+
db %00000000
  db %00001000
+
db %00001000
+
 
  db %10100101
+
db %10100101
  db %10101111 ; " #
+
db %10101111 ; " #
  db %00000101
+
db %00000101
  db %00001111
+
db %00001111
+
 
  db %11111010
+
db %11111010
  db %11110100 ; $ (block) %
+
db %11110100 ; $ (block) %
  db %11111000
+
db %11111000
  db %11111010
+
db %11111010
+
 
  db %01001000 ; & '
+
db %01001000 ; & '
  db %11101000
+
db %11101000
  db %10100000
+
db %10100000
  db %01010000
+
db %01010000
+
 
  db %01001000
+
db %01001000
  db %10000100 ; ( )
+
db %10000100 ; ( )
  db %10000100
+
db %10000100
  db %01001000
+
db %01001000
+
 
  db %00000000 ; * +
+
db %00000000 ; * +
  db %10100100
+
db %10100100
  db %01001110
+
db %01001110
  db %10100100
+
db %10100100
+
 
  db %00000000
+
db %00000000
  db %00000000 ; , -
+
db %00000000 ; , -
  db %01001110
+
db %01001110
  db %10000000
+
db %10000000
+
 
  db %00000001 ; . /
+
db %00000001 ; . /
  db %00000010
+
db %00000010
  db %00000100
+
db %00000100
  db %10001000
+
db %10001000
+
 
  db %11101000 ;0  1
+
db %11101000 ;0  1
  db %10101000
+
db %10101000
  db %10101000
+
db %10101000
  db %11101000
+
db %11101000
+
 
  db %11101110 ; 2 3
+
db %11101110 ; 2 3
  db %00100110
+
db %00100110
  db %11000010
+
db %11000010
  db %11101110
+
db %11101110
+
 
  db %10101110
+
db %10101110
  db %10101100 ; 4 5
+
db %10101100 ; 4 5
  db %11100010
+
db %11100010
  db %00101110
+
db %00101110
+
 
  db %10001110 ; 6 7
+
db %10001110 ; 6 7
  db %11100010
+
db %11100010
  db %10100010
+
db %10100010
  db %11100010
+
db %11100010
+
 
  db %11101110 ; 8 9
+
db %11101110 ; 8 9
  db %11101010
+
db %11101010
  db %10101110
+
db %10101110
  db %11100010
+
db %11100010
+
 
  db %00000100
+
db %00000100
  db %10000000 ; : ;
+
db %10000000 ; : ;
  db %00000100
+
db %00000100
  db %10001000
+
db %10001000
+
 
  db %00000000
+
db %00000000
  db %01001110 ; < =
+
db %01001110 ; < =
  db %10000000
+
db %10000000
  db %01001110
+
db %01001110
+
 
  db %00001110
+
db %00001110
  db %10000010 ; > ?
+
db %10000010 ; > ?
  db %01000000
+
db %01000000
  db %10000100
+
db %10000100
+
 
  db %01100100
+
db %01100100
  db %10101010
+
db %10101010
  db %11101110 ; @ A
+
db %11101110 ; @ A
  db %01101010
+
db %01101010
+
 
  db %11101100
+
db %11101100
  db %11101000
+
db %11101000
  db %10101000 ; B C
+
db %10101000 ; B C
  db %11101100
+
db %11101100
+
 
  db %11001100
+
db %11001100
  db %10101100 ; D E
+
db %10101100 ; D E
  db %10101000
+
db %10101000
  db %11001100
+
db %11001100
+
 
  db %11001110 ; F G
+
db %11001110 ; F G
  db %11001000
+
db %11001000
  db %10001010
+
db %10001010
  db %10001110
+
db %10001110
+
 
  db %10101000
+
db %10101000
  db %10101000 ; H I
+
db %10101000 ; H I
  db %11101000
+
db %11101000
  db %10101000
+
db %10101000
+
 
  db %00101010
+
db %00101010
  db %00101010 ; J K
+
db %00101010 ; J K
  db %10101100
+
db %10101100
  db %11101010
+
db %11101010
+
 
  db %10001110
+
db %10001110
  db %10001110 ; L M
+
db %10001110 ; L M
  db %10001010
+
db %10001010
  db %11001010
+
db %11001010
+
 
  db %11001110
+
db %11001110
  db %10101010 ; N O
+
db %10101010 ; N O
  db %10101010
+
db %10101010
  db %10101110
+
db %10101110
+
 
  db %11101110 ; P Q
+
db %11101110 ; P Q
  db %10101010
+
db %10101010
  db %11101110
+
db %11101110
  db %10001110
+
db %10001110
+
 
  db %11101100
+
db %11101100
  db %10101000 ; R S
+
db %10101000 ; R S
  db %11000100
+
db %11000100
  db %10101100
+
db %10101100
+
 
  db %11101010 ; T U
+
db %11101010 ; T U
  db %01001010
+
db %01001010
  db %01001010
+
db %01001010
  db %01001110
+
db %01001110
+
 
  db %10101010
+
db %10101010
  db %10101010 ; V W
+
db %10101010 ; V W
  db %10101110
+
db %10101110
  db %01001110
+
db %01001110
+
 
  db %10101010
+
db %10101010
  db %10101010
+
db %10101010
  db %01000100 ; X Y
+
db %01000100 ; X Y
  db %10100100
+
db %10100100
+
 
  db %11000000
+
db %11000000
  db %01000000 ; Z
+
db %01000000 ; Z
  db %10000000
+
db %10000000
  db %11000000
+
db %11000000
 +
</nowiki>

Latest revision as of 14:13, 26 October 2009

; 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