First attempt writing an emulator
The development of this emulator started in late 2018, but it was only made fully functional until early 2021. Back then, I hoped to gain a foothold on emulation development by implementing this CHIP-8 emulator, but progress soon came to a cease due to a lack of computer architecture knowledge and inadequate debugging skills. It took just a few days to fix the bugs previously committed once I picked up this project the second time. The way that CHIP-8 handles IO, dedicated instructions for drawing sprites and blocking for keypad input, drastically differs from real machines, which is usually done by MMIO. Nevertheless, I think it is a fun and worthwhile experience.
This emulator is created with cross-platform support in mind. Two binaries are generated at build, libchip.a
and chip
. The former is a static library that implements the core logic of the CHIP-8 interpreter. By default, the console
struct is allocated on the stack; no allocation is needed. Rom loading functionality is up to the user to implement to avoid dependency on the file system. Core functions are exposed in the console.h
header file. chip
is tested on both Windows and Linux, but presumably adapting it to embedded devices would require minimal effort.
console console_new();
void console_timer_tick(console *console);
void console_cpu_tick(console *console);
void console_tick(console *console);
...
void disassemble(u8 lo, u8 hi);
void disassemble_rom(u8 *rom, usize start, usize len);
meson build
meson compile -C build
build/chip <path_to_rom.ch8>
meson
cmake
ninja
chip
relies on MiniFB
to get a frame buffer, but you don't need to install it yourself explicitly. meson
directly fetch source files from the MiniFB
repository declared in subprojects/minifb.wrap
. However, you still need cmake
to build MiniFB
. Prebuilt binaries are available in the GitHub release section.