Fortran CHIP-8 interpreter
The following tools and libraries are required:
gfortran
or ifx
Clone the repository and build using CMake
$ git clone
$ mkdir build && cd build
$ cmake .. -DFC8_KEYBOARD=qwertz
$ make
The keyboard binding is fixed at compile time. You can select between:
qwerty
(default)qwertz
azerty
If the build was succesful, you should now be able to play a CHIP-8 game using:
$ ./fc8 <path/to/cartridge>
The full set of command-line options is:
Usage: fc8 [-h] [-s] [-zoom=Z] [--config=FILE] <path-to-ch8>
Fortran CHIP-8 interpreter
required arguments:
<path-to-ch8> a CHIP8 ROM file
options:
-h, --help show this help text and exit
-v, --version display version and exit
-s, --silent silent mode (disable audio)
--zoom=Z zoom percentage, 30 <= Z <= 200
--display=:N server display number; the default is 0
--config=FILE configuration file: a Fortran namelist
The interpreter display responds to the following keys
The CHIP-8 keypad is bound to conventional keyboards as follows:
When the X11 version of fc8 was built, you can run it on a remote machine using X-forwarding. To do so you must have a running X-server (e.g. Xming on Windows, XQuartz on Mac). After logging in with
$ ssh -Y <userID>@<destination>
you should be able to run fc8 remotely.
Some example ROMs can be bound in the cartridges/
directory. ROMS/cartridges can be loaded at the command line:
$ ./fc8 <cartridge>
To test the interpreter, I have used the ROM images found in the following third-party repositories (in this order of helpfulness):
It's often insightful to compare results with interpreters of others. Here are just a few:
(Note that many interpreters found on the internet are incomplete or misinterpret certain opcodes. In some cases, also the ROMs are broken or rely on implementation quirks.)
Larger collection of games and other demos can be found in:
One of my aims in this project was to investigate design patterns. One of the typical design problems in game development (or graphical programs in general) is how to support different graphical engines on different platforms.
The easy solution is to pick a graphics framework with widespread platform support. This way all of the platform specific issues are pushed down into the graphical layer.
Obviously, the requirements of a black and white, 2D game view are low compared to more realistic programs, however the designs patterns still apply.
For a true experience you can write the games by hand in pseudo-assembly,
and compile them to hex manually. You can use a hex editor such as hexyl
or hexedit
to save and edit your CHIP-8 programs.
The hexdump
tool can be used to quickly inspect a cartridge (watch out as different tools might display the byte-order differently). Alternatively, HexEd.it client-side JavaScript based hex editor is a more powerful tool which runs in the browser.
A far better developer experience is to use a high-level assembler. The most famous one today is Octo, which also includes a disassembler and emulator, as well as a sprite editor. A second alternative is Dorito.
Personally, I have found the customasm
tool working well too. Examples of CHIP8 programs written in a custom assembly language can be found in the asm/
folder of this repository.
Other assemblers:
Special thanks goes to: