[TI BASIC] Optimizing

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

KevinJB
Calc Wizard
Posts: 501
Joined: Sat 28 May, 2005 5:34 am
Location: Chesapeake, Virginia
Contact:

Post by KevinJB »

I dont think your post above will stay on this forum for long.
I think you misinterpreted it. Although I understand your point, allow me to explain what I meant by it.

When I said, 'BASIC was MADE for idiots', I meant that the language was not created with people that have an IQ higher than 12 in mind- it's meant to be crash proof, so that no unknowing buyer makes a quick program, then ends up crashing their calculator.

What I did not say was 'BASIC is ONLY for idiots'... meaning that there are people who can make it almost as powerful as assembly- like you, Kevin (btw we have the same name ;)). So, T.I is not going to risk the situation Patori stated.

Which means that, when they were deciding whether or not to include archiving programs, they said 'BASIC is not being made for advanced programmers. So if it can crash the calc in the hands of an idiot, we won't include archiving prgms'.

Sorry for the long explanation, I just didn't want that post to be take the wrong way. Remember, there is a difference between MADE for, and ONLY for. Perhaps I should have said 'made with idiots in mind'.

EDIT #1: originally stated 'sorry for the explanation'. added long.
EDIT #2: Oh, yeah, Kevin, I thought you might want to know that I'm proud to be a BASIC programmer too- as well as assembly. In fact, I'm about 75% done with my own RPG in TI-BASIC, called Dragon Tears.
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
KevinJB | RevSoft
User avatar
DJ_O
Calc King
Posts: 2323
Joined: Mon 20 Dec, 2004 6:47 pm
Location: Quebec (Canada)
Contact:

Post by DJ_O »

Rezek wrote:
I dont think your post above will stay on this forum for long.
I think you misinterpreted it. Although I understand your point, allow me to explain what I meant by it.

When I said, 'BASIC was MADE for idiots', I meant that the language was not created with people that have an IQ higher than 12 in mind- it's meant to be crash proof, so that no unknowing buyer makes a quick program, then ends up crashing their calculator.

What I did not say was 'BASIC is ONLY for idiots'... meaning that there are people who can make it almost as powerful as assembly- like you, Kevin (btw we have the same name ;)). So, T.I is not going to risk the situation Patori stated.

Which means that, when they were deciding whether or not to include archiving programs, they said 'BASIC is not being made for advanced programmers. So if it can crash the calc in the hands of an idiot, we won't include archiving prgms'.

Sorry for the long explanation, I just didn't want that post to be take the wrong way. Remember, there is a difference between MADE for, and ONLY for. Perhaps I should have said 'made with idiots in mind'.
No I didnt fully misinterpreted it, I just though that saying "for idiots" would be a bit harsh for some people, but I didnt found it really harsh for me though

I think you should have said:
"TI-BASIC was made by idiots." :lol: j/k

EDIT: oops missed your double-post, nice you are working on a RPG too I cant wait to see screenshots :)

EDIT 2: hmm Dragon Tears, remind me of a RPG I made with a friend 2.5 years ago called Mystique: La Larme Du Dragon (La Larme Du Dragon means The Dragon Tear in english) :roll:
ImageImageImageImage
merthsoft
Extreme Poster
Posts: 496
Joined: Tue 21 Dec, 2004 6:49 am
Location: WI

Post by merthsoft »

Kevin wrote:It's annoying for game programmers though, but its because TI philosophy is that calcs are for maths, not gaming :roll:
Calculators made to calculate something, blasphemy...
Shaun
thecheat
Calc Guru
Posts: 901
Joined: Tue 29 Mar, 2005 9:13 pm
Location: almost..........there........

Post by thecheat »

yes blasphemy get the heretic!!!!! :lol:
KevinJB
Calc Wizard
Posts: 501
Joined: Sat 28 May, 2005 5:34 am
Location: Chesapeake, Virginia
Contact:

Post by KevinJB »

EDIT: oops missed your double-post, nice you are working on a RPG too I cant wait to see screenshots Smile
screenshots? bahh... it'll be done on wednsday! (see sig) :twisted:

EDIT 2: hmm Dragon Tears, remind me of a RPG I made with a friend 2.5 years ago called Mystique: La Larme Du Dragon (La Larme Du Dragon means The Dragon Tear in english)
Great minds think alike. :wink:
It's annoying for game programmers though, but its because TI philosophy is that calcs are for maths, not gaming Rolling Eyes
Not always ;) (send9prgmXXX)
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
KevinJB | RevSoft
thecheat
Calc Guru
Posts: 901
Joined: Tue 29 Mar, 2005 9:13 pm
Location: almost..........there........

Post by thecheat »

err your sig says:
CANT THINK OF A GOOD SIG YET

how is that supposed to tell how close you are to being done?
KevinJB
Calc Wizard
Posts: 501
Joined: Sat 28 May, 2005 5:34 am
Location: Chesapeake, Virginia
Contact:

Post by KevinJB »

uh, woopsie! wrong account :oops:. check my sig on unitedti :roll: !
EDIT: NOW check it.. :wink:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
KevinJB | RevSoft
thecheat
Calc Guru
Posts: 901
Joined: Tue 29 Mar, 2005 9:13 pm
Location: almost..........there........

Post by thecheat »

hehe raised it up 100 people :P 8) :D *stops being off topic*
KevinJB
Calc Wizard
Posts: 501
Joined: Sat 28 May, 2005 5:34 am
Location: Chesapeake, Virginia
Contact:

Post by KevinJB »

167 :shock: if you just 'upped' it to 100, that means 67 people checked the site JUST FROM THIS POST! (it's been on anther sig on this forum, that didn't happen). *hopes to build suspense* :twisted: :twisted: :twisted: </off topic>

To make this on topic, hhe is a nice text input optimization:
--------------------------------------------------------
When you need to input a string on the graph screen, most people choose one of two methods, the most popular being the first:
1- Getkey Loop, then a series of 'If A=31:"A"->Str1', on and on and on.
2- Create a large string, where the 31st place in it is an 'A', then sub(str1,getkey,1) it...
The first one is SLOW, and the second one take a HUGE amount of memory for the string, not to mention the string creation. In the words of Sigma, hopefully you are depressed by now, so here's the simple way: (// are comments)

ROUTINE: Text Input- Store a keypress character to str1.

Code: Select all

"ABCDEFGHIJKLMNOPQRSTUVWXYZ"->Str0     //Holds our placefinder
Repeat Ans:Getkey->A:End     //Simple getkey loop
10 fPart( A / 10 ) -> B     //B holds first decimal place of keycode
iPart(A / 10) -> A     //A holds 'tens' or second decimal place

//This next part is a formula to convert keypress to 1-26 pointer to char.
A-4-> A     //A is now 0 - 5
B-((B^2)A/(A+1)  //A, B, and C are now correct
4A -> A                     //??? Can't remember, just know it's part of the formulae!
If not(A):B->C           //A,B,and,C
If A=4:A+B-1 -> C     //D,E,F,G,H
If A=8:A+B -> C        //I,J,K,L,M
If A=12:A+B+1 -> C  //N,O,P,Q,R
If A=16:A+B+2 -> C  //S,T,U,V,W
If A=20:A+B+3 -> C  //X,Y,Z
Disp sub(Str0,C,1)     //Brownie points if you noticed a pattern in the above if/then statements!
I'm working on a complete 1 line formula for just a keypress based on the patterns. It's difficult however.
BTW: I know the above code could be HILARIOUSLY optimized, but I left it there for less confusion

-------LEFT FOR POSTERITY-------------
ADMINS: Give me about an hour- I lost the rest of the formulae, I'll have it here soon (all i remember is it has to do with B^2... :(, but i have it stored somewhere.)

EDIT: By dumb lock I had the orignal program stored in groups, but half of it is gone! So I've updated this post, and am currently working out the last half...
EDIT: DONE!!!!
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
KevinJB | RevSoft
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

The second way does take a lot of memory, but something like

Code: Select all

Repeat Ans:getKey:End
sub("ABC       DEFGH     IJKLM     NOPQR     STUVW     XYZ",Ans-40,1
is still smaller than most methods of trying to shrink the size of the string. The code below is most likely the best you can do:

Code: Select all

Repeat Ans:getKey:End
sub("ABC  DEFGHIJKLMNOPQRSTUVWXYZ",Ans-20-5int(.1Ans),1
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
User avatar
dysfunction
Calc Master
Posts: 1454
Joined: Wed 22 Dec, 2004 3:07 am
Location: Through the Aura

Post by dysfunction »

Which is faster,

Code: Select all

If...
Then
command
Else
command
End
or

Code: Select all

If...
command
If...
command
Image


"You're very clever, young man, but it's turtles all the way down!"
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

There are no general rules for If statements. The best way is to test both and see which gives you the better speed.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
tokijnct
Regular Member
Posts: 105
Joined: Sat 18 Dec, 2004 3:01 pm

Post by tokijnct »

Is there any way to optimize the following code for recalling map data?

Temp(3)=Map CoordX
Temp(4)=Map CoordY

Code: Select all

 PRGM MAP01A
:If Temp(3)=10 and 10=Temp(4
:[matrix]
:If Temp(3)=10 and 9=Temp(4
:[matrix]
:
and so on...
:
:Ans=>[A]                     - for XLib
:{1=>theta                    - Tells previous prgm that map data has been obtained to avoid ERR:UNDEFINED
This code currently gives me about 9 screens worth of a map for over 2.5k of memory'
Projects:
Phantasy Star Dark Millenia - Put aside for the moment...

UnitedTI BASIC Competition
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

Code: Select all

{Temp(3),Temp(4 -> L1

If min(L1={10,10:[matrix]
If min(L1={10,9:[matrix]
...
there's one way.

Code: Select all

10Temp(3)+Temp(4 -> A
If A=99:[matrix]
If A=98:[matrix]
...
And there's another. (you'd use 0..9 for map coordinates instead of 1..10)
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
tifreak8x
Sir Posts-A-Lot
Posts: 297
Joined: Mon 11 Jul, 2005 4:42 pm
Location: Indiana
Contact:

Post by tifreak8x »

Rezek wrote:167 :shock: if you just 'upped' it to 100, that means 67 people checked the site JUST FROM THIS POST! (it's been on anther sig on this forum, that didn't happen). *hopes to build suspense* :twisted: :twisted: :twisted: </off topic>

To make this on topic, hhe is a nice text input optimization:
--------------------------------------------------------
When you need to input a string on the graph screen, most people choose one of two methods, the most popular being the first:
1- Getkey Loop, then a series of 'If A=31:"A"->Str1', on and on and on.
2- Create a large string, where the 31st place in it is an 'A', then sub(str1,getkey,1) it...
The first one is SLOW, and the second one take a HUGE amount of memory for the string, not to mention the string creation. In the words of Sigma, hopefully you are depressed by now, so here's the simple way: (// are comments)

ROUTINE: Text Input- Store a keypress character to str1.

Code: Select all

"ABCDEFGHIJKLMNOPQRSTUVWXYZ"->Str0     //Holds our placefinder
Repeat Ans:Getkey->A:End     //Simple getkey loop
10 fPart( A / 10 ) -> B     //B holds first decimal place of keycode
iPart(A / 10) -> A     //A holds 'tens' or second decimal place

//This next part is a formula to convert keypress to 1-26 pointer to char.
A-4-> A     //A is now 0 - 5
B-((B^2)A/(A+1)  //A, B, and C are now correct
4A -> A                     //??? Can't remember, just know it's part of the formulae!
If not(A):B->C           //A,B,and,C
If A=4:A+B-1 -> C     //D,E,F,G,H
If A=8:A+B -> C        //I,J,K,L,M
If A=12:A+B+1 -> C  //N,O,P,Q,R
If A=16:A+B+2 -> C  //S,T,U,V,W
If A=20:A+B+3 -> C  //X,Y,Z
Disp sub(Str0,C,1)     //Brownie points if you noticed a pattern in the above if/then statements!
I'm working on a complete 1 line formula for just a keypress based on the patterns. It's difficult however.
BTW: I know the above code could be HILARIOUSLY optimized, but I left it there for less confusion

-------LEFT FOR POSTERITY-------------
ADMINS: Give me about an hour- I lost the rest of the formulae, I'll have it here soon (all i remember is it has to do with B^2... :(, but i have it stored somewhere.)

EDIT: By dumb lock I had the orignal program stored in groups, but half of it is gone! So I've updated this post, and am currently working out the last half...
EDIT: DONE!!!!
Hmm, I made two programs, one that types text on the homescreen, the other on the graphscreen, both programs are only 330 bytes each... And it runs fairly fast. There is also my command input program, used for TI-City, it runs extremely fast...

Text Program: http://calcgames.org/cgi-bin/files/files.cgi?ID=622

TI-City: http://calcgames.org/cgi-bin/files/files.cgi?ID=495

Something you might check out...
http://tifreakware.net - Connecting TI communities
Post Reply