{"id":13522871,"url":"https://github.com/binji/binjgb","last_synced_at":"2025-05-15T12:07:02.059Z","repository":{"id":9230362,"uuid":"60131146","full_name":"binji/binjgb","owner":"binji","description":"Gameboy emulator implemented in C, that also runs in the browser","archived":false,"fork":false,"pushed_at":"2025-03-02T03:31:18.000Z","size":2584,"stargazers_count":567,"open_issues_count":10,"forks_count":67,"subscribers_count":20,"default_branch":"main","last_synced_at":"2025-04-11T21:49:01.480Z","etag":null,"topics":["emulator","gameboy","gameboy-emulator","gb-emulator","wasm","webassembly"],"latest_commit_sha":null,"homepage":"https://binji.github.io/binjgb/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binji.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-31T23:45:35.000Z","updated_at":"2025-04-10T12:51:30.000Z","dependencies_parsed_at":"2024-06-20T14:06:12.994Z","dependency_job_id":"72568c6c-31a0-43d7-b05c-572389979d5f","html_url":"https://github.com/binji/binjgb","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binji%2Fbinjgb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binji%2Fbinjgb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binji%2Fbinjgb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binji%2Fbinjgb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binji","download_url":"https://codeload.github.com/binji/binjgb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337614,"owners_count":22054254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emulator","gameboy","gameboy-emulator","gb-emulator","wasm","webassembly"],"created_at":"2024-08-01T06:00:53.130Z","updated_at":"2025-05-15T12:06:57.048Z","avatar_url":"https://github.com/binji.png","language":"C","readme":"[![Github CI Status](https://github.com/binji/binjgb/workflows/CI/badge.svg)](https://github.com/binji/binjgb)\n\n# binjgb\n\nA simple GB/GBC emulator.\n\n## Features\n\n* [Runs in the browser using WebAssembly](https://binji.github.io/binjgb)\n* Hacky-but-passable **CGB support**!\n* Mostly-there **Super GB support**!\n* Cycle accurate, passes many timing tests (see below)\n* Supports MBC1, MBC1M, MMM01, MBC2, MBC3, MBC5 and HuC1\n* Save/load battery backup\n* Save/load emulator state to file\n* **Fast-forward**, pause and step one frame\n* **Rewind** and seek to specific cycle\n* Disable/enable each audio channel\n* Disable/enable BG, Window and Sprite layers\n* Convenient Python test harness using hashes to validate\n* (WIP) **Debugger** with various visualizations (see below)\n\n## DMG Screenshots\n\n![Bionic Commando](/images/bionic.png)\n![Donkey Kong](/images/dk.png)\n![Kirby's Dreamland 2](/images/kirby2.png)\n![Mole Mania](/images/mole.png)\n![Mario's Picross](/images/picross.png)\n![Trip World](/images/trip.png)\n![Wario Land](/images/wario.png)\n![Game Boy Wars](/images/wars.png)\n![Is That a Demo in Your Pocket?](/images/pocket.png)\n\n## CGB Screenshots\n\n![Dragon Warrior](/images/dw.png)\n![Hamtaro](/images/ham.png)\n![Metal Gear Solid](/images/mgs.png)\n![It Came From Planet Zilog](/images/pz.png)\n![Survival Kids](/images/sk.png)\n![Aevilia](/images/aevilia.png)\n![Toki Tori](/images/toki.png)\n![Wario 3](/images/wario3.png)\n\n## SGB Screenshots\n\n![Donkey Kong](/images/dk-sgb.png)\n![Kirby's Dreamland 2](/images/kirby2-sgb.png)\n![Mole Mania](/images/mole-sgb.png)\n\n## Debugger Screenshots\n\n![Debugger](/images/debugger.png)\n![OBJ](/images/obj-window.png)\n![Map](/images/map-window.png)\n![Tile Data](/images/tiledata-window.png)\n![Breakpoints](/images/breakpoint.png)\n\n## Embedding binjgb in your own web page\n\nCopy the folowing files to your webserver:\n* `docs/binjgb.js`\n* `docs/binjgb.wasm`\n* `docs/simple.html`\n* `docs/simple.js`\n* `docs/simple.css`\n* your `.gb` or `.gbc` file\n\n`simple.html` will fill the entire page, so if you don't want that, you should put it into an\n[iframe](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe).\n\nThe emulator will also display an on-screen gamepad if the device supports\ntouch events.\n\nYou can configure the emulator by editing `simple.js`:\n\n| Constant name | Description |\n| - | - |\n| ROM_FILENAME | The path to your `.gb` or `.gbc` file |\n| ENABLE_REWIND | Whether to enable rewinding with the backspace key |\n| ENABLE_PAUSE | Whether to enable pausing with the space bar |\n| ENABLE_SWITCH_PALETTES | Whether to enable switching palettes with `[` and `]` |\n| OSGP_DEADZONE | How wide to make the deadzone for the onscreen gamepad, as a decimal between between `0` and `1` |\n| CGB_COLOR_CURVE | How to tint the CGB colors so they look more like a real CGB. \u003cul\u003e\u003cli\u003e0: none\u003c/li\u003e\u003cli\u003e1: Use Sameboy's \"Emulate Hardware\" colors\u003c/li\u003e\u003cli\u003e2: Use Gambatte/Gameboy Online colors\u003c/li\u003e\u003c/ul\u003e |\n| DEFAULT_PALETTE_IDX | Which palette to use by default, as an index into `PALETTES` |\n| 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 |\n\nSee `simple.js` for more info.\n\n## Cloning\n\nUse a recursive clone, to include the submodules:\n\n```\n$ git clone --recursive https://github.com/binji/binjgb\n```\n\nIf you've already cloned without initializing submodules, you can run this:\n\n```\n$ git submodule update --init\n```\n\n## Building\n\nRequires [CMake](https://cmake.org) and\n[SDL2](http://libsdl.org/download-2.0.php). Debugger uses\n[dear imgui,](https://github.com/ocornut/imgui) (included as a git submodule).\n\n### Building (Linux/Mac)\n\nIf you run `make`, it will run CMake for you and put the output in the `bin/`\ndirectory.\n\n```\n$ make\n$ bin/binjgb foo.gb\n```\n\nYou can also just use cmake directly:\n\n```\n$ mkdir build\n$ cd build\n$ cmake ..\n$ make\n```\n\n### Building (Windows)\n\nWhen building on Windows, you'll probably have to set the SDL2 directory:\n\n```\n\u003e mkdir build\n\u003e cd build\n\u003e cmake .. -G \"Visual Studio 15 2017\" -DSDL2_ROOT_DIR=\"C:\\path\\to\\SDL\\\"\n```\n\nThen load this solution into Visual Studio and build it. Make sure to build the\n`INSTALL` target, so the exectuables are built to the `bin` directory.\n\n### Building WebAssembly\n\nYou can build binjgb as a WebAssembly module. You'll need an incoming build of\nemscripten. See https://github.com/kripken/emscripten/wiki/WebAssembly and\nhttp://kripken.github.io/emscripten-site/docs/building_from_source/index.html#installing-from-source.\n\nPut a symlink to Emscripten in the `emscripten` directory, then run make.\n\n```\n$ ln -s ${PATH_TO_EMSCRIPTEN} emscripten\n$ make wasm\n```\nOr set Makefile variables via command line:\n```\n$ make wasm EMSCRIPTEN_CMAKE=\"/path/to/Emscripten.cmake\"\n```\n\n### Changing the Build Configuration\n\nIf you change the build config (e.g. update the submodules), you may need to run CMake again.\nThe simplest way to do this is to remove the `out/` directory.\n\n```\n$ rm -rf out/\n$ make\n```\n\n## Running\n\n```\n$ bin/binjgb \u003cfilename\u003e\n$ bin/binjgb-debugger \u003cfilename\u003e\n```\n\nKeys:\n\n| Action | Key |\n| --- | --- |\n| DPAD-UP | \u003ckbd\u003e↑\u003c/kbd\u003e |\n| DPAD-DOWN | \u003ckbd\u003e↓\u003c/kbd\u003e |\n| DPAD-LEFT | \u003ckbd\u003e←\u003c/kbd\u003e |\n| DPAD-RIGHT | \u003ckbd\u003e→\u003c/kbd\u003e |\n| B | \u003ckbd\u003eZ\u003c/kbd\u003e |\n| A | \u003ckbd\u003eX\u003c/kbd\u003e |\n| START | \u003ckbd\u003eEnter\u003c/kbd\u003e |\n| SELECT | \u003ckbd\u003eTab\u003c/kbd\u003e |\n| Quit | \u003ckbd\u003eEsc\u003c/kbd\u003e |\n| Save state | \u003ckbd\u003eF6\u003c/kbd\u003e |\n| Load state | \u003ckbd\u003eF9\u003c/kbd\u003e |\n| Toggle fullscreen | \u003ckbd\u003eF11\u003c/kbd\u003e |\n| Disable audio channel 1-4 | \u003ckbd\u003e1\u003c/kbd\u003e-\u003ckbd\u003e4\u003c/kbd\u003e |\n| Disable BG layer | \u003ckbd\u003eB\u003c/kbd\u003e |\n| Disable Window layer | \u003ckbd\u003eW\u003c/kbd\u003e |\n| Disable OBJ (sprites) | \u003ckbd\u003eO\u003c/kbd\u003e |\n| Fast-forward | \u003ckbd\u003eLshift\u003c/kbd\u003e |\n| Rewind | \u003ckbd\u003eBackspace\u003c/kbd\u003e |\n| Pause | \u003ckbd\u003eSpace\u003c/kbd\u003e |\n| Step one frame | \u003ckbd\u003eN\u003c/kbd\u003e |\n\n## INI file\n\nBinjgb tries to read from `binjgb.ini` on startup for configuration. The\nfollowing keys are supported:\n\n```\n# Load this file automatically on startup\nautoload=filename.gb\n\n# Set the audio frequency in Hz\naudio-frequency=44100\n\n# Set the number of audio frames per buffer\n# lower=better latency, more pops/clicks\n# higher=worse latency, fewer pops/clicks\naudio-frames=2048\n\n# Set to the index of a builtin palette\n# (valid numbers are 0..82)\nbuiltin-palette=0\n\n# Force the emulator to run in DMG (original gameboy) mode.\n# 0=Don't force DMG\n# 1=Force DMG\nforce-dmg=0\n\n# The number of video frames to display before storing a full dump of\n# the emulator state in the rewind buffer. Probably best to leave this\n# alone\nrewind-frames-per-base-state=45\n\n# The number of megabytes to allocate to the rewind buffer.\n# lower=less memory usage, less rewind time\n# higher=more memory usage, more rewind time\nrewind-buffer-capacity-megabytes=32\n\n# The speed at which to rewind the game, as a scale.\n# 1=rewind at 1x\n# 2=rewind at 2x\n# etc.\nrewind-scale=1.5\n\n# How much to scale the emulator window at startup.\nrender-scale=4\n\n# What to set the random seed to when initializing memory. Using 0\n# disables memory randomization.\nrandom-seed=0\n\n# Whether to display the SGB border or not.\n# 0=Don't display SGB border\n# 1=Display SGB border, even if it doesn't exist.\nsgb-border=0\n```\n\nThe INI file is loaded before parsing the command line flags, so you can use\nthe command line to override the values in the INI file.\n\n## Running tests\n\nRun `scripts/build_tests.py` to download and build the necessary testsuites.\nThis works on Linux and Mac, not sure about Windows.\n\n`scripts/tester.py` will only run the tests that match a filter passed on the\ncommand line. Some examples:\n\n```\n# Run all tests\n$ scripts/tester.py\n\n# Run all tests mooneye tests\n$ scripts/tester.py mooneye\n\n# Run all gpu tests\n$ scripts/tester.py gpu\n```\n\n## Test status\n\n[See test results](test_results.md)\n","funding_links":[],"categories":["Software Development","C","Engines","软件开发"],"sub_categories":["Emulators","模拟器"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinji%2Fbinjgb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinji%2Fbinjgb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinji%2Fbinjgb/lists"}