Skip to content
NES emulator in your browser, based on jsnes.
Branch: master
Clone or download
Pull request Compare This branch is 6 commits ahead, 42 commits behind bfirsh:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
roms
src
test Add explanation of test for frame buffer output Mar 2, 2018
.eslintrc.json Use eslint May 22, 2018
.gitignore Build uncompressed dist Sep 7, 2017
.npmignore Build uncompressed dist Sep 7, 2017
.travis.yml
AUTHORS.md
LICENSE Put license in one place Sep 7, 2017
README.md Add @shicks as maintainer Aug 20, 2018
_redirects
index.html Fixed a bug where the CSS wasn't loading Oct 7, 2018
package.json Bump eslint from 4.19.1 to 5.0.0 Jun 25, 2018
react.css
react.js js Oct 7, 2018
webpack.config.js Use eslint May 22, 2018
yarn.lock Bump sinon from 6.0.1 to 6.1.0 Jul 4, 2018

README.md

JSNES

A JavaScript NES emulator.

It's a library that works in both the browser and Node.js. The browser UI is available at https://github.com/bfirsh/jsnes-web.

Installation

For Node.js or Webpack:

$ npm install jsnes

(Or yarn add jsnes.)

In the browser, you can use unpkg:

<script type="text/javascript" src="https://unpkg.com/jsnes/dist/jsnes.min.js"></script>

Usage

// Initialize and set up outputs
var nes = new jsnes.NES({
  onFrame: function(frameBuffer) {
    // ... write frameBuffer to screen
  },
  onAudioSample: function(left, right) {
    // ... play audio sample
  }
});

// Read ROM data from disk (using Node.js APIs, for the sake of this example)
const fs = require('fs');
var romData = fs.readFileSync('path/to/rom.nes', {encoding: 'binary'});

// Load ROM data as a string or byte array
nes.loadROM(romData);

// Run frames at 60 fps, or as fast as you can.
// You are responsible for reliable timing as best you can on your platform.
nes.frame();
nes.frame();
// ...

// Hook up whatever input device you have to the controller.
nes.buttonDown(1, jsnes.Controller.BUTTON_A);
nes.frame();
nes.buttonUp(1, jsnes.Controller.BUTTON_A);
nes.frame();
// ...

Build

To build a distribution:

$ yarn run build

This will create dist/jsnes.min.js.

Running tests

$ yarn test

Formatting code

All code must conform to Prettier formatting. The test suite won't pass unless it does.

To automatically format all your code, run:

$ yarn run format

Maintainers

You can’t perform that action at this time.