A Chip 8 Emulator in Webassembly. Renderer in WebGPU.
Demo: soumen-pradhan.github.io/chip8-wasm
The core logic of Chip-8 spec is implemented in Rust, compiled to WASM (WebAssembly). The compiled WASM module exposes its display ram
and set_key
functions.
The exposed Display ram is then used as a texture for our canvas
element. This allows us to use the WebGPU API and efficiently scale and draw the display. The exposed pointer is stable, since no rellocation happens.
This decouples the emulator logic and render logic.
Ensure you have wasm-pack installed.
Tested on
Tool | Version |
---|---|
chrome | 115 |
node | 18.16.0 |
npm | 9.5.1 |
cargo | 1.71.0 |
wasm-pack | 0.12.1 |
npm run dev
Caution:
- The first time you run
npm run dev
, a resolve error will be displayed (related to esbuild), however the packages will be served correctly. This will not happen for subsequent builds or production build. - You can add multiple rust crates, but
vite
will compile all of them regardless of which crate you modified.
npm run build