| Crates.io | chip8wasm |
| lib.rs | chip8wasm |
| version | 0.1.0 |
| created_at | 2026-01-13 02:24:37.922895+00 |
| updated_at | 2026-01-13 02:24:37.922895+00 |
| description | A wasm wrapper for a CHIP-8 emulator library |
| homepage | https://github.com/nebulous-code/chip-8 |
| repository | https://github.com/nebulous-code/chip-8 |
| max_upload_size | |
| id | 2039190 |
| size | 15,246 |
This crate provides a wasm-bindgen wrapper around the CHIP-8 core emulator
from chip8sys. It exposes a web-friendly API for JavaScript and TypeScript
clients while keeping emulator logic inside the Rust core.
Repository: https://github.com/nebulous-code/chip-8
cargo add chip8wasm
Use wasm-pack to build the package for browser consumption.
wasm-pack build --target web --out-dir pkg --out-name chip8wasm
The output in pkg/ is a standard ES module package that front ends can
consume via bundlers like Vite.
import initWasm, { Chip8Wasm } from "chip8wasm";
async function run(romBytes) {
await initWasm();
const emulator = new Chip8Wasm();
emulator.loadRom(romBytes);
emulator.tick(10);
emulator.tickTimers(1);
const framebuffer = emulator.framebuffer();
console.log(framebuffer.length);
}
run(romBytes);
loadRom(romBytes) loads a ROM byte buffer.tick(cycles) advances CPU cycles.tickTimers(ticks) advances delay/sound timers.setKeys(mask) sets keypad state via a bitmask.framebuffer() returns an unpacked pixel array.chip8sys: The emulator core that chip8wasm wraps.Fork the repository and open a pull request with the changes.