I love hacking with the Game Boy. Writing an emulator for this console is one of my main projects.
But tinkering with real hardware is also very fun.
This time I wanted to create a dumping tool to read and write Game Boy cartridges with Arduino. Before we start, you can grab all the sources and schematics in my GitHub repository.
Game Boy cartridges have 32 pins so we are going to need a lot of IO pins in the Arduino part. Using shift registers will also do but having all dedicated IO pins is easier and faster so I went straight for the Arduino Mega 2560. Game Boy uses 5v so it is safe to wire the cartridge directly to the Arduino.
With a cartridge pinout in hand I started wiring the cartridge header I salvaged from a Super Game Boy straight to the Arduino.
In order to save the ROM and RAM I wired up an SD card reader module. So once we are dumping the contents of the cart we are going to store them in the SD card. We could also read a file from the SD card and write it in the cartridge RAM, if any.
Just for safety sake I put some resistors between the cartridge and Arduino, so in case I make a mistake avoid frying up the cartridge. Anyway, the cartridges seem to be pretty strong.
Reading from a Game Boy cartridge is fairly simple. Put an address in the 16 bit address bus then read the data in the 8 bit data bus. Loop through all the memory addresses of the cartridge and you are done.
Some cartridges use memory bank controllers (MBCs) in order to avoid the limit of the 16 bit address bus and store more data.
You can find all the information about the memory map, cartridge headers and MBC controllers in the Pan Docs.
This is the full setup.