• Stars
    star
    5,921
  • Rank 6,619 (Top 0.2 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 15 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A JavaScript NES emulator.

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

Embedding JSNES in a web page

You can use JSNES to embed a playable version of a ROM in a web page. This is handy if you are a homebrew ROM developer and want to put a playable version of your ROM on its web page.

The best implementation is jsnes-web but unfortunately it is not trivial to reuse the code. You'll have to copy and paste the code from that repository, the use the <Emulator> React component. Here is a usage example..

A project for potential contributors (hello!): jsnes-web should be reusable and on NPM! It just needs compiling and bundling.

A more basic example is in the example/ directory of this repository. Unfortunately this is known to be flawed, and doesn't do timing and sound as well as jsnes-web.

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

JSNES is based on James Sanders' vNES, and owes an awful lot to it. It also wouldn't have happened without Matt Wescott's JSSpeccy, which sparked the original idea. (Ben, circa 2008: "Hmm, I wonder what else could run in a browser?!")

More Repositories

1

jsnes-web

A browser UI for JSNES, a JavaScript NES emulator
JavaScript
569
star
2

django-shorturls

A URL shortening app for Django
Python
405
star
3

serverless-docker

Build serverless apps with Docker
305
star
4

funker

Functions as Docker containers
252
star
5

dynamicaudio.js

An interface for the Web Audio API with a Flash shim for older browsers
JavaScript
168
star
6

loom

Elegant deployment with Fabric and Puppet.
Python
116
star
7

whiskerboard

Stashboard, now with less vendor lock-in.
Python
112
star
8

otter

A server that runs your client-side apps.
CoffeeScript
82
star
9

django-class-based-views

Work on class-based views, now part of Django 1.3. For a backport to Django 1.2, see https://github.com/sorl/django-cbv
Python
79
star
10

serverless-docker-voting-app

A serverless web app built with Docker
HTML
60
star
11

naming-test-suite

How I name products/projects/tools
39
star
12

vNES

A mirror of Jamie Sanders' Java NES emulator, which once lived at virtualnes.com
Java
36
star
13

django-docker-heroku-template

Get a Django app up and running in dev, test, and production with best practices in 10 minutes
Python
35
star
14

python-echoprint

Python library for the Echoprint music identification service
C++
27
star
15

dockerrun

A dead simple Python library for running Docker commands
Python
25
star
16

funker-example-voting-app

An example app using Funker
JavaScript
24
star
17

pspec

Python testing for humans.
Python
21
star
18

syndication-view

Django feeds as class based views, now part of Django 1.2.
Python
21
star
19

pytest_django

A Django plugin for py.test.
Python
19
star
20

django-database-files

A storage system for Django that stores uploaded files in the database.
Python
19
star
21

docker-export-volumes

A Docker image to export volumes from containers
Python
16
star
22

go-dcgi

CGI, but with Docker containers
Go
13
star
23

django-docker-cloud-template

A template for creating Django applications that run on Docker Cloud
Python
12
star
24

funker-go

Funker for Go
Go
12
star
25

heroku-tarsnap-backups

Make offsite backups of Heroku apps on Tarsnap
Shell
11
star
26

django-mptt

It's MPTT, but with abstract model awesomeness.
Python
11
star
27

docker-redoc

A Docker image which serves ReDoc documentation
HTML
11
star
28

funker-python

Python
9
star
29

swarm-viz

HTML
9
star
30

miles

A JavaScript framework for actually getting things done
JavaScript
8
star
31

dotfiles

Vim Script
8
star
32

virtualdocker

Go
8
star
33

docker-reticulate-splines

Shell
7
star
34

herokup

Upload stuff to Heroku that isn't in Git.
Shell
7
star
35

funker-node

JavaScript
7
star
36

jstunes

A JavaScript audio player
JavaScript
7
star
37

rrun

rsync the current directory and run a command over ssh
Shell
6
star
38

docker-sdk-go

WIP: Prototype of a better Go client for Docker
Go
5
star
39

fir.sh

SCSS
5
star
40

paperpets

Mini origami pets for Little Printer
CSS
5
star
41

jsnes-roms

4
star
42

charingcross

Project planning with GitHub issues
Python
4
star
43

docker-api-reference

WIP: Better API reference for Docker, built on Swagger
HTML
3
star
44

docker-go-client-example

Go
3
star
45

vqgan-clip

Python
3
star
46

antsy

Multi-line console animation in Go
Go
2
star
47

cog-segformer

Python
2
star
48

ip

Python
2
star
49

backbone-otter

Tools for writing Otter apps with Backbone
JavaScript
2
star
50

puppet-cloudkick

A Puppet module for Cloudkick.
Shell
2
star
51

haikuplayer

Python
2
star
52

docker-sdk-python

WIP
Python
2
star
53

riffusion-cog

Riffusion as a Cog model
Python
2
star
54

docker-cloud-subdomains

Automatic Heroku-style subdomains for Docker Cloud
Python
2
star
55

internetarchive-pdfjs-isbn-links

JavaScript
2
star
56

hubot-shipping-forecast

CoffeeScript
1
star
57

replicate-screenshots

1
star
58

docker-oauth2_proxy

1
star
59

interlock-haproxy-swarm

Interlock configured to use a Swarm set up by Machine
Shell
1
star
60

python-sdk

Facebook Platform Python SDK
Python
1
star
61

patchwork

JavaScript
1
star
62

compose-mongodb-demo

Python
1
star