SkillAgentSearch skills...

Chip8Java

An XO Chip, Super Chip, and Chip 8 emulator written in Java

Install / Use

/learn @craigthomas/Chip8Java
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Yet Another (Super) Chip 8 Emulator

GitHub Workflow Status Coverage Status Dependencies Version Downloads License: MIT

An Octo compatible XO Chip, Super Chip, and Chip 8 emulator.

Table of Contents

  1. What is it?
  2. License
  3. Compiling
  4. Running
    1. Requirements
    2. Starting the Emulator
    3. Running a ROM
    4. Screen Scale
    5. Instructions Per Second
    6. Quirks Modes
      1. Shift Quirks
      2. Index Quirks
      3. Jump Quirks
      4. Clip Quirks
      5. Logic Quirks
    7. Memory Size
    8. Colors
  5. Customization
    1. Keys
    2. Debug Keys
  6. ROM Compatibility
  7. Third Party Licenses and Attributions
    1. JCommander
    2. Apache Commons IO

What is it?

This project is a Chip 8 emulator written in Java. There are two other versions of the emulator written in different languages:

The original goal of these projects was to learn how to code a simple emulator.

In addition to supporting Chip 8 ROMs, the emulator also supports the XO Chip and Super Chip specifications. Note that while there are no special flags that are needed to run an XO Chip, Super Chip, or normal Chip 8 ROM, there are other compatibility flags that may need to be set for the ROM to run properly. See the Quirks Modes documentation below for more information.

License

This project makes use of an MIT license. Please see the file called LICENSE for more information. Note that this project may make use of other software that has separate license terms. See the section called Third Party Licenses and Attributions below for more information on those software components.

Compiling

To compile the project, you will need a Java Development Kit (JDK) version 17 or greater installed (note that these steps are only needed if you want to compile the software yourself - if you just want to run the emulator, see the Running section below).

  1. For Linux - the simplest way to install the JDK is to use OpenJDK:

    sudo apt update
    sudo apt install openjdk-17-jdk
    
  2. For Windows - I recommend using Eclipse Temurin (formerly AdoptJDK) as the software is licensed under the GNU license version 2 with classpath exception. The latest JRE builds are available at https://adoptium.net/en-GB/temurin/releases (make sure you select JDK as the type you wish to download). The MSI method will download an installer that will download and can be run to install the JDK for you. Follow the prompts for more information. Note that this will also install the appropriate JRE as well.

To build the project, switch to the root of the source directory, and type:

./gradlew build

On Windows, switch to the root of the source directory, and type:

gradlew.bat build

The compiled JAR file will be placed in the build/libs directory, as a file called emulator-2.0.2-all.jar.

Running

The project needs several different packages installed in order to run the emulator properly. Please see the platform specific steps below for more information.

Linux

You will need to install the Java Runtime Environment (JRE) 17 or higher.

  1. Java Runtime Environment (JRE) version 17 or higher. The simplest way to do this is to install OpenJDK 17 or higher. On Ubuntu or Debian systems, this can be done with :

    sudo apt update
    sudo apt install openjdk-17-jre
    
  2. Check that installation was successful by typing:

    java -version
    

Windows

You will need to install the Java Runtime Environment (JRE) 17 or higher.

  1. I recommend using Eclipse Temurin (formerly AdoptJDK) as the software is licensed under the GNU license version 2 with classpath exception. The latest JRE builds are available at https://adoptium.net/en-GB/temurin/releases (make sure you select JRE as the type you wish to download). The MSI method will download an installer that will download and can be run to install the JRE for you. Follow the prompts for more information.

Starting the Emulator

By default, the emulator can start up without a ROM loaded. Simply double-click the JAR file, or run it with the following command line:

java -jar emulator-2.0.2-all.jar

Running a ROM

The command-line interface currently requires a single argument, which is the full path to a Chip 8 ROM:

java -jar emulator-2.0.2-all.jar /path/to/rom/filename

This will start the emulator with the specified ROM.

Screen Scale

The --scale switch will scale the size of the window (the original size at 1x scale is 64 x 32):

java -jar emulator-2.0.2-all.jar /path/to/rom/filename --scale 10

The command above will scale the window so that it is 10 times the normal size.

Instructions Per Second

The --ticks switch will limit the number of instructions per second that the emulator is allowed to run. By default, the value is set to 1,000. Minimum values are 200. Use this switch to adjust the running time of ROMs that execute too quickly. For Super Chip 8 or XO Chip 8 ROMs, you will probably want to execute more instructions per second. For simplicity, each instruction is assumed to take the same amount of time.

Quirks Modes

Over time, various extensions to the Chip8 mnemonics were developed, which resulted in an interesting fragmentation of the Chip8 language specification. As discussed in Octo's Mastering SuperChip documentation, one version of the SuperChip instruction set subtly changed the meaning of a few instructions from their original Chip8 definitions. This change went mostly unnoticed for many implementations of the Chip8 language. Problems arose when people started writing programs using the updated language model - programs written for "pure" Chip8 ceased to function correctly on emulators making use of the altered specification.

To address this issue, Octo implements a number of quirks modes so that all Chip8 software can run correctly, regardless of which specification was used when developing the Chip8 program. This same approach is used here, such that there are several quirks flags that can be passed to the emulator at startup to force it to run with adjustments to the language specification.

Additional quirks and their impacts on the running Chip8 interpreter are examined in great depth at Chromatophore's HP48-Superchip repository. Many thanks for this detailed explanation of various quirks found in the wild!

Shift Quirks

The --shift_quirks flag will change the way that register shift operations work. In the original language specification two registers were required: the destination register x, and the source register y. The source register y value was shifted one bit left or right, and stored in x. For example, shift left was defined as:

Vx = Vy << 1

However, with the updated language specification, the source and destination register are assumed to always be the same, thus the y register is ignored and instead the value is sourced from x as such:

Vx = Vx << 1

Index Quirks

The --index_quirks flag controls whether post-increments are made to the index register following various register based operations. For load (Fn65) and store (Fn55) register operations, the original specification for the Chip8 language results in the index register being post-incremented by the number of registers stored. With the Super Chip8 specification, this behavior is not always adhered to. Setting --index_quirks will prevent the post-increment of the index register from occurring after either of these instructions.

Jump Quirks

The --jump_quirks controls how jumps to various addresses are made with the jump (Bnnn) instruction. In the original Chip8 language specification, the jump is made by taking the contents of register 0, and adding it to the encoded numeric value, such as:

PC = V0 + nnn

With the Super Chip8 specification, the highest 4 bits of the instruction encode the register to use (Bxnn) such. The behavior of --jump_quirks becomes:

PC = Vx + nn

Clip Quirks

The --clip_quirks controls whether sprites are allowed to wrap around the display. By default, sprits will wrap around the borde

Related Skills

View on GitHub
GitHub Stars27
CategoryDevelopment
Updated1mo ago
Forks2

Languages

Java

Security Score

95/100

Audited on Feb 6, 2026

No findings