’Cause all games were better on the GBC

You are not logged in.

#1 2015-02-09 21:11:31

New member
Registered: 2015-02-09
Post 1/1

Red/Blue serial protocol

I'm trying to hook up my CGB to an Arduino and talk to it.
I have it wired up to my Arduino Mega, according to some pinout I found.

16299939857_8c03bdeb27_s.jpgGame Bey <-> Arduino cable by fliebel, on Flickr

Then I found a mix of documents describing the protocol.
It seems to be basically SPI with an active-low clock.
Every time the master pulls the clock low, they exchange one bit with the most significant bit first.
Who is the master and who is the slave is not defined.

It seems Pokemon tries to be both when you talk to the lady at the cable club.

When I put out a clock pulse and just send back the last byte I received, I can trade with myself.
I have no idea why this works, but it does.

When I just listen for a clock pulse, it sends me 0x01 and then nothing. nothing!
This drives me mad.

I found someone on the web that successfully connected a Game Boy to some ARM dev board.
I ported his code to Arduino, but it's doing what I described above. It just sends me 0x01 and then nothing happens. It's not even trying to read my 0x02 that I'm supposed to send.

I tried to look at the Pokemon disassembly what it's actually doing, but it's hard to read for me.
I have hello-world-level X86 ASM experience, and none at all with this CPU.

My Arduino code:

#define MOSI_ 22
#define MISO_ 23
#define SCLK_ 24

volatile int bytes = 0;
volatile uint8_t shift = 0;
volatile uint8_t in_data = 0;
volatile uint8_t out_data = 0;

void transferBit(void) {
    in_data |= digitalRead(MISO_) << (7-shift);

    if(++shift > 7) {
        shift = 0;
        //Serial.print(" ");
        //Serial.print(" ");
        out_data = 2;
        in_data = 0;
    //Serial.print(out_data & 0x80 ? HIGH : LOW);
    digitalWrite(MOSI_, out_data & 0x80 ? HIGH : LOW);
    out_data <<= 1;

void setup() {
    pinMode(SCLK_, INPUT);
    pinMode(MISO_, INPUT);
    pinMode(MOSI_, OUTPUT);
    Serial.print("hello world\n");
    digitalWrite(MOSI_, LOW);
    out_data <<= 1;


void loop() {

The circuit you see in the picture is an overvolt protection, because I initially used my Raspi at 3.3V, but I switched to a 5V Arduino because I thought maybe the 3.3V plus the series resistor does not register a HIGH on the gameboy. So now I have some series resistors and diodes going nowhere. I think the series resistors are a safe idea, in case both try to be master.


But now I wonder if there is a mistake that makes it not register a LOW. I read a disconnected Game Boy reads 0xFF, so I assume the pin is pulled HIGH.
I also asume when it sends a 0x01 the byte I send is a 0x00. I tried just connection the MOSI to GND with no effect.
Still only one byte sent.

Ok, it's working. It was probably an electrical problem. I changed hardly anything.


Last edited by pepijndevos (2015-02-10 12:34:28)


Board footer

Powered by FluxBB