Encounter - 256 bytes intro for WASM MicroW8 fantasy console

What is it?

Attempt to bring a cinematic experience in 256 bytes.

Watch

You can watch it on YouTube (recommended to select 720p60 quality)

or click the following link if you have the FireFox browser (Chrome’s implementation of WebAssembly has much worse performance). Mobile Firefox should also work well on relatively new mobile phones. The 256 bytes are encoded in the URL:

https://exoticorn.github.io/microw8/v0.2.2/#AgMvvqs+jH95brXMAYjUjZwn1apTrm62ncvO+qq+kAesx0vh5NB3sa3YEg8JasHVk0OOFeN09Qi/yWyEuuIHweJv5+qt4lQhS0q/exKHo4rtSsnqkY7oWUwXXgbWfGEwKrTto4wxOG4JXZck7ehBB9YHmyanOZxFZeCkpib2M/JXhCmCfPb3mF6tq++ZG2Mm73NopaaKwUFHm2KjpEjYFMEzCZsu98uZmvhD5GzCUXSw8G5Z1V8nfv9uiIQ1+5N+rcjpFezbIXG5/haUR7Lnre3xZVJcp+I6rXkboKqK6SoG5h92w/jndB3sdZyT4G9Lq872lkEkUIM7ciqdsyYJMg==

I personally love seeing creative process of the others (“making of”) and If you are interested in the steps I went through to create this intro, check the following recording:

I love intellectual challenges, art, computer science and in May 2024 there was another Outline demoscene party with size-coding competition. I did some 256 byte intros in the past (like drawing Mona Lisa for 6502 8bit Atari, ported to a crazy number of platforms or Thrive for TIC-80 showing a growing tree through the seasons), so I decided to join the competition once again.

If you don’t know what a demoscene is, it’s a computer subculture with roots in Europe https://en.wikipedia.org/wiki/Demoscene similar to Hacker Camps.

A large collection of demoscene productions you can find on https://demozoo.org or https://www.pouet.net

The intro is done for MicroW8 platform, which is a Fantasy Console similar to PICO-8, TIC-80 or WASM-4.

MicroW8 has capabilities close to DOS-era machines (16 bit real-mode x86 with FPU and VGA):

Screen: 320x240, 256 colors, 60Hz, customizable palette.

Memory: 256KB

but with a MUCH faster CPU powered by WebAssembly (therefore more like running nowadays FreeDOS on a modern PC).

Important note: the compiled “virtual cartridge” is compressed, therefore 256 bytes is not equal to 256 bytes of WASM code. The WASM code needs to be interconnected with the MicroW8 platform and the compression negates this overhead, leading to (according to sizecoding gurus) “code density” in 256 bytes similar to uncompressed x86/FPU code. The compression brings more benefits the bigger the code/data is, however in x86 you can also make tiny code decompressors, that you cannot do easily in WebAssembly due to executable code space separation, therefore for size-constrained programming DOS with x86 and all the tricks it offers can still be the king.

Commented code

WebAssembly is a stack-based virtual machine, which makes it easy to represent as an Abstract Syntax Tree or… in infix syntax. That’s the idea behind CurlyWAS language, that compiles Rust-like syntax into a WASM code.

CurlyWAS has ability to use keywords like “inline” (expression is evaluated every time, works similarly to C’s #define), or “lazy” (which uses the local.tee instruction which combines local.set and local.get and therefore saves on bytes).

In WebAssembly the 32bit integers are encoded in LEB128 format and CurlyWAS has sugar syntax of adding _f to a constant to convert integer to 32bit float:

(320_f) is equal to (320 as f32)