Author Topic: Saving previous hook states  (Read 6770 times)

0 Members and 1 Guest are viewing this topic.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Saving previous hook states
« on: November 11, 2010, 01:53:08 pm »
Suppose that someone has Celtic III, Omnimaga or Xlib installed.  If another program uses the parser hook, is there anything that program can do to save and restore the installations of Celtic III and Xlib?  For example, suppose a program uses the parser hook when Xlib was installed.  When the program exits, is there any way to make sure Xlib is installed again?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Saving previous hook states
« Reply #1 on: November 11, 2010, 01:57:19 pm »
I think what you are referring to chaining of hooks, like how Omnicalc and Axe can both have hooks running at the same time.  Im not quite sure how to do it though D:


...On a separate note, what is the Omnimaga lib?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Saving previous hook states
« Reply #2 on: November 11, 2010, 02:02:33 pm »
I think he needs to disable the hooks, then re-enable them: http://ourl.ca/7858

I have no idea, though, sorry.

...On a separate note, what is the Omnimaga lib?

http://www.omnimaga.org/index.php?action=library
« Last Edit: November 11, 2010, 02:02:46 pm by Deep Thought »




Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Saving previous hook states
« Reply #3 on: November 11, 2010, 02:04:07 pm »
I think what you are referring to chaining of hooks, like how Omnicalc and Axe can both have hooks running at the same time.  Im not quite sure how to do it though D:


...On a separate note, what is the Omnimaga lib?

Actually, chaining would be nice.  Quigibo, how do you do it?
« Last Edit: November 11, 2010, 02:04:42 pm by Hot_Dog »

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: Saving previous hook states
« Reply #4 on: November 11, 2010, 03:35:40 pm »
Restoring hooks is easy when you know how they work. For each hook, there is a 3 byte area of ram and a flag. The ram is 2 bytes of the address followed by the page byte. And the flag is as simple as on/off. Here's the wikiti page on the parser hook. As you can see, its ram is at $9BAC and its flag is 1, (iy + $36).

As far as backing up goes, that's pretty easy. Save the three bytes as $9BAC and that flag. Then when you are done, just restore them.

But chaining is a little more difficult. First, you are going to have to get the information from those areas, but save them somewhere where you can find them later (this can be difficult sometimes.) Then install your hook. Now when your hook is called you do your thing, but when you are done, you need to put the calculator right back in the state you found it and jump to the address you just saved. If you have any differences in calculator state, the other hook won't know what to do and you'll run into problems. And of course, if you need to return a value to the OS, you won't be jumping to the other hook.
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 Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Saving previous hook states
« Reply #5 on: November 11, 2010, 04:35:22 pm »
Restoring hooks is easy when you know how they work. For each hook, there is a 3 byte area of ram and a flag. The ram is 2 bytes of the address followed by the page byte. And the flag is as simple as on/off. Here's the wikiti page on the parser hook. As you can see, its ram is at $9BAC and its flag is 1, (iy + $36).

As far as backing up goes, that's pretty easy. Save the three bytes as $9BAC and that flag. Then when you are done, just restore them.

But chaining is a little more difficult. First, you are going to have to get the information from those areas, but save them somewhere where you can find them later (this can be difficult sometimes.) Then install your hook. Now when your hook is called you do your thing, but when you are done, you need to put the calculator right back in the state you found it and jump to the address you just saved. If you have any differences in calculator state, the other hook won't know what to do and you'll run into problems. And of course, if you need to return a value to the OS, you won't be jumping to the other hook.

Thanks, thepenquin!  I had no idea of the $9BAC area.

So, does anyone know which areas of RAM the hook code for Xlib, Celtic III and Omnicalc are?  I want to make sure I find a safe spot for my hook code
« Last Edit: November 11, 2010, 04:37:30 pm by Hot_Dog »

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: Saving previous hook states
« Reply #6 on: November 11, 2010, 06:19:46 pm »
Get on wabbitemu, clear your ram. Then install an app and check the memory around $9BAC. You should see mostly 00's, but there should be a few 3 byte strings. Depending on which app page those strings give, you can tell which app sent out the hook. (You can use omnicalc to figure out which app is on which page.) Then use brandonW's ti83plus.inc to figure out which hook it is.
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 Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Saving previous hook states
« Reply #7 on: November 11, 2010, 06:28:58 pm »
Get on wabbitemu, clear your ram. Then install an app and check the memory around $9BAC. You should see mostly 00's, but there should be a few 3 byte strings. Depending on which app page those strings give, you can tell which app sent out the hook. (You can use omnicalc to figure out which app is on which page.) Then use brandonW's ti83plus.inc to figure out which hook it is.

Oh, duh, the code is run from the applications themselves.  I'm using appbackupscreen for my parser hook since it's copied from pgrmTEXT

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: Saving previous hook states
« Reply #8 on: November 11, 2010, 06:30:58 pm »
Use smallEditRam, it will persist through most Asm programs. It's only 117 bytes, but that's enough to find code in the archive and stream it to appBackUpScreen.
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 Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Saving previous hook states
« Reply #9 on: November 11, 2010, 06:34:15 pm »
Use smallEditRam, it will persist through most Asm programs. It's only 117 bytes, but that's enough to find code in the archive and stream it to appBackUpScreen.

My goal is to have an ASM program and to use Ti-Basic hooks for it.  What would I need smallEditRam for?  I'm confused :O

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Saving previous hook states
« Reply #10 on: November 11, 2010, 06:36:53 pm »
Restoring hooks is easy when you know how they work. For each hook, there is a 3 byte area of ram and a flag. The ram is 2 bytes of the address followed by the page byte. And the flag is as simple as on/off. Here's the wikiti page on the parser hook. As you can see, its ram is at $9BAC and its flag is 1, (iy + $36).

As far as backing up goes, that's pretty easy. Save the three bytes as $9BAC and that flag. Then when you are done, just restore them.

But chaining is a little more difficult. First, you are going to have to get the information from those areas, but save them somewhere where you can find them later (this can be difficult sometimes.) Then install your hook. Now when your hook is called you do your thing, but when you are done, you need to put the calculator right back in the state you found it and jump to the address you just saved. If you have any differences in calculator state, the other hook won't know what to do and you'll run into problems. And of course, if you need to return a value to the OS, you won't be jumping to the other hook.

Thanks, thepenquin!  I had no idea of the $9BAC area.

So, does anyone know which areas of RAM the hook code for Xlib, Celtic III and Omnicalc are?  I want to make sure I find a safe spot for my hook code
Doors CS too, since it also has backwards xLIB/CIII/Omnicalc compatibility plus many other functions. Hopefully you can find some spot somewhere, although it might be best to ask one of the author of those programs.

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: Saving previous hook states
« Reply #11 on: November 11, 2010, 06:37:19 pm »
SmallEditRam is my favorite ram location because nothing uses it. You can put a hook there and a week later, it will still be there. Appbackupscreen gets killed by almost every single asm program. Not to mention omnicalc uses it quite a bit for hook activities.

I am saying put your hook code in smallEditRam because you don't have to worry about it getting overwritten.
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 Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Saving previous hook states
« Reply #12 on: November 11, 2010, 06:38:53 pm »
SmallEditRam is my favorite ram location because nothing uses it. You can put a hook there and a week later, it will still be there. Appbackupscreen gets killed by almost every single asm program. Not to mention omnicalc uses it quite a bit for hook activities.

I am saying put your hook code in smallEditRam because you don't have to worry about it getting overwritten.

Oh, that makes a lot of sense!  I'll definitely keep it in mind