Part 3: A Link Between Worlds

If I wanted to transfer Pokémon out of the GameBoy games and into the GameBoy Advance games, I needed some way to obtain the Pokémon data. Fortunately, the game has a way already built in- trading through the Link Cable! When two people trade, ~440 bytes of data are sent over the Link Cable, which contain all of the information about the six Pokémon in the player’s party. If we could some how trick the GameBoy into thinking it was communicating with another GameBoy, we could obtain that party data.

The idea was simple enough, but there was a large issue. Despite the GameBoy Advance being backwards compatible with the GameBoy, the two are very different systems. The GameBoy has a CPU based on a Sharp Z80, while the Advance’s CPU is an ARM7TDMI. The GameBoy also runs at 5 volts, while the Advance runs at 3.3 volts. Really, the only thing that’s helpful with the Advance’s backward compatibility is that the Link Cable port can accept GBA and GB Link Cables. Thanks to some testing by Goppier, another amazing person who has bridged the gap between generation 1/2 and generation 3, the difference in voltage is not enough to damage either system. That leaves the two different CPUs as our main issue. Since the two systems run off of different CPUs, we’ll have to write our own code to take the data from the GameBoy, interpret it, and send back what it’s expecting.

The GameBoy Link Cable uses SPI protocol, meaning it has two data pins, a clock pin, and a ground pin. The two devices’ grounds are connected, and each one runs one of the data lines. The device in charge, known as the “master”, runs the clock. Every time the clock signal is high, the state of the data pins are read- if it is high, it is read as a 1, and if it is low it is read as a 0. This happens eight times to form an 8-Bit binary number. This is repeated for however many bytes the device wants to send. Making sure the clock signal is not too fast, nor too slow is crucial

After some research, I found someone who had done something very similar, but with an Arduino instead of the GameBoy Advance: arduino-poke-gen2 by stevenchaulk. This code was almost exactly what I was looking for, and after removing the Arduino specific code and replacing it with a Link Cable library called gba-link-connection by afska, I was able to successfully spoof a trade.

The Arduino set-up I used to test stevenchaulk’s code

While it may seem like this was a simple task, this was the section of development that was the most frustrating. Bug testing the Link Cable was tough and time consuming, and often I had to rewrite the whole thing from scratch when I found an issue. Summer of 2023 was almost all about getting this Link Cable data to work, and I ended up rewriting it again in early 2024. Fortunately, I knew it was possible thanks to Lorenzooone, and even reached out to them a few times during the debugging process. They were super helpful, and I cannot thank them enough for their help!

At this point, I had a way to inject the Pokémon data into generation 3, and I had a way to receive the Pokémon data from generation 1 and 2. Next up was the part I was most looking forward to- converting from one to the other.

Previous
Previous

Part 2: What’s in a Save?

Next
Next

Part 4: Time for an Upgrade