$ show deltabeard/Peanut-GB
Peanut-GB is a high-speed, portable Game Boy (DMG) emulator library implemented as a single C99 header file (peanut_gb.h). It provides a complete emulation core including CPU, memory, LCD, cartridge (MBC1/2/3/5), RTC, serial link, and boot ROM support. The library is designed for easy integration into other projects via a callback-based architecture where the frontend provides ROM read, RAM read/write, error handling, and optional LCD line drawing and audio callbacks. The repository includes multiple example frontends demonstrating integration with SDL2 (full emulator with audio and controls), MiniFB (minimal X11 framebuffer), a debug CLI, a Nuklear-based GUI debugger with disassembler and VRAM viewer, and a benchmark tool. A test suite using the minctest.h framework runs Blargg's CPU instruction and timing tests as well as the dmg-acid2 LCD hash test. The library is MIT-licensed and has been used in several real-world projects (Pico-GB, CPBoy, PlayGB). While the core is well-crafted and portable, known inaccuracies exist (line-by-line LCD rendering, audio timing) and some features are incomplete (MBC6/7, camera). The build system is fragmented across Makefiles and CMake, and some examples have version drift in vendored dependencies.
The LLM identified 2 files worth highlighting for reuse:
The entire Game Boy emulator core in a single C99 header file. It implements CPU, memory, LCD, cartridge, timing, and interrupt handling with a clean callback interface for ROM, RAM, error, LCD, audio, and serial I/O. The header is self-contained, portable (no external dependencies), and can be used in both header-only and separate-object compilation modes. It demonstrates high craftsmanship in packing a complex emulator into a single file with compile-time feature flags and minimal coupling to the frontend.
A standalone Game Boy audio processing unit library based on MiniGBS. It provides audio callback functions that can be plugged into any audio backend (SDL2, etc.). The library is self-contained, handles all Game Boy sound channels (pulse, wave, noise), and is designed for easy integration. It is reused across multiple examples (SDL2 and debug-nuklear) and could be extracted for use in other emulator projects.