KermMartian wrote:
I really think you should be able to optimize Fireball further in pure TI-BASIC; it felt more sluggish than it should have to me. Can you please perhaps post in your original Fireball topic (if there is one) asking us for some optimization help, mainly in your innermost main loop?

Well, here is the code:

:StoreGDB 1
:SetUpEditor FB,FBHI
:Lbl ME
:Lbl QU
:DelVar [A]
:RecallGDB 1
:DelVar GDB1
:Lbl HS
:Goto ME
:Lbl CO
:If not(∟FB(1
:Goto NG
:If ∟FB(1)=1
:Goto L1
:If ∟FB(1)=2
:Goto L2
:If ∟FB(1)=3
:Goto L3
:If ∟FB(1)=4
:Goto L4
:If ∟FB(1)=5
:Goto L5
:If ∟FB(1)=6
:Goto L6
:If ∟FB(1)=7
:Goto L7
:If ∟FB(1)=8
:Goto L8
:If ∟FB(1)=9
:Goto L9
:If ∟FB(1)=10
:Goto L0
:Lbl NG
:Lbl L1
:Goto GM
:Lbl L2
:Goto GM
:Lbl L3
:Goto GM
:Lbl L4
:Goto GM
:Lbl L5
:Goto GM
:Lbl L6
:Goto GM
:Lbl L7
:Goto GM
:Lbl L8
:Goto GM
:Lbl L9
:Goto GM
:Lbl L0
:Lbl GM
:Lbl BL
:If K=45
:Goto ME
:If K=24 or K=26
:If θ
:A+4(K=26 and A≠80)-4(K=24 and A≠0→A
:If θ
:If K=21 or K=105
:If not(θ
:If V=93 or V=1 or W={-}1 or (pxl-Test({-}W+3,V) and W<{-}48)
:If pxl-Test({-}W+3,V) and W<{-}48
:If V=93
:If V=1
:If W={-}1
:DelVar R
:If V≠93
:If V≠1
:If W≠{-}1
:If (pxl-Test({-}W+3,V) and W≥{-}48) or R or pxl-Test({-}W+1,V-1) or pxl-Test({-}W-1,V+1) or pxl-Test({-}W+1,V+1) or pxl-Test({-}W-1,V-1
:If pxl-Test({-}W+3,V
:If W≠{-}1:Then
:If pxl-Test({-}W-2,V)
:If V≠93:Then
:If pxl-Test({-}W,V+3)
:If V≠1:Then
:If pxl-Test({-}W,V-2)
:If pxl-Test({-}W-1,V-1
:If pxl-Test({-}W-1,V+1
:If pxl-Test({-}W+1,V-1
:If pxl-Test({-}W+1,V+1
:If not(∟FB(2
:If ∟FB(1)≠10
:Goto 10
:If W<{-}58 and not(θ
:Goto LL
:If not(∟FB(2
:Goto CO
:Goto BL
:Lbl LL
:Goto CO
:Lbl 10
:Pause "YOU WIN!
:Goto ME

I would love to kow if any of you have any suggestions for code on how to speed it up. Thanks.
To start out in optimizing, we need to be rid of the Lbl/Goto loop you've got this set up in. Everytime it comes across a Goto command, it restarts the program, which effectively sets the search pointer at the top of the program, and begins looking for the proper Lbl command. This will cause a massive slow down. Need to wrap Lbl BL/Goto BL into a While or Repeat loop, pending what you feel comfortable using.

Though, I'm having a hard time not saying to remove all Lbl and Goto commands, but that's just me. Kerm knows of my distaste with those 2 functions. :p

But putting the engine loop into the proper point is where it needs to start for sure.

Sadly, looking deeper into that engine, you have several Goto commands in that. So yeah, the engine will need a bit of an overhaul to remove those so you don't cause memory leaks.
Whats the best way to avoid a memory leak without using goto commands? I block memory leaks by assigning a var within a loop then checking after and using a goto...
Well, I use

While iPart(W)=# <- 'Master loop'
If fPart(W)= <- conditionals based on the decimal value of W, lets you skip on to a different value of W

<various While W= loops, or If W= conditionals>

Of course, hardest part of this is keeping tabs on where End statements are. To leave loops, just change the value of W.
I use something like this:

:// start of game
:Lbl AA
:// Main menu
:DelVar WWhile not(W
:// Outer loop: rendering and stuff
:While not(W
:// Inner loop: keys and stuff
:Repeat K:getKey->K:End
:If K=45:1->W // 1== quit prematurely
:If [lose condition]:2->W // 2 == lose
:If [win condition]:3->W // 3 == win
:End // end inner loop
: Rerender or whatever
:End // end outer loop
:If W=1:Goto AA
:If W=2://display lose message
:If W=3://display win message and deal with high scores
:Goto AA
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 1
» 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