Admin | Edit

Twigs - Linux 512b (inérciaDemoparty 2020)


My first tiny program which is basically a POC and demonstrated that some of my engraving-like IFS fractals can be reduced down to a small program.

The process was simple on this one because it is a straightforward port from the Processing sketch, there was four issues if i recall :
There was no saturation on the party release so pixels value loop around if run for too long, it can be seen on the image above on parts of the leaves, a decision i had to make because i couldn't fit saturation arithmetic at the time, later found a "cheap" solution by using SIMD SSE2 instructions.

Also found a quite obvious optimization (code redundancy) after the party release which resulted in 8 bytes gain on the final binary.

The PRNG part can also use the RDRAND instruction with a ~6 bytes gain for a small compatibility price (won't works on old CPU).

The code is full C with some minimal assembly language for the fbdev API calls, first version also use floats.

One advantage of doing it full C (there is no ELF header tricks on the party version) is that it both works on 32 and 64 bits systems without issues, porting it is thus fairly easy.

The final binary is compressed with LZMA and a small shell stub is added at the front of the binary, the stub execute some command-line instructions at the start of the executable and unpack the binary somewhere then run it.

Not too fond of the stub method due to the shell / requirements but it works okay for this kind of size target and it is a cheap / fast method to shrink the executable.

Perhaps this program could have been reduced to 256 bytes with assembly and fixed-point arithmetic.

The binary size vary with the framebuffer resolution (it is fixed), party version is reduced to 497 bytes at 1024x768.

I later improved the code so that everything fit into 426 bytes at 1920x1080 without the compression / stub phase, it also use fixed-point arithmetic and a custom ELF header with fbdev setup code in assembly which helped to reduce the binary size a lot .

what if you zoom out ? (also did a quick post-processed version later)

the original

back to topLicence Creative Commons