nes_rust_wasm

NES emulator written in Rust and compiled to WebAssembly

Usage no npm install needed!

<script type="module">
  import nesRustWasm from 'https://cdn.skypack.dev/nes_rust_wasm';
</script>

README

nes_rust_wasm

npm version

nes_rust_wasm is a WebAssembly NES emulator based on nes-rust.

How to install

$ npm install nes_rust_wasm

How to use

const nes = require('nes_rust_wasm').WasmNes.new();
nes.set_rom(new Uint8Array(romArrayBuffer));

const pixels = new Uint8Array(256 * 240 * 4);

// Audio example code is T.B.D.
const audioBuffer = new Float32Array(4096);

const runFrame = () => {
  setTimeout(runFrame, 0);
  nes.step_frame();
  nes.update_pixels(pixels);
  // Render pixels
};

nes.bootup();
runFrame();

API

Refer to the comments in WasmNes

How to build WebAssembly RISC-V emulator locally

Prerequirements

$ git clone https://github.com/takahirox/nes-rust.git
$ cd nes-rust/wasm
$ bash build.sh