diff --git a/src/fix/main.c b/src/fix/main.c index af8c33f0..c3db145f 100644 --- a/src/fix/main.c +++ b/src/fix/main.c @@ -151,10 +151,16 @@ static bool readMBCSlice(char const **name, char const *expected) static enum MbcType parseMBC(char const *name) { - if (name[0] >= '0' && name[0] <= '9') { + if ((name[0] >= '0' && name[0] <= '9') || name[0] == '$') { + int base = 0; + + if (name[0] == '$') { + name++; + base = 16; + } // Parse number, and return it as-is (unless it's too large) char *endptr; - unsigned long mbc = strtoul(name, &endptr, 0); + unsigned long mbc = strtoul(name, &endptr, base); if (*endptr) return MBC_BAD; diff --git a/test/fix/dollar-hex.bin b/test/fix/dollar-hex.bin new file mode 100644 index 00000000..8c56fd22 Binary files /dev/null and b/test/fix/dollar-hex.bin differ diff --git a/test/fix/dollar-hex.err b/test/fix/dollar-hex.err new file mode 100644 index 00000000..84c93183 --- /dev/null +++ b/test/fix/dollar-hex.err @@ -0,0 +1 @@ +warning: Overwrote a non-zero byte in the cartridge type diff --git a/test/fix/dollar-hex.flags b/test/fix/dollar-hex.flags new file mode 100644 index 00000000..40f14473 --- /dev/null +++ b/test/fix/dollar-hex.flags @@ -0,0 +1 @@ +-m '$2a' diff --git a/test/fix/dollar-hex.gb b/test/fix/dollar-hex.gb new file mode 100644 index 00000000..197cdce8 Binary files /dev/null and b/test/fix/dollar-hex.gb differ