Allow dollar-prefixed hex for RGBFIX -m

Fixes #872
This commit is contained in:
ISSOtm
2021-05-01 23:48:23 +02:00
parent 21b59c4651
commit ad9a766a56
5 changed files with 10 additions and 2 deletions

View File

@@ -151,10 +151,16 @@ static bool readMBCSlice(char const **name, char const *expected)
static enum MbcType parseMBC(char const *name) 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) // Parse number, and return it as-is (unless it's too large)
char *endptr; char *endptr;
unsigned long mbc = strtoul(name, &endptr, 0); unsigned long mbc = strtoul(name, &endptr, base);
if (*endptr) if (*endptr)
return MBC_BAD; return MBC_BAD;

BIN
test/fix/dollar-hex.bin Normal file

Binary file not shown.

1
test/fix/dollar-hex.err Normal file
View File

@@ -0,0 +1 @@
warning: Overwrote a non-zero byte in the cartridge type

View File

@@ -0,0 +1 @@
-m '$2a'

BIN
test/fix/dollar-hex.gb Normal file

Binary file not shown.