# chipx

A CHIP-8 emulator built in C using SDL2.

status: completed
C
SDL2
Make
created: 2026-07-09T03:59:44.066447+00:00updated: 2026-07-09T03:59:44.066447+00:00

## About this project

CHIP-8 emulator in C using SDL2. If you don't know what that is, CHIP-8 is an old interpreted language from the 70s that a bunch of simple games were built on (Tetris, Pong, Space Invaders, etc), and building it forces you to actually understand how a CPU works instead of just knowing it in theory. I learnt a lot from this project, especially around bitwise operations, memory addressing, and what a program counter and stack actually do instead of just being words in a textbook. At one point I spent way too long debugging a bug where my call stack was silently chopping 16-bit addresses down to 8 bits because I typed uint8_t instead of uint16_t in one line, which broke everything and took real log digging to catch. I relied a lot on Cowgod's CHIP-8 technical reference and Columbia University's CHIP-8 design specification PDF to get the instruction set, timing behavior, and overall structure right. Also ended up building a little CLI tool so I could just run chipx <game name> from any terminal on the system instead of dealing with paths every time, which covered some shell scripting and PATH stuff along the way.

## Repository

stars1
forks0
open issues0
languageRoff
cchip-8chip-8-emulatorchip8emulator
license: MIT Licenselast commit: 2026-07-07T10:01:59Z

šŸ“„ README.md

CHIP-8 Emulator

A CHIP-8 interpreter written in C using SDL2 for graphics, input, and audio.

Features

  • Full CHIP-8 instruction set (all 35 opcodes)
  • SDL2-based display, keyboard input, and square-wave audio for the sound timer
  • Configurable emulation speed (instructions per frame)
  • A chipx command-line tool for launching ROMs from anywhere on your system, with fuzzy name matching and a numbered ROM browser
  • Built-in test targets for validating opcode correctness against the Timendus CHIP-8 test suite and the IBM logo test ROM

Demo

https://github.com/user-attachments/assets/fcc2e3ee-be03-496d-ba1d-31d5049c34c7

Requirements

  • gcc (or another C17-compatible compiler)
  • make
  • SDL2 development libraries

On Arch Linux:

sudo pacman -S sdl2

On Debian/Ubuntu:

sudo apt install libsdl2-dev

Building

make

This produces the emulator binary at build/program.

Running a ROM directly

make run ROM="rom/Tetris [Fran Dachille, 1991].ch8"

or by fuzzy name:

make run rom=tetris

Installing chipx (recommended)

To install the emulator as a global command, callable from any terminal or directory:

./install.sh

This will:

  • Build the project
  • Copy the compiled binary and ROM library to ~/.local/share/chip8
  • Install a chipx command to ~/.local/bin
  • Add ~/.local/bin to your shell's PATH if it isn't already there (fish, bash, and zsh are detected automatically)

Restart your terminal (or run exec fish / source ~/.bashrc, depending on your shell) after installing for the chipx command to become available.

Usage

chipx                # numbered menu of every ROM
chipx tetris          # fuzzy-match by name and launch directly
chipx space           # multiple matches -> prompts you to pick one
chipx -h              # help

Uninstalling

make uninstall

Controls

CHIP-8 uses a 16-key hexadecimal keypad, mapped to the following keys:

Keypad:            Keyboard:
1 2 3 C            1 2 3 4
4 5 6 D            Q W E R
7 8 9 E            A S D F
A 0 B F            Z X C V

Controls vary per game — check each ROM's accompanying .txt file where available, since key bindings are not standardized across CHIP-8 programs.

Press Backspace to quit the emulator at any time.

Testing

Run the full opcode/quirks test suite:

make test

Run an individual numbered test (e.g. the flags test):

make test-4

List all available ROMs:

make list

Project Structure

.
ā”œā”€ā”€ main.c
ā”œā”€ā”€ src/                    # Core emulator implementation
│   ā”œā”€ā”€ emulator_core.c
│   ā”œā”€ā”€ emulator_operations.c
│   ā”œā”€ā”€ emulator_display.c
│   └── emulator_audio.c
ā”œā”€ā”€ include/                # Headers
ā”œā”€ā”€ rom/                    # ROM library (see Credits)
ā”œā”€ā”€ install.sh              # One-step build + install script
ā”œā”€ā”€ emu-runner.sh           # The chipx command dispatcher (installed as `chipx`)
└── Makefile

Credits

ROMs included in the rom/ directory are sourced from kripod/chip8-roms, a public domain compilation of CHIP-8 programs originally assembled by Revival Studios. Original authorship of individual games belongs to their respective creators, credited where known in each ROM's filename or accompanying .txt file.

The Timendus CHIP-8 test suite and the IBM logo test ROM are used for opcode/quirks validation during development.

References

This emulator's instruction set and behavior were implemented primarily based on:

License

This project is licensed under the MIT License — see LICENSE for details.

ROMs in the rom/ directory retain their own original licensing/public domain status as documented by their respective sources and are not covered by this project's license.