Technology JavaScript (ES6)

Concept NES emulator for the web, with an exposed API for programmatic manipulation.

nES6 is a Nintendo Entertainment System emulator written in pure JavaScript which can be played in web browsers. The emulator was created to allow programmatic control of internal mechanisms. For example, nES6 does not bind inputs to joypads by default. It does, however, expose an API which allows devs to manipulate inputs. A developer can add support for players to use keyboards, gamepads, tilt controls, hoop and stick, etc. Common functionality such as keyboard/gamepad support is also provided in the form of plugins.

Existing NES emulators (for the web) attempt to be an all-in-one solution. As a result, UI and emulator code is tightly coupled together, and you can’t do much with the package outside of using it as a ‘standalone’ emulator. I was interested in creating a project which relied on the ability to control player inputs, import/export savestates, and looked/worked pretty decently. nES6 was the result.

Good Artists Copy, Great Artists Fork

I will say here and now: my work stands on the shoulders of giants. Without finding Pete Ward’s WebNES repo, my project would not have gone anywhere. WebNES offered support for most games, WebGL + shader capability, and save states could painlessly be imported/exported. Having never worked with an emulator before, it was also easy to approach the pure javascript codebase. I forked WebNES, and with the intention of a complete overhaul into ‘modern’ javascript, renamed the project nES6.

Additional Features

After converting the codebase to ES6 (expect a blog post on that soon!), I added a handful of features, which primarily stemmed from needs while developing MultiNES. Features included:

Plugin System Developers can create their own plugins, or use one of the built-in plugins:

  • bindGamepad maps USB controller inputs to nES6
  • bindKeyboard provides sensible default keyboard controls, as well as a modifiable keymap.
  • dragDropLoader provides functionality to let the user load a local ROM file via drag-n-dropping the file into the emulator. Great for single-player applications.

Headless Rendering Due to the model used for networking, a key requirement for MultiNES’s success was the ability to run a copy of the emulator on a Node server. For that, nES6 needed a mode of rendering which would produce identical gamestates without actually rendering any of the graphics to the screen.

Current Status

At the moment, nES6 fulfills my needs and performs adequately, for the most part. The emulator still runs pretty sluggish on phones (if at all), and work must be done on that front in order for nES6 to succeed in all contexts. That said, at this point in time, the emulator is functional enough to build small applications and demos with it!