Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Speler on November 16, 2006, 03:08:00 pm

Title: New Tricks For Pure Basic Coders.
Post by: Speler on November 16, 2006, 03:08:00 pm
Everything here uses ZoomStandard.

Lately I have done alot of experementing with using Y functions for full screen graphics.  I found that you can actually make very fast and fairly memory efficiant graphics using nothing but Y commands (Y1, Y2 etc).  Here is a list of several things that can be done:

Brick Wall:
First set to mode Simul and store 8 to xRes, now store -10(X-20 to Y1 -10 to Y2 and -10 to Y3.  Select the graph style that looks like an upside down staircase.  Hit graph.  You have a Brick Wall.  This can be used in program.

Grayscale Bug
This can be used in a program but I can't see any real way to... anywho:  use all the same settings as for the brick wall (including the upside down staircase's) except graph different things.  -10(X-20)/(X<8 to Y1 and -10(X<8 to Y2.
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on November 16, 2006, 04:10:00 pm
interesting find :)smile.gif
Title: New Tricks For Pure Basic Coders.
Post by: Speler on November 16, 2006, 04:10:00 pm
Thanks.
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 17, 2006, 09:38:00 am
Woah that's pretty sweet and awesome find. These are the kind of advances we need

For the brick wall you could set those -10's to 0's so that half the screen is bricks and that is like a background to a room or something

Another thing is yes I noticed this grayscale bug before and it is like wierd cause if you put that stuff you said for grayscale into the graphing screen and graph it then you'll notice on the last line of vertical pixels that it will be flickerless grayscale which is very wierd
Title: New Tricks For Pure Basic Coders.
Post by: Radical Pi on November 17, 2006, 10:10:00 am
Great job documenting these!
The 'grayscale bug' I have noticed, but only when trying to get different shades of blue with the fast contrast setting (it works there too. Try setting the left half of the graphscreen all black, right half clear, and run the bluescale loop. You get Perfect gray and blue!)
Title: New Tricks For Pure Basic Coders.
Post by: dinhotheone on December 10, 2006, 07:01:00 am
that is so sweet, im going to have to look up simulate mode in the manual to figure out how it works tho
Title: New Tricks For Pure Basic Coders.
Post by: bfr on December 10, 2006, 11:20:00 am
dinhotheone:  Simulate mode?  Of of the top of me head, I'm not completely sure, but I think that it's simultaneaus (sp?) mode, meaning that it graphcs equations simultaneausly, or at the same time.

Super_Speler:  Nice work!   :thumbup:google.gif
Title: New Tricks For Pure Basic Coders.
Post by: elfprince13 on December 10, 2006, 02:32:00 pm
psuedo local variables for recursion:
  keep a list with the variable name you want, and an index variable measuring your recursion depth. every time you enter a routine that needs the local variable increase the index variable and push onto the variable list with augment{(L)VARNM,{VAL}). every time you exit, decrease the index variable and pop off the variable list with indexvar->dim((L)VARNM

you can access the local variable with (L)VARNM(indexvar)
Title: New Tricks For Pure Basic Coders.
Post by: dinhotheone on December 16, 2006, 03:51:00 pm
Ya i didn't really put the correct ending to the abreviation. I understand now.
plus i can't feel to bad since it was an extreme programmer that corrected me. not just one of the regular ones.
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on December 17, 2006, 12:24:00 am
This is always something that has annoyed me and I figured I should say it. Shouldnt TI call it concurrently cause it doesn't do it simultaneously. It searches ever vertical row for if a pixel should be on
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on December 17, 2006, 07:17:00 am
moved to calc help and support and pinned
Title: New Tricks For Pure Basic Coders.
Post by: Netham45 on August 10, 2007, 12:24:00 pm
I found this earlier:
c1-->
CODE
ec1
for(a,0,1000)
If G=1
Then
getkey
end
end
c2
ec2
too roughly 10 seconds longer than this:
c1
-->
CODE
ec1
for(a,0,1000)
1->g
while g=1
getkey
->g
end
end
c2
ec2
Title: New Tricks For Pure Basic Coders.
Post by: JonimusPrime on August 11, 2007, 03:12:00 am
So While is faster than if then That is an awesome find.
Title: New Tricks For Pure Basic Coders.
Post by: Speler on August 11, 2007, 03:36:00 am
Did you use StartTmr, a timer, or your own counting for the tests?
Title: New Tricks For Pure Basic Coders.
Post by: dinhotheone on August 11, 2007, 03:59:00 am
wow, thats pretty nasty, the only annoying part is that it might be a pain to break outa that while. i guess you could just do while condition and g, and then change g for it to work like a true if then
Title: New Tricks For Pure Basic Coders.
Post by: JonimusPrime on August 11, 2007, 05:09:00 am
I wonder if it is th same for repeat?
Title: New Tricks For Pure Basic Coders.
Post by: Speler on August 11, 2007, 05:20:00 am
Well, Repeat works differently (it always completes the loop at least once).
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on August 11, 2007, 11:07:00 am
what is StartTmr?
Title: New Tricks For Pure Basic Coders.
Post by: Speler on August 11, 2007, 11:58:00 am
It is a command built into 84+'s and 84+ SE's which tells you in interger form what time it is.  It is used like this:

:StartTmr->T
...Test Code...
:CheckTmr(T
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on August 11, 2007, 12:45:00 pm
ah ok i see
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on October 12, 2007, 09:15:00 am
*bump*

I don't know if this has been said before in another topic but...

c1-->
CODE
ec1
10->X
100->X
200->X
c2
ec2

optimizes to

c1
-->
CODE
ec1
E2->X
E3->X
2E3->X
c2
ec2

Just a play scientific notation. It works just as fast, if not faster than the former.

I don't know about math operations on scientific notation numbers, but I would expect it to be the same. Either way this is a great way to save bytes.
Title: New Tricks For Pure Basic Coders.
Post by: Speler on October 12, 2007, 09:33:00 am
Actually, 10^( is generally a faster way to do the same (or rather, a very similar) thing.
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on October 12, 2007, 09:40:00 am
Really? It has been tested?
Title: New Tricks For Pure Basic Coders.
Post by: Speler on October 12, 2007, 09:43:00 am
Yup, it's in basic code timing thingy... I mean 10^( as one token by the way.
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on October 12, 2007, 10:00:00 am
Yeah, I understand, cool. I didn't know that. :)smile.gif
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on October 12, 2007, 12:33:00 pm
i didn't knew E can be used without a number as prefix o.oblink.gif
Title: New Tricks For Pure Basic Coders.
Post by: JonimusPrime on October 12, 2007, 03:59:00 pm
Yep it is very helpful that way
Title: New Tricks For Pure Basic Coders.
Post by: kalan_vod on November 07, 2007, 03:41:00 pm
Well I just saw burr post about the graphing vars, and it is very useful!
c1-->
CODE
ec1:"randInt(X,Y->u;2nd 7 or 8 (u or v)c2
ec2
Now execute u/v and it works as an instruction ;)wink.gif
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on November 07, 2007, 03:44:00 pm
example, screenshot? o.oblink.gif
Title: New Tricks For Pure Basic Coders.
Post by: kalan_vod on November 07, 2007, 03:51:00 pm
QuoteBegin-burr+-->
QUOTE (burr)
You don't need to store C to a variable; Ans can be used instead.
CODE
:For(A,1,26+8D
:Repeat (B,Ans
:randInt(1,9→B
:randInt(1,9
:End
:0→(B,Ans
:End

However, if you use the randInt(1,9 statement elsewhere in your program, you can store it to one of the graphing variables (such as u or v) and then use that instead.
CODE
:"randInt(1,9→u
:For(A,1,26+8D
:Repeat (B,Ans
:u→B:u
:End
:0→(B,Ans
:End
Title: New Tricks For Pure Basic Coders.
Post by: nitacku on November 07, 2007, 03:54:00 pm
Holy crap! This could make many things so much easier.
Especially things where you want to save memory.
Title: New Tricks For Pure Basic Coders.
Post by: Speler on November 08, 2007, 09:21:00 am
It's somewhat slower but that can be useful.
Title: New Tricks For Pure Basic Coders.
Post by: kalan_vod on November 08, 2007, 09:34:00 am
c1-->
CODE
ec1:DelVar X"X+(Ans=26)-(Ans=24->u
:While 1
:Output(1,1,X
:getkey
:u:Ans->X
:Endc2
ec2
Could be used in menus, since it is slower (saving some bytes when needed).
Title: New Tricks For Pure Basic Coders.
Post by: angel14995 on November 08, 2007, 10:32:00 am
And what's even better is you can save the value of u or v into a normal variable (just checked). Its really useful I can see for using the same formula over and over... hehehe, no need for prgmθTDH anymore, u -> H will got fine, and smaller :)smile.gif
Title: New Tricks For Pure Basic Coders.
Post by: Speler on November 08, 2007, 10:38:00 am
I suppose I should mention that you can do a similar thing with lists.  Try this:

:"randInt(1,3,2->LA
:Disp LA
Title: New Tricks For Pure Basic Coders.
Post by: kalan_vod on November 08, 2007, 01:29:00 pm
This could be really useful with xlib ;)wink.gif..
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 16, 2007, 04:27:00 pm
QuoteBegin-Super Speler+12 Oct, 2007, 15:33-->
QUOTE (Super Speler @ 12 Oct, 2007, 15:33)
Actually, 10^( is generally a faster way to do the same (or rather, a very similar) thing.  

 I actually just tested this today. 10^( takes 6 seconds while E only takes 4 seconds.

(1000 iterations were done by storing 1000 to variable B.)

c1
-->
CODE
ec1
For(A,1,1000
E3->B
End
c2
ec2

c1
-->
CODE
ec1
For(A,1,1000
10^(3->B
End
c2
ec2

And they both take the same number of bytes, so I would go with E since it is faster.
Title: New Tricks For Pure Basic Coders.
Post by: Speler on November 16, 2007, 04:56:00 pm
Really?  Did you use StartTmr?  Did you use the 10^( token or write that out?
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 16, 2007, 05:29:00 pm
I used the token. And I ran the programs, respectively, 20 times to make sure that it wasn't just a fluke.

Also, I use getTmr->L1 and getTmr->L2 and then subtract the start time from the end time.
Title: New Tricks For Pure Basic Coders.
Post by: Xphoenix on November 16, 2007, 07:12:00 pm
Is getTmr some command I've never heard of?
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on November 16, 2007, 07:36:00 pm
same here, must be a 84+ only command.

We should keep this topic for 83+ only, to make sure all optimization tricks works on all calcs in the 83+ series
Title: New Tricks For Pure Basic Coders.
Post by: vuurrobin on November 17, 2007, 03:27:00 am
QUOTE
Also, I use getTmr->L1 and getTmr->L2 and then subtract the start time from the end time.


using gettmr->A and checktmr(A is easier (I think)

yes all time and date functions are 84+ (SE) only, but they are usefull if you want to see if a command is faster or not.  
Title: New Tricks For Pure Basic Coders.
Post by: Speler on November 17, 2007, 04:49:00 am
DJ Omnimaga, that's silly.  Not everyone codes on a 83+.

Halifax, if that's true then there are some errors in the Basic Code Timings... someone should redo that using startTmr.
Title: New Tricks For Pure Basic Coders.
Post by: Xphoenix on November 17, 2007, 06:45:00 am
No, no, I HAVE an 84+, I just don't see getTmr in the catalog.

There's Get(, GetCalc(, getDate, getDtFmt, getDtStr(,getTime, getTmFmt, getTmStr(, and getKey. No getTmr.
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 17, 2007, 06:57:00 am
Well then it is getTime, which ever one returns a list of three values.

And yes that is very silly, especially since it would be applied to 83+ in some way. I am pretty sure that e3 would be faster on the 83+ too. ;)wink.gif
Title: New Tricks For Pure Basic Coders.
Post by: Speler on November 17, 2007, 07:00:00 am
Just use StartTmr->T and StartTmr-T
Title: New Tricks For Pure Basic Coders.
Post by: JoostinOnline on November 17, 2007, 09:11:00 am
I don't think you need to keep it an 83+ only thread. Just make sure you specify that commands are only found on an 84+ when making reference to them.
Title: New Tricks For Pure Basic Coders.
Post by: simplethinker on November 17, 2007, 10:19:00 am
I think the only commands on an 84 that aren't on an 83+ are the time/date commands and the OpenLib,ExecLib ones
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on November 17, 2007, 12:47:00 pm
Sry I misphrased my post, I meant to say that all 83+ BASIC posts should be kept 83+ and that a warning should be made if a trick is 84+ only, for example bold text at top of the post saying "warning: this trick is 84+ only"

that way new people can make the difference and not ask why they cannot find the command or get confused
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 17, 2007, 01:28:00 pm
Oh okay, well yeah the trick isn't 84+ only. The trick can work for both calculators just fine.
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on November 17, 2007, 01:30:00 pm
Really? Cuz it had Tmr suffix/prefix in the function name and 83+/SE has no clock o.oblink.gif
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 17, 2007, 01:44:00 pm
The timer thing wasn't the trick.

The e3 against 10^( was the trick.
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on November 17, 2007, 02:22:00 pm
yeah i know this was 83+ compatible, i was talking about the starttmr thing afterward
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 17, 2007, 02:33:00 pm
Ah, okay. Yeah, I don't think anyone was mentioning startTmr as a trick. They were just correcting what someone was saying.

Sorry if I am misinterpreting what you are saying.
Title: New Tricks For Pure Basic Coders.
Post by: DJ Omnimaga on November 18, 2007, 01:54:00 pm
nah this is ok, I may have missed something too, It was weird that it jumped right from e3 to startTmr o.oblink.gif
Title: New Tricks For Pure Basic Coders.
Post by: simplethinker on November 19, 2007, 10:18:00 am
They were just using the timer to prove which command was faster/slower, it's easier than counting bars/pixels
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 19, 2007, 11:54:00 am
Haha, yeah. Easier is an understatement; counting with bars/pixels sucks compared to letting the timer do it. Plus I can run as many tests as I want, and as fast as I want without screwing up.
Title: New Tricks For Pure Basic Coders.
Post by: JoostinOnline on November 20, 2007, 05:37:00 am
QuoteBegin-simplethinker+17 Nov, 2007, 16:19-->
QUOTE (simplethinker @ 17 Nov, 2007, 16:19)
I think the only commands on an 84 that aren't on an 83+ are the time/date commands and the OpenLib,ExecLib ones  

 They added others as well. For a complete list visit http://education.ti.com/educationportal/sites/US/productDetail/us_os_84plus.html?subid=4&topid=60 and http://education.ti.com/educationportal/sites/US/productDetail/us_os_84plus.html?subid=2&topid=60
Title: New Tricks For Pure Basic Coders.
Post by: Halifax on November 20, 2007, 02:02:00 pm
Ah, that's cool. So basically, yeah, it is only the timer and lib commands, and a new GetCalc that are added.