Handheld Underground

New Game Boy ROM format proposal(??!)

posted by taizou @ 2018-02-19 02:44:54 Other Stuff

SO A LITTLE BACKGROUND HERE.

Currently, the common format for Game Boy and Game Boy Color ROMs (usually given the .gb/.gbc file extension) is just a raw binary dump of the ROM data from the cartridge. Unlike the NES, where some extra data must be tacked on to tell an emulator crucial details such as which of the hundreds of different mappers is used by the game, Nintendo's requirements for Game Boy developers specified an internal ROM header that must be populated with this information. So that's fine right? Emulators can just read the internal header! Nintendo, unintentionally, solved the problem and made emulation easier for everyone! Right??

NOT SO FAST BUBSY HERE COME UNLICENSED GAMES TO FUCK EVERYTHING UP

For, you see, the header being populated correctly is a Nintendo requirement, not a hardware one. A real Game Boy requires a few things to be correct - the header checksum, the Nintendo logo, GBC/SGB flags to enable enhancements for those systems - but doesn't care about things like cartridge type and ROM size. So if you're an unlicensed dev, you can put any old shit in there. You might even intentionally set incorrect values to fool copiers and emulators. And if your game uses some kind of custom unlicensed mapper or copy protection, it's probably not even possible to represent it within the specs of Nintendo's header format!

Until now, most Game Boy emulators have relied on heuristic auto-detection for these games, checking for certain signifiers present in the ROM that can somewhat-reliably identify a given type of non-standard cartridge. hhugboy also allows you to select a cartridge type manually, to run games that are not correctly auto-detected. So far, this has sort of been okay - hhugboy's auto-detection works correctly for the most part, with only a handful of dumps needing manual selection.

But the new unlicensed dumps just keep coming, and the heuristic approach is getting increasingly unwieldy. I've recently dumped a bunch of games from a Certain Developer, and while it's possible to reliably identify their games, I haven't found a way to distinguish between the ones that run on their publisher's custom mapper and the ones that don't, meaning at least one set of those would end up only working via manual selection. There are a bunch of other carts I haven't yet tackled that I foresee causing similar problems.

So what I've been thinking is: why not create a new Game Boy ROM format, allowing all this information to be specified outside of the internal header? Admittedly the use cases for such a format at this point are fairly niche, so it would have to be low-overhead, backwards-compatible if possible and unintrusive. But hopefully it would be a step towards making emulation of unlicensed Game Boy games (and a handful of licensed ones too!) a much nicer thing to deal with and much less of a mess of heuristics and hacked dumps.

Here's my proposal for the format, which I'm tentatively calling GBX. Any and all feedback would be greatly appreciated, just leave a comment below! Even if you just want to call me a big dumbass or something!

(UPDATED 21/02/2018 current version 0.3)

When it's finalised, the next version of hhugboy will support it, and I'll probably make some kind of tool to allow for conversion to and from the new format, hashing, editing and other such stuff.

9 Comments

Comments

1posted by Jon @ 2018-02-21 03:24:08

Sounds awesome can't wait for updates!

2posted by Jake @ 2018-09-11 04:21:04

Thank you for what you're doing here. It's amazing.

3posted by Rex Dart, Eskimo Spy @ 2019-09-11 00:59:55

Can't believe you did not use the "What could possibly go wrong?" quote

4posted by guyzis @ 2020-05-11 00:47:33

Yay for hhugboy's 2 year anniversary! ...maybe

5posted by SuperfishMEMZ @ 2020-08-12 09:20:49

so why don`t you program a tool for GBX in 2020 like what you said in the end of the post? Also currently there are only hhugboy supporting the GBX format so you should widely advertise this format

6posted by taizou @ 2020-08-13 02:27:02

honestly i haven't programmed a GBX tool because no one has shown any interest in having one in the past two years

there are a lot of things i haven't done and a lot of reasons i haven't done them and GBX is just really low down my priority list

7posted by cuavas @ 2022-11-11 14:57:21

FWIW both MAME and mGBA can load at least some GBX files now, so "only hhugboy supporting the GBX format" is no longer true.

8posted by cuavas @ 2022-11-11 18:18:09

BTW there’s an error in the current GBX format description page – in the “Valid example (hex)” it says “64k footer, minor v1, major v0, signature” when it should say “64-byte footer…”.

9posted by taizou @ 2023-05-28 22:40:47

@cuavas oh good catch, I've fixed that now