Author Topic: Key Code hacking  (Read 3661 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Key Code hacking
« on: April 08, 2012, 02:13:35 pm »
When I first discovered the ti83plus.inc file provided by TI, I went through and played with all the RAM equates that I thought would do something. For the newer folks that don't know me well, I started my assembly programming days by programming in hex, so I had a knack for playing with hex codes. Anyways, I saw a few peculiar gaps in RAM and then one that gave me the most reward was the one between 843Fh and 8445h. What struck me as odd was the fact that there were 4 bytes unaccounted for, so I played with them and I made a very fun program:

So what was in the secrets of these bytes? These bytes were counters, but the one at 8442h was the one that you could really take advantage of. When a key is not being pressed, it has a value of 50. As you hold a key down, that decrements until zero. If it is a repeating key and the counter hits zero, it "presses again" so to speak and resets the counter to ten and repeats in this way. The above example is a getkey hook that checks the counter and updates it itself. This is also a feature I put in several programs including BatLib.

However, that ws not the only thing I discovered in playing around. I also made a program to simulate keypresses. The user passes a value through Ans and that key is simulated. For example, Enter has a key code of 9 (these are the same keycodes that you use in Grammer, Axe, and a number of other programs). So to simulate Enter, you do 9:Asm(prgmKS. unfortunately, that just causes the program to be executed over and over (until you press some other key). However, this also lets you open up menus and whatnot, too. What I figured out is that when you add 56 to the keycode, that is like pressing [2nd] and then the key and add another 56, you get [alpha] press. Some of these codes are also replaced with things to clear your RAM, display prgmA (even if you don't have it) and others.


So why did I make this topic now? To be honest, I was looking for a way to redraw the homescreen because I couldn't find a bcall to do it. I just simulated [2nd][mode] on my way out which costs 5 bytes and only 20 cycles XD

EDIT: Added the proggies seen in the screenshot. Also, I would like to note that I added the RAM equate 8442h on WikiTI a while ago and called it keyDelay if anybody is interested.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Key Code hacking
« Reply #1 on: April 08, 2012, 02:15:26 pm »
O.O +1

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Key Code hacking
« Reply #2 on: April 08, 2012, 02:24:00 pm »
so it simulates key press? cool. :D
Sig wipe!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Key Code hacking
« Reply #3 on: April 08, 2012, 02:26:31 pm »
Yep :D Also, I added the downloads for the two programs and I would also like to note that I added the RAM equate 8442h to WikiTI about a year ago.

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Key Code hacking
« Reply #4 on: April 08, 2012, 03:45:10 pm »
ooh, cool! so you can make parser hooks that automatically open up different menus and things like that? if so, could this be used to add simpler keybindings for inserting tokens into the program EDITor? (pressing three keys at once automates opening up the program menu and selecting something or other)?
« Last Edit: April 08, 2012, 07:46:10 pm by shmibs »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Key Code hacking
« Reply #5 on: April 08, 2012, 04:00:49 pm »
ooh, cool! so you can make parser hooks that automatically open up different menus and things like that? if so, could this be used to add simpler keybindings for inserting tokens into the program manager? (pressing three keys at once automates opening up the program menu and selecting something or other)?
Actually, that might be a good idea o.o There is a way to automatically open menus, so all that would need to be done is set the proper menu and simulate the key you want and it would all happen super fast. I don't know how I could get it to be customizable, but it would be worth it if possible.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Key Code hacking
« Reply #6 on: April 09, 2012, 03:56:55 pm »
In response to Shmibs' idea, I made this little program :) (Well, 144 bytes). There is one small issue that I have to attend to, but I will detail that later.
-Send it to your calc
-Run it
-You now have the hook installed, overwriting any existing key hooks and a small chunk of AppBackUpScreen

Now you can go to a menu of your liking and press [ON]+[Vars]. This is your menu :)
Now when you are in the OS (like the homescreen or program editor), you can press [ON]+[number] and that item number will be selected from the menu. For example, if you set the String menu as the quick menu, pressing ON+0 will select Str0.

The issue-- When you are viewing a menu like the App menu or program list, it messes with a flag or something that I have to find. This temporarily prevents the hook from working. To fix it, just view another menu :)

This can also let you jump to certain menus and whatnot, so feel free to be hacky with it :) For example, I set the memory menu so the hook let me go right to specific memory menus easily :)
Here is a screenie:


EDIT: Also, unfortunately, I have not added the ability to go beyond 10 options, but I can try to do that...

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Key Code hacking
« Reply #7 on: April 09, 2012, 06:03:31 pm »
O.O
This will certainly be helpful!
Sig wipe!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Key Code hacking
« Reply #8 on: April 09, 2012, 09:16:25 pm »
Awesome :D I am going to try to use it on one of my BASIC projects because it uses strings like a bazillion times.