Tim Hentenaar's Blog

Nov 10, 2014 17:00

Expanding the Gameboy's I/O Capabilities

As a follow-up to my last post, I starting thinking about simple ways to interface with the Gameboy dev cart I now own. Of course, I could just use my arduino and a couple of 74595's, but nowadays that's a bit cliche. Not to mention, plenty of people have already done it. :P

I figured it would be much more interesting to build a Gameboy cart which can interface with other Gameboy cartridges (or any other hardware that you can drive at TTL or CMOS line levels.) Since a Gameboy cart has 29 I/O pins (if you count the bus control lines,) this new cart would have to add that many lines.

That made me think back to the days of the 8085, and the more widespread availability of I/O expansion chips for microprocessors. The first such chip to come to mind was, of course, the Intel 8255. In more "modern" computer systems, the functionality of the 8255 is likely provided by the southbridge chip on the motherboard. However, the 8255 is still in production, and still just as useful in 8-bit systems.

The 8255 provides three 8-bit I/O ports (A, B, and C -- although, port C is actually comprised of two independent 4-bit ports) on one IC. To oversimplify a bit, you just read from / write to the ports on the 8255, and it relays your wishes to the outside world, or vice versa.

Here's the datasheet for the 8255 I'ved used in the design below.

The downside to this approach is that reads and writes to another cartridge, for example, will be about 4x slower than if the Gameboy did it directly, as it requires 4x as many writes, and each write cycle probably takes around 450 ns or so.

Anyhow, I set about to design such an interface, and came up with this. Ain't it a beauty? The two 8255's map to the Gameboy's address space at $7FF8 - $7FFF as shown.

So, after you've built this thing, you plug it in, and boot some code stored on the EEPROM that interacts with some hardware via the ports on the 8255, but, assuming I want to, for example, dump a cart, flash an EEPROM, etc., how would I get the data onto the Gameboy without having to re-burn the EEPROM each time? From the built-in serial port, of course!

In order to interface the Gameboy's "Game Link" port with a (9-pin) RS-232 port, we need to use a good ol' MAX3232 to convert between RS-232 and TTL line levels. Going directly from the "Link" port to an RS-232 port is possible, if you don't mind blowing-up your Gameboy.

Here's a schematic for a simple "Game Link" port to RS-232 converter:

Well, that's all for now. Once I get the components in, I'm going to build this bastard, and write some code to see what it can do!