Beyond

Demoscene

I wrote a 3,184-byte intro for this site. This page is how intros that small are made, and why I care.

How it is built

01 · My intro

demoscene.sys

One fragment shader and one synth, in 3,184 bytes. No textures, no models, no samples. If it is on screen, the code computed it.

Picture
A quaternion Julia set, raymarched over a black mirror floor
Sound
WebAudio oscillators and one noise buffer, 16 steps per bar
Structure
Four shots of eight bars, cut on the bar
File
demo.bin, a raw deflate stream that the page inflates and runs

It has sound. Press M to mute and Escape to exit, or enter the Konami code anywhere on the site. The crimson lights pulse on the kick, less than once a second. With reduced motion on, it shows one still frame. The toolbar belongs to the page and is not counted in the 3,184 bytes.

A frame from the intro: a dark chrome fractal shaped like a drill hangs over a black mirror floor, lit in crimson, with its reflection below.
Another frame: a pale chrome ring-shaped fractal with a crimson halo above its reflection.
Two frames from demoscene.sys, rendered from the same shader that ships in the file.

02

Size limits

The rule is simple and brutal: the whole program has to fit in a size limit. 64k means 65,536 bytes. 4k means 4,096 bytes, music included. Some people compete at 256.

At that size you cannot ship a picture or a sound. You ship the code that makes them. This page is heavier than the intro it hosts.

Budget to scale

log scale · bytes

    Log scale. The dashed line is the budget you picked. The page and the 4k intro are measured, the rest is arithmetic from round sizes.

    03

    Packing

    Then you cheat, legally. The code is minified until nobody can read it, then compressed, and a tiny stub unpacks it at launch. Malware authors do exactly the same thing, for worse reasons.

    One picture, four sizes

    code · pixels · deflate
    …

      Counts are real: the browser counts the characters and runs the same kind of deflate stream demoscene.sys uses. Log scale, so the gap from 192,000 to 304 bytes looks smaller than it is.

      04

      Procedural effects

      The old effects need no image at all. A plasma is a few sine waves added per pixel and looked up in a palette. A starfield is (x, y) divided by z. Turn the sines off one by one and watch the plasma fall apart.

      Plasma, four sines

      canvas · no textures

      4 of 4 terms added

      1.0×
      1.0×

      Each pixel adds the active waves and looks the result up in a palette. With one term left you get plain bands.

      Recalculated each frame at low resolution. Starts still if reduced motion is on.

      05 · 1993 to 2004

      Milestones

      Two productions that still do not look possible.

      A frame from a 64k intro: a bright spiral galaxy with small dark planets against a starfield, rendered in soft blue light.
      A frame from Beyond, a 64k intro by Conspiracy from 2004. Image: Gargaj, Wikimedia Commons, CC BY-SA 2.5.

      Future Crew · Assembly 1993 · MS-DOS

      Second Reality

      Future Crew's Second Reality won the PC demo competition at Assembly 1993. It runs under MS-DOS on a 386 with 570 KB of free memory, and every effect lands on the music. In 1993.

      Second Reality: a plasma effect in purple and blue. Second Reality: a tunnel of dotted rings. Second Reality: rings of dots hovering above a grey floor. Second Reality: rolling blue water.
      Four effects from Second Reality: plasma, tunnel, vector balls and water. Public-domain screenshots, Wikimedia Commons.

      .theprodukkt · Breakpoint 2004 · 97,280 B

      .kkrieger

      Eleven years later, Farbrausch's offshoot .theprodukkt won the Breakpoint 2004 96k game competition with .kkrieger, a full 3D shooter in one 97,280-byte file. It stores no textures and no meshes, only the recipe to build them, and unfolds into hundreds of megabytes in RAM at launch. It is a packer taken as far as it goes.

      A screenshot of .kkrieger, a first-person shooter showing a dim corridor with textured walls.
      .kkrieger, the 97,280-byte shooter. Image: .theprodukkt, Wikimedia Commons, BSD licence.

      06

      Why a reverse engineer cares

      Sizecoding is my job run backwards. To save bytes you have to know exactly how the loader maps a file, how much precision a constant can lose, and what compresses well. When I unpack a sample in IDA or x64dbg, I am looking at the same tricks from the other side.

      The one everybody points to is Elevated (RGBA and TBC, Breakpoint 2009): mountains, clouds, water and a full score in under 4,096 bytes. My intro is nowhere near that, and I am fine with it.

      Old source code

      Future Crew released the source of Second Reality in 2013, for its 20th anniversary: Watcom C, Turbo Pascal and x86 assembly. Fabien Sanglard wrote a full code walkthrough. It is the best way I know to see how it was really made.

      Still running

      The scene is not a museum. It still meets every Easter at Revision. Between parties, Pouët keeps every production with its comment thread, and scene.org keeps the original files.

      A fisheye photo of an indoor arena filled with rows of tables and computers at Assembly 2002.
      The hall at Assembly 2002, filled with rows of people and their computers. Image: Jone, Wikimedia Commons, CC BY-SA 3.0.