WebAssembly Fantasy Consoles

There are various serious use cases of WebAssembly out there.

That is all well and good, for your day job.

A somewhat less serious, but arguably more ✨ fun✨ use case of WebAssembly 2 is to rely on it when developing games (or other art for that matter) targeting a Fantasy Console. 3

Fantasy consoles

Three such consoles (fantasy machines with access to a WebAssembly runtime) are WASM-4, MicroW8 and TIC-80. Over the last couple of years I have experimented with all three of them.

Tips💡

Being able to write some code, compile it into a .wasm and have it automatically reloaded in the fantasy console is great. (I often use a file system watcher to trigger the recompilation)

You’ll be limited to a number of colors (in a palette), you are however free to replace the palette with one of your own, or maybe (more likely) one of the most popular ones from the Lospec Palette list 🎨

You can also rely on tricks such as palette shifting 4 and dither 5

I have published a *-init CLI for each of these consoles. (Linked in respective section below)


WASM-4

WASM-4 6 is currently my favorite fantasy console, it is severely limited.

Specs

  • Resolution: 160x160
  • Colors: 4
  • Memory: 64 KB (A single WebAssembly memory page)
  • Input: 4 gamepads with D-Pad + 2 Buttons, Mouse
  • Audio: 2 pulse wave channels, 1 triangle wave channel, 1 noise channel
  • Storage: 1024 bytes

Website | GitHub | w4-init

Example of a WASM-4 cart I’ve written


MicroW8

MicroW8 7 is less limited than WASM-4. However, I have found its web runtime to be less convenient for development.

The initial motivation behind MicroW8 was to explore whether there was a way to make WebAssembly viable for size-coding. 8

Specs

  • Resolution: 320x240
  • Colors: 256
  • Memory: 256KB (4 WebAssembly memory pages)
  • Input: 1 gamepad with D-Pad + 4 Buttons
  • Audio: 4 channels with individual volume control. (rect, saw, tri, noise wave forms selectable per channel. 32 bytes of sound registers)

Website | GitHub | uw8-init


TIC-80

TIC-80 9 is a console with an IDE 10, not for the code resulting in a .wasm though.

You will need the PRO version of TIC-80 in order to load cartridges in text format (such as .wasmp)

Specs

  • Resolution: 240x136
  • Colors: 16
  • Memory: 256KB addressable memory 11
  • Sprites: 256 8x8 tiles and 256 8x8 sprites
  • Map: 240x136 cells, 1920x1088 pixels
  • Input: 4 gamepads with 8 buttons / mouse / keyboard
  • Audio: 4 channels with configurable waveforms

Website | GitHub | tic-init


  1. A content delivery network (CDN) is a geographically distributed network of proxy servers. ↩︎

  2. WebAssembly is a binary instruction format for a stack-based virtual machine↩︎

  3. A fantasy console is an emulator for a fictitious video game console. ↩︎

  4. Palette shifting is a technique used in computer graphics in which colors are changed in order to give the impression of animation. ↩︎

  5. Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. ↩︎

  6. WASM-4 is a low-level fantasy game console for building small games with WebAssembly. ↩︎

  7. The MicroW8 repo hasn’t had much activity lately. ↩︎

  8. Size coding being the art of creating tiny (often <= 256 bytes) graphical effects and games. ↩︎

  9. TIC-80 is pretty similar to the more popular PICO-8 (Unfortunately PICO-8 does not support WebAssembly based games) ↩︎

  10. An integrated development environment (IDE) is a software application that provides comprehensive facilities for software development. ↩︎

  11. TIC-80 WASM “hardware” limits; 112KB base RAM for memory mapped I/O, SFX, VRAM, etc. 160KB of RAM free for cartridge use. ↩︎

Peter Hellberg

My name is Peter Hellberg and I’m a Systems Developer in Stockholm, Sweden.