Skip to content

zerootoad/chip8-emulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CHIP-8 Emulator

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.

image image


Table of Contents

  1. About CHIP-8
  2. Project Structure
  3. Features
  4. Getting Started
  5. Usage
  6. Development
  7. References

About CHIP-8

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.


Project Structure

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.

Features

  • 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.

Getting Started

Prerequisites

  • Rust installed on your system.
  • A CHIP-8 ROM file to test (e.g., maze.ch8).

Installation

  1. Clone the repository:
    git clone https://github.com/zerootoad/chip8-emulator.git
    cd chip8-emulator
  2. Build the project:
    cargo build --release

Usage

Running the Emulator

  1. Place your ROM file in the src/roms/ directory.
  2. Start the emulator:
    cargo run --release
    This will load the default ROM (maze.ch8). You can modify the ROM path in the main.rs file.

Controls

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

Development

Key Files

  • 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.

Adding Features

  1. To add support for additional opcodes, extend the decode_opcode and execute functions in cpu.rs.
  2. For graphical improvements, modify the display module.

Debugging

  • Enable opcode logging by inspecting println! statements in cycle and execute.

References


Enjoy building and experimenting with the CHIP-8 Emulator! Feel free to contribute or report issues on the GitHub repository. 😊

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages