Gameboy emulator written in JavaScript
MIT License
Gameboy.js is a gameboy emulator written in JavaScript.
It's a work in progress, see the Features section.
Tested on:
You can try the emulator directly on the demo site.
Tests ROM can be downloaded here and are runnable, but some tests fail. See the Tests section for more details.
Currently, most tested games run (tested with Tetris, Super Mario, Pokemon Red) but have some glitches.
You can directly use the distributed compiled file in a custom HTML page of your own, and create a new Gameboy object. It will expect a Canvas element and an optional options object.
var canvas = document.getElementById('canvas');
new GameboyJS.Gameboy(canvas);
You can customize the configuration by passing a list of options to the Gameboy.
var options, canvas;
//...
new GameboyJS.Gameboy(canvas, options);
pad
: Object representing the pad to use as a physical gamepad. The class
key is mandatory andmapping
object that will be used if you choose the GameboyJS.Gamepad class.{class: GameboyJS.Keyboard, mapping: null}
zoom
: The zoom level as an integer. Default is 1romReaders
: An array of ROM reader objects that can read a ROM file[]
), leading to a GameboyJS.RomFileReader to be created.statusContainerId
: ID of the HTML element for status display. Default is 'status'.gameNameContainerId
: ID of the HTML element for game name display. Default is 'game-name'.errorContainerId
: ID of the HTML element for error display. Default is 'error'.If you want to build the compiled JavaScript file from source to be sure you have the latest updates, just clone the repository and run the grunt tasks :
git clone https://github.com/juchi/gameboy.js
npm install
./node_modules/.bin/grunt
The LCD screen is working but still has some sprite glitches.
User input is available : arrow keys are mapped to the keyboard arrows,
and A, B, START and SELECT are mapped to G, B, H, N respectively.
Also, it's possible to use a gamepad using a custom pad
option.
Game saves are working fine and are stored as serialized data in the LocalStorage.
Sound is partially implemented (the noise channel is not done yet) and is quite good on Firefox (latest release) but really bad on Chrome and Safari. This seems to be due to the implementation of the Web Audio API in webkit.
The serial port can be used by the program as an output, the received bytes are displayed in the console (this is mainly used for tests).
The ROM files are accessed using an explorer on your computer. Other methods may be included (AJAX and Drag & Drop are supported).
There is no boot program provided (nor supported). The execution starts automatically at address 0x0100 which is the start address of all ROMs.
All of the standard Gameboy instructions are implemented. Super Gameboy and Gameboy Color are not supported.
The following features are in progress or partially working:
The following features are not currently supported at all:
The tests perform as follow :
Test | status |
---|---|
CPU instructions | pass |
instruction timing | pass |
memory timing | fail |
DMG sound | fail |
OAM bug | fail |