A CHIP-8 emulator written in C, compiled to WebAssembly using Emscripten. Rendering is done via SDL2 on an HTML5 canvas.
| Action | Key |
|---|---|
| Player 1 up | 1 |
| Player 1 down | 4 |
| Player 2 up | D |
| Player 2 down | C |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh # Linux / macOS
# or on Windows:
.\emsdk_env.bat
emccmust be available in your PATH before running any build command. Re-runemsdk_envin each new terminal session, or use--permanentto add it to your system PATH.
# Production build
npm run build
# Debug build (assertions + heap checking)
npm run build-debug
# Build then start local server (requires: npm install -g http-server)
npm start
# Start server only, no build
npm run server
# Alternative server using Python (no install needed)
python3 -m http.server 8080Open http://localhost:8080 in your browser.
The game must be served over HTTP — opening
index.htmldirectly viafile://will not work due to browser WASM restrictions.
chip8.c / chip8.h — Emulator core (opcodes, display, input)
html_template/ — Emscripten HTML shell template
rom/pong.c8 — Bundled ROM
index.html — Generated output (from emcc build)
index.js / index.wasm — Generated WebAssembly bundle
- Full CHIP-8 instruction set (35 opcodes)
- 64×32 display scaled to 640×320 via SDL2 streaming texture
- Keyboard mapped to CHIP-8 hex keypad (0–F)
- Delay and sound timers decrement at 60 Hz
- 10 CPU cycles executed per frame
- Emulator logic inspired by arnsa/Chip-8-Emulator
- General architecture inspired by ColinEberhardt
