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:
Code:
:Func
:StoreGDB 1
:FnOff
:PlotsOff
:AxesOff
:CoordOff
:ExprOff
:GridOff
:RectGC
:ClrDraw
:Full
:0→Xmin
:94→Xmax
:{-}62→Ymin
:0→Ymax
:SetUpEditor FB,FBHI
:3→dim(∟FB
:8→dim(∟FBHI
:UnArchivePic1
:Lbl ME
:Menu("FIREBALL","CONTINUE",CO,"NEW GAME",NG,"QUIT",QU
:Lbl QU
:ArchivePic1
:Archive∟FB
:Archive∟FBHI
:DelVar [A]
:RecallGDB 1
:DelVar GDB1
:FnOn
:ClrHome
:Disp "PROGRAMMED BY","AARON ROTH"
:Stop
:Lbl HS
:ClrHome
:For(A,1,8
:Output(A,1,A
:Output(A,2,":
:Output(A,4,∟FBHI(A
:End
:Pause
:ClrHome
: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
:1→∟FB(1
:18→∟FB(2
:[[11,11,11,11,11,11,11,11,11,11,11,11][0,1,0,1,0,1,0,1,0,1,0,1][11,11,11,11,11,11,11,11,11,11,11,11][2,3,2,3,2,3,2,3,2,3,2,3][11,11,11,11,11,11,11,11,11,11,11,11][6,7,6,7,6,7,6,7,6,7,6,7]]→[A]
:Goto GM
:Lbl L2
:2→∟FB(1
:28→∟FB(2
:[[12,13,12,13,11,11,11,11,14,15,14,15][12,13,12,13,12,13,14,15,14,15,14,15][11,11,12,13,12,13,14,15,14,15,11,11][11,11,14,15,14,15,12,13,12,13,11,11][14,15,14,15,14,15,12,13,12,13,12,13][14,15,14,15,11,11,11,11,12,13,12,13]]→[A]
:Goto GM
:Lbl L3
:3→∟FB(1
:16→∟FB(2
:[[11,11,11,11,2,3,2,3,11,11,11,11][11,11,2,3,11,11,11,11,2,3,11,11][2,3,11,11,6,7,6,7,11,11,2,3][2,3,11,11,6,7,6,7,11,11,2,3][11,11,2,3,11,11,11,11,2,3,11,11][11,11,11,11,2,3,2,3,11,11,11,11]]→[A]
:Goto GM
:Lbl L4
:4→∟FB(1
:18→∟FB(2
:[[4,5,11,11,16,17,11,11,4,5,11,11][11,11,16,17,11,11,4,5,11,11,16,17][16,17,11,11,4,5,11,11,16,17,11,11][11,11,4,5,11,11,16,17,11,11,4,5][4,5,11,11,16,17,11,11,4,5,11,11][11,11,16,17,11,11,4,5,11,11,16,17]]→[A]
:Goto GM
:Lbl L5
:5→∟FB(1
:16→∟FB(2
:[[0,1,0,1,11,11,11,11,14,15,14,15][0,1,11,11,11,11,11,11,11,11,14,15][11,11,11,11,14,15,0,1,11,11,11,11][11,11,11,11,0,1,14,15,11,11,11,11][14,15,11,11,11,11,11,11,11,11,0,1][14,15,14,15,11,11,11,11,0,1,0,1]]→[A]
:Goto GM
:Lbl L6
:6→∟FB(1
:18→∟FB(2
:[[20,21,11,11,6,7,20,21,11,11,6,7][11,11,20,21,11,11,11,11,6,7,11,11][20,21,11,11,6,7,20,21,11,11,6,7][11,11,20,21,11,11,11,11,6,7,11,11][20,21,11,11,6,7,20,21,11,11,6,7][11,11,20,21,11,11,11,11,6,7,11,11]]→[A]
:Goto GM
:Lbl L7
:7→∟FB(1
:23→∟FB(2
:[[12,13,6,7,12,13,6,7,12,13,6,7][6,7,11,11,11,11,11,11,11,11,12,13][12,13,11,11,12,13,6,7,11,11,6,7][6,7,11,11,6,7,11,11,11,11,12,13][12,13,11,11,12,13,11,11,11,11,6,7][6,7,11,11,6,7,12,13,6,7,12,13]]→[A]
:Goto GM
:Lbl L8
:8→∟FB(1
:24→∟FB(2
:[[11,11,11,11,11,11,2,3,16,17,2,3][11,11,11,11,2,3,16,17,2,3,16,17][11,11,2,3,16,17,2,3,16,17,2,3][2,3,16,17,2,3,16,17,2,3,11,11][16,17,2,3,16,17,2,3,11,11,11,11][2,3,16,17,2,3,11,11,11,11,11,11]]→[A]
:Goto GM
:Lbl L9
:9→∟FB(1
:14→∟FB(2
:[[11,11,20,21,11,11,11,11,20,21,11,11][11,11,20,21,11,11,11,11,20,21,11,11][11,11,11,11,11,11,11,11,11,11,11,11][12,13,11,11,11,11,11,11,11,11,12,13][12,13,12,13,11,11,11,11,12,13,12,13][11,11,12,13,12,13,12,13,12,13,11,11]]→[A]
:Goto GM
:Lbl L0
:10→∟FB(1
:28→∟FB(2
:[[2,3,2,3,2,3,2,3,2,3,2,3][4,5,11,11,11,11,11,11,11,11,4,5][4,5,4,5,2,3,2,3,4,5,4,5][4,5,4,5,2,3,2,3,4,5,4,5][4,5,11,11,11,11,11,11,11,11,4,5][2,3,2,3,2,3,2,3,2,3,2,3]]→[A]
:Lbl GM
:40→A:1→θ:1→T:1→U
:real(2,0,0,0,12,6,0,12,0,6,1,0,8,1
:real(1,A,56,2,8,1,2,16,0,0,1
:Pt-On(A+9,{-}57,3
:Lbl BL
:getKey→K
:If K=45
:Goto ME
:If K=24 or K=26
:Then
:real(1,A,56,2,8,1,4,16,0,0,1
:If θ
:Pt-Off(A+9,{-}57,3
:A+4(K=26 and A≠80)-4(K=24 and A≠0→A
:real(1,A,56,2,8,1,2,16,0,0,1
:If θ
:Pt-On(A+9,{-}57,3
:End
:
:If K=21 or K=105
:Then
:0→θ
:A+9→V:{-}57→W
:Pt-Off(V,W,3
:End
:
:If not(θ
:Then
:Pt-Off(V,W,3
:V+2T-2not(T→V
:W+2U-2not(U→W
:Pt-On(V,W,3
:
:If V=93 or V=1 or W={-}1 or (pxl-Test({-}W+3,V) and W<{-}48)
:Then
:If pxl-Test({-}W+3,V) and W<{-}48
:Then
:1→U
:∟FB(3)+5→∟FB(3
:End
:If V=93
:0→T
:If V=1
:1→T
:If W={-}1
:0→U
:End
:DelVar R
:If V≠93
:pxl-Test({-}W,V+3
:R+Ans→R
:If V≠1
:pxl-Test({-}W,V-2
:R+Ans→R
:If W≠{-}1
:pxl-Test({-}W-2,V
:R+Ans→R
: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
:Then
:If pxl-Test({-}W+3,V
:Then
:{-}W+3→L
:8(2int(V/16→K
:1→U:End
:If W≠{-}1:Then
:If pxl-Test({-}W-2,V)
:Then
:{-}W-9→L
:8(2int(V/16→K
:0→U:End:End
:If V≠93:Then
:If pxl-Test({-}W,V+3)
:Then
:V+3→K
:8int({-}W/8→L
:0→T:End:End
:If V≠1:Then
:If pxl-Test({-}W,V-2)
:Then
:V-17→K
:8int({-}W/8→L
:1→T:End:End
:If pxl-Test({-}W-1,V-1
:Then
:V-15→K:{-}W-7→L
:1→T:0→U:End
:If pxl-Test({-}W-1,V+1
:Then
:V-1→K:{-}W-7→K
:0→T:0→U:End
:If pxl-Test({-}W+1,V-1
:Then
:V-15→K:{-}W+1→L
:1→T:1→U:End
:If pxl-Test({-}W+1,V+1
:Then
:V+1→K:{-}W+1→L
:0→T:1→U
:End
:real(1,K,L,2,8,1,4,16,0,0,1
:∟FB(2)-1→∟FB(2
:∟FB(3)+10→∟FB(3
:End
:End
:If not(∟FB(2
:Then
:If ∟FB(1)≠10
:Then
:∟FB(1)+1→∟FB(1
:real(1,A,56,2,8,1,2,16,0,0,1
:Else
:Goto 10
:End:End
:If W<{-}58 and not(θ
:Goto LL
:If not(∟FB(2
:Goto CO
:Goto BL
:Lbl LL
:Goto CO
:Lbl 10
:ClrDraw
:ClrHome
:Pause "YOU WIN!
:ClrHome
:Goto ME
I would love to kow if any of you have any suggestions for code on how to speed it up. Thanks.