Skip to main content

Gate-by-Gate Simulation of Game Boy is Slowest Way to Emulate Zelda

A Game Boy and the photo of its silicon
(Image credit: Austin Appleby/Nintendo)

When it comes to emulation, there are a few different approaches. You can use ROM images, reverse-engineered hardware, software abstraction layers... but one thing that’s rarely attempted is a gate-by-gate recreation of the silicon you’re trying to emulate. The GateBoy project, as brought into the light by Hackaday, does just that.

A screen from the simulator showing a Zelda game

(Image credit: Austin Appleby)

There is a degree of reverse engineering involved here - the project is based on photographs of the chip die for DMG-01, the earliest Game Boy model - the initials stood for Dot Matrix Game, the product’s internal codename at Nintendo. Unfortunately, due to the poor quality of the photo of the CPU, that chip is more of a best guess than a direct software recreation, and the audio chip isn’t being stimulated, as it runs too slowly.

Despite those caveats, however, this is a fascinating project. Simulating all the gates and clock phases on a single 4GHz CPU core gives an output of six to eight frames per second, a long way off the 59.7fps you could expect from the original hardware. 

Project creator Austin Appleby addresses the speed issue on the GitHub page: “GateBoy simulates every logic gate on the DMG chip, one gate at a time. Adding two 8-bit values isn't simulated as 'a = b + c', it's simulated as eight 1-bit adders and eight 1-bit registers and all the control logic that goes along with it. GateBoy also simulates every clock phase, not just individual clock cycles. While you may have read that the Game Boy runs at 1 megahertz, this is not quite correct. The 4.19 megahertz clock crystal feeds a set of gates... that produce four 1 MHz clocks that are out of phase with each other. So, it's more accurate to say that the Game Boy has a one-megahertz, eight-phase clock. 

“Even with heroic optimization and all the error checking turned off in 'fast mode', we still only hit 6-8 fps on a modern CPU. Simulating hardware in software is usually thousands of times slower than realtime - GateBoy is 'only' eight times slower than realtime.”

There’s still work to do, clearly, especially figuring out the quirks of the Game Boy’s custom chipset, but getting the project to this stage is a phenomenal achievement. To find out more, and compile and run the software yourself, check out the project’s GitHub page.

Alternatively, you could always emulate retro consoles with RetroPie.

Ian Evenden
Ian Evenden

Ian Evenden is a UK-based news writer for Tom’s Hardware US. He’ll write about anything, but stories about Raspberry Pi and DIY robots seem to find their way to him.