How tathack-tathva/chip8-emulator works
This is a desktop Chip-8 virtual machine: the user supplies a ROM, the SDL-driven application loads it and runs instructions, then presents the emulated display, keypad input, and sound. The graph separates application I/O, VM state and execution, and SDL output. The README documents the full opcode set and display/audio capabilities; the sampled implementation excerpts are partial, so detailed opcode wiring is not expanded.
Main entry points: main.cpp Emulator loop · chip8.cpp Instruction cycle · chip8.h Pixel display · roms Chip-8 ROMs
Components 13
Application I/O
- Emulator loop
src/main.cpp
Chip-8 VM
- ROM loading
src/chip8.cpp - VM state
src/chip8.h - Instruction cycle
src/chip8.cpp - Pixel display
src/chip8.h - Keypad state
src/chip8.h - Timers
src/chip8.cpp
SDL Media
- SDL2
- Input handling
src/main.cpp - Graphics rendering
src/main.cpp - Beep generation
src/main.cpp
Other components
- User
- Chip-8 ROMs
roms
Connections 17
- User → Emulator loop: starts with ROM
- Chip-8 ROMs → ROM loading: ROM data
- Emulator loop → ROM loading: loads ROM
- Emulator loop → Instruction cycle: runs cycles
- Instruction cycle → VM state: updates state
- Instruction cycle → Pixel display: draws sprites
- Instruction cycle → Keypad state: checks keys
- Instruction cycle → Timers: updates timers
- SDL2 → Input handling: delivers events
- Input handling → Keypad state: sets key state
- Emulator loop → Input handling: polls events
- Emulator loop → Graphics rendering: draws frame
- Graphics rendering → Pixel display: reads pixels
- Emulator loop → Timers: reads sound timer
- Emulator loop → Beep generation: sets beep state
- SDL2 → Beep generation: invokes callback
- Emulator loop → SDL2: initializes media