Speed, quirks and screenshots
Most ROMs run with the defaults. When one runs too slowly, misbehaves or needs a bigger window, change it with an option on the command line. Options go before or after the ROM name.
Change the speed
CHIP-8 has no fixed CPU speed. chip8 runs 540 instructions per second by default, close to the original COSMAC VIP. ROMs tuned for other interpreters may want 700 to 1000.
./build/chip8 --ips 800 game.ch8The delay and sound timers always count down 60 times a second, whatever --ips is. A faster setting makes the program logic run faster without making timers or beeps shorter. Values below 60 are raised to 60.
Pick a quirk profile
"Quirks" are the instructions where the original COSMAC VIP interpreter and later SUPER-CHIP-era interpreters behave differently. A ROM written for one family can draw garbage or hang on the other.
chip8 starts in the vip profile. If a ROM misbehaves, try modern:
./build/chip8 --profile modern game.ch8| Behaviour | vip (default) | modern |
|---|---|---|
8XY1, 8XY2, 8XY3 | Reset VF to 0 | Leave VF alone |
8XY6, 8XYE | Shift VY into VX | Shift VX in place |
FX55, FX65 | Leave I = I + X + 1 | Leave I unchanged |
BNNN | Jump to NNN + V0 | Jump to NNN + VX |
DXYN timing | Waits for the 60 Hz tick | No wait |
Both profiles wrap a sprite's starting position and clip its pixels at the right and bottom edges. In both, FX0A (wait for a key) completes when the key is released.
Good to know
Only the vip profile is checked by the test suite. modern is a convenience for ROMs written against SUPER-CHIP-style interpreters.
Why drawing is slower in the vip profile
On the VIP, a sprite draw waited for the display's 60 Hz tick. chip8 copies this: each frame allows one DXYN draw, and a second draw in the same frame pauses the CPU until the next tick. A ROM that draws a lot runs at no more than about 60 draws a second in vip, however high you set --ips. The modern profile removes the wait.
Resize the window
The CHIP-8 screen is 64×32 pixels. --scale multiplies it. The default is 12, which gives a 768×384 window.
./build/chip8 --scale 20 game.ch8Values below 1 are raised to 1.
Turn off the sound
./build/chip8 --mute game.ch8With --mute, chip8 does not open an audio device at all.
Save a screenshot
--screenshot saves the screen as a BMP file when chip8 exits. Pair it with --frames to exit on its own after a number of 60 Hz frames:
./build/chip8 --frames 180 --screenshot logo.bmp tests/roms/2-ibm-logo.ch8This runs for three seconds, saves logo.bmp and quits. Without --frames, the screenshot is saved when you press Esc or close the window.
To get a picture without opening a window at all, use the headless runner:
./build/chip8_run_rom tests/roms/2-ibm-logo.ch8 --frames 120 --bmp logo.bmp