OpenGL 1k Framework with Nasm/GoLink

For the past 20 years I have been fascinated with the demoscene, it's always truly amazing to see what demomakers can achieve and during the 90s you could say the demoscene was way ahead of its time when talking about what could be done with a home computer. Coders would find a way to run computer intensive programs in realtime, things most of us would think impossible because of the hardware limitation. Trackers would always find a way to make their module sound better, or manage to fit many instruments in a limited 4 channels mod. Gfx artists would create fantastic images either because of the originality or because they were getting closer and closer to a photography. Spending days participating in contests and watching the audience going crazy when the productions are playing on the big screen at a demoparty is really something.

Enough with the nostalgia, while reading the bbs over pouet.net I stumbled upon this nice little thread about 1k OpenGL framework. Jeff "drift" Symons shares some tips and tricks to get started and make a tiny program running an OpenGL fragment shader. Since the original code was in C/C++ I thought it would be nice to make a Nasm/GoLink assembly version and see how I could squeeze some bytes.

The reason to do this in assembly is to make the binary as small as possible. Demomakers use packers to get their binary even smaller and fit the 1k/4k/64k limits. My goal was just to have a starting point in assembly and try making a tiny unpacked binary.

The results are:

  • 19,456 bytes for the C/C++ version compiled with MinGW
  • 2,560 bytes for the Assembly version compiled with Nasm

Both versions are exactly the same, it plays a plasma effect in an OpenGL fragment shader and some MIDI ambient noise in the background.

OpenGL 1k Framework with Nasm/GoLink - 01

I might experiment and put another fragment shader soon to show what such a tiny binary can do.

You can find the source on github: github.com/mrt-prodz/NASM-OpenGL-1k-Framework