Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:10 29 Mar 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Bubble Universe Demo

     Page 2 of 2    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1567
Posted: 07:21pm 21 Nov 2022
Copy link to clipboard 
Print this post

  Goksteroo said  OOps... public video now

what is that running on please?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8516
Posted: 07:38pm 21 Nov 2022
Copy link to clipboard 
Print this post

Best I can do incrementally 411mSec

' Bubble Universe
Dim Float u,a,p,q,t,v=0, x=0
Dim Integer b,i,j,c(1764*2),d(1764*2),e(1764*2),f(1764*2)
Math set 3,e()
Const w=MM.HRes/2, h=MM.VRes/2
Const r=(2*Pi)/235, o=h/2
Backlight 95:CLS RGB(black)
t=Rnd*10
Timer =0
b=0
For i=50 To 255 Step 5
For j=50 To 255 Step 5
  f(b)=0
  Inc b
  f(b)=RGB(i,j,130)
  Inc b
Next j
Next i
Do
Print Timer
Timer =0
b=Peek(varaddr c())
Memory copy b+8,b,1764*2*8-8
b=Peek(varaddr d())
Memory copy b+8,b,1764*2*8-8
Inc t,0.025:b=1

For i=50 To 255 Step 5
  a=r*i
  For j=50 To 255 Step 5
    p=i+v:q=a+x
    u=Sin(p)+Sin(q):v=Cos(p)+Cos(q)
    x=u+t:c(b)=u*o+w:d(b)=v*o+h
    Inc b,2
  Next
Next
Box c(),d(),e(),e(),0,,f()
Loop
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 400
Posted: 08:00pm 21 Nov 2022
Copy link to clipboard 
Print this post

You got me thinking, bad thing, so.. how about this, using my original of doing the plotting in blocks of 41, but storing the result in a 2D array, then using the Math Split and Insert to move chunks around, into 1D arrays for plotting, smooth animation and 350mS refresh :-) So close to 3Hz update...
' 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)
Dim Integer f(41,41),l(41,41),m(41,41)
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()

g=0
For i=50 To 255 Step 5
b=0
For j=50 To 255 Step 5
 m(g,b)=RGB(i,j,130):Inc b
Next
Inc g
Next
Do
Inc t,0.025:g=0:Timer =0
For i=50 To 255 Step 5
b=0
a=r*i
Math Slice f(),g,,c()
Math Slice l(),g,,d()
Box c(),d(),e(),e(),0,,0
For j=50 To 255 Step 5
 p=i+v:q=a+x
 u=Sin(p)+Sin(q):v=Cos(p)+Cos(q)
 x=u+t:c(b)=w+u*o:d(b)=h+v*o
 Inc b
Next
Math Slice m(),g,,n()
Box c(),d(),e(),e(),0,,n()
Math Insert f(),g,,c()
Math Insert l(),g,,d()
Inc g
Next i
Print Timer
Loop
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3422
Posted: 09:22am 22 Nov 2022
Copy link to clipboard 
Print this post

Pico VGA version
' Bubble Universe
mode 2
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)
Dim Integer f(41,41),l(41,41),m(41,41)
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 2,e()'Math set 3,e()

For g=0 to 41
 for b=0 to 41
   m(g,b)=rgb(g*6,b*6,128*(g+b>30)*(g+b<60))
Next:Next

Do
Inc t,0.025:g=0:Timer =0
For i=50 To 255 Step 5
b=0
a=r*i
Math Slice f(),g,,c()
Math Slice l(),g,,d()
Box c(),d(),e(),e(),0,,0
For j=50 To 255 Step 5
p=i+v:q=a+x
u=Sin(p)+Sin(q):v=Cos(p)+Cos(q)
x=u+t:c(b)=w+u*o:d(b)=h+v*o
Inc b
Next
Math Slice m(),g,,n()
Box c(),d(),e(),e(),0,,n()
Math Insert f(),g,,c()
Math Insert l(),g,,d()
Inc g
Next i
'Print Timer
Loop

PicomiteVGA PETSCII ROBOTS
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 400
Posted: 11:54am 22 Nov 2022
Copy link to clipboard 
Print this post

Hi Volhout,
Yes I like the way you've got the colours working with a limited set. :-)
You could of course, make use of the framebuffer on the VGA, which means you can get rid of all the array saving and copying, which only saves a surprisingly small amount of time, but it does mean you can increase the number of pixies to 2600, for approx the same refresh rate, I've reduced the pixi size as well, because I thought it looked a bit better, your choice, also if you want the faster update, or more points? just change the loop step back to 5 amazingly, there is almost no difference between drawing a small box 1x1 or 2x2 or even 10x10 rather than using the pixel command?
Regards, Kevin.

' Bubble Universe
MODE 2
Dim Float u,a,p,q,t,v=0, x=0
Dim Integer g,b,i,j,c(51),d(51),e(51),n(51)
'Dim Integer f(51,51),l(51,51),m(51,51)
Dim Integer m(41,51)
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 1,e()'Math set 3,e()
FRAMEBUFFER create
FRAMEBUFFER write f

For g=0 To 41
For b=0 To 51
  m(g,b)=RGB(g*6,b*5,128*(g+b>30)*(g+b<60))
  If g<26 And b<13 Then m(g,b)=RGB(0,128,0)
Next :Next

Do
CLS
Inc t,0.025:g=0:Timer =0
For i=50 To 255 Step 5
b=0:a=r*i
'Math Slice f(),g,,c()
'Math Slice l(),g,,d()
'Box c(),d(),e(),e(),0,,0
'Pixel c(),d(),0
For j=50 To 255 Step 4
p=i+v:q=a+x
u=Sin(p)+Sin(q):v=Cos(p)+Cos(q)
x=u+t:c(b)=w+u*o:d(b)=h+v*o
Inc b
Next
Math Slice m(),g,,n()
Box c(),d(),e(),e(),0,,n()
'Pixel c(),d(),n()
'Math Insert f(),g,,c()
'Math Insert l(),g,,d()
Inc g
Next i
FRAMEBUFFER copy f,n
Print Timer
Loop


PS. just noticed that a subset of the pixels were being coloured black, so I've forced them to be mid green.
Edited 2022-11-22 23:32 by Bleep
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1567
Posted: 05:33pm 27 Nov 2022
Copy link to clipboard 
Print this post

  Volhout said  Pico VGA version
' Bubble Universe
mode 2
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)
Dim Integer f(41,41),l(41,41),m(41,41)
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 2,e()'Math set 3,e()

For g=0 to 41
 for b=0 to 41
   m(g,b)=rgb(g*6,b*6,128*(g+b>30)*(g+b<60))
Next:Next

Do
Inc t,0.025:g=0:Timer =0
For i=50 To 255 Step 5
b=0
a=r*i
Math Slice f(),g,,c()
Math Slice l(),g,,d()
Box c(),d(),e(),e(),0,,0
For j=50 To 255 Step 5
p=i+v:q=a+x
u=Sin(p)+Sin(q):v=Cos(p)+Cos(q)
x=u+t:c(b)=w+u*o:d(b)=h+v*o
Inc b
Next
Math Slice m(),g,,n()
Box c(),d(),e(),e(),0,,n()
Math Insert f(),g,,c()
Math Insert l(),g,,d()
Inc g
Next i
'Print Timer
Loop


lcd but needed to remove mode 2
https://www.youtube.com/watch?v=kxrZFLxrB18
I prefered the first one https://www.youtube.com/watch?v=9hnGAgYMIv0
Edited 2022-11-28 03:37 by stanleyella
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 400
Posted: 09:18pm 07 Dec 2022
Copy link to clipboard 
Print this post

Hi Peter,
I've just found something interesting and unexpected.
I've installed your latest release, to have a play with the Pack and Unpack functions.
I decided to try packing the colour information in this program, so it only uses half the space, just because. In doing this, so basically replacing the Math Slice with a Memory pack and unpack, the program now runs in 344mS instead of 350mS as in the listing above, for the LCD, of the 22nd Nov. This seems counter intuitive, to me, as I would suspect there is a little bit more work involved in the unpacking, than a straight Slice, whatever the reason, it's magically faster. I tested both versions on the same release, just in case some new compiler optimisation had occurred. I also tried doing this on my VGA version and that sped up from 377mS to 359mS?
Interesting.
Regards, Kevin.
' Bubble Universe LCD
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(41,41),l(41,41),m(21,41)
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()

nn=Peek(varaddr n())
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 i
Do
Inc t,0.025:g=0:Timer =0
For i=50 To 255 Step 5
b=0:a=r*i
Math Slice f(),g,,c():Math Slice l(),g,,d()
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()
Math Insert f(),g,,c()
Math Insert l(),g,,d()
Inc g
Next i
Print Timer
Loop

Edited 2022-12-08 07:33 by Bleep
 
Goksteroo
Senior Member

Joined: 15/03/2021
Location: Australia
Posts: 110
Posted: 11:01am 08 Dec 2022
Copy link to clipboard 
Print this post

  stanleyella said  
  Goksteroo said  OOps... public video now

what is that running on please?


software is MMB4W on my latest PC build:
 CPU - Gen 12 I5-12600 @ 4.9GHz max (10 cores, 16 threads)
 Memory - 32GB @3200
 GPU - Nvidia GTX 1650
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 400
Posted: 12:06pm 08 Dec 2022
Copy link to clipboard 
Print this post

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
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024