Plasma 1k

From wiki.gp2x.org
I was inspired on irc by jix, who made the first 1k demo I had seen on the GP2X, so I followed suit. Color cycling plasma in 1k. 
The real binary is actually about 1.4k, but jix introduced me to a neat trick using tail and zcat to decompress my binary at runtime
with only a little overhead.

The important (large, reusable, improvable) parts, and their pre-compression sizes:
shell script wrapper, to decompress the binary and restart the menu, 82 bytes
palette calculation, 104 bytes
palette cycler, 136 bytes (to be improved)
random number generator, 52 bytes
recursive plasma fractal generator, 432 bytes (possibly nearly optimal)

For your enjoyment:
http://sparr.homeip.net/gp2x/plasma_1.gpe

Possible significant size improvements could still be made by moving some of the simpler algorithms to thumb mode.

At 432 bytes, the plasma generator itself makes up over 1/3 of the code. The demo-specific other parts total up to maybe 200
more bytes. Clearing all that out leaves me about 158 instructions worth of space to implement some sort of game. 
I am thinking maybe tron or pong in 1k would be a neat next project.

-- Sparr

Personal tools