Skip to content

Reference ​

Every option, key and exit code of gameboy and gb_run_rom.

gameboy options ​

text
gameboy [options] <rom.gb>
OptionDefaultWhat it does
--scale N4Window scale factor. 4 gives 640×576. Values below 1 become 1.
--turbooffRuns uncapped for the whole session. Sound is dropped.
--muteoffDisables audio.
--frames Nrun until quitExits after N frames. For automated tests.
--help, -hPrints the usage text.

If you name more than one ROM, the last one is used. An unknown option or a missing ROM prints the usage text.

Key bindings ​

KeyAction
Arrow keysD-pad
XA
ZB
EnterStart
Right ShiftSelect
Tab (hold)Turbo
EscQuit

Keys are matched by physical position and cannot be remapped.

gameboy exit codes ​

CodeMeaning
0Normal exit
1The ROM could not be loaded, or SDL failed to start
2Bad command line, or --help

Messages ​

MessageMeaning
error: cannot open ROM: …The file is missing or unreadable.
error: ROM too small to have a header: …The file is shorter than a Game Boy header (336 bytes).
error: unsupported cartridge type 0x… (ROM-only/MBC1/MBC3 only)The cartridge type is not emulated.
warning: no audio device (…), running silentNo audio output could be opened.
CPU stopped (STOP or illegal opcode) at PC=0x…The program halted the CPU for good. gameboy exits.

Supported cartridge types ​

Header byte 0x147Type
0x00, 0x08, 0x09ROM-only
0x01, 0x02, 0x03MBC1
0x0F to 0x13MBC3, banking only (no real-time clock)

gb_run_rom options ​

text
gb_run_rom <rom.gb> [--max-cycles N] [--frames N] [--screenshot PATH]
           [--press BUTTON:FRAME]...
OptionDefaultWhat it does
--max-cycles N800000000Cycle budget before giving up, about 190 seconds of emulated time.
--frames NnoneStops after N frames instead of waiting for a verdict.
--screenshot PATHnoneSaves the final screen as a BMP file.
--wav PATHnoneSaves the sound output as a WAV file.
--press BUTTON:FRAMEnonePresses a button at that frame, released 8 frames later. Repeatable.

Button names: right, left, up, down, a, b, select, start.

Exit codeMeaning
0The ROM reported Passed, or a --frames run finished
1The ROM reported Failed, or a file could not be read or written
2Timeout with no verdict, or a bad command line

Test scripts ​

ScriptWhat it does
tests/roms/fetch_roms.shDownloads blargg's test ROMs and dmg-acid2.gb into tests/roms.
tests/run_tests.sh [BUILD_DIR]Runs the suite. BUILD_DIR defaults to build.
tests/run_tests.sh --update [BUILD_DIR]Rewrites tests/expected/*.sha256.
Environment variableUsed byWhat it does
GB_TEST_ROMS_REFfetch_roms.shFetches another commit or ref of the blargg test ROM mirror instead of the pinned one.

Hardware facts ​

ItemValue
Screen160×144 pixels, four shades
Frame rateAbout 59.73 frames per second
Sound48 kHz stereo

Next steps ​