Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
Ian Z


Member


Joined: 28 Jun 2004
Posts: 111

Posted: 12 Oct 2004 03:21:16 pm    Post subject:

Keyhooks:


Because of many questions around the boards about keyhooks, I've taken the liberty of explaining them, and hopefully those who do not understand them, will.

What Is a Keyhook?
Simple. A keyhook is a program, that is run on the TI-OS, after the _getkey routine if one is installed. Here is a simple array of what happens when a key is pressed on the TI-OS (when no program or app is running):

1.) B_CALL(_Getkey) is routine waiting for a keypress. (If ON or 2nd+ON is pressed the OS handles it here, rather than going to any number below)
2.) (a key has been pressed) Checks to see if keyhook is installed if so goto 3, if not goto 4
3.) Transfers control to where in RAM the keyhook program is installed. Once the program "rets" then it goes to number 4
4.) TI-OS will do something depending on what key code is returned in register a. If zero is returned it goes back to number 1.

Now, then how do you install a keyhook? Well, first just install the routine you want to run into a safe RAM area. Next, load the address where you stored the routine in hl. Next get the memory mapping page with in, a(06) ( port 06 is a memory mapping port.). Then install the keyhook with B_CALL(4F66h). Here is an example of the outline explained above in source code:

#define B_CALL(xxxx) rst 28h \ .dw xxxx
appbackupscreen = 9872h
.org 9D95h
ld hl, keyhook ;The label of the keyhook
ld de, appbackupscreen ; it will be saved at the appbackupscreen
ld bc, hook_end-keyhook ; this is the number of bytes the routine is
ldir ; copy it into appbackupscreen (safe RAM area) Not needed if ;an application is doing this
ld hl, appbackupscreen ; tell the TI-OS where the keyhook is
in a, (06h) ; get the memory page
B_CALL(4F66h) ; undocumented call that installs it
ret
keyhook: ; this routine will be the keyhook
.org appbackupscreen ; if you use a jump it will be to one of the RAM areas where the keyhook ;is stored
add a,e ; you will need this for any keyhook. It's needed for the op-;code
;put your hook data here!!! Don't leave it blank.
hook_end:
.end

If your still confused, Here is an example:

#define B_CALL(xxxx) rst 28h \ .dw xxxx
appbackupscreen = 9872h
.org 9D95h
ld hl, keyhook ; same code from above...
ld de, appbackupscreen
ld bc, hook_end-keyhook
ldir
ld hl, appbackupscreen
in a, (06h)
B_CALL(4F66h)
ret
keyhook:
.org appbackupscreen
add a,e
cp 36h ;36h is the key code for the [2nd]+[MEM] key. See if it has been pressed
jr z, disable ; if so disable it
ret ; if not just quit
disable:
xor a
ret
hook_end:
.end

Uninstalling a keyhook:
To uninstall a keyhook just use B_CALL(4F6Fh). Or temporarily with res 5, (IY+34h). If you do that then you can re-install it with set 5, (IY+34h).
If you have any more questions on keyhooks, I'll be happy to answer any of them.

As an additional note, there is also something called parser hooks as well.


Last edited by Guest on 18 Oct 2004 02:21:05 pm; edited 1 time in total
Back to top
nathanpetersenn


Newbie


Joined: 11 Apr 2012
Posts: 4

Posted: 12 Apr 2012 10:43:52 pm    Post subject:

Hey! I'm a newbie at asm but I'm pretty good at TI Basic. I wrote a math assistant program and then converted it to a app via the basicbuilder application for windows. Long story short, I have a app.

I would like to run the app when a key sequence is pressed, similar to MirageOS and its [ON]+[APPS] hook.

HOW THE HECK DO I DO THIS! I've been looking around all over the internet for hooks and how to use them and such... I have a small understanding of them but whenever I get sample code for a hook, it never works. I don't know enough about asm to debug the program, so I look for a new example. (I have a compiler and all that [I made a "Hello World!" program so I know it works]) Could you perhaps modify your program so that [ON]+[PROGRAM] starts an app? Idk if its useful but I'm using a 84+SE and my app name is AAAMathy.

If anything, point me in the right direction so I can make this keyhook. THANKS!
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

Advertisement