27

Inside of the GBCs Cartridge header there is the metadata for the game and the Nintendo logo.

The program that runs on boot (the BIOS or Boot ROM) checks the checksum of the Nintendo logo, and always has, but in the GBC Boot ROM, I noticed an interesting update. Now, the Boot ROM checks the title checksum?? How does this choice make any sense? If there were any new GBC games they'd have to title the game 'TETRIS' or 'SUPER MARIOLAND'. This would not work, so developers wouldn't be able to make games. So the question is, why did they do this on the GBC? It is not a practical nor sensible choice.

2 Answers 2

41

What is the purpose the checksum feature?

To provide limited colorization to a selection of legacy, Nintendo-published games, as well as show the Nintendo logo for two specific games, explained later. This feature allows individual games to get a light touchup, by assigning a single palette to the background layer, and two palettes mapped onto the two sprite palettes available for black and white Game Boy games. A notable example of this is that Pokémon Blue and Red, which are not GBC enhanced titles, will receive a blue and red tint by default, respectively. However, this pre-specified palette can be modified by the user by pressing a direction on the D pads during startup, just like with any other legacy game.

Pokémon Blue title screen colorized Pokémon Red title screen colorized

This feature is only applied to legacy games, as GBC enhanced games are able to set the color palettes freely, and have hardware access to many more palettes, up to 8 for the background layer, and 8 for sprites. Because no further legacy games were to be released at this point, the full back catalog was known and no further accommodations needed to be made for legacy games after the release of the GBC.

For this feature to be enabled by the boot ROM, a number of conditions need to be true:

  • The Game Boy Color enabled flag must not be set in the ROM header, ie address 0x0143 must have bit 7 set to 0.
  • The licensee id, in either the old or new licensee field of the ROM header must be set to 0x01, indicating a first party game published by Nintendo.
  • The checksum of the ROM title must exactly match one of the entries in the table.

The Cutting Room Floor has a list of all used palette configurations and their respective games.

A Nintendo logo is shown for two games

A lesser known effect is that two games are specified to have the Nintendo logo shown on screen on startup. Earlier versions of the boot ROM left a Nintendo on screen, whereas the GBC boot ROM clears the screen by default. However, two games (Chessmaster and X) rely on that initially shown logo being there for their own intro animation. If you left it out, the screen would look empty (see the examples below) so Nintendo made the GBC boot ROM display the logo for those particular games. They could have shown the logo for all games, but that would make the logo quickly show and disappear in a flash before the game boots for many games, which would have been ugly.

Chessmaster booting X booting

Why check only for a checksum and not the full title?

To save space in the boot ROM. Putting a boot ROM on the silicon die of the CPU chip is expensive, so there's an incentive to make it as small as possible to make the physical size of the die as small as possible. Storing only the checksum takes one byte per game, whereas storing the full title would take 16 bytes per game. This means that there will be hash collisions, however...

  • The full catalog was known and no future non-Color games would be released at this point, so future hash collisions were not an issue.
  • Only Nintendo-published games are included, making the collision risk much lower.
  • Some hash collisions do exist and are checked specifically by the boot ROM. In this case, the 4th byte of the title is used as a decider.
6
  • 1
    Considering there are only 93 titles in the list (per your link to Cutting Room Floor), it's surprising Nintendo didn't spend a little longer to find a hash without collisions.
    – grahamj42
    Oct 27, 2022 at 11:12
  • 5
    @grahamj42 They're doing the simplest thing possible: adding up the bytes values of the title. Anything more complex would make the code larger. Besides, with only an 8-bit hash value (256 possible values) you're almost guaranteed to get collisions as per the birthday paradox. Going up to a two byte value (65536 possible values) would reduce the collision risk, but would double the size of the hash list.
    – nitro2k01
    Oct 27, 2022 at 12:04
  • 2
    Finding a "perfect hash function" for a set of strings is hard, but might not be impossible with 1/3rd of the 8-bit coding space filled. gperf is a tool for finding such hash functions, the GNU Perfect Hash generator. (e.g. for compiler keywords). Maybe a trivial hash function like summing the characters, and then a fallback check, is less total code+data size than a complex 8-bit hash, or a fairly simple 16-bit hash. How much data space does the 4th-char check take? Does that not take a 2nd byte in every entry? @grahamj Oct 27, 2022 at 12:33
  • 1
    @PeterCordes It iterates through the list of hash values and triggers a second check if the index is higher than a certain value. So, you can place the value before or after this point at compile time. The code for the extra check is in the order of 30 bytes, and the data another 30 bytes.
    – nitro2k01
    Oct 27, 2022 at 12:42
  • Ok, so a bit less code+data than an extra byte in all 93 entries, plus whatever code size increase it would cost to make a 16-bit hash in the first place instead of just 8-bit adding the bytes. Thanks for confirming that only some of the entries have extra data for this. Oct 27, 2022 at 12:45
50

The GameBoy Color has predefined colour palettes for a number of black-and-white GameBoy games. The title checksum is used to see if the current game is one of those, and if so, select the right palette. If the title checksum doesn't match, the system will proceed with a default palette (if it's a black-and-white game). Unlike the logo checksum, it will not lock out games with a non-matching checksum.

6
  • 2
    Is this answer saying that the checksum is only applicable to original GameBoy games, and thus the question's assumption about new GBC games is wrong?
    – Bobson
    Oct 26, 2022 at 17:18
  • 22
    It sounds like a lookup table - the newer GameBoy Color, when playing older games, would compute the checksum of the title, and then use this result to select the proper palette so the game would look right (at least, that's what I get from this answer). So, it's not a security thing, but a backwards-compatibility thing. (I know almost nothing about GB ...)
    – Steve
    Oct 26, 2022 at 17:27
  • Why wouldn't they store the palette in the game's code though? What if they wanted to change the colors? Again, the whole idea of the GameBoy checking the title just to confirm it's made by Nintendo sounds a bit nutty to me. Oct 30, 2022 at 6:03
  • 2
    @MissingUser This feature is meant to improve a selection of games that were released before the Game Boy Color. Because they were released before the GBC and are black and white games, they don't contain any color information. Game Boy Color games do not use this feature, and instead set the colors freely on their own.
    – nitro2k01
    Oct 30, 2022 at 12:43
  • 1
    @MichaelGraf OP is conflating two things. The GBC boot ROM checks if licensee field is Nintendo to decide if the (black and white) game is eligible for enhanced colorization, then it checks the title to see if it's listed for colorization. Likely done for both practical reasons (smaller search space) and legal/product reasons (no need to colorize games from other publishers). This is not done to prevent the game from running, only to decide if it can get colorized automatically. The exact details are explained in my answer to this question.
    – nitro2k01
    Oct 30, 2022 at 15:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .