About this project

JSNES is a full-featured Nintendo Entertainment System (NES) emulator written in JavaScript. It works both in the browser and in Node.js environments, making it suitable for web-based retro gaming projects, embedded emulators, or server-side tooling. The library offers two main entry points: - `jsnes.Browser` — a high-level wrapper that handles canvas rendering, Web Audio API playback, keyboard and gamepad input, and frame timing automatically. It can load ROMs from URLs or raw data and provides methods for screenshots, pause/resume, and cleanup. - `jsnes.NES` — a low-level core for custom integrations. It emits raw frame buffers (256×240 ARGB Int32Array) and audio samples via callbacks, leaving timing, rendering, and input handling to the developer. Key features include: - Support for standard NES controllers (two players) with configurable key bindings persisted to localStorage. - Gamepad API support for modern controllers. - Zapper light gun emulation. - Battery-backed SRAM persistence via callbacks for save states. - Save/load state serialization (`toJSON`/`fromJSON`). - Adjustable frame rate and FPS monitoring. - React component example included; a full React frontend lives in the `web/` directory. Installation is via npm (`npm install jsnes`) or direct unpkg CDN script tag. The build uses Prettier formatting and includes a test suite. JSNES originated from James Sanders' vNES and was inspired by Matt Wescott's JSSpeccy. It is actively maintained and used in projects like NEStation for multiplayer NES over the internet.