A CHIP-8 interpreter written in Scala, using the Processing library for graphics.
Some context on CHIP-8:
CHIP-8 is a simple, interpreted, programming language which was first used on some do-it-yourself computer systems in the late 1970s and early 1980s. The COSMAC VIP, DREAM 6800, and ETI 660 computers are a few examples. These computers typically were designed to use a television as a display, had between 1 and 4K of RAM, and used a 16-key hexadecimal keypad for input. The interpreter took up only 512 bytes of memory, and programs, which were entered into the computer in hexadecimal, were even smaller.
- Update the
gradle.properties
file- Either:
- delete it, and use Java 8
- set it to your JAVA_HOME
- It is currently set to my own (macOS) Java 8 installation
- This is needed because I cannot use Java 8 as my main Java version, due to other applications needing newer versions.
- Either:
- If wanted, modify the
quirks.properties
file to a different ROM.- by default, it is set to
roms/3-corax+.ch8
, which is an extensive test rom
- by default, it is set to
- Run the
run
gradle task, or, as in Tetris, click on the green "play button" inChipVM.scala
inside of IntelliJ
I based my implementation mostly on the testing ROMs, the demo (games, etc.) roms were not tested much.
The keypad is mapped to the following keys:
1234
QWER
ASDF
ZXCV
These are various testing roms that I found online and used to test the interpreter. Many games might still be buggy, but this is because they might depend on specific quirks and behaviours I did not implement.
roms/1-chip8-logo.ch8
- Displays a CHIP-8 testing suite logo
roms/2-ibm-logo.ch8
- Displays the IBM logo
roms/3-corax+.ch8
- Tests many instructions
roms/4-flags.ch8
- Tests if flags are properly set (VF)
roms/5-quirks.ch8
- quirks that the test suite considers important to follow (might cause bugs in some roms)
roms/6-keypad.ch8
- tests keypad
roms/7-fontTest.ch8
- displays a character from the font set
roms/7-fontTest-Double.ch8
- displays a character twice, as to make the display clear again
These are demos that I found online, I did not make them myself, nor did I test them extensively.
roms/sir.ch8
- Triangleroms/maze.ch8
- Randomly generated mazeroms/pong.ch8
- Pong1
for P1 UpQ
for P1 Down4
for P2 UpR
for P2 Down
roms/br8kout.ch8
- BreakoutA
for LeftD
for Right
roms/tetris.ch8
- TetrisW
for LeftE
for RightQ
for Rotate
roms/buggy-RoShamBo.ch8
- RoShamBo/RPS- Known bug: Display also is a bit wonky: the indicated letters do not actually show that RPS move, and it does not always reset properly. It might rely on quirks or extended behaviours.
Z
for RockX
for PaperC
for Scissors
roms/war.ch8
- Press F to pay respectsV
to pay respects (V is placed on the location of the original keypad's F)
This interpreter passes pretty much all tests across corax+, flags, quirks and keypad:
I implemented CHIP-8 as correctly and extensively as I could, yet limitations are still present:
- All test roms work
5-quirks.ch8
: the display being "low" is the only complaint, but seemingly it is not a bug.
- Trying to use Minim for sound was a horrible experience, and I was forced to remove it from my interpreter as I feared it would make it crash in unexpected ways.
- It bugged out saying files did not exist when they did
- The Oscillator (for custom square wave generation) was not working as well as needed: it did not turn on and off quirkly enough
- at times, it slowed down the program to a crawl
- Some roms are buggy (e.g. RPS), but they work well enough to demonstrate the interpreter's full functionality.
- RPS has a bug where dual input might happen, I fear this might have to do with Processing and Java's AWT.
Note that there was a best effort to make the interpreter immutable.