In the console
WASM-4 Arcade
Controls
Keys: arrows, X and Z. A second player uses ESDF, A and Tab. Gamepads work too. R resets, Esc gives the arrow keys back to the page. Click the TV screen first, or press Play.
To swap a cart, click it in the rack, or drag it onto the console. Click the cart in the console to push it again (a reset). Drag the room to look round, double-click to look straight again.
What is WASM-4?
WASM-4 is a fantasy console by Bruno Garcia and contributors: a games machine that exists only as a specification and a runtime. A game is a WebAssembly module of 64 KB or less. The screen is 160 × 160 pixels with four colours from a palette that the cart can change. Input is up to four gamepads with a d-pad and two buttons, X and Z, and a mouse. Sound comes from four channels: two pulse waves, a triangle and noise. A cart can save 1024 bytes.
Because the cart is plain WebAssembly, it can be written in any language that compiles to it: C, Rust, Zig, Go, AssemblyScript, Nim, Odin and more. The console gives each cart one 64 KB page of memory. The framebuffer, palette, gamepads and mouse are at fixed addresses in that memory, and the cart calls a small set of functions: blit, rect, line, oval, text, tone, diskr and diskw. The console calls the cart's update 60 times a second.
This room runs a JavaScript port of the official WASM-4 web runtime (ISC licence). The room, the TV and the CRT are our own: the glass is a shader with barrel curvature, a beam for each of the 160 lines, an aperture grille, bloom, flicker and the static of a channel change. With no WebGL, the page shows a flat CRT (a WGSL shader, or the 2D tube of our slow-scan television page).
Credits and licences
Runtime: WASM-4 by Bruno Garcia, ISC licence (runtime/LICENSE.txt). Carts: the binaries that the wasm4.org showcase serves, by their authors under the licences below. The full licence text of each cart is in carts/licenses/, and the full list, with the carts that we did not take and why, is in CREDITS.md. 3D: three.js r160 (MIT). The room, its models and textures are our own; the drinks are unbranded.