Gameboy emulator implemented in C, that also runs in the browser
Gameboy emulator implemented in C, that also runs in the browser
A simple GB/GBC emulator.
Copy the folowing files to your webserver:
docs/binjgb.jsdocs/binjgb.wasmdocs/simple.htmldocs/simple.jsdocs/simple.css.gb or .gbc filesimple.html will fill the entire page, so if you don't want that, you should put it into an
iframe.
The emulator will also display an on-screen gamepad if the device supports touch events.
You can configure the emulator by editing simple.js:
| Constant name | Description |
|---|---|
| ROM_FILENAME | The path to your .gb or .gbc file |
| ENABLE_REWIND | Whether to enable rewinding with the backspace key |
| ENABLE_PAUSE | Whether to enable pausing with the space bar |
| ENABLE_SWITCH_PALETTES | Whether to enable switching palettes with [ and ] |
| OSGP_DEADZONE | How wide to make the deadzone for the onscreen gamepad, as a decimal between between 0 and 1 |
| CGB_COLOR_CURVE | How to tint the CGB colors so they look more like a real CGB. |
0: none
1: Use Sameboy's "Emulate Hardware" colors
2: Use Gambatte/Gameboy Online colors
|
| DEFAULT_PALETTE_IDX | Which palette to use by default, as an index into PALETTES |
| PALETTES | An array of built-in palette IDs, between 0 and 83. Useful if you only want the player to switch between a few of the built-in palettes |
See simple.js for more info.
Use a recursive clone, to include the submodules:
$ git clone --recursive https://github.com/binji/binjgbIf you've already cloned without initializing submodules, you can run this:
$ git submodule update --initRequires CMake and SDL2. Debugger uses dear imgui, (included as a git submodule).
If you run make, it will run CMake for you and put the output in the bin/
directory.
$ make
$ bin/binjgb foo.gbYou can also just use cmake directly:
$ mkdir build
$ cd build
$ cmake ..
$ makeWhen building on Windows, you'll probably have to set the SDL2 directory:
> mkdir build
> cd build
> cmake .. -G "Visual Studio 15 2017" -DSDL2_ROOT_DIR="C:\path\to\SDL\"Then load this solution into Visual Studio and build it. Make sure to build the
INSTALL target, so the exectuables are built to the bin directory.
You can build binjgb as a WebAssembly module. You'll need an incoming build of emscripten. See https://github.com/kripken/emscripten/wiki/WebAssembly and http://kripken.github.io/emscripten-site/docs/building_from_source/index.html#installing-from-source.
Put a symlink to Emscripten in the emscripten directory, then run make.
$ ln -s ${PATH_TO_EMSCRIPTEN} emscripten
$ make wasmOr set Makefile variables via command line:
$ make wasm EMSCRIPTEN_CMAKE="/path/to/Emscripten.cmake"If you change the build config (e.g. update the submodules), you may need to run CMake again.
The simplest way to do this is to remove the out/ directory.
$ rm -rf out/
$ make$ bin/binjgb
$ bin/binjgb-debugger Keys:
| Action | Key |
|---|---|
| DPAD-UP | ↑ |
| DPAD-DOWN | ↓ |
| DPAD-LEFT | ← |
| DPAD-RIGHT | → |
| B | Z |
| A | X |
| START | Enter |
| SELECT | Tab |
| Quit | Esc |
| Save state | F6 |
| Load state | F9 |
| Toggle fullscreen | F11 |
| Disable audio channel 1-4 | 1-4 |
| Disable BG layer | B |
| Disable Window layer | W |
| Disable OBJ (sprites) | O |
| Fast-forward | Lshift |
| Rewind | Backspace |
| Pause | Space |
| Step one frame | N |
Binjgb tries to read from binjgb.ini on startup for configuration. The
following keys are supported:
…The INI file is loaded before parsing the command line flags, so you can use the command line to override the values in the INI file.
Run scripts/build_tests.py to download and build the necessary testsuites.
This works on Linux and Mac, not sure about Windows.
scripts/tester.py will only run the tests that match a filter passed on the
command line. Some examples:
# Run all tests
$ scripts/tester.py
# Run all tests mooneye tests
$ scripts/tester.py mooneye
# Run all gpu tests
$ scripts/tester.py gpuNo open issues yet, or sync has not completed.