New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

gc_nes_web

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gc_nes_web

WASM wrapper for my gc_nes_core crate.

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
1
Created
Source

NPM

gc_nes_web

gc_nes_web wraps the public functions exposed by my gc_nes_core crate for use in the browser through Web Assembly - Javascript interop. It provides an interface to load and run NES ROMs, provide input, and extract rendered image data. Audio is currently unsupported.

Install in an NPM Project

npm install gc_nes_web

Using the NES Emulator with Javascript

// Import the package
const wasm = await import ("gc_nes_web");
// Create the NES object
let nes = this.state.wasm.nes(romArrayOfBytes);
// Run the emulator to the completion of the next frame and retrieve it
let frame = nes.frame();
// Or run just one cycle and get the frame separately
nes.cycle();
let frame = nes.get_screen();
// Drawing to a Canvas
let offscreenCanvas = new OffscreenCanvas(256, 240);
let offscreenCanvasContext = offscreenCanvas.getContext("2d");
let imageData = offscreenCanvasContext?.createImageData(256, 240);
imageData.data.set(frame);
offscreenCanvasContext.putImageData(imageData, 0, 0);
// mainCanvasContext is the 2D context for the Canvas you actually want to draw to.
mainCanvasContext.drawImage(offscreenCanvas, 0, 0);

Through wasm-pack, gc_nes_web has full Typescript support

Try it Now

You can try out gc_nes_emulator on my website, at https://garettcooper.com/#/nes-emulator

Current version: 0.1.5

Keywords

emulator

FAQs

Package last updated on 31 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts