Author Topic: Hooks  (Read 6245 times)

0 Members and 1 Guest are viewing this topic.

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
Hooks
« on: October 23, 2010, 12:28:15 pm »
Really plain question: What are hooks? (As you've probably guessed from that question, I don't know anything at all, so links would be great ;D) TInA!
« Last Edit: October 23, 2010, 12:28:25 pm by Deep Thought »




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: Hooks
« Reply #1 on: October 23, 2010, 12:58:13 pm »
I would have linked to http://wikiti.brandonw.net/index.php?title=Category:83Plus:Hooks:By_Name but it doesn't really explain what are hooks, it just lists them.

SirCmpwn

  • Guest
Re: Hooks
« Reply #2 on: October 23, 2010, 01:00:50 pm »
Hooks are assembly routines called by the OS in certain situations.  The parser hook, for instance, is run when a command is executed.  This is how xLib works.

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: Hooks
« Reply #3 on: October 23, 2010, 01:02:03 pm »
There are multiple types of hooks, though, right? Key kooks, parser hooks, etc...

SirCmpwn

  • Guest
Re: Hooks
« Reply #4 on: October 23, 2010, 01:03:23 pm »
Yep.  That page you linked to earlier has all of them ;)

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: Hooks
« Reply #5 on: October 23, 2010, 01:04:14 pm »
Oh wow I didn't realise every single of those were different types of hooks. I am noticing the parser hook in there now.

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: Hooks
« Reply #6 on: October 23, 2010, 01:06:14 pm »
Oh, thanks. I was just wondering if it'd be possible to make a hook that allows me to calculate something while inside the prgm editor (so that I don't have to quit and scroll all the way back down again just to check what 324*73 is). Can hooks even do something like that?




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: Hooks
« Reply #7 on: October 23, 2010, 01:09:31 pm »
It depends. Can hooks be real-time?

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: Hooks
« Reply #8 on: October 23, 2010, 01:30:17 pm »
That sounds possible. As for hooks, you basically look through that list to see where the closest hook is to what you will be doing. For your purposes, I would say you want the raw key hook. That hook is called any time the OS receives a key press. So lets say that you decide that VARS is going to be your goto button. You would have to find a ram area that you don't think is going to be killed in the near future. My favorite is smallEditRAM, no one knows about it so it is never used; it will persist through almost all games.

Then at smallEditRam you will make the code for your hook, your first line must be a .db $83, this is so the OS knows that it is calling a hook and not jumping to an outdated address. Since this ram area is pretty small ~170 bytes, I like to make the code at this area find the real program in the archive, and stream the real code into appBackUpScreen. Then for your hook, the first thing you want to do is figure out which button was pressed, and if it wasn't vars, quit. Then if it was vars, you probably want to have some other qualifier so that the vars button is not useless, like the ON button which doesn't trigger the hook.

So now you are ready to do your calculations. Remember that since you are editing a program, the edit buffer is open and there is 0 free ram available. And when your calculation is done, I'm not exactly sure how you would put the screen back to normal you'll have to ask someone else for that. A bcall(_jForceCMDNoChar) might do it, but I think that will go to the homescreen. Also, don't forget to enable the hook with it's corresponding enable bcall.

Edit:
   Now that I think about it, don't stream the info in on every single key press, you're calculator will be sooo slow. Instead, do the checks in smallEditRAM and then stream in your calculator GUI code when you get a match.
« Last Edit: October 23, 2010, 01:33:08 pm by thepenguin77 »
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 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: Hooks
« Reply #9 on: October 23, 2010, 02:34:26 pm »
Yeah what you mention in your edit was my concern. We must not make user input too slow either, same for scrolling through the program. MathPrint was slow enough like that x.x.

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: Hooks
« Reply #10 on: October 25, 2010, 11:57:43 am »
Thanks for the info. So here's what I've figured out so far:

The hook will find and run a program the way you suggested. The program will let the user input the equation on the final (eighth) line of the BASIC prgm editor, storing everything to some saferam area. And then it calls _ParseInp and copies the result into the editor. _JForceCmdNoChar doesn't work because it returns to the homescreen, so it's just going to simply quit and clear the last line.

Then I realized: _ParseInp requires that the input be stored to some equation variable. Since I can't create a new equation variable, I'm thinking of hacking the VAT to make Y1 or something point to the equation loaded in the saferam area where the actual expression's stored, then restoring the VAT later. Anyone know a reason why I shouldn't (like if it would be unstable)?
« Last Edit: October 25, 2010, 12:04:25 pm by Deep Thought »