GameBoy Synth Module

Adil Soubki
5 min readJul 31, 2020

--

The GameBoy is among the most loved pieces of hardware in the chiptune community. This is, at least in part, due to the wonderful accessibility of making music on the device and its surprisingly powerful sound chip. With two pulse channels, a wave table synthesizer, sample playback, and a noise channel, the breadth of its feature set outclasses some modern digital oscillator synthesizer modules and at a modest price. If these parameters could be driven with control voltage and placed in a eurorack form factor it would be a cheap way to add a lot of power to your set up.

A failed attempt at using level shifters as CMOS bilateral switches. At least it looks cool.

This is, unfortunately, harder than you might expect. Unlike the Commodore 64 with its famed SID chip, for example, the GameBoy’s sound chip is embedded into the MCU and as a result cannot be manipulated independently. In order to interact with the GameBoys sound chip, users must provide Z80 instructions over the bus and load values into special sound control registers. This means that it isn’t really feasible to remove the chip and drive it directly and instead it needs to be driven with code running natively on the GameBoy.

That’s all well and good but if we want to be able to modulate these synthesizer parameters with external hardware we are going to need a way of getting information from the outside world, about the values of control signals and when to gate different channels, into the GameBoy somehow.

Getting Data Into the GameBoy

The GameBoy is not a development board. It doesn’t expose much GPIO, unless you count its buttons, and much of its memory has already been mapped for existing peripherals. What we would like is to connect a development board to the GameBoy and establish a channel of communication somehow.

A breakout board I designed for the cartridge connector.

Experimenting with how to achieve this is where I have spent most of my time on this project so I’ll start by listing some of my ideas.

  • Serial communication using the link port.
  • UART communication by polling the joypad buttons.
  • Emulating the cartridge with a microcontroller/FPGA.
  • Having a microcontroller write to the GameBoys external cartridge RAM.

All of these methods have trade-offs and I tried many of them with varying degrees of effort before landing on a less-than-optimal prototype that uses a Teensy 3.5 as the microcontroller, a TinyFPGA BX as glorified dual-port RAM, and an AT28C256 EEPROM to hold the GameBoy code. I didn’t get to this configuration without many, many failed attempts and, though it gives me some pause, I’ll spare you the details.

If you think it looks bad here you should see the breadboard.

The set up has three different devices all running (or synthesized with) code written in three different languages. It’s a real Frankenstein but I just need a proof of concept to show that this is possible. The plan is pretty simple. On the GameBoy, a program will loop through a block of shared RAM and load the values into corresponding sound control registers. The FPGA will act as that RAM talking to both the GameBoy, when reads are requested, and the Teensy, when writes are requested. The Teensy will deal with translating control voltages, button presses, and knob turns into values to be loaded into RAM and subsequently the sound control registers resulting in a fully controllable sound card with whatever hardware you want.

Controlling the envelope and frequency of one of the GameBoys pulse channels with potentiometers.

As an aside, this set up need not only be used for controlling the sound card. Since we have a communication channel with the GameBoy the possibilities are endless. I could read my email on the GameBoy if I wanted to.

A Detour from Modularizing

I’m away from my home in New York at the moment so much of this project was done with limited tools. I actually ended up making my own janky EEPROM programmer just to get my code onto the AT28C256. I mention this because not only did I leave my soldering iron and logic analyzer at home, I also left my modular synth.

While I now have the ability to start designing the module and patching CV, I don’t have any modulation sources! So I took a detour and instead started trying to control the GameBoy by using the Teensy as a MIDI host device. I’ve seen Trash80’s famous ArduinoBoy project and the similar TeensyBoy which allow MIDI syncing over the link port but I don’t think anyone has fully driven and controlled the sound chip with MIDI.

The Teensy has a MIDI library which I was able to use to pipe note data from Ableton Live into the microcontroller. The GameBoy supports an 11-bit value for frequency while MIDI notes are sent as 8-bit values. With a bit of algebra, I was able to translate the MIDI note into a value for the GameBoys control registers representing the same frequency.

You can tell we’re doing engineering because of all the magic numbers.

Once that was working it was just a matter of setting up a callback for MIDI events and forwarding the data to the GameBoy.

Controlling the sound chip from Ableton Live.

Next Steps

I don’t plan on beginning layout work for the module until I get back to New York but that is definitely my primary goal. In the meantime, I would like to write a more feature-rich VST for controlling the GameBoy with MIDI. Currently, only note data is used and I have knobs for changing other parameters but what might be better is sending that information over from a VST using MIDI control change events.

If your dual-port RAM chip doesn’t communicate over UART that’s probably a good thing.

I would also like to simplify the hardware in this design a bit. For one thing, a cheaper and less powerful microcontroller could be substituted for the Teensy 3.5. Similarly, while what I have works, an FPGA is both overkill and very expensive. I would like to test an alternative set up that replaces the TinyFPGA BX with an IDT7130 dual-port RAM chip since that would significantly reduce the cost for anyone looking to recreate this.

On that note, if you have any questions feel free to message me on Twitter as I’ll be happy to help. At your own risk, you can peruse all the code and schematics I used for this project here but it’s a mess in there so you’ve been warned.

References

This project could not have been possible without help from these resources.

  1. GBDev
  2. OpenCores
  3. Chickadee Tech Kicad Libs
  4. Emulating a GameBoy Cartridge with an STM32F4 [Dhole]
  5. GameBoy FPGA Cartridge [GhidraNinja]
  6. EEPROM Programmer [Ben Eater]

A special thanks goes to Charles Affel for enduring several scuffed video calls of debugging.

--

--