Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Spellshaper on April 24, 2006, 12:25:00 am

Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Spellshaper on April 24, 2006, 12:25:00 am
I think it's time to collect them all again  :lol:laugh.gif
later I can gather them and store them into one nice post :)smile.gif

me starts off with:

---

Kill "Done"

Kill the pesky "Done" at the end of your BASIC program by entering the following code as last line:
c1-->
CODE
ec1:Output(1,1,"c2
ec2

---

-=removed, the px function is well documented in the manual last time I checked=-

---

Using Complex numbers

Utilizing complex numbers to minimize variable usage:
Complex numbers have the following properties:

-Positivity/Negativity or real number (boolean)
-Integer part of real number
-Decimal part of real number
-Positivity/Negativity of imaginary number (boolean)
-Integer part of imaginary number
-Decimal part of imaginary number

commands to get these values:
-real(   (ok, xLib may interfere with this, so this is unusable while also using xLib)
-imag(
-iPart(
-fPart(

using these properties of complex variables in the right way can substitute the usage of six real variables!

---


:)smile.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Krid on April 24, 2006, 12:38:00 am
c1-->
CODE
ec1Text(-54125+1,X,Y,"Text herec2
ec2
To use homescreen font on the graphscreen :)smile.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: tifreak on April 24, 2006, 01:09:00 am
http://s4.invisionfree.com/TIFreakware/index.php?showforum=60

That is all that needs to be said. 8)
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on April 24, 2006, 01:59:00 am
we need to repost them here as well, maybe I could find some tricks in the google cache
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on April 24, 2006, 11:29:00 am
Erasing 'Done' is easier with c1-->
CODE
ec1"c2
ec2 :)smile.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: BCTurk on April 27, 2006, 05:16:00 pm
xLIB Check
c1-->
CODE
ec11
real(0
If not(Ans:Then
Pause "xLib Needed
Stop
Endc2
ec2

Will check to see if xLIB is installed or not.  We had it before and I think this is the most optimized version...

White lines using "Line("
c1
-->
CODE
ec1Line(x1,y1,x2,y2,0c2
ec2
Credit to CDI, I picked this trick up from ADotRPG...
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Zeromus on April 28, 2006, 08:47:00 am
the line one is in the book too I belive
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on April 28, 2006, 10:22:00 am
white lines too I think, at least the old ti manual for 83+
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on April 28, 2006, 10:24:00 am
The fifth argument can also be a variable, useful in Paint programs with eraser mode...
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: shadow on April 28, 2006, 10:47:00 am
this one is't mine but it helped me a lot

getkey>G
End

this waits until you press ANY key then continous on, useful for talking in your game
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on April 28, 2006, 10:54:00 am
Do you mean Repeat getKey:End? It is useful most of the time.

Another trick I like I used in GQES to boost speed:c1-->
CODE
ec1Repeat (long keypress condition here)
Repeat Ans
(grayscaling code here)
getKey
End
End
Ans->Kc2
ec2The long condition slowed down the loop on every cycle. This way fixes that.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on April 28, 2006, 12:26:00 pm
actually if u want better key detection that can be useful, I did that in reuben quest
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on April 28, 2006, 12:44:00 pm
Really? ^^
I'm finally learning something...

I have a nice string searching routine I'll post.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: crzyrbl on April 28, 2006, 03:06:00 pm
QuoteBegin-tifreak8x+Apr 24 2006, 07:09 AM-->
QUOTE (tifreak8x @ Apr 24 2006, 07:09 AM)
http://s4.invisionfree.com/TIFreakware/index.php?showforum=60

That is all that needs to be said. 8)  

 *reads Definition of memory errors

uh oh, does recursion really cause a memory leak?
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: shadow on April 28, 2006, 03:10:00 pm
sigh, i hate goto's that the number one problem with my game right now (well maybe number two, laziness comes first :Ptongue.gif )
but so far it kinda works fine right now
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: kalan_vod on April 28, 2006, 03:30:00 pm
QuoteBegin-Radical Pi+Apr 28 2006, 04:24 PM-->
QUOTE (Radical Pi @ Apr 28 2006, 04:24 PM)
The fifth argument can also be a variable, useful in Paint programs with eraser mode...  

 Yeah, I have save quite a few bytes this way :D

It is in the 83+ manual (line routine).
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: g28401 on April 28, 2006, 05:28:00 pm
I fixed DDR, (but not on my website yet) to not have Goto's inside an If Then loop.  ya!
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: kalan_vod on April 28, 2006, 05:48:00 pm
QuoteBegin-g28401+Apr 28 2006, 11:28 PM-->
QUOTE (g28401 @ Apr 28 2006, 11:28 PM)
I fixed DDR, (but not on my website yet) to not have Goto's inside an If Then loop.  ya!  

 Great, but why did you say it in here? ;)wink.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on April 29, 2006, 01:33:00 am
it was goto/lbl talk as well kala :/
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: tifreak on April 29, 2006, 01:46:00 am
QuoteBegin-crzyrbl+Apr 29 2006, 02:06 AM-->
QUOTE (crzyrbl @ Apr 29 2006, 02:06 AM)
QuoteBegin-tifreak8x+Apr 24 2006, 07:09 AM-->
QUOTE (tifreak8x @ Apr 24 2006, 07:09 AM)
http://s4.invisionfree.com/TIFreakware/index.php?showforum=60

That is all that needs to be said. 8)

*reads Definition of memory errors

uh oh, does recursion really cause a memory leak?  

 Everything listed in there is stuff that I have experienced to get a memory error. So yes, I guess it does. :)smile.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: kalan_vod on April 29, 2006, 04:30:00 am
QuoteBegin-xlibman+Apr 29 2006, 07:33 AM-->
QUOTE (xlibman @ Apr 29 2006, 07:33 AM)
it was goto/lbl talk as well kala :/  

 Sorry lol, I just didn't see it I guess >.>
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Risen Phoenix on June 07, 2006, 11:22:00 am
Good teacher protection code
c1-->
CODE
ec1
:ClrHome
:1X
:While X
:Input "",Str1
:If Str1="DONE
:0X
:Disp expr(Str1
:Endc2
ec2
It's not optomized, but it can be used in programs to solve problems as if it was the homescreen. (to some extent) :)smile.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on June 07, 2006, 11:45:00 am
While the topic is active again...

I discovered an interesting flaw in the interpreter. It only checks the condition on Repeat at the repeat's End. Thus a program, though memory erroring, like the following would cause no syntax error:

Repeat -----------------+++-++++++++-
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Dragon__lance on June 07, 2006, 03:20:00 pm
that's cool :)smile.gif i have a question though, according to my understanding, the BASIC interpreter converts each line of BASIC code into ASM, checks for errors, and then executes it. If it is like this, can't there be a program that just first automatically converts the BASIC into ASM, thus gaining speed?
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: tifreak on June 07, 2006, 03:45:00 pm
Not really, because of the way asm s written and interpreted. And none of the normal variables are easily accessed,  am not sure of the procedure, but you can use only 8 bit and 16 bit registers... To add in asm, you do:

inc a

or something very similar ;)wink.gif I only have a simple understanding of asm...
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on June 08, 2006, 08:11:00 am
The addition term you want would be add, not increment. Let's end any assembly controversy before it begins...

So yeah, I found an interesting glitch in TI-84+(SE) OS v2.30. Could someone confirm it elsewhere?

Good luck trying to take advantage of this undocumented trick. XDsmiley.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on June 08, 2006, 08:31:00 am
I know this is not pure basic but more xLIB related but in xlib if you want a non scrolling map engine to run faster you just have to store the map into a picture, and during the walkign loop just recall that picture instead of recalling the map over and over , it run much faster. Only downside: the last sprite row isnt displayed
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Dragon__lance on June 08, 2006, 08:39:00 am
yep radicalpi, the glitch exists on Ti-83+ black additions :)smile.gif Do u guys know anyway to make a pic store all 64 rows of data?
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on June 08, 2006, 08:42:00 am
in BASIC or using an asm lib, no. xLIB wont even do it :Ptongue.gif

you can use rigview tho
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on June 08, 2006, 08:55:00 am
I thought you could use xlib to fill in those pixels, and RecallPic would revive those normally unobtainable spots?
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Spellshaper on June 08, 2006, 08:57:00 am
no... it's the TI pic files that's missing the last row X_X
you'd have to have an Asm-lib that stores its pics as either prgms or Appvars
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Zeromus on June 11, 2006, 08:17:00 am
I can store everything but the 7-8 pixels in the VERY top right with xLIB
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on June 11, 2006, 08:37:00 am
even if they seems to be gone they are still here, its just that the calc wont display them since this part is for the run indicator
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: something1990 on June 15, 2006, 03:08:00 am
QuoteBegin-Risen Phoenix+Jun 7 2006, 05:22 PM-->
QUOTE (Risen Phoenix @ Jun 7 2006, 05:22 PM)
Good teacher protection code
c1-->
CODE
ec1
:ClrHome
:1X
:While X
:Input "",Str1
:If Str1="DONE
:0X
:Disp expr(Str1
:Endc2
ec2
It's not optomized, but it can be used in programs to solve problems as if it was the homescreen. (to some extent) :)smile.gif

I made something like this a while ago. Here's an adaptation for quick use in a program by pressing mode.
c1
-->
CODE
ec1:getkey
:If Ans=22
:Then
:ClrHome
:Repeat Str1="Quit
:Input "",Str1
:If Str1=/="Quit
:Disp expr(Str1
:End
:Delvar Str1End
c2
ec2
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Vladik on June 23, 2006, 04:47:00 am
GAH! TI-83+ BASIC PROGRAMMERS! Lol.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Spellshaper on June 23, 2006, 07:42:00 am
QuoteBegin-Vladik+Jun 23 2006, 05:47 PM-->
QUOTE (Vladik @ Jun 23 2006, 05:47 PM)
GAH! TI-83+ BASIC PROGRAMMERS! Lol.  

 That's your opinion. So please let us have our own opinion, too.
Thanx.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Speler on June 23, 2006, 09:10:00 am
Something1990, that code can be optimized to:

Repeap A=E5  //When's this acctually going to be the answer?
input "",A
Disp A
End


Vladic, just because they can only afford an 83+ doesn't mean that a person should be excluded.

One interesting unknown fact is that finance variables run faster then even ans.  I often use finance variables in phisics engines or other programs that need every slight speed boost they can get.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: crzyrbl on June 23, 2006, 10:57:00 am
thats good to know, what are they
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on June 23, 2006, 12:24:00 pm
Seems like someone asked for a ban above... trolling=bad

EDIT: to avoid confusion my post was directed toward vladik
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: threefingeredguy on June 25, 2006, 07:10:00 am
QuoteBegin-crzyrbl+Jun 23 2006, 04:57 PM-->
QUOTE (crzyrbl @ Jun 23 2006, 04:57 PM)
thats good to know, what are they

The finance APP (the one you can't delete) contains variables made specifically for that app that you can use in normal programming. You can always use them because you can't get rid of the finance app. They are faster because they are programmed differently than the other variables (which use built-in bcalls). These are processed by hooks (like xLIB) and executed from the APP instead of the OS's horrible methods.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Demon on July 15, 2006, 07:07:00 am
Here's an interesting one:

If you want your programs and games to be smaller, don't use lowercase letters for the text unless it's really necessary.  Lowercase letters and some other symbols are like Unicode on the calc and they take up two bytes for each one you use. If you have lots of text in your program, and you're using lowercase, try making it all uppercase and see how many bytes you save (doing this has saved saved up to 75% of space per program on my calc...)

This post is 588 bytes long.  If you put this in your calc, it would be double that unless you made it uppercase.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: dinhotheone on December 09, 2006, 11:02:00 am
Alot of the time i use
Output(X,Y,"I%"
Output(X,Y," ")

to output a % at X,Y+1 for loading screens because that is the only %sign on the calc  (I% is a finance variable)
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on December 09, 2006, 11:07:00 am
thats an useful thing, i never understood why TI didnt made the % symbol avaliable in BASIC by default
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Halifax on December 09, 2006, 11:32:00 am
yea same here I hated then and I never knew how to get a % sign without making it your self on the graphscreen but now I know so thanks
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: kalan_vod on December 09, 2006, 01:05:00 pm
You can use the percent that is to dots and a slash.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on December 09, 2006, 01:38:00 pm
that too, altough on home screen it take 3 chars slots :(sad.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: elfprince13 on December 09, 2006, 01:42:00 pm
o.oblink.gif where did my reply go.....you can use the % to actually perform % operations in TI-Basic (assuming Symbolic ISNT installed)
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on December 09, 2006, 01:54:00 pm
hmm idk you prbly forgot to click submit or it didnt reached the database, forum was slow earlier.

EDIT: hmm kalan trick doesnt seems to work anymore :(sad.gif

i remember how on the TI-80 the
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: tifreak on December 09, 2006, 02:53:00 pm
Or you can dl and use http://www.ticalc.org/archives/files/fileinfo/384/38404.html
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on December 09, 2006, 02:57:00 pm
yeah that too
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: dinhotheone on February 01, 2007, 03:03:00 pm
this may be late but...

when/if you use the homescreen for a graphical game without "smooth" scrolling. you can convert what you would output into a string and then use that as an almost screen buffer. if you do this it actually will shorten your code. all you do it redraw the string before you update the position. Well im not sure if it will shorten everyone's code but it defenitely shortened my perhaps unoptimized code a few bytes. plus you can use sub(str,(a-1)*16+B) as hit detection, i think its faster than matrix hit detection.

Edit by Netham45: part of your code was showing up as a smiley.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on February 01, 2007, 03:51:00 pm
there is no post time limit on this topic, as it's a trick topic and its pinned :)smile.gif
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Speler on February 01, 2007, 04:41:00 pm
I use that in my Harrierfalcon Contest entry (sort of).
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on February 01, 2007, 11:46:00 pm
That was used in tifreak's RPGSK and I'm using it in WoM.
I didn't think it was a 'trick' more than common knowledge... :Ptongue.gif

Here's a trick I'd like to see done efficiently:
Using IS>() or DS<() to exit some kind of loop
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Speler on February 02, 2007, 09:19:00 am
Yeah, but that causes memory leaks.
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on July 19, 2007, 11:13:00 am
I did not know this until today

QuoteBegin-kalan_vod+18 Jul, 2007, 12:09-->
QUOTE (kalan_vod @ 18 Jul, 2007, 12:09)
If you make something like the other basic game, you can now draw circles faster!

Circle(X,Y,R,{i

R=radius, X=x coord. Y= y coord..


Thanks kalan for posting this. This draws circles 3 times faster
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: Radical Pi on July 19, 2007, 12:09:00 pm
I want to find the writer of the TI-OS and personally tell him how random of a feature that Fast Circle routine is.
It's been there all this time and no one ever knew... We knew there was a routine deep in the OS to do it, but no way to call it outside ASM...
That find really inspires me. There's so much to calcs that we still don't know...
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: dinhotheone on July 19, 2007, 04:26:00 pm
there doesnt happen to be a way to draw white circles is there? also, fast circle seems...not dumb but why wouldnt you want to draw circles 3x as fast everytime? is it crappyer resolution or something?
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on July 19, 2007, 04:59:00 pm
i barely see any difference in them. I think its slightly lower quality and they wanted the people in math to view the circle build slowly so they made them slower
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: kalan_vod on July 19, 2007, 05:15:00 pm
QuoteBegin-DJ Omnimaga+19 Jul, 2007, 17:13-->
QUOTE (DJ Omnimaga @ 19 Jul, 2007, 17:13)
I did not know this until today

QuoteBegin-kalan_vod+18 Jul, 2007, 12:09-->
QUOTE (kalan_vod @ 18 Jul, 2007, 12:09)
If you make something like the other basic game, you can now draw circles faster!

Circle(X,Y,R,{i

R=radius, X=x coord. Y= y coord..


Thanks kalan for posting this. This draws circles 3 times faster  

 I saw it on UTI, and it is amazing! But that faster way would be to calculate the circle points and draw...
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: dinhotheone on July 23, 2007, 04:47:00 am
i just made a basic program that draws circles a tiny bit slower than the circle command. i wonder what terrible method they use if basic can nealy equal the OS?
Title: Undocumented BASIC tricks (TI83/84 series)
Post by: DJ Omnimaga on July 23, 2007, 06:13:00 pm
cool, is it the speed of fast circles or just the normal circles?