2022-07-02 22:41:04 +00:00
|
|
|
; NOTE: meant to test to virtual machine output target (use -target virtual)
|
|
|
|
|
2022-10-22 14:35:57 +00:00
|
|
|
%import math
|
|
|
|
|
2022-07-02 22:41:04 +00:00
|
|
|
main {
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
word[128] particleX
|
|
|
|
word[128] particleY
|
|
|
|
byte[128] particleDX
|
|
|
|
byte[128] particleDY
|
|
|
|
|
|
|
|
ubyte pi
|
|
|
|
for pi in 0 to 127 {
|
2022-10-22 14:35:57 +00:00
|
|
|
particleX[pi] = math.rndw() % 319 as word
|
|
|
|
particleY[pi] = math.rndw() % 240 as word
|
|
|
|
particleDX[pi] = (math.rnd() & 1)*2 as byte - 1
|
|
|
|
particleDY[pi] = (math.rnd() & 1)*2 as byte - 1
|
2022-07-02 22:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sys.gfx_enable(0) ; enable lo res screen
|
|
|
|
|
|
|
|
repeat {
|
|
|
|
fade()
|
|
|
|
plot_particles()
|
2022-09-25 18:21:35 +00:00
|
|
|
sys.wait(1)
|
2022-07-02 22:41:04 +00:00
|
|
|
sys.waitvsync()
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fade() {
|
|
|
|
uword xx
|
|
|
|
uword yy
|
|
|
|
for yy in 0 to 239 {
|
|
|
|
for xx in 0 to 319 {
|
|
|
|
ubyte pixel = sys.gfx_getpixel(xx, yy)
|
2022-08-07 08:16:22 +00:00
|
|
|
if pixel>4 {
|
2022-07-02 22:41:04 +00:00
|
|
|
pixel-=4
|
2022-08-07 08:16:22 +00:00
|
|
|
sys.gfx_plot(xx, yy, pixel)
|
|
|
|
}
|
2022-07-02 22:41:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub plot_particles() {
|
|
|
|
for pi in 0 to 127 {
|
|
|
|
particleX[pi] += particleDX[pi]
|
|
|
|
particleY[pi] += particleDY[pi]
|
|
|
|
if particleX[pi]<0 or particleX[pi]>319 {
|
|
|
|
particleDX[pi] *= -1
|
|
|
|
particleX[pi] += particleDX[pi] * 2
|
|
|
|
}
|
|
|
|
if particleY[pi]<0 or particleY[pi]>239 {
|
|
|
|
particleDY[pi] *= -1
|
|
|
|
particleY[pi] += particleDY[pi] * 2
|
|
|
|
}
|
|
|
|
sys.gfx_plot(particleX[pi] as uword, particleY[pi] as uword, 255)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|