Bubble Universe Demo


Author Message
Bleep

Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 795
Posted: 12:06pm 08 Dec 2022      

As a result of the speed improvement I found by using the new Pack and Unpack functions, I've gone the whole hog and compressed all the 2D arrays, the bubble universe animation now runs at 319mS per iteration (better than 3Hz) on my 480x320 LCD Picomite, at 378MHz a not insignificant improvement on the previous of 350mS :-)
Still don't really understand why though?
' Bubble Universe
Dim Float u,a,p,q,t,v=0, x=0
Dim Integer g,b,i,j,c(41),d(41),e(41),n(41),nn
Dim Integer f(11,41),l(11,41),m(21,41),dd,cc
Const w=MM.HRes/2, h=MM.VRes/2
Const r=(2*Pi)/235, o=h/2
CLS RGB(black):Backlight 95
t=Rnd*10:Math set 3,e()
t=1
nn=Peek(varaddr n())
dd=Peek(varaddr d())
cc=Peek(varaddr c())
g=0
For i=50 To 255 Step 5
b=0
For j=50 To 255 Step 5
 n(b)=RGB(i,j,130):Inc b
Next
Memory pack nn, Peek(varaddr m(0,g)),42,32
Inc g
Next
Do
Inc t,0.025:g=0:Timer =0
For i=50 To 255 Step 5
b=0:a=r*i
Memory unpack Peek(varaddr f(0,g)),cc,42,16:Memory unpack Peek(varaddr l(0,g)),dd,42,16
Box c(),d(),e(),e(),0,,0
For j=50 To 255 Step 5
u=Sin(i+v)+Sin(a+x):v=Cos(i+v)+Cos(a+x)
x=u+t:c(b)=w+u*o:d(b)=h+v*o:Inc b
Next
Memory unpack Peek(varaddr m(0,g)),nn,42,32:Box c(),d(),e(),e(),0,,n()
Memory pack cc,Peek(varaddr f(0,g)),42,16:Memory pack dd,Peek(varaddr l(0,g)),42,16
Inc g
Next i
Print Timer
Loop

Edited 2022-12-08 22:10 by Bleep