- Edge Computing in a content delivery network 1 such as Fastly and Cloudflare.
- Plugins, such as in sqlc, Typst and Extism.
- Browser based applications, for example Figma, Adobe Photoshop and AutoCAD Web.
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
Links
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 not to be as 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)
Links
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
Links
-
A content delivery network (CDN) is a geographically distributed network of proxy servers. ↩︎
-
WebAssembly is a binary instruction format for a stack-based virtual machine. ↩︎
-
A fantasy console is an emulator for a fictitious video game console. ↩︎
-
Palette shifting is a technique used in computer graphics in which colors are changed in order to give the impression of animation. ↩︎
-
Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. ↩︎
-
WASM-4 is a low-level fantasy game console for building small games with WebAssembly. ↩︎
-
The MicroW8 repo hasn’t had much activity lately. ↩︎
-
Size coding being the art of creating tiny (often <= 256 bytes) graphical effects and games. ↩︎
-
TIC-80 is pretty similar to the more popular PICO-8 (Unfortunately PICO-8 does not support WebAssembly based games) ↩︎
-
An integrated development environment (IDE) is a software application that provides comprehensive facilities for software development. ↩︎
-
TIC-80 WASM “hardware” limits; 112KB base RAM for memory mapped I/O, SFX, VRAM, etc. 160KB of RAM free for cartridge use. ↩︎