All selected work

03 / Systems & correctness

Game Boy Emulator

Making correctness observable.

A dependency-free emulation core sits behind a headless CLI and a MonoGame desktop frontend. Test harnesses compare instruction state and exercise hardware test ROMs.

C#.NET 8MonoGamexUnit

Implemented · accuracy work ongoing. Recent GitHub CI runs passed. Battery saves and remaining timing accuracy are still identified as work ahead.

The problem

An emulator can appear to run while subtle timing or state errors remain. Correctness needs to be examined at several levels: individual CPU instructions, memory behavior, and the interaction of graphics, audio, and timers.

How it fits together

GBEmu.Core contains the CPU, bus, cartridge mappers, timers, graphics, and audio. A CLI supports headless execution and screenshots. A separate MonoGame desktop project provides input, display, and audio playback.

SM83 CPUMemory busGraphics / audio / timerCLI or desktop

Decisions & tradeoffs

01Separate the machine from its window

The core has no desktop dependency. The same emulation behavior can be exercised by the CLI, the test suite, and the MonoGame frontend, which makes failures easier to isolate.

02Compare against reference instruction state

The SingleStepTests harness loads initial registers and memory, executes one instruction, and compares final state and timing. It makes failures specific enough to investigate.

03Use hardware tests alongside unit tests

Blargg, Mooneye, graphics, and sound harnesses test interactions that isolated instruction fixtures cannot fully establish. CI fetches the test data so those suites are not silently skipped there.

Validation & evidence

Evidence from the project’s implementation, test harnesses, and recorded status.

  • The linked GitHub CI run records a successful build and test execution.
  • xUnit harnesses cover instruction fixtures, timers, cartridge mappers, and hardware test ROMs.
  • The README documents graphics and sound results alongside known timing limitations.

Current scope

Passing reference suites does not mean complete cycle accuracy or universal compatibility. The README identifies battery saves and a remaining timer edge case as future work. Local hardware suites can skip when external test data is absent.

The next engineering step

Continue timing-accuracy work, implement battery saves, and tie any advertised compatibility or exact test totals to reproducible runs.