Jump to content
  • Advertisement
Sign in to follow this  
kelcharge

Efficient Calculator Programming...

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


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

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

Share this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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 this post


Link to post
Share on other sites
Quote:
Original post by kelcharge
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.


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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!