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

  1. ;The _substr routine didn't work last time, the new one will (thanks Jonah =p)
  2. ;-}InFuZeD{
  3.     .org $D748    ;_asm_exec_ram
  4.  
  5. Program:
  6.     ld hl,DemoString
  7.     ld b,15
  8.     ld c,2
  9.     call _substr
  10.     call _strpixels
  11.     ld a,128
  12.     sub c
  13.     rra
  14.     ld ($C37C),a
  15.     xor a
  16.     ld ($C37D),a
  17.     ld hl,$C0F9
  18.     call 4AA5h    ;_vputs
  19.     jp 55AAh    ;_getkey
  20.  
  21.  
  22. DemoString:
  23.     .db "_This Is Centered_",0
  24.  
  25. ;Find The Length (# Of Characters) Of The String Pointed To By HL
  26. ;-=-=--=-=-=-=-==-=--=-=-=-===-=-=-=-=-==--=-=-==-=-=-==--=-=-==-
  27. ;Input: HL = Pointer to Zero-Terminated String
  28. ;Output: A = Length Of String
  29. ;Destroys: HL, BC, A
  30. ;=-=-=-=-=-===-=-=-=-=-=-===-=-=-=-=--==--=-=-===-=-=-=-===-=-=-=
  31. _strlen:
  32.     xor a
  33.     ld c,a
  34.     cpir
  35.     dec a
  36.     sub c
  37.     ret
  38.  
  39. ;Get A Piece Of A String - Thanks To Jonah For Improving It (Then fixing it)
  40. ;-=-=--=-=-=-=-==-=--=-=-=-===-=-=-=-=-==--=-=-==-=-=-==--=-=-==-
  41. ;Input:
  42. ;        HL = Pointer To String
  43. ;        E = First Character
  44. ;        D = How Many Characters After The First
  45. ;Output: HL points to your new string (_textShadow)
  46. ;Destroys: All Registers
  47. _substr:
  48.  dec e
  49.  ld d,0
  50.  add hl,de
  51.  ld b,d
  52.  ld de,$C0F9
  53.  push de
  54.  ldir
  55.  pop hl
  56.  ret
  57.  
  58. ;Find The Length (# Of Pixels) Of The String Pointed To By HL (_vputs text)
  59. ;-=-=--=-=-=-=-==-=--=-=-=-===-=-=-=-=-==--=-=-==-=-=-==--=-=-==-
  60. ;Input: HL = Pointer to Zero-Terminated String
  61. ;Output: C = Length Of String (Pixels)
  62. ;Destroys: All Registers
  63. ;=-=-=-=-=-===-=-=-=-=-=-===-=-=-=-=--==--=-=-===-=-=-=-===-=-=-=
  64. _strpixels:
  65.     ld c,0
  66. _strpl:
  67.     ld a,(hl)
  68.     or a
  69.     ret z
  70.     push hl
  71.     call $56A1        ;_get_vchar
  72.     ld a,(hl)
  73.     add a,c
  74.     ld c,a
  75.     pop hl
  76.     inc hl
  77.     jr _strpl
  78.     
  79.     
  80.  
  81.  
  82.  
  83. .end
  84.