Skip to content

JDeepD/chip8emu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chip8emu

A CHIP-8 emulator written in C++17 with SDL2.

Features

  • Full CHIP-8 instruction set (35 opcodes)
  • 64x32 monochrome display (scaled 10x)
  • 16-key hex keypad input
  • Delay and sound timers
  • COSMAC VIP and CHIP-48/SUPER-CHIP quirk toggles
  • Runtime debug trace
  • Configurable CPU speed

Requirements

  • C++17 compiler (clang, gcc)
  • CMake 3.20+
  • SDL2
  • just (optional, for build commands)

macOS

brew install sdl2 cmake just

Linux (Debian/Ubuntu)

sudo apt install libsdl2-dev cmake

Build

just build        # debug build with sanitizers
just release      # optimized release build

Or with plain CMake:

cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel

Usage

just br roms/Pong1P.ch8
# or
./build/chip8emu roms/Pong1P.ch8

Flags

Usage: chip8emu <rom> [-d|--debug] [--chip48] [--cycles N]
Flag Description
-d, --debug Enable CPU trace logging to stderr
--chip48 Use CHIP-48/SUPER-CHIP quirks for shift and jump opcodes
--cycles N CPU cycles per frame (default: 10)

Controls

CHIP-8 uses a 16-key hex keypad (0-F), mapped to the QWERTY keyboard:

CHIP-8       QWERTY
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
  • ESC — quit

CHIP-8 System Specs

Component Value
Memory 4KB
Registers 16x 8-bit (V0-VF), VF is flag
Index register 12-bit (I)
Program counter 16-bit, starts at 0x200
Stack 16 levels
Display 64x32 monochrome
Keypad 16 keys (0-F)
Timers delay + sound, 60Hz
Fonts 16 chars (0-F), 5 bytes each, loaded at 0x50

Quirks

Some CHIP-8 instructions behave differently between the original COSMAC VIP interpreter and later CHIP-48/SUPER-CHIP variants:

Opcode COSMAC VIP (default) CHIP-48/SUPER-CHIP (--chip48)
8XY6 (SHR) Copy VY to VX, then shift VX right Shift VX in place, ignore VY
8XYE (SHL) Copy VY to VX, then shift VX left Shift VX in place, ignore VY
BNNN (JP) Jump to NNN + V0 Jump to NNN + VX

Use --chip48 for ROMs written for CHIP-48 or SUPER-CHIP.

Resources

pong1p.mov

About

A CHIP8 Emulator. Find CHIP8 ROMS here: https://github.com/kripod/chip8-roms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors