GithubHelp home page GithubHelp logo

nvdnkpr / jsnes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bfirsh/jsnes

0.0 1.0 0.0 736 KB

A JavaScript NES emulator.

Home Page: https://jsnes.fir.sh

License: Other

JavaScript 100.00%

jsnes's Introduction

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.

jsnes's People

Contributors

bfirsh avatar dependabot[bot] avatar dependabot-support avatar benshelton avatar workhorsy avatar isharacomix avatar jancborchardt avatar matthewbauer avatar rcopera avatar minimi avatar nosrevi avatar ecin avatar yasaricli avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.