I created a program to display a series of progressively smaller frames(rectangles) that appear and then dissapear to create a tunnel effect. This is achieved with a set of 4 line commands (with exact screen coordinates) to draw each frame, then later another set of four line commands (with exact screen coordinates) to erase that frame. There are 11 frames so there are 11 sets to draw + 11 sets to erase = 22 sets. These are inside a goto loop. The total is 110 lines and 5Kb. Here's an example of the code to draw a single frame:

Line(9.574468,ú9.354839,ú9.574468,ú9.354839,1

Line(ú9.574468,ú9.354839,ú9.574468,9.3548387,1

Line(ú9.574468,9.3548387,9.5744681,9.3548387,1

Line(9.5744681,9.3548387,9.5744681,ú9.3548389,1

And to erase the same frame:

Line(9.574468,ú9.354839,ú9.574468,ú9.354839,0

Line(ú9.574468,ú9.354839,ú9.574468,9.3548387,0

Line(ú9.574468,9.3548387,9.5744681,9.3548387,0

Line(9.5744681,9.3548387,9.5744681,ú9.3548389,0

Is there a better, more efficient way to achieve the same effect?
Welcome to Cemetech! Absolutely. So that we can understand what you're saying as well as possible, can you please run your program through SourceCoder (http://sc.cemetech.net) and post the full program?

Code:
:ClrDraw
:Lbl A
:Line(‾10,10,10,10,1
:Line(10,10,10,‾10,1
:Line(10,‾10,‾10,‾10,1
:Line(‾10,‾10,‾10,10,1
:Line(9.574468,‾9.354839,‾9.574468,‾9.354839,1
:Line(‾9.574468,‾9.354839,‾9.574468,9.3548387,1
:Line(‾9.574468,9.3548387,9.5744681,9.3548387,1
:Line(9.5744681,9.3548387,9.5744681,‾9.3548389,1
:Line(‾9.14839362,‾8.709677,‾9.148936,8.709677,1
:Line(‾9.1483936,‾8.709677,‾9.148936,8.7096774,1
:Line(‾9.148936,8.7096774,9.1489362,8.7096774,1
:Line(9.1489362,8.7096774,9.1489362,‾8.709677,1
:Line(9.148936,‾8.709667,‾9.148936,‾8.709667,1
:Line(‾8.723404,‾8.064516,‾8.723404,8.0645161,1
:Line(‾8.723404,8.064161,8.7234043,8.0645161,1
:Line(8.7234043,8.0645161,8.7234043,‾8.064516,1
:Line(8.7234043,‾8.064516,‾8.723404,‾8.064516,1
:Line(‾8.297872,‾7.419355,‾8.297872,7.4193548,1
:Line(‾8.297872,7.4193548,8.297823,7.4193548,1
:Line(8.297823,7.4193548,8.2978723,‾7.419355,1
:Line(8.2978723,‾7.419355,‾8.297872,‾7.419355,1
:Line(‾7.87234,‾6.774194,‾7.87234,6.7741936,1
:Line(‾7.87234,6.774936,7.8723404,6.7741936,1
:Line(7.8723404,6.7741936,7.8723404,‾6.774194,1
:Line(7.8723404,‾6.774194,‾7.8723,‾6.774194,1
:Line(‾7.446809,‾6.129032,‾7.446809,6.1290323,1
:Line(‾7.446809,6.1290323,7.4468085,6.1290323,1
:Line(7.4468085,6.1290323,7.4468085,‾6.129032,1
:Line(7.4468085,‾6.1290323,‾7.446809,‾6.129032,1
:Line(‾7.021277,‾5.483871,‾7.021277,5.483871,1
:Line(‾7.021277,5.483871,7.0212766,5.483871,1
:Line(7.0212766,5.483871,7.0212766,‾5.483871,1
:Line(7.0212766,‾5.483871,‾7.021277,‾5.483871,1
:Line(‾6.595745,‾4.83871,‾6.595745,4.8387097,1
:Line(‾6.595745,4.8387097,6.5957447,4.8387097,1
:Line(6.5957447,4.387097,6.5957447,‾4.83871,1
:Line(6.5957447,‾4.83871,‾6.595745,‾4.83871,1
:Line(‾6.170213,‾4.193548,‾6.170213,4.1935484,1
:Line(‾6.170213,4.1935484,6.1702118,4.1935484,1
:Line(6.1702118,4.1935484,6.1702128,‾4.193548,1
:Line(6.1702128,‾4.193548,‾6.170213,‾4.193548,1
:Line(‾5.744681,‾3.548387,‾5.744681,3.5483871,1
:Line(‾5.744681,3.5483871,5.7446809,3.5483871,1
:Line(5.744681,3.5483871,5.7446809,‾3.548387,1
:Line(5.7446809,‾3.548387,‾5.744681,‾3.548387,1
:Line(‾5.319149,‾2.903226,‾5.319149,2.9032258,1
:Line(‾5.319149,2.9032258,5.3191489,2.9032258,1
:Line(5.3191489,2.9032258,5.3191489,‾2.903226,1
:Line(5.3191489,‾2.903226,‾5.319149,‾2.903226,1
:Line(‾4.893617,‾2.258065,‾4.893617,2.2580645,1
:Line(‾4.893617,2.2580645,4.893617,2.2580645,1
:Line(4.893617,2.2580645,4.893617,‾2.2580645,1
:Line(4.893617,‾2.2580645,‾4.893617,‾2.258065,1
:Text(28,28,"TIMs  TI-84+"
:Line(‾10,10,10,10,0
:Line(10,10,10,‾10,0
:Line(10,‾10,‾10,‾10,0
:Line(‾10,‾10,‾10,10,0
:Line(9.574468,‾9.354839,‾9.574468,‾9.354839,0
:Line(‾9.574468,‾9.354839,‾9.574468,9.3548387,0
:Line(‾9.574468,9.3548387,9.5744681,9.3548387,0
:Line(9.5744681,9.3548387,9.5744681,‾9.3548389,0
:Line(‾9.14839362,‾8.709677,‾9.148936,8.709677,0
:Line(‾9.1483936,‾8.709677,‾9.148936,8.7096774,0
:Line(‾9.148936,8.7096774,9.1489362,8.7096774,0
:Line(9.1489362,8.7096774,9.1489362,‾8.709677,0
:Line(9.148936,‾8.709667,‾9.148936,‾8.709667,0
:Line(‾8.723404,‾8.064516,‾8.723404,8.0645161,0
:Line(‾8.723404,8.064161,8.7234043,8.0645161,0
:Line(8.7234043,8.0645161,8.7234043,‾8.064516,0
:Line(8.7234043,‾8.064516,‾8.723404,‾8.064516,0
:Line(‾8.297872,‾7.419355,‾8.297872,7.4193548,0
:Line(‾8.297872,7.4193548,8.297823,7.4193548,0
:Line(8.297823,7.4193548,8.2978723,‾7.419355,0
:Line(8.2978723,‾7.419355,‾8.297872,‾7.419355,0
:Line(‾7.87234,‾6.774194,‾7.87234,6.7741936,0
:Line(‾7.87234,6.774936,7.8723404,6.7741936,0
:Line(7.8723404,6.7741936,7.8723404,‾6.774194,0
:Line(7.8723404,‾6.774194,‾7.8723,‾6.774194,0
:Line(‾7.446809,‾6.129032,‾7.446809,6.1290323,0
:Line(‾7.446809,6.1290323,7.4468085,6.1290323,0
:Line(7.4468085,6.1290323,7.4468085,‾6.129032,0
:Line(7.4468085,‾6.1290323,‾7.446809,‾6.129032,0
:Line(‾7.021277,‾5.483871,‾7.021277,5.483871,0
:Line(‾7.021277,5.483871,7.0212766,5.483871,0
:Line(7.0212766,5.483871,7.0212766,‾5.483871,0
:Line(7.0212766,‾5.483871,‾7.021277,‾5.483870,0
:Line(‾6.595745,‾4.83871,‾6.595745,4.8387097,0
:Line(‾6.595745,4.8387097,6.5957447,4.8387097,0
:Line(6.5957447,4.387097,6.5957447,‾4.83871,0
:Line(6.5957447,‾4.83871,‾6.595745,‾4.83871,0
:Line(‾6.170213,‾4.193548,‾6.170213,4.1935484,0
:Line(‾6.170213,4.1935484,6.1702118,4.1935484,0
:Line(6.1702118,4.1935484,6.1702128,‾4.193548,0
:Line(6.1702128,‾4.193548,‾6.170213,‾4.193548,0
:Line(‾5.744681,‾3.548387,‾5.744681,3.5483871,0
:Line(‾5.744681,3.5483871,5.7446809,3.5483871,0
:Line(5.744681,3.5483871,5.7446809,‾3.548387,0
:Line(5.7446809,‾3.548387,‾5.744681,‾3.548387,0
:Line(‾5.319149,‾2.903226,‾5.319149,2.9032258,0
:Line(‾5.319149,2.9032258,5.3191489,2.9032258,0
:Line(5.3191489,2.9032258,5.3191489,‾2.903226,0
:Line(5.3191489,‾2.903226,‾5.319149,‾2.903226,0
:Line(‾4.893617,‾2.258065,‾4.893617,2.2580645,0
:Line(‾4.893617,2.2580645,4.893617,2.2580645,0
:Line(4.893617,2.2580645,4.893617,‾2.2580645,0
:Line(4.893617,‾2.2580645,‾4.680851,‾2.258065,0
:Goto A
first off, you should use a repeat instead of a lbl so you dont fill up your rams, then use a for loop running from 0 to 1 to determine whether your line draw command should turn pixels on or off, then set your window x to 0,94 and your y to -62,0 so a difference of one in respect to TI's drawing commands is also a difference of exactly one pixel (this works because ti uses only 95 by 63 of the lcd's 96 by 64 pixels and these numbers are shifted over again to account for zero). then set up another for loop running from zero to 53(it took me a while to count all those draw commands Razz). this will be used to tell the drawing command how many pixels in from the start position you want it to move(use your initial value and add or subtract the for loops variable from it). finally, finish it all off with a hardy dose of ends. if you need to move the sides in faster than the top and bottom use a percentage of the for loop variable(eg .5M)

Code example:(the placements may be a little off, but this is the general idea and you can tweak those on your own)

:Text(28,28,"tim's ti84+
:Repeat getkey
:for(L,0,1
:for(M,0,53
:Line(-23+M,60.5-.5M,89-M,22+.5M,L
:end
:end
:end
That looks great, but After changing my window to Xmin=0, Xmax=94, Ymin=-62, Ymax=0, then entering the code in your example, all it does is display:

tims ti 84+

no lines are displayed on the screen. Am I missing something? Like what are the L and the M in your example? Am I supposed to sto> values to those as variables? It's looks very optimized compared to my mess, but how do I get it to work? Sorry if I'm missing the obvious...
oh right, sorry(i am tres moron)
if the y setting is 0,-62 then all your Y values have to be negative in the drawing command

so this
:Line(-23+M,60.5-.5M,89-M,22+.5M,L

should be this instead
:Line(-23+M,-60.5+.5M,89-M,-22-.5M,L

sorry about that

edit: yet again im not paying enough attention the first time(i didnt see your other question)
the Repeat command will repeat the commands it encompasses until the condition immediately to it's right is satisfied(Repeat getkey repeats until a key is pressed).
for loops take a given variable, store the initial value to it, and then increment or decrement that value by the fourth value given until it reaches the third value(ie for(L,0,6,2: ...code here... :end will store 0 to L and then increment the value of L until L=6, at which point it continues past the end and to the following code. if you want the last value to be one just leave it out and it will be one by default
Thanks, but it still not working. Now displays a sweeping pattern near center of screen. Am I supposed to set the window manually or with code? And are those [-] negative numbers or minus signs. I ran what I have through the sourcecoder and her it is including your correction:

:Text(28,28,"TIMs TI-84+
:Repeat getKey
:For(L,0,1)
:For(M,0,53)
:Line(‾23+M,‾60.5+.5M,89-M,‾22-.5M,L
:End
:End
:End

Hey, we're getting there. At least it showed something on screen. Haha
Please leave the [quote] tags and the copyright line around the code, it makes it much easier to read. Smile Here's my attempt at fixing the code:


Code:
:0->XMin:1->[deltaX]
:0->Ymin:1->[deltaY]
:ClrDraw
:Text(28,28,"TIMs TI-84+
:Repeat getKey
:For(L,0,1
:For(M,0,46
:Line(M,0.67M,94-M,0.67M,L
:Line(M,62-0.67M,94-M,62-0.67M,L
:Line(M,0.67M,M,62-0.67M,L
:Line(94-M,0.67M,94-M,62-0.67M,L
:End
:End
:End


Hopefully this does the trick for you.

Edit: Pro-tip: To leave more of the center blank, change the 46 in the line "For(M,0,46" to a smaller number.
I figured if you had a chance to take a look at it, that you would pull off some wizardry and you did. That actually fills the screen more completely but with 96 less lines of code and 4 Kb less file size! Thank you very much. The size issue was because this resides in RAM so I can use it with Start-up to run when I turn on my calculator. I made some minor adjustments to better frame my name in the middle:


Code:
:0→Xmin:1→[deltaX]
:0→Ymin:1→[deltaY]
:ClrDraw
:Text(28,28,"TIMs TI-84+
:Repeat getKey
:For(L,0,1)
:For(M,0,23)
:Line(M,0.90M,94-M,0.90M,L
:Line(M,62-0.90M,94-M,62-0.90M,L
:Line(M,0.90M,M,62-0.90M,L
:Line(94-M,0.90M,94-M,62-0.90M,L
:End
:End
:End


Thank you again and thanks to all who made suggestions. Good Idea
Awesome, glad we were able to help. I hope you stick around and perhaps learn a bit more about programming with us. Smile
I've been interested in programming for a while, but since getting my first programmable graph calc a few weeks ago, I've been really inspired (no pun intended (I have a TI-Nspire/TI-84+) haha). I've seen several examples of your work and installed some very fun and helpful programs on my calc by you and others. I hope to become more skilled at it. I'm not great at math, so in addition to computer classes, I am taking math classes as well. That should help in the long run. Should've done it years ago but better late than never! You and the other highly-skilled programmers on here are also an inspiration. This is a cool site!

-Have a good one. Talk to you soon.
Don't mean to pull you away from here or anything, continue asking your questions! However, you might have a run through some of the tutorials on TI BASIC here: http://tifreakware.net/tutorials/83p/b/

This might help you advance much faster than just trial and error, and you can still ask questions about how certain things works if you still don't understand. =]

Also, code optimization, might be a touch faster, definitely smaller:


Code:
:0→Xmin:1→[deltaX]
:0→Ymin:1→[deltaY]
:ClrDraw
:Delvar L
:Text(28,28,"TIMs TI-84+
:Repeat getKey
:not(L→L
:For(M,0,23)
:Line(M,.9M,94-M,.9M,L
:Line(M,62-.9M,94-M,62-.9M,L
:Line(M,.9M,M,62-.9M,L
:Line(94-M,.9M,94-M,62-.9M,L
:End
:End


Removed all the excess 0's, they aren't needed. Replaced a For( loop, with not(L→L because if it is 1 or 0, not(L will give the opposite. I would take the ending parenthesis off the For( but I heard rumors that putting it on there makes it faster? Don't really remember.
tifreak8x wrote:
I would take the ending parenthesis off the For( but I heard rumors that putting it on there makes it faster? Don't really remember.
That is only true when the next byte of the program is an If statement, IE "For(a,b,c : If" in all other cases its no faster and may even be slower if you count the time taken to read the extra byte from memory.
ah, well, like I said, couldn't remember. I use While for almost everything XD Have much better control of things that way.
Yeah I did that myself after I realized those zeros weren't needed. I leave the parenthesis on the For commands until it is on the calc along with other on calc optimizations like closing quotes etc. This is because I often use a program editor on my computer and it gives me syntax error messages if I exclude them. Once it is on the calc I go in and remove them. I should've edited that last example. I am trying to use as many resources as I can. I'll chk out your link thank you. I might already have it bookmarked as I've been looking at several tutorials. I also installed the on-calc tutorial and Catalog Help. Gotta run. Be back in awhile to try the examples you posted.

-Thanks again.
First here is the latest optimizations & changes that I made on my own before I saw your latest suggetions:

:0→Xmin:1→[deltaX]
:0→Ymin:1→[deltaY]
:AxesOff
:ClrDraw
:UnarchivePic9
:RecallPic 9
:Text(28,28,"TIMs TI-84+
:Repeat getKey
:For(L,0,1
:For(M,0,23
:Line(M,.9M,94-M,.9M,L
:Line(M,62-.9M,94-M,62-.9M,L
:Line(M,.9M,M,62-.9M,L
:Line(94-M,.9M,94-M,62-.9M,L
:End
:End
:End
:ArchivePic9
:ClrDraw
:ClrHome

Besides removing zeros and parenthesis, I added a call to a Pic of the first frame of the animation to my program so that it appears to start almost immediately. It's worth it to me to add a few bytes to the program and also temporarily have Pic9 in RAM in order to not have a noticable delay before the animation starts. That was the one thing I liked about my original, no delay. So today, as I have time, I will try the above examples and check out your link(s). Thanks again for all the help!

Sorry, didn't mean to be rude or hog the forum. Never done this before. Thanks for the tip. I'll try the delvar, thanks. I haven't tried any of the latest optimizations posted here yet. I'll be back in 24+hrs.
Please avoid double-posting with a 24-hour period, it's generally considered bad netiquette. Editing your post is the generally-accepted way to do it. Smile Anywho, I recommend that you at least keep TIFreak8x's Delvar L / not(L->L optimization. The Delvar will set L to 0, and the not(L->L changes L from 0 to 1 or 1 to 0, thus eliminating the L,0,1 loop (and making the program respond faster when a key is pressed.
lol, I normally don't care if it has been a full 24 hours Kerm, I usually make sure the date has at least changed. XD
tifreak8x wrote:
0x5, I normally don't care if it has been a full 24 hours Kerm, I usually make sure the date has at least changed. XD
It _was_ sixteen hours, good point. I thought it was 10pm to 2am, not pm. Smile But anyway, optimizations.
yeah. I don't really see any other things to add to it to make it any faster or smaller. About as good as it gets I think.

And the pic is not necessary with my version, as it is all pretty much instant.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement