CHIP-8 (and SUPERCHIP) interpreter written in Zig
Find a file
rodolpheh d1626e3c22
Some checks failed
/ Build roms with c-octo (push) Successful in 1m22s
/ Deploy web page (push) Has been skipped
/ Build and run tests (push) Successful in 1m20s
/ Build desktop for Linux x64 (push) Successful in 1m22s
/ Build desktop for Windows x64 (push) Successful in 1m4s
/ Build desktop for Linux ARM64 (push) Successful in 1m15s
/ Build for web (push) Failing after 4m13s
Try reverting to emsdk 4.0.3
2025-09-01 21:49:15 +01:00
.forgejo/workflows Set canvas size 2025-08-21 23:05:25 +01:00
roms Fix small bugs with games not in db 2025-04-13 21:43:16 +01:00
src Build logo ROM from a PBM image 2025-09-01 20:56:26 +01:00
.gitignore Build logo ROM from a PBM image 2025-09-01 20:56:26 +01:00
build.zig Build logo ROM from a PBM image 2025-09-01 20:56:26 +01:00
build.zig.zon Try reverting to emsdk 4.0.3 2025-09-01 21:49:15 +01:00
flake.lock Add Nix flake and option to use system's raylib 2025-01-09 22:15:58 +00:00
flake.nix Implement simple audio 2025-01-11 23:05:04 +00:00
LICENSE Add LICENSE 2025-06-18 22:23:52 +01:00
README.md Update README 2025-06-18 22:22:19 +01:00
treefmt.nix Add Nix flake and option to use system's raylib 2025-01-09 22:15:58 +00:00

Chipz

A CHIP8 emulator written in Zig.

Features

  • Supports CHIP-8, SuperCHIP and XO-CHIP
  • CHIP8 database integration: automatically apply known quirks and settings to your game
  • Signature, custom hand-made font
  • Can run in your browser

Build and use

Common build parameters

There are a few common build parameters that you might find useful:

  • -Dno-bin: Do not emit a binary for chipz, useful for a clean web build or for incremental compilation
  • -Dstrip: true/false, enables or disables stripping the executable
  • -Drom_path: Path to the rom to include as the rom to play by default (when no argument is given). This rom should be located in src.

Desktop

This will produce the simplest, cleanest build:

zig build -Doptimize=ReleaseFast -Dstrip=true

And to use, you can play the default game, or pass an URI to a game as the first argument:

# Just plays the default game
./chipz

# Plays a local game
# Go download this one: https://johnearnest.github.io/chip8Archive/roms/slipperyslope.ch8
./chipz slipperyslope.ch8

# Plays a game downloaded directly from the internet
./chipz https://johnearnest.github.io/chip8Archive/roms/snake.ch8

Use the --help parameter to print out an exhaustive help.

Web

Note: build in Debug mode doesn't work yet

# Build for web
zig build -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast -Dno-bin

You will need to host the resulting build on a server, or alternatively, use emrun which is integrated to the build script:

# Build and run for web
zig build -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast -Dno-bin emrun

This will open a page in your browser, showing the default game included during the build. To load a game from any URL, add it as parameter to chipz URL under the game key. For example:

http://127.0.0.1:6931/chipz.html?game=https://johnearnest.github.io/chip8Archive/roms/turnover77.ch8

Roms

This repository contains a few roms source code used to print all possible characters in all possible resolutions:

  • small_font_display.8o: print characters from 0 to F with the small font
  • big_font_display.8o: print characters from 0 to F with the big font
  • hires_both_display.8o: print characters from 0 to F in both formats, in hi-res mode

You can build them with zig build roms.

The build script uses c-octo to build the roms and you can reuse it to build your own roms! Just add them to the roms directory and re-build.

In-game keyboard shortcuts

Key Action
F1 Open the rom information panel
F2 Open the quirks list panel
F3 Open the emulator internals panel
F4 Open the instructions view
O Pause/Resume execution
Space Step through one instruction
L Next platform
K Previous platform
Escape Exit current dialog or window