TI-86 Programming For The Weak Of Finger: Tips and Tricks

0 Conversations

What is a TI-86? If you don't know, what are you doing reading this? I do admit, all these tricks can work in any programming language, it just isn't always obvious what the commands mean. This article will be heavily footnoted;* this is to help those who do not know the inane programming language that you really should know to program. A TI-86 is a five-inch black box covered with buttons and a screen, with a chewy, creamy, circuit center. It has advanced matematical and statisitics functions, but it's most famous capability is... Programs! There is a programming group to which I belong; it is called SiCoDe Software1, and we use all these tricks entered here, including the example stupid mistakes. A good place for more information, and, best of all, free programs: Ticalc.org, click here!
1Yes, the capitalisation really is that way- when the company was created, the TI-82 was all we had and they had no lowercase versions of the uppercase letters... or so we thought. The o is really a degree sign.
Jumping In With Both Feet: The Sleeping2 GetKy Wait LoopOK, here's a classic loop, it reads a button you push and then sees what it is. This is a mistake you shouldn't make, at right:(line starts are marked by :s because comments carry over to multiple lines 3

:\\Code up to the loop

:Lbl WHARPLE \\ This line is now called WHARPLE if a menu or GOTO wants to go there.

:getky-)K \\ Getky, for those TI-Ilitterate, sees what the last keypress since the last GETKY, prompt, or pause command was; it returns the key value or 0 if no key was pressed; it doesn't wait for a key. Please note that since there is no STORE TO arrow in standard ASCII font, and the greater than symbol is used in GuideML, I have to use -) as the STORE TO arrow.


:If K==15 \\that's the F5 key

:Goto Something \\Go to the line that says :LBL Something.

:If K==23 \\ that's EXIT

:Stop \\Halt excecution of ALL programs- Return just stops this one but not a program that calls it (and would have been a better choice.)

:\\More "If" statements for several lines more

:Goto WHARPLE \\ This will only be hit if all other keychecks failed.



OK, here's the problem with this code: performance. Even if no keys were pressed and the GETKY returns a 0, the program still checks it to every keycode in the book. If you really do check it to all 51 keycodes, then you could probably solve the problem more quickly with pencil and scrap paper. The user wil become confused when you have to wait 15 seconds for the program to see that you hit EXIT. Whoops, too late, it exited too slowly, you can't hid the game you were playing from your teacher. This code is much faster, better, and more responsive at left:

:Lbl Wharple \\Look disgustingly familliar? It gets better.

:Getky-)K \\ Again, boringly same.

:If K!=0 \\Whoops! That's different! Note that!= means NOT EQUAL TO.

:Goto KEYCHECK \\Now all that slow code in the previous code is done out of the loop, which means better performence.

:Goto Wharple \\If no key was pressed, check again.


Note how many fewer lines are actually IN the loop. The keychecking code (about 54.8957983794753 IF-THENs) is not run inless you pressed a key, and we only used 1 if-then in the loop instead of 54.8957983794753 checks. This code does the same thing in much less effort, code, and time. It is optimised, but if you think it works far too well, go back to the old way.
3Unlike in real TI-BASIC, where the "genius" engineers failed to put any commenting syntax in, this code is commented. If you do not know C++ coding, (and if you're reading this, I doubt you are,) a \\ preceeds all comments; the remainder of the line is a comment.
The Live4 Getky Loop
OK, that's all well and good for a thinking puzzle where it waits for the Slowpoke human to finish, but in a game line Nibbles, Mario, or Hard Hat Mack Gets A Big Gun5, waiting for the human to move just won't do. Yes, it sure makes sense for the baddies to just sit there while Mario is stopped, instead of attacking while he's vulnerable. Riiiiight.

:Lbl Wharple \\You still need something to goto to. Otherwise, the program would get hopelessly lost and your calc would blow up if you told it to GOTO where there was no LBL... or maybe you'd just get an ERR 22 LABEL. I wouldn't know.

:Getky-)K \\K, the classic variable for the entered key.

:If K!=0 \\Look familliar? If not, get glasses, a better memory, or a clue.

:Then \\The THEN is only for multi-line statements, like {} in C++.

:\OK, the keytest code goes here, but now there's a little problem in the code- the rate is irregular. It will run more quickly when you do not press keys because this area is not ever hit by the calc; if you want regularity, 1. Try Metamucil, or 2. Take out the IF K!=0:THEN lines.

:End \\Ends the IF-THEN statement

:\\OK, movement code goes here. Kind of boring to poke buttons and nothing happens.

:IF !LOSTALIFE\\ You do not have to test for "=0", a 0 in an "IF" does not run it, a non0 does.

:Goto Wharple \\and back to the start.



On the code at left, the mistake that gives sleeping controls that don't respond well was made in Nibbles Arcade, and the blunder is something that ISN'T there. There is ONE line of code missing that would fix that. Just before the Lostalife test, insert the following line of code:

:Getky

Not too impressive, hmm? Here's what it does: Your controlls, in the unchanged loop, will not get cleared from the Getky buffer until one cycle AFTER you release them- remember, Getky looks at the last button pressed since a prompt, pause, or Getky, and doesn't care if it's being pushed right now or not, so trying to not push any keys willl, for one possibly fatal cycle, repeat the last press. So that's another miracle repair from I, the researcher, SmartGamer, the TI-MASTER!
5Head to Ticalc.org and you'll find out that this is indeed a real game.

More coming soon- I'm really just saving my work for another day.
1Yes, the capitalisation really is that way- when the company was created, the TI-82 was all we had and they had no lowercase versions of the uppercase letters... or so we thought. The o is really a degree sign.2Snore... Snore... 3Unlike in real TI-BASIC, where the "genius" engineers failed to put any commenting syntax in, this code is commented. If you do not know C++ coding, (and if you're reading this, I doubt you are,) a \\ preceeds all comments; the remainder of the line is a comment.4 Liiivvve... Liiiivvvee.... LIVE! HA HA HA HA HA! OK, I'm sane again.5Head to Ticalc.org and you'll find out that this is indeed a real game.

Bookmark on your Personal Space


Conversations About This Entry

There are no Conversations for this Entry

Entry

A285419

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry


References

External Links

Not Panicking Ltd is not responsible for the content of external internet sites

Disclaimer

h2g2 is created by h2g2's users, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the Not Panicking Ltd. Unlike Edited Entries, Entries have not been checked by an Editor. If you consider any Entry to be in breach of the site's House Rules, please register a complaint. For any other comments, please visit the Feedback page.

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more