Implemented with the guide from Tobias V. Langhoff.
This guide also contains some ambiguous instructions so I additionally looked at Cowgod's Chip-8 Technical Reference v1.0 (e.g. shift instructions like 8XY6 and 8XYE or jump with offset BNNN).
- 4Kb of RAM
- 64 * 32 pixels display ("pixel" actually 16*16 pixels)
- program counter (PC), which points at the current insruction in memory
- one 16-bit index register (I) which is used to point at locations in memory
- stack of 16-bit addresses
- 8-bit delay timer which is decremented at a rate of 60 Hz
- 8-bit sound timer which functions like the delay timer, but which also gives off a beeping sound as long as it’s not 0
- 16 8-bit registers, numbered
0throughF, and calledV0throughVFVF- flag register
- instructions are executed at 700Hz (700 instructions/second)
| Original keypad | Keyboard keypad |
|---|---|
| 1 2 3 C | 1 2 3 4 |
| 4 5 6 D | Q W E R |
| 7 8 9 E | A S D F |
| A 0 B F | Z X C V |
Keypad button is considered pressed when it released. In this implementation emulator doesn't support multiple buttons pressed at the same time. In this case it will consider pressed only first button from KeypadButtons bit_set.
Examples directory contains some CHIP-8 ROM-s which can be executed with this emulator.
To build emulator and then run example use this commands:
odin build src -o:speed -out:chip8emu
./chip8emu examples/Chip8-Picture.ch8Or you can run it without build:
odin run src -o:speed -- examples/Chip8-Picture.ch8