# bfirsh/jsnes

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/bfirsh-jsnes).**

6,397 stars · 851 forks · JavaScript · Apache-2.0

## Links

- GitHub: https://github.com/bfirsh/jsnes
- Homepage: https://jsnes.org
- awesome-repositories: https://awesome-repositories.com/repository/bfirsh-jsnes.md

## Topics

`6502` `emulation` `emulator` `javascript` `nes`

## Description

jsnes is a JavaScript-based NES emulator that runs classic NES games in the browser or in Node.js. It provides cycle-accurate CPU emulation, frame-buffer-based video rendering, and sample-buffer audio synthesis, along with a ROM cartridge mapper abstraction for broad game compatibility.

The emulator exposes a programmable core with a simple API for controlling emulation state, capturing screenshots, and managing save data. It supports keyboard control remapping at runtime, with settings persisted to localStorage, and offers state serialization for save and restore operations. Battery-backed SRAM changes are handled through a callback-driven persistence mechanism.

The project covers browser-based NES emulation with automatic canvas rendering and input handling, as well as headless emulation in Node.js for custom rendering pipelines. It also provides programmatic control over emulator state, including pause, resume, reset, and ROM reloading.

## Tags

### Game Development

- [Retro Game Emulation](https://awesome-repositories.com/f/game-development/retro-game-emulation.md) — Boots and runs classic NES games inside a web page with canvas rendering, audio, and input handling. ([source](https://cdn.jsdelivr.net/gh/bfirsh/jsnes@main/README.md))
- [JavaScript Emulator Cores](https://awesome-repositories.com/f/game-development/retro-game-emulation/web-based-emulators/javascript-emulator-cores.md) — Provides a JavaScript-based NES emulator with cycle-accurate CPU, PPU, and audio emulation for browser and Node.js.
- [Save State Managers](https://awesome-repositories.com/f/game-development/emulation-save-management/save-state-managers.md) — Serializes complete emulator state into JSON for save and restore operations.
- [Emulation State Scripting](https://awesome-repositories.com/f/game-development/game-logic-scripting/emulation-state-scripting.md) — Provides a scripting interface for pausing, resuming, resetting, and reloading emulator state. ([source](https://cdn.jsdelivr.net/gh/bfirsh/jsnes@main/README.md))
- [Web-Based Emulators](https://awesome-repositories.com/f/game-development/retro-game-emulation/web-based-emulators.md) — Runs classic NES games inside a web page with automatic canvas rendering, audio, and input handling.
- [Battery-Backed SRAM Persistence](https://awesome-repositories.com/f/game-development/game-save-synchronization-tools/save-data-importers/battery-backed-sram-persistence.md) — Writes battery-backed SRAM changes to a callback for external save data storage. ([source](https://cdn.jsdelivr.net/gh/bfirsh/jsnes@main/README.md))

### Part of an Awesome List

- [Emulator Mapper Abstractions](https://awesome-repositories.com/f/awesome-lists/data/cartridge-development/emulator-mapper-abstractions.md) — Implements a pluggable mapper interface for broad NES cartridge compatibility.
- [Node.js Emulation Cores](https://awesome-repositories.com/f/awesome-lists/devtools/hardware-and-emulation/node-js-emulation-cores.md) — Runs NES CPU and PPU cycles programmatically in Node.js for custom rendering pipelines.

### Data & Databases

- [Emulator SRAM Callbacks](https://awesome-repositories.com/f/data-databases/data-change-callbacks/emulator-sram-callbacks.md) — Provides a callback mechanism for persisting battery-backed SRAM changes to external storage.

### Graphics & Multimedia

- [Sample-Based Buffer Callbacks](https://awesome-repositories.com/f/graphics-multimedia/audio-music/audio-processing/asynchronous-callbacks/sample-based-buffer-callbacks.md) — Produces raw PCM audio samples from APU state through a sample-buffer-based pipeline.

### Hardware & IoT

- [Game Controller Remappers](https://awesome-repositories.com/f/hardware-iot/keyboard-key-mappings/single-key-remappers/game-controller-remappers.md) — Ships runtime keyboard remapping for NES controller buttons with localStorage persistence.

### Operating Systems & Systems Programming

- [Emulation Session Control](https://awesome-repositories.com/f/operating-systems-systems-programming/emulation-session-control.md) — Provides a simple interface for pausing, resuming, resetting, and reloading emulator state.
- [Programmable Emulator APIs](https://awesome-repositories.com/f/operating-systems-systems-programming/emulator-core-orchestrators/programmable-emulator-apis.md) — Exposes a simple API for controlling emulation state, capturing screenshots, and managing save data.
- [Cycle-Accurate Emulators](https://awesome-repositories.com/f/operating-systems-systems-programming/virtualization-emulation/hardware-emulators/cycle-accurate-emulators.md) — Implements cycle-accurate emulation of the 6502 CPU for precise NES hardware timing.
- [Node.js Emulation Cores](https://awesome-repositories.com/f/operating-systems-systems-programming/retro-hardware-emulation/node-js-emulation-cores.md) — Runs NES CPU and PPU cycles programmatically in Node.js for custom rendering pipelines. ([source](https://cdn.jsdelivr.net/gh/bfirsh/jsnes@main/README.md))

### System Administration & Monitoring

- [Emulator Frame Buffers](https://awesome-repositories.com/f/system-administration-monitoring/terminal-buffering-systems/double-buffering/graphical-frame-buffers/emulator-frame-buffers.md) — Generates complete 256x240 pixel frame buffers from PPU state for canvas drawing or external processing.

### User Interface & Experience

- [Keyboard Input Mapping](https://awesome-repositories.com/f/user-interface-experience/form-and-input-management/input-handling/secondary-modifier-keys/keyboard-input-mapping.md) — Translates browser keyboard events into NES controller button states via a configurable mapping table.

### Development Tools & Productivity

- [Game Keyboard Controls](https://awesome-repositories.com/f/development-tools-productivity/keyboard-interaction-controls/game-keyboard-controls.md) — Rebinds NES controller buttons to different keyboard keys at runtime with localStorage persistence. ([source](https://cdn.jsdelivr.net/gh/bfirsh/jsnes@main/README.md))
