Author Topic: Menu hook  (Read 2702 times)

0 Members and 1 Guest are viewing this topic.

Offline bored_student

  • LV3 Member (Next: 100)
  • ***
  • Posts: 44
  • Rating: +3/-0
    • View Profile
Menu hook
« on: October 16, 2013, 12:05:41 pm »
I have a question.
Can menu hooks be used to block or hide certain menu entries of the TI-OS menus.
Sorry for my bad English, I'm German.

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: Menu hook
« Reply #1 on: October 17, 2013, 06:36:28 pm »
Yes, I've done this before to add an option to a menu.

Now, there are two ways to do this, method 1 will only work for a specific OS (well, it will work unless they changed the menu), while method 2 will always work. I'm only going to talk about method 1 though because looking at my code, you don't want to do method 2.

The first thing you have to do is find the actual data for the menu you want to replace. To do this, set a menu hook that returns zero, set a breakpoint on the menu hook, and then open the menu you want to replace. Skip the first call (A = 4) and on the second call (A = 0) follow the function when it returns. It's going to "un-bcall" a few times but eventually you'll end up back where the hook was called. When it does LD A, ($85DE), you'll know that you're back. Take note of A because it's the value for the current menu. It's then going to do a little math and load HL with the value pointed to by HL. When it does this, HL is now pointing to the data for the menu.

Look at wikiti to see how the data is represented and then copy down everything for the menu (make sure you're still on the right flash page). (If there are 2 submenus, it's going to be the initial size byte, and then two of those data structures). Once you have the menu data, you need to figure out which item it is that you want to remove (you can probably just count). Remove those two bytes and readjust the size byte of that menu subgroup. This is now the actual menu you want to display.

To actually replace the menu. Make a menu hook and returns zero unless ($85DE) (it's called menuCurrent btw) equals the A value from before. (You can also look these values up by doing a ctrl + F "menuCurrent" on this page) The hook also needs to return zero if it's been called for any event besides A = 0. At this point, you need to have the menu data in ram. Just point HL to the menu data and return nz. The OS will handle the rest from here ;D
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 bored_student

  • LV3 Member (Next: 100)
  • ***
  • Posts: 44
  • Rating: +3/-0
    • View Profile
Re: Menu hook
« Reply #2 on: October 18, 2013, 01:47:19 pm »
I first tried to block the entries by returning with the zero flag reset on the first call (A=4) of the hook.
It didn't work well so I asked me if there's another way.

I'm going to try this when I'm coming home next week.

Maybe I will ask another question then, but for now thank you a lot   :D
Sorry for my bad English, I'm German.