Welcome to the CHIP-8 Emulator project! This emulator replicates the functionality of the CHIP-8 virtual machine, which was used in classic systems and is a popular starting point for emulator development. Below is a detailed explanation of the emulator, its capabilities, and how you can use it.
CHIP-8 is a simple, interpreted virtual machine used to run small games from the 1970s. It features:
- A 64x32 monochrome display.
- A 16-key hexadecimal keypad.
- Simple instruction sets for drawing, input, and computation.
This emulator provides a modern implementation of CHIP-8 in Rust, suitable for learning and experimenting with low-level systems.
The project is divided into the following modules:
cpu
: The core logic for opcode decoding and execution.memory
: Handles memory operations and fontset loading.display
: Manages rendering and user interface.utils
: Utility functions like random number generation.opcodes
: Enum definitions for CHIP-8 instructions.
- Instruction Set Implementation: Supports all original CHIP-8 opcodes.
- ROM Loading: Load and execute
.ch8
ROM files. - Emulation Cycle: Simulates the CPU cycle, including opcode fetch, decode, and execute.
- Graphics Rendering: Renders the 64x32 monochrome display.
- Timers: Implements delay and sound timers.
- Rust installed on your system.
- A CHIP-8 ROM file to test (e.g.,
maze.ch8
).
- Clone the repository:
git clone https://github.com/zerootoad/chip8-emulator.git cd chip8-emulator
- Build the project:
cargo build --release
- Place your ROM file in the
src/roms/
directory. - Start the emulator:
This will load the default ROM (
cargo run --release
maze.ch8
). You can modify the ROM path in themain.rs
file.
Use the following keys for input (mapped to a typical keyboard layout):
CHIP-8 Key | Keyboard Key |
---|---|
1 |
1 |
2 |
2 |
3 |
3 |
C |
4 |
4 |
Q |
5 |
W |
6 |
E |
D |
R |
7 |
A |
8 |
S |
9 |
D |
E |
F |
A |
Z |
0 |
X |
B |
C |
F |
V |
cpu.rs
: Implements CHIP-8's CPU, including opcode execution.memory.rs
: Handles memory management.display.rs
: Implements graphical output.main.rs
: Entry point of the application.
- To add support for additional opcodes, extend the
decode_opcode
andexecute
functions incpu.rs
. - For graphical improvements, modify the
display
module.
- Enable opcode logging by inspecting
println!
statements incycle
andexecute
.
Enjoy building and experimenting with the CHIP-8 Emulator! Feel free to contribute or report issues on the GitHub repository. 😊