Efficient Calculator Programming...

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I was trying to make a game on my friends TI-84 calculator and when I do key presses they don't exactly work efficiently and slow down the whole rest of the program. I was wondering if anyone had any knowledge about the subject.

Share on other sites
i assume you are using just the programming tools already on the calc. best way is to use Z80 assembly to program ti but i have no idea how to, but u can still make pong and snake and other simple games using just whats already on there.

try something like this ...

:lbl 0
:getkey->k
:if k>0 then
:output(1,1,k)
:end
:goto 0

that will display the key code for which ever key you press, basically the only trick is to assign a variable to the key pressed once in each loop and not use multiple getkey's. if this doesnt solve the problem post the code.

Share on other sites
the part of my code that i think is messed up is in the loop
:0->x:0->y:0->a:While a<9999999 //pretty much forever:a+1->a:If getky=whatever key:x+1->x:If getky=whatever other key:y+1->y:ClrHome:End

in the for statements, but any way I set them up it still doesnt update smoothly and efficiently.

Share on other sites
Try putting an else if when detecting the key presses. Also, clearing home every frame is slow in basic. Avoid it if possible [ie. hard coded dirty rects].

Expect basic programs on the calculator to be slow. Even on the Ti-89, it's so difficult to develop good real-time games. Assembly programming will allow you to write pretty fast games, but expect it to be a challenge if this is your first experience with such low level code.

Share on other sites
Use While 1 instead of using a variable. Then for keypresses do this:

getKey->A
If A=keycode
dosomething
...

Share on other sites
If you want to create games for TI calculators, I suggest you check out http://www.ticalc.org/. TI-BASIC is way too slow for pretty much everything. Assembly is the way to go, though I've also seen C compilers for several TI calculators (83, 83+, 89, etc).

Share on other sites
try this:
:0->x
:0->y
:0->a
:While 1
:getkey
:a+1->a
:if Ans = key
:x+1->x
:if Ans = key
:y+1->y
:ClrHome
:End
having ClrHome in the loop will slow it down so move it out unless you must have it in

Share on other sites
Quote:
 Original post by kelchargethe part of my code that i think is messed up is in the loop:0->x:0->y:0->a:While a<9999999 //pretty much forever:a+1->a:If getky=whatever key:x+1->x:If getky=whatever other key:y+1->y:ClrHome:Endin the for statements, but any way I set them up it still doesnt update smoothly and efficiently.

ticalc.org is indeed a good resource for TI calculator programming. You should change your code to something like this:

:0->x
:0->y
:0->a
:While 1 //this is a better choice as a previous poster suggested
:a+1->a
:GetKey->k;
:If k=whatever key
:x+1->x
:If k=whatever other key
:y+1->y
:ClrHome
:End

So what it's doing is only calling GetKey once per frame and storing the result in a variable. I made a simple 2 player tron clone and when I called GetKey more than once per frame things got really messed up, which I suspect is your problem. Anyway, so just GetKey->k or whatever variable you want and check the value of k for key presses.

Share on other sites
thanx l_b_f. the way you put it works just fine.

• 10
• 17
• 9
• 13
• 41