home *** CD-ROM | disk | FTP | other *** search
- ;--------= put string centered =--------
- ; Author: Ian Graf
- ; (ian_graf@geocities.com)
- ; Platform: TI-83 Assembly
- ; Version: 1.0
- ; Date: 10/6/98
- ;---------------------------------------
- ; to use this routine load hl with the
- ; location of the string to center on
- ; the graph screen. the string will be
- ; drawn centered at penrow.
- ;
- ; ex:
- ;
- ; ld hl,somestring
- ; call vputsc
- ;
- ; feel free to use this in your own
- ; programs, but please give me credit.
- ;---------------------------------------
-
-
- #define sfontlen $4A6C
- #define vputs $4781
- #define pencol $8252
-
-
- ;--------= put string centered =--------
- ; input: hl - string
- ; penrow - row
- ; output: string drawn centered/
- ; cliped
-
- vputsc: push hl ;
- call getlength ; get length of string
- ld b,e ;
- xor a ;
- countl: push bc ;
- push hl ;
- push af ;
- ld a,(hl) ; get character
- ld h,0 ;
- ld l,a ;
- add hl,hl ; hl = hl*8
- add hl,hl ;
- add hl,hl ;
- call sfontlen ; get char width
- pop af ;
- cp 93 ; clip?
- jr nc,contc ;
- add a,b ;
- contc: pop hl ;
- inc hl ;
- pop bc ;
- djnz countl ;
- ld b,a ; center string
- ld a,96 ;
- sub b ;
- srl a ;
- ld (pencol),a ;
- pop hl ;
- jp vputs ; draw string
-
-
- ;--------= get length of string =-------
-
- getlength:
- ld bc,100 ; get length of string in hl
- xor a ; max length 100 chars
- push hl ; (the max length can be changed
- cpir ; to fit your needs)
- ld hl,99 ;
- sbc hl,bc ;
- ex de,hl ;
- pop hl ;
- ret ; de = length
-
-