home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / routines / centered.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  1.3 KB  |  58 lines

  1. ;these are two routines for displaying centered text in both the large and small font.
  2. ;the input to both is basically the same.
  3. ;
  4. ; - for puts_center to be centered on the screen, d=10
  5. ; - for vputs_center to be centered on the screen, d=64
  6. ;
  7. ;-Jonah Cohen            <ComAsYuAre@aol.com>
  8.  
  9. #include <ti86asm.inc>        ;ACZ include file contains all rom calls used
  10.  
  11.  
  12. puts_center:
  13.     ;display centered string pointed to by hl in large font
  14.     ;input:
  15.     ;    hl->string
  16.     ;    a=row to display on
  17.     ;    d=middle column
  18.     ld (_curRow),a
  19.     call _strlen                ;c=size of string
  20.     srl c                    ;divide by 2
  21.     ld a,d                ;center column
  22.     sub c                ;a=start column
  23.     ld (_curCol),a
  24.     jp _puts                ;display line
  25.  
  26.  
  27. vputs_center:
  28.     ;display centered string pointed to by hl in small font
  29.     ;input:
  30.     ;    hl->string
  31.     ;    a=row to display on
  32.     ;    d=middle column
  33.     push hl
  34.     push de
  35.     ld (_penRow),a            ;set pen row
  36.     ld e,0                ;length
  37. get_size:
  38.     ld a,(hl)                ;get next byte
  39.     or a                    ;check if a=0
  40.     jr z,got_size            ;finished getting size
  41.     push hl
  42.     push de
  43.     call _get_vchar            ;hl->size of char
  44.     pop de
  45.     ld a,(hl)                ;get size
  46.     add a,e                ;add to cumulative length
  47.     ld e,a                ;save
  48.     pop hl
  49.     inc hl                    ;next byte
  50.     jr get_size
  51. got_size:
  52.     srl e                    ;divide by 2
  53.     pop af                ;center column
  54.     sub e                ;a=center column
  55.     ld (_penCol),a
  56.     pop hl                ;retrieve start of text
  57.     jp _vputs                ;print the text
  58.