[TI BASIC] Optimizing

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
merthsoft
Extreme Poster
Posts: 496
Joined: Tue 21 Dec, 2004 6:49 am
Location: WI

Post by merthsoft »

Hey, I edited that post to say it didn't... crap, AOL is evil...
Shaun
MooK
New Member
Posts: 61
Joined: Sat 12 Mar, 2005 1:58 pm

Post by MooK »

I guess this maybe deserves some testing...
That_One_Guy
New Member
Posts: 65
Joined: Sun 03 Apr, 2005 7:55 pm
Location: The seventh circle of Hell.
Contact:

Post by That_One_Guy »

Hey, I was wondering what the fastest GetKey routine would be? I use

:DelVar A
:Repeat A(not equal)0
:GetKey->A
:End
:If A=21
:do this
:if A=31
:do this


and this is really slow. I'll post some more bits of code i need optimized. Thanks in advance!
Truly great madness cannot be achieved without significant intelligence.

http://www.xanga.com/jakku_kun, rants by me.
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

Repeat Ans
getKey->A
End
If A=21:Then
...
End
If A=31:Then
...
End

if you only need the key once and don't have to save the keypress:
Repeat Ans
getKey
End
If Ans=21:Then
..2nd pressed...
Else
..other keys pressed..
End

if you don't need the key at all and just want to wait for any key:

Repeat getKey
End
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
That_One_Guy
New Member
Posts: 65
Joined: Sun 03 Apr, 2005 7:55 pm
Location: The seventh circle of Hell.
Contact:

Post by That_One_Guy »

Thanks a lot, every little bit helps. is there a faster way than:

Repeat Ans
GetKey
End

If Ans=24
Y-1->Y
If Ans=25
X-1->X
If Ans=26
Y+1->Y
If Ans=34
X+1->X


I seem to recall someone mentioning a faster way, but if not, oh well.
Truly great madness cannot be achieved without significant intelligence.

http://www.xanga.com/jakku_kun, rants by me.
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Repeat Ans
GetKey
End
Y+(Ans=26)-(Ans=24->Y
X+(Ans=34)-(Ans=25->X
That_One_Guy
New Member
Posts: 65
Joined: Sun 03 Apr, 2005 7:55 pm
Location: The seventh circle of Hell.
Contact:

Post by That_One_Guy »

kalan_vod wrote:Repeat Ans
GetKey
End
Y+(Ans=26)-(Ans=24->Y
X+(Ans=34)-(Ans=25->X
That works, but only the Y one works. The X one doesnt do anything. But other than that, very speedy.
Truly great madness cannot be achieved without significant intelligence.

http://www.xanga.com/jakku_kun, rants by me.
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post by Timendus »

Ans is fucked up by the Y statement... you will need to store the getkey value somewhere I'm affraid...
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
That_One_Guy
New Member
Posts: 65
Joined: Sun 03 Apr, 2005 7:55 pm
Location: The seventh circle of Hell.
Contact:

Post by That_One_Guy »

No worries, it'll only slow it down a tad bit, if that. And true, minus one variable, but i never use many variables, unless im working on something big. this is just to satisfy boredom. May go big, but doubt it
Truly great madness cannot be achieved without significant intelligence.

http://www.xanga.com/jakku_kun, rants by me.
User avatar
dysfunction
Calc Master
Posts: 1454
Joined: Wed 22 Dec, 2004 3:07 am
Location: Through the Aura

Post by dysfunction »

The Y variable has interesting problems with the TI-OS.. I've written several program movement loops wherein Y was randomly set to 0. I think there's some issue between the Ans variable and the Y variable, though I don't know why.
Image


"You're very clever, young man, but it's turtles all the way down!"
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post by Timendus »

Yes, I had that too... And Q also has some problems; I managed to reset my calc with a basic program getting input in Q once :?
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
User avatar
DJ_O
Calc King
Posts: 2324
Joined: Mon 20 Dec, 2004 6:47 pm
Location: Quebec (Canada)
Contact:

Post by DJ_O »

This happens with Y and X, when in Func mode. If you put the calc in another mode I believe this cause problems with other variables like theta, R and P or something, basically all real veriables that cannot be archived. The only way to prevent this is to cleardraw at the beginning of your program, use the Disp command followed with a Dispgraph and every time you need to clear the screen BCALL ClrLCDFull using Omnicalc execasm function or use an Asm lib to clear the screen
Image Image Image Now active at https://discord.gg/cuZcfcF (CodeWalrus server)
merthsoft
Extreme Poster
Posts: 496
Joined: Tue 21 Dec, 2004 6:49 am
Location: WI

Post by merthsoft »

Or just don't use X or Y.
Shaun
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

I used to hate that, when X or Y would get over-written for no reason :S.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
DJ_O
Calc King
Posts: 2324
Joined: Mon 20 Dec, 2004 6:47 pm
Location: Quebec (Canada)
Contact:

Post by DJ_O »

Since I use xLIB instead of ClrDraw to clear the screen I have no more problems in using those vars, altough I still tend to use them in last resort. It's hard in BASIC to deal with 33 variables (A-Z, theta, n, N, I%, PV, PMT, FV) and lists are very slow
Image Image Image Now active at https://discord.gg/cuZcfcF (CodeWalrus server)
Post Reply