FPGA-based custom Gameboy cart

These pages record the progress of my Gameboy cart project, which I've abbreviated to ecgc (Elialm's Custom Gameboy Cartridge).

Context

About 2 years ago, in 2020, I was browsing the web and stumbled on the awesome Gameboy development repository. Here, I found the reference manual for the Gameboy and there is where it happened: love at first sight. I don't know why, but there was just something magical about it.

I quickly installed the bgb emulator and tried playing around with it. The first time I got "Hello world" printed on the screen was just great. I wrote the hello-world program in rgbds assembly, which was also my first time writing in assembly.

It was cool seeing the emulator, but I wanted to see my code on an actual Gameboy. I proceeded to buy a second-hand Gameboy Color and modded it to include a backlit screen (the original screen is honestly crap). I had just forgot to buy on of those carts where you could stick in an SD card. After a quick Google search, I found one for €50. I had a teaching job on the side, but I had one or two students, so I wasn't exactly making bank. Then suddenly, one of my brain cells fired giving me the dumbest, stupidest idea ever: "What if I made my own flash cart?".

That's what brings us to today. After 2 years of on-and-off development, I finally have a promising prototype. I was able to run the first program I ever made, which I used to play around with the Gameboy, on my modded Gameboy. The sight of which gave me child-like joy. It had been a while...

A quick side note, the whole Corona crisis was ending in my country, so it was a rough couple of years.

When I eventually had the working prototype, I started thinking about documenting it. I also remembered that I always wanted to have a devlog of the project. I am a fan of Markdown to write stuff in Confluence, so I thought of ways to incorporate that into the devlog. That's what brought me to make this site. Having it would also make it easier to share other products, so it seemed like a good idea.

The end goal

The cartridge I envisioned at first was just a "simple" flash cartridge. I just wanted something I could plug a micro-SD card in filled with games. Here's a MoSCoW list of stuff I want to implement:

  • The cartridge must be able to load games from a micro-SD card:
    • When you boot from the cartridge, you see a list of games from the SD card
    • A user can select a game and play that game
  • The cartridge must save save-data to the micro-SD card
  • The cartridge must support games for the following handhelds:
    • Original Gameboy (DMG)
    • Gameboy Color (GBC)
  • The cartridge should be compatible with as many games as possible:
    • That means being able to emulate different MBCs and an RTC.
  • The cartridge UI should be pleasant (not just something functional)
  • The cartridge UI could be customisable:
    • Custom splash-screen
    • Custom colours
    • Custom layout

Later down the line when I started playing with FPGAs, I started thinking of ways I could utilise the full potential of such programmable logic. Ideas include:

  • A co-processor to accelerate a bunch of stuff:
    • Graphics processing
    • General workloads
  • Several memory mapped peripherals:
    • ALU for multiplication, division, modulus, matrix arithmetic, etc.
  • An audio decoder + DAC for better music:
    • One of the cartridge pins is connected to the Gameboy speakers. The original idea for this was to have cartridges with dedicated sound chips to play more than just beeps and boops. However, few (if any) games actually used this.

The prospects are interesting, but the first requirements mentioned is what I'll be focussing on. I can't really promise the rest.

I'll try to provide semi-regular updates, but I am a student so I don't have much time to work on it.