Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
/ pich8 Public archive

A cross-platform CHIP-8, SUPER-CHIP and XO-CHIP interpreter and debugger written in Rust

License

Notifications You must be signed in to change notification settings

philw07/pich8

Repository files navigation

pich8

A cross-platform CHIP-8, SUPER-CHIP and XO-CHIP interpreter and debugger written in Rust

Build and Test Dependency Status

I've recently decided to look into emulators and found many recommendations to start with a CHIP-8 interpreter.
Since I had just started to read the book, I've decided to use this opportunity as my first Rust project.
I can definitely recommend giving it a try, I learned a lot during this journey.

I also ported the interpreter (partly) to Go: pich8-go.

pich8

Features

  • Cross-platform
  • Support for CHIP-8, SUPER-CHIP 1.1 (S-CHIP) and XO-CHIP
  • Supports screen resolutions 64x32 (CHIP-8 Default), 64x64 (CHIP-8 HiRes) and 128x64 (S-CHIP, XO-CHIP)
  • Rendering and sound using native Rust crates glium and rodio
  • GUI using crate imgui-rs (Rust bindings for Dear ImGui)
  • Load ROMs from local file system or download them directly from a URL
  • Save and load current CPU state
  • Fullscreen mode and possibility to change background and foreground colors
  • Change CPU speed dynamically
  • Enable or disable several quirks (some ROMs require specific quirks)
  • Debug windows displaying current register values, stack and executed opcodes as well as allowing to set breakpoints

Screenshots

CHIP-8 ROM Blinky
CHIP-8 ROM Blinky

CHIP-8 HiRes ROM Astro Dodge
CHIP-8 HiRes ROM Astro Dodge

S-CHIP ROM Ant
S-CHIP ROM Ant

XO-CHIP ROM Red October
XO-CHIP ROM Red October

Changing colors using presets or individually
Changing Colors

Debugging ROM
Debugging ROM

Compatibility

During my testing, I haven't come across any ROM which did not work correctly, some ROMs however require specific settings.
Without going too much into detail, the following are just guidelines and some ROMs may behave differently.

  • Quirks
    • The default setting usually works good for legacy ROMs, however some title may need specific quirks turned off.
    • Modern ROMs written with Octo usually use different settings, therefore an Octo preset is included.
  • CPU speed
    • Legacy CHIP-8 ROMs usually work well around the default speed setting.
    • S-CHIP ROMs usually require one of the faster speed settings.
    • XO-CHIP ROMs often require significantly higher speeds, therefore a 50x multiplier is available.

Key Mapping

As with most other emulators, the keys are mapped as follows.
On other keyboard layouts it should be the same keys (not the same characters) as the keys are determined by scancode.

    Keyboard                     CHIP-8
┌───┬───┬───┬───┐           ┌───┬───┬───┬───┐
│ 1 │ 2 │ 3 │ 4 │           │ 1 │ 2 │ 3 │ C │
├───┼───┼───┼───┤           ├───┼───┼───┼───┤
│ Q │ W │ E │ R │           │ 4 │ 5 │ 6 │ D │
├───┼───┼───┼───┤     →     ├───┼───┼───┼───┤
│ A │ S │ D │ F │           │ 7 │ 8 │ 9 │ E │
├───┼───┼───┼───┤           ├───┼───┼───┼───┤
│ Z │ X │ C │ V │           │ A │ 0 │ B │ F │
└───┴───┴───┴───┘           └───┴───┴───┴───┘

Building

Make sure the rust toolchain is installed (on Windows both gnu and msvc are fine), best using rustup.

Windows

You can simply build using cargo or run directly.

> cargo build

Linux

You need to install the required packages, on a Debian/Ubuntu based system:

$ sudo apt install gcc g++ libasound2-dev libssl-dev
$ cargo build

On a Fedora based system:

$ sudo yum install g++ alsa-lib-devel openssl-devel
$ cargo build

If you run cargo build --no-default-features, you won't need the openssl package, but then it's not possible to download ROMs from the internet.

Note: I couldn't get the application to run in a Linux VM due to this issue in glutin.

macOS

I have no macOS system, but I assume it should work if you have a proper build system installed.

Sources for CHIP-8 ROM files

Resources