Skip to content

Reference ​

Every option, key and exit code of chip8 and chip8_run_rom.

chip8 options ​

text
chip8 [options] <rom.ch8>
OptionDefaultWhat it does
--ips N540Instructions per second. Values below 60 become 60.
--scale N12Window scale factor. 12 gives 768×384. Values below 1 become 1.
--profile PvipQuirk profile: vip or modern.
--muteoffDisables the beeper.
--frames Nrun until quitExits after N 60 Hz frames. For automated tests.
--screenshot PATHnoneSaves a BMP screenshot before exiting.
--help, -hPrints the usage text.

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

Key bindings ​

KeyAction
SpacePause or resume
EscQuit
1 2 3 4CHIP-8 keys 1 2 3 C
Q W E RCHIP-8 keys 4 5 6 D
A S D FCHIP-8 keys 7 8 9 E
Z X C VCHIP-8 keys A 0 B F

Keys are matched by physical position, so the block stays in the same place on any keyboard layout.

chip8 exit codes ​

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

Quirk profiles ​

Behaviourvipmodern
8XY1, 8XY2, 8XY3Reset VF to 0Leave VF alone
8XY6, 8XYEShift VY into VXShift VX in place
FX55, FX65I = I + X + 1 afterI unchanged
BNNNJump to NNN + V0Jump to NNN + VX
DXYN timingWaits for the 60 Hz tickNo wait
DXYN edgesStart wraps, pixels clipSame
FX0ACompletes on key releaseSame

chip8_run_rom options ​

text
chip8_run_rom <rom.ch8> [--frames N] [--ips N] [--profile vip|modern]
              [--seed N] [--poke ADDR=VAL]... [--key K:DOWN:UP]... [--bmp PATH]
OptionDefaultWhat it does
--frames N480Number of simulated 60 Hz frames to run.
--ips N540Instructions per second.
--profile PvipQuirk profile: vip or modern.
--seed NfixedSeed for the random-number instruction, so runs repeat exactly.
--poke ADDR=VALnoneWrites one byte to memory after the ROM loads. Repeatable.
--key K:DOWN:UPnonePresses hex key K at frame DOWN and releases it at frame UP. Repeatable.
--bmp PATHnoneAlso saves the final screen as a BMP file.

The runner prints a status line (ROM, frames, speed, profile, and the final PC, I, delay timer and sound timer), a WARNING line if an unknown opcode was met, then the screen as text.

It exits with 0 on success, 1 if the ROM could not be loaded or the BMP could not be written, and 2 for a bad command line.

Test scripts ​

ScriptWhat it does
tests/roms/fetch_roms.shDownloads the Timendus test ROMs 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/*.txt.
Environment variableUsed byWhat it does
TIMENDUS_REFfetch_roms.shFetches another branch, tag or commit of the test suite instead of the pinned one.

Limits ​

ItemValue
Screen64×32 pixels, one colour
Memory4096 bytes; ROMs load at 0x200
Largest ROM3584 bytes
Timers60 Hz
Beep440 Hz square wave

Next steps ​