A Dangerous Hybrid: Speeding up the Super Game Boy
The Super Game Boy allows you to play Game Boy games on your Super Nintendo. This is an impressive feat, when you consider that the two consoles share basically nothing in common. Today, we’ll look at the hybrid machine that creates: a multi-processor machine where the two CPUs share nothing in common. And maybe, just maybe, we can make the Super Game Boy go fast.
It’s a bird, it’s a plane
So, the Super Game Boy. Christine Love has already said pretty much everything there is to say about it, right? And I think from an aesthetic standpoint, and from a standpoint of how the thing was actually used by developers, that may well be true. So go read her series. This post will be here when you get back.
Are you back? Great. Never leave me again. So one of the games Christine Love talked about was World Heroes 2 Jet. She notes that it used some clever palette tricks to make it look good. Cool stuff. Unfortunately it’s still a Game Boy fighting game.
Oh hey, it’s Takara again, the same people who ported Fatal Fury to the SNES. I swear I’m not targeting them. After all, they went above and beyond in the port– as The Cutting Room Floor notes, it even included an adorable little “4 Mega Shock” message, though it was removed in the final and you’ll need a Game Genie code to make it show again.
No, what this is about is a ROM hack of the game by TCRF contributor nensondubois, World Heroes 2 Jet True SGB Turbo Mode, which purports to overclock the Super Game Boy. Now, this sort of “turbo mode” is something you might have already heard of; but it was new to me. Let’s dig in.
Take command… or not
Another device that purports to be able to change the speed of the Super Game Boy is third-party controller manufacturer Hori’s Super Game Boy Commander. Hori is known to be a contributor to the Super Game Boy’s development, so it makes sense that they would understand it well. Unfortunately, my SGB Commander looks like this:
A previous owner of this controller flexed it so aggressively the surface-mount microcontroller tore off all the pads on one side; this is also the side where the buttons press down, so it’s quite a challenge to fix, beyond my repair skills, though I did attempt. For now, it stays in a bag. This is the risk you take by buying “untested” things. We all know they’re broken– you just never know how broken.
Clock speeds
I’m using a US-market Super Game Boy. This is well-known to run fast as-is. Listen to this segment from The Castlevania Adventure on the Super Game Boy:
Now, here it is on the Game Boy Player for the Nintendo GameCube, which doesn’t have the speed issue. (This is using the popular Game Boy Interface homebrew, in case you’re curious)
This might not sound that significant, but this speed difference also causes the link cable to not work. But what causes the speed difference? Did Nintendo just think that early Game Boy games like The Castlevania Adventure were too sluggish? Well, maybe, but probably not. There’s a technical reason.
Here’s pin 1 on the Super Game Boy’s circuitboard. SNES connoisseurs will note that this side segment is usually not populated on most games; they contain signals that usually aren’t needed. This signal here is MASTER_CLOCK
, the 21.477MHz main clock of the Super Nintendo, generated by a crystal oscillator.
Why 21.477MHz? Why, because that’s the color carrier frequency in composite video! Specifically, it’s six times the color burst frequency, which makes it fairly convenient. Every other frequency in the Super Nintendo is derived from this. Remember those three clock speeds?
Frequency | Ratio | Use |
---|---|---|
21.48MHz | 1 | Main crystal, pin 1 |
3.58MHz | 1/6 | S-CPU Fast ROM, hardware registers, color burst |
2.68MHz | 1/8 | S-CPU Slow ROM, RAM |
1.79MHz | 1/12 | Accessing controllers |
1.79MHz is also the clock speed of the NES CPU. Oh, and all of these, including the console speeds, the color burst frequency, are from the NTSC standard and refer to the Super Nintendo used in North America and Japan. The rest of the world is on its own.
Deriving all your other frequencies from a master clock has a few big benefits. The biggest is you only need one oscillator. The other is that all your pieces will run in a predictable synchronized way; every crystal has some variation, so once you have multiple clocks on one board, you start running into issues with determinism.
You might notice that these are all multiples of even numbers. This makes sense when you think about clock divisions; it’s easy to divide a clock by two and get a nice even clock. Dividing by three, though, can result in an asymmetric clock pulse. Generally, you want each “up” and “down” phase to be the same width, so fractions like 1/2, 1/4, and 1/6 are preferred over 1/3.
The downside, though, is that you can’t really divide things by weird fractions. I mean, you can, but it’s weird and complicated and probably not great. And this is a problem, as the Nintendo Game Boy’s “I can’t believe it’s not a Z80!” CPU runs at a clock speed of 4.19MHz.
And so the Super Game Boy has to fudge the numbers a bit.
Specifically, it’s the ICD2 that fudges the numbers. The default clock divider of the Super Game Boy is divided by 5, giving 4.296MHz. You might notice that this isn’t a nice even number to divide by; I’m not sure if the clock divider is able to equalize this or if that doesn’t matter to the Game Boy.
What’s more worthwhile is that the clock divider can actually be controlled by the lowest two bits of a register on the S-CPU side, 0x6003
. I’ve gotten some values from the byuu/ares emulator, which I consider the gold standard for SNES documentation.
Divider | CPU Clock | Change from DMG | |
---|---|---|---|
00 |
1 / 4 | 5.12MHz | +22% |
01 |
1 / 5 | 4.30MHz | +2.5% |
10 |
1 / 7 | 3.07MHz | -27% |
11 |
1 / 9 | 2.39MHz | -43% |
Back to fast mode
So let’s take a look at nensondubois’ hack.
You might not have the experience with World Heroes 2 Jet to recognize it’s running faster, so here’s the audio from Castlevania again.
And look at the World Heroes 2 Jet footage again. Sure, it’s running faster. But why is it so glitchy? And that applies pretty much everywhere. Because I don’t have a working SGB Commander (see above), I took this screenshot using an Everdrive. Since The Castlevania Adventure has no Super Game Boy functionality, it kept the existing border.
By default, the Game Boy CPU runs at, as we saw, runs at 4.19MHz. Its frame rate is 59.73Hz. The Super Nintendo’s frame rate is 60.09Hz; it runs a little fast, much like its predecessor. Realistically, these are close enough; the ICD2 is designed to bridge the gap. But running faster, the ICD2, and the Super Game Boy firmware running on the slow S-CPU for that matter, can’t keep up. Hence, we start getting failed frames, where wrong bits are read out, areas meant for different parts of the screen.
The opposite issue doesn’t seem to be a big deal with slower modes.
How does it work?
So, what if you wanted to do something with this yourself? It seems that Nintendo didn’t quite want people using this mode. For one thing, it’s only accessible from the Super Nintendo side of the system; it’s not exposed by the Super Game Boy BIOS to the Game Boy side. That isn’t a huge deal; a Super Game Boy-aware Game Boy game can upload code to the Super Nintendo the same way it can upload graphics data to use as a border. But it is an extra step compared to the registers.
We actually have the documentation Nintendo gave to its developers back in the 1990’s. It documents the 0x6003
register as follows:
Notice that the last two bits, which control the clock divider, are fixed to 01
; since the speed-changing features are undocumented, my expectation is that Nintendo would probably fail any Game Boy game in lot check that tried to use them if they found out. (As noted, Hori contributed to development of the SGB) And of course, the glitchiness makes the fastest speed not particularly usable.
Still, this is a cool feature to mess around with nowadays, and I didn’t even know it existed until now. I hope I can get my SGB Commander working; though come on, we all know I’ll just buy a working one.