ref: ad9a766a56aa6bc4aacad97f4e65462fb182ec54
parent: 21b59c46519eb80ea48211cae6ab055d487cea57
author: ISSOtm <[email protected]>
date: Sat May 1 19:48:23 EDT 2021
Allow dollar-prefixed hex for RGBFIX -m Fixes #872
--- a/src/fix/main.c
+++ b/src/fix/main.c
@@ -151,10 +151,16 @@
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;
binary files /dev/null b/test/fix/dollar-hex.bin differ
--- /dev/null
+++ b/test/fix/dollar-hex.err
@@ -1,0 +1,1 @@
+warning: Overwrote a non-zero byte in the cartridge type
--- /dev/null
+++ b/test/fix/dollar-hex.flags
@@ -1,0 +1,1 @@
+-m '$2a'
binary files /dev/null b/test/fix/dollar-hex.gb differ