Author Topic: about hooks..  (Read 13096 times)

0 Members and 5 Guests are viewing this topic.

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
about hooks..
« on: May 17, 2011, 07:23:39 pm »
Umm how does hooks work?:P i want to make a token like "csc("
please, detailed explanation :)

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: about hooks..
« Reply #1 on: May 17, 2011, 08:28:15 pm »
Well, what you're talking about is a "token" hook.  (There are many different kinds of hooks.)  You would have to pick a token to CHANGE to csc(.  Unfortunately you cannot create your own token.

So I can only give you a semi-detailed explination, since I do not know what token you would want to change to csc(.  You take the value of the token you want to change, multiply it by 2, and put the value in DE.  HL should point to the location in RAM that the zero-terminated (I think)  name of your token is located at.

http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9BC8

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: about hooks..
« Reply #2 on: May 17, 2011, 08:42:12 pm »
oh thanks :) and i want to change "sinh("(C8h) to "csc(" can you show me how should i do this?

 btw is it possible to hide the tokens?
« Last Edit: May 17, 2011, 08:53:06 pm by Hot_Dog »

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: about hooks..
« Reply #3 on: May 17, 2011, 08:53:57 pm »
Please refrain from double posting.  I combined your two posts into one.

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: about hooks..
« Reply #4 on: May 17, 2011, 09:00:48 pm »
alright thanks

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: about hooks..
« Reply #5 on: May 17, 2011, 09:29:07 pm »
Here you go. This is a sample implementation of what you want to do.
Code: [Select]
ld hl, tokenHook
ld de, smallEditRam ;nothing touches this, ever
ld bc, tokenHookEnd-tokenHook
ldir ;copy it to a place where it won't get destroyed

ld a, 1 ;1 means ram
ld hl, smallEditRam
bcall(_enableTokenHook)
ret




tokenHook:
.db $83 ;necessary for hooks, indicates that it hasn't been overwritten
push hl
ld hl, $C8*2
or a
sbc hl, de
add hl, de ;essentially, cp DE
pop hl
ret nz
ld hl, cscText-tokenHook+smallEditRam-1 ;give it a ptr 1 behind where it should be
ret ;I do not know why

cscText:
.db 4, "csc(" ;length, then string

tokenHookEnd:

If you are writing an App, then obviously you do not need to relocate this to smallEditRam. If you get some compiler errors, (you will), check this to get the equates you need. (Ctrl + F to find what you need)

Also, don't forget that just because you changed the words, it doesn't mean that you actually changed the function. For that, you are going to have to go into the scary world of parser hooks.

Lastly, I just remembered that I actually wrote a guide on this.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: about hooks..
« Reply #6 on: May 17, 2011, 10:24:18 pm »
Ah thank you :) and is it okay if i use .db     "csc(",0  instead of  .db     4, "csc("?
because the "sinh(" changes to "sc(..........", not "csc("

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: about hooks..
« Reply #7 on: May 17, 2011, 10:35:41 pm »
Ummm... Maybe. I thought I tried that and it didn't work. But if it works for you, then good. There must be a flag or something we don't know about.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: about hooks..
« Reply #8 on: May 17, 2011, 10:43:49 pm »
Oh well then:P and I spasm assembler gives me error on enableTokenHook. i dont think the ti83inc has it. what should i do?

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: about hooks..
« Reply #9 on: May 17, 2011, 10:48:20 pm »
Add
Code: [Select]
_enableTokenHook equ 4F99h
to your ti83plus.inc. And preferably, add it in where it fits alphabetically, just for organizing.

Sometimes brandonW doesn't always name the bcall's what you would expect. So to find that I had to ctrl + F: "tokenHook" to find the address for it in that big .inc file I linked to up top.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: about hooks..
« Reply #10 on: May 17, 2011, 10:56:00 pm »
oh now it works :) i found out why the token was looking weird.. it doesnt work with null terminated string :P aha too bad that Mimas only support null terminated string...:(

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: about hooks..
« Reply #11 on: January 12, 2012, 12:31:25 am »
Up !

I found this and now I use it, so thank you thepenguin77 :thumbsup:

TiAddict : to use hooks with Mimas, you must use the length and the hex codes of the ascii catacteres instead of the length and the string.

Code: [Select]
cscText:
.db 4,$63,$73,$63,$28
; instead of
.db 4,"csc("

And I've a question : with your code thepenguin77, how do you define several hooks in one file ?
« Last Edit: January 12, 2012, 12:37:46 am by Matrefeytontias »

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: about hooks..
« Reply #12 on: January 12, 2012, 10:40:22 am »
@Matrefeytontias: I'm glad you found this useful. The last post date was however 8 months ago, and TiAddict hasn't logged in to Omnimaga in 5 months. It's possible he may not see your post. :P

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: about hooks..
« Reply #13 on: January 12, 2012, 11:58:47 am »
Wow, I am glad you posted here because I find this useful, too ! I do have experience with hokks, so what do you mean by several hooks? Do you mean like changing several names and commands or do you mean like a font hook, parser hook, and token hook in one app?

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: about hooks..
« Reply #14 on: January 12, 2012, 12:42:37 pm »
No, change several names, sorry ^^