If you really want to know how a particular computer works, there's no better way to learn than by emulating that computer. The goal of this project is to emulate the original Game Boy and Game Boy Color in Rust with 100% accuracy compared to the original hardware.
Reading emulator code isn’t easy—at least not for me. To really understand why things are implemented the way they are, you first need a solid grasp of how the original hardware works. And since some components don’t behave quite the way you might expect, the best way to understand, contribute to, or learn from this project is through the documentation. There, I explain each component and the reasoning behind the code in simpler terms, even if more in-depth documentation already exists elsewhere. I also walk through what a full console cycle looks like, from execution to rendering a frame on screen.
Check documentation here: https://oscarcpozas.github.io/gb_emu_rs
The emulator can run any Game Boy (.gb) game and most Game Boy Color (.gbc) games; you just need to pass the file name as an argument when running it:
cargo run --bin emu -- ./rom/legend_of_zelda.gbThe CPU instructions implemented in instr.rs are generated from a JSON file obtained here: https://gbdev.io/gb-opcodes/optables
You can regenerate the processor instructions by doing the following:
cargo run --bin instr-codegen ./instr-codegen/res/LR35902_opcodes.patched.json ./emu/src/instr.rsDocumentation on how the emulator works and the decisions made are compiled here in the form of an mdBook. To build or serve the book, you need to have the tool installed.
mdbook build bookmdbook serve bookBlargg’s GB tests are a collection of ROMs designed to verify different parts of the emulated hardware, including CPU instructions and timing, graphics, sound, and a few well-known hardware quirks such as the OAM bug and the halt bug. I use them to measure how close the emulator is to accurate, full-system emulation.
![]() |
![]() |
![]() |
|---|---|---|
| 🔴 FAILED | 🔴 FAILED | 🟢 PASSED |
![]() |
![]() |
![]() |
|---|---|---|
| 🔴 FAILED | 🔴 FAILED | 🔴 FAILED |
- Pan Docs, probably the most complete technical documentation about Gameboy
- Gameboy autopsy Part 1, Part 1.5, Part 2
- Gameboy / Color Architecture
- Game Boy CPU (SM83) instruction set ← Used to generate all the CPU instructions
- GB Accuracy tests ← Used to test the accuracy of the emulator







