Last week on HCWP I was showing off a mini project testing a particle effects method I had been meaning to try for the past few years.

The features of it are:
- Speed is independent of the number of particles. For example, the particle engine in Grammer gets about 5.66FPS for 2048 particles, but much better speed for fewer particles. This version is a constant speed whether there is 1 or 6000 particles.
-The particle buffer is only 768 bytes and so it can fit in non-user (static) RAM. It holds 6144 particles, compared to 12288 bytes for an "array" type method.

How does it work?
I keep two buffers. One has the static "particles" (the stuff that doesn't move) and the other has the moving particles. To add a a particle, draw on the particle buffer. To remove, just erase the pixels. When updating the particle buffer, I scan through the pixels. If they can move down, move down, else move left or right if possible. When updating the LCD, OR the two buffers together.

Disadvantages:
Scanning through and operating on every pixel is very, very slow! To mitigate this, I scan through one byte at a time, or one whole row at a time using byte operations and bit tricks.
Advantages:
-It is very easy to add or remove particles
-The buffers are fixed size and relatively small
-Constant speed
-Performing large scale operations, such as relocating blocks of particles is much easier than it would be storing particles in a dynamic array.

So the program in action looks like this:

I decided to add a circle as a pen tool to demonstrate how easy it is to add particles. It slows the engine down quite a bit, though. With the method I use in Grammer, adding any non-rectangular shapes would be very time consuming.

Since this was just an experiment and not a project, I don't plan to add more to it. If anybody wants a copy to play with, you can download it here.
Readme:
Run it with the Asm( token.
Use [ON] to exit.
Use arrows to move the cursor.
Use [2nd] to draw on the fixed buffer (makes impassable barriers).
Use [Mode] to draw particles.
Use [Del] to delete from the fixed buffer (deletes barriers).
Use [Y=]+[Up] to increase the radius of the circle.
Use [Y=]+[Down] to decrease the radius of the circle.
Multiple key presses are supported.
The F2-F5 keys shadow [up],[right],[left],[down]
15MHz is automatically set if it is supported by your calculator.
6MHz should still expect ~22FPS according to WabbitEmu.
That's really awesome looking Very Happy You come up with some really amazing things in asm.
Thanks! I had a bunch of days off from work now that everybody is healthy again and I have been wanting to put this together.
I'm mesmerized by the particles. Awesome project, congratulations!
Nice work. It reminds me of 'Powder Game' - which would, by the way be an awesome calc project Smile
  
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

 

Advertisement