Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Xeda112358 on April 24, 2012, 10:37:21 pm

Title: MenuHook Findings
Post by: Xeda112358 on April 24, 2012, 10:37:21 pm
I was playing with an idea that I found on TIBD. I thought that it would be really cool if we could open the string menu or Pic menu and have access to all 256 tokens. Sorry if I got your hopes up, because that has failed (so far). To get it to work, I might have to do a hackjob, but I did uncover a random tidbit of info.

When the OS calls your hook, if it is sending A=1, then you will want to exit with the z flag set. I do this with xor a \ ret. What I found was that we can change the token to be displayed from here without having to write a whole table. How do we do this? DE contains a extended keycode that maps to a token. All you have to do is change this value and the token that will be displayed gets changed. What I did, since my tokens were based on the menu item number and the token was arbitrary:
Code: [Select]
;E contains the Pic number
     ld d,60h            ;Start of a Pic token
     bcall(_TokToKey)    ;4A0Bh   Stores the extended key code to 8446h, A has the rest
     ld de,(8446h)       ;E know has the extended value
     ld d,a              ;DE now has the whole keycode
     xor a
     ret
I don't know where else this might prove useful, but have fun :)
Title: Re: MenuHook Findings
Post by: thepenguin77 on April 25, 2012, 06:40:46 pm
I don't remember the specifics, but I know in one of the early menu hook calls, you get to specify the table that it looks at. With a little bit of OS debugging, you can figure out the format of those tables, and from there you can design your own table which includes whatever you want in the menu.

This is how I added Solver++ to the math menu in zStart a while ago.
Title: Re: MenuHook Findings
Post by: Xeda112358 on April 26, 2012, 07:06:46 am
Yeah, you can define your own table, but I was looking for a way to change only certain menu items without having to make a table. Of course, it probably would be easier to just use a table, but hey, it's good to have options :)

You can also use this idea when the hook is exiting (I think A=4) and you can change which token gets pasted.
Title: Re: MenuHook Findings
Post by: thepenguin77 on April 26, 2012, 04:45:55 pm
Yeah, you can define your own table, but I was looking for a way to change only certain menu items without having to make a table. Of course, it probably would be easier to just use a table, but hey, it's good to have options :)

Well, that's actually what I did. I ran a search for the MATH table and then modified it and used it as my own table. It worked on all OS's, so it was pretty cool.
Title: Re: MenuHook Findings
Post by: Xeda112358 on April 26, 2012, 04:54:36 pm
Hmm, I assume you copied the table to RAM? I was looking at avoiding that :/ Or is automatically copied to RAM? I haven't checked yet.
Title: Re: MenuHook Findings
Post by: thepenguin77 on April 26, 2012, 05:03:47 pm
Yes, I did copy it to ram. So you'll have to deal with that if you do it.
Title: Re: MenuHook Findings
Post by: Xeda112358 on April 26, 2012, 05:14:55 pm
Yeah, the reason why I was avoiding that was because the menu was going to need 255 elements. I figured that it would be easier to draw the tokens based on a formula.