"There's a saying that states: 'The road to hell is paved with good intentions'. There's hardly anything that better describes communism than that. All good hopes and dreams of justice and equality have ended in oppression and dictatorship."
- Peter Eriksson, Green Party of Sweden

My first 1K demo
Sunday, February 13, 2011 | Permalink

Even though I have written demos for over a decade now, I have never been part of the demoscene, never gone to a demo party, and only once in a long while have I ever really run the demos that come out of the demoscene. This tends to surprise people when they get to know me if they happened to have followed my site before. In general, I've been more interested in pushing the boundaries in terms of visual quality and performance in general, rather than squeezing the most out of a particular machine or shoehorning things into tiny executables. I did at some point in my early years give 4K demos a try, maybe around 1999 or so, but I gave up pretty quickly. With even an empty main() I got an executable that was 27KB IIRC. So I figured I had a few things to learn. Well, skip forward to 2011 and I got a renewed interest in the subject, and after a little research on the subject I was up and running with a simple OpenGL app that compiled to like 950 bytes or so. Given the small size I thought it would be cool to aim for 1K instead of 4K since that was within reach.

So I made another Mandelbrot viewer, since it's something relatively compact I thought I would be able to do quickly. A Mandelbrot viewer is perhaps the most original idea, I mean, it's not something that hasn't been done before, in fact I've done several myself before, although this one has the smoothest gradients I've managed to make so far. However, the project took far more time than I had originally anticipated. Once it was visually and functionally complete, I was somewhere over 1400 bytes. In the beginning it was rather quick to trim it down, shaving off dozens of bytes with every change. Until I got down to like 1100 bytes, after which I was happy to cut off another 5-10 bytes after an hour's work. Eventually after I got down to 1045 bytes I got kind of stuck and rewriting it all in assembly might have removed another few bytes, but I wasn't sure if it would be enough to shave off 21 bytes, so instead I changed the functionality a little. Thus there are two versions of the executables, one that's small enough to fit within the 1K limit, and one that contains the originally intended functionality, and thus is like 55 bytes larger.

If anyone knows any good tricks for slimming it down further that I might have missed, please let me know.

Update 2011-02-14:
Some sources I used to get started on this project:
1k/4k demo framework and examples
Crinkler secrets, 4k intro executable compressor at its best
Graphics Size Coding

[ 23 comments | Last comment by Nuninho1980 (2016-07-30 15:51:09) ]