Advertisement
Zeda

TokenHook Template

Mar 10th, 2014
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     call SetTokenHook
  2.     bcall(4027h)
  3. TokenTable:
  4. ; format: .dw 2*tokenID \ .db bytelength,newstring
  5. ; End the table with a .db 0
  6. ;
  7. ; For example, 'prgm' is 5Fh, so twice that is 00BE. To replace it with "Run ":
  8. ;    .dw $00BE \ .db 4,"Run "
  9.  
  10.  
  11.     .dw $00BE \ .db 4,"Run "
  12.     .db 0   ;keep this for your End-Of-Table
  13.  
  14. SetTokenHook:
  15. ;  This sets the token hook to your token hook if others are installed
  16. ;  If yours is already installed, it toggles it on/off
  17.     in a,(6)
  18.     ld hl,9BCAh
  19.     cp (hl)
  20.     ld hl,TokenHook
  21. ;Manually setting hook
  22.     ld (9BC8h),hl
  23.     ld (9BCAh),a
  24.     jr nz,$+13
  25.     bit 0,(iy+35h)
  26.     jr z,$+7
  27.     res 0,(iy+35h)
  28.     ret
  29.     set 0,(iy+35h)
  30.     ret
  31. tokenHook:
  32.      .db $83
  33.      ld a,b
  34.      or a
  35.      ret nz
  36.      push hl
  37.      ld hl,TokenTable
  38.      ld b,0
  39. TokenSearchLoop:
  40.        ld a,e
  41.        cp (hl)
  42.        inc hl
  43.        jr z,ChkByte2
  44. NotTokenMatch:
  45.        inc hl
  46.        ld c,(hl)
  47.        inc c
  48.        add hl,bc
  49.        ld a,(hl)
  50.        or a
  51.        jr nz,TokenSearchLoop
  52.      pop hl
  53.      ret
  54. ChkByte2:
  55.      ld a,d
  56.      cp (hl)
  57.      jr nz,NotTokenMatch
  58.      ex (sp),hl
  59.      pop hl
  60.      ld de,8478h
  61.      push de
  62.      inc hl
  63.      ld c,(hl)
  64.      inc c \ inc c
  65.      dec hl
  66.      ldir
  67.      pop hl
  68.      ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement