Giter Club home page Giter Club logo

gameboy.js's Introduction

Gameboy.js

Gameboy.js is a gameboy emulator written in JavaScript.

It's a work in progress, see the Features section.

Browser support

Tested on:

  • Firefox
  • Chrome (sound issues)
  • Safari (sound issues)

Usage

Run now

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.

Run on a custom page

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);

Options

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 and should contain the class implementing the device you want to play with. You can implement any kind of pad as long as this class implements the init() method. See GameboyJS.Keyboard class for an example of implementation. You may also provide a mapping object that will be used if you choose the GameboyJS.Gamepad class. Default is {class: GameboyJS.Keyboard, mapping: null}
  • zoom: The zoom level as an integer. Default is 1
  • romReaders: An array of ROM reader objects that can read a ROM file and send the data to the Gameboy. Default is empty ([]), 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'.

Build from source

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

Features

Devices

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).

Internal processes

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:

  • sprites (no support for sprite flags)
  • MBC (only MBC 1, MBC 3 and MBC 5 are partially supported)
  • sound (ok on Firefox, poor on Chrome)

The following features are not currently supported at all:

  • boot program

Tests

The tests perform as follow :

Test status
CPU instructions pass
instruction timing pass
memory timing fail
DMG sound fail
OAM bug fail

gameboy.js's People

Contributors

juchi 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.