A Game Boy emulator written in OCaml that runs in your browser 🐫 🎮
637
stars
397
commits
OCaml
primary language
Jan 7, 2026
updated
CAMLBOY is a Game Boy emulator that runs in the browser. It is written in OCaml and compiled to JavaScript using js_of_ocaml (edit: After #15 CAMLBOY is now compiled to WASM!).
Try it out in our demo page!
cpu_insrts.gb and instr_timing.gb (tests using Blargg's test ROMs can be found here, and tests using Mooneye's test ROMs can be found here).We ran the first 1500 frames of Tobu Tobu Girl in headless mode (i.e., without UI) for ten times each and calculated the average FPS. The error bars represent the standard deviation. See benchmark.md for details about the environment/commands used for the benchmark.1
Here is a rough sketch of the various modules and their relationship. You can find details in the accompanied blog post.
lib - Main emulator codebin - UI code
web - Websdl2 - SDL2test
unit_test - Unit testsrom_test - Integration tests that use test romsresource
games - Game romstest_roms - Test roms used in rom_testsgit clone https://github.com/linoscope/CAMLBOY.git
cd CAMLBOY
opam switch create . --locked --with-test
eval $(opam env)
dune build
dune build
# Usage: main.exe [--mode {default|withtrace|no-throttle}] <rom_path>
dune exec bin/sdl2/main.exe -- resource/games/tobu.gb
dune build
# Serve the web directory
python -m http.server 8000 --directory _build/default/bin/web
# Open localhost:8000 in your browser
# Usage: bench.exe [--frames <frames>] <rom_path>
dune exec bin/sdl2/bench.exe -- resource/games/tobu.gb --frames 1500
After starting the web server (see above), open:
http://localhost:8000/bench.html?frames=1500&rom_path=./tobu.gb

# Run all tests:
dune runtest
# Run unit tests only:
dune runtest test/unit_test/
# Run integration tests (tests that use test ROMs):
dune runtest test/rom_test/
After modifying dependencies in dune-project:
opam pin add camlboy.dev . --no-action
opam lock camlboy
Commit the updated camlboy.opam.locked file.
Note that we can not use this benchmark to compare the FPS with other Game Boy emulators. This is because the performance of an emulator depends significantly on how accurate it is and how much functionality it has. For example, CAMLBOY does not implement the APU (Audio Processing Unit), so there is no point in comparing its FPS with emulators with APU support. ↩
OCaml
96.9%
HTML
3.0%
A Game Boy emulator written in OCaml that runs in your browser 🐫 🎮
637
stars
397
commits
OCaml
primary language
Jan 7, 2026
updated
CAMLBOY is a Game Boy emulator that runs in the browser. It is written in OCaml and compiled to JavaScript using js_of_ocaml (edit: After #15 CAMLBOY is now compiled to WASM!).
Try it out in our demo page!
cpu_insrts.gb and instr_timing.gb (tests using Blargg's test ROMs can be found here, and tests using Mooneye's test ROMs can be found here).We ran the first 1500 frames of Tobu Tobu Girl in headless mode (i.e., without UI) for ten times each and calculated the average FPS. The error bars represent the standard deviation. See benchmark.md for details about the environment/commands used for the benchmark.1
Here is a rough sketch of the various modules and their relationship. You can find details in the accompanied blog post.
lib - Main emulator codebin - UI code
web - Websdl2 - SDL2test
unit_test - Unit testsrom_test - Integration tests that use test romsresource
games - Game romstest_roms - Test roms used in rom_testsgit clone https://github.com/linoscope/CAMLBOY.git
cd CAMLBOY
opam switch create . --locked --with-test
eval $(opam env)
dune build
dune build
# Usage: main.exe [--mode {default|withtrace|no-throttle}] <rom_path>
dune exec bin/sdl2/main.exe -- resource/games/tobu.gb
dune build
# Serve the web directory
python -m http.server 8000 --directory _build/default/bin/web
# Open localhost:8000 in your browser
# Usage: bench.exe [--frames <frames>] <rom_path>
dune exec bin/sdl2/bench.exe -- resource/games/tobu.gb --frames 1500
After starting the web server (see above), open:
http://localhost:8000/bench.html?frames=1500&rom_path=./tobu.gb

# Run all tests:
dune runtest
# Run unit tests only:
dune runtest test/unit_test/
# Run integration tests (tests that use test ROMs):
dune runtest test/rom_test/
After modifying dependencies in dune-project:
opam pin add camlboy.dev . --no-action
opam lock camlboy
Commit the updated camlboy.opam.locked file.
Note that we can not use this benchmark to compare the FPS with other Game Boy emulators. This is because the performance of an emulator depends significantly on how accurate it is and how much functionality it has. For example, CAMLBOY does not implement the APU (Audio Processing Unit), so there is no point in comparing its FPS with emulators with APU support. ↩
OCaml
96.9%
HTML
3.0%