From ad9a766a56aa6bc4aacad97f4e65462fb182ec54 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sat, 1 May 2021 23:48:23 +0200 Subject: [PATCH] Allow dollar-prefixed hex for RGBFIX -m Fixes #872 --- src/fix/main.c | 10 ++++++++-- test/fix/dollar-hex.bin | Bin 0 -> 512 bytes test/fix/dollar-hex.err | 1 + test/fix/dollar-hex.flags | 1 + test/fix/dollar-hex.gb | Bin 0 -> 512 bytes 5 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test/fix/dollar-hex.bin create mode 100644 test/fix/dollar-hex.err create mode 100644 test/fix/dollar-hex.flags create mode 100644 test/fix/dollar-hex.gb 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 0000000000000000000000000000000000000000..8c56fd22eb0d17dfa06460414d8e355f31b869e3 GIT binary patch literal 512 zcmV+b0{{JXABPMhao6a8-o+E=uoc!Z24b5{ne^xvJyjqpujIs-2F+9^3|q(nCH`K? zB`RO;!_RF8POL>eh|c*j%4>S>#gc149v)_@y5VLDGvaePXf2|A=w4p1Z9@sAXqkem zuW>Zs4b*GYTHHtu%$X_pCQ~_wo2one+37uYx|18QH*-Nf#MhR`&^_iE?_Op0c5b{B zfBfftLSPT-wFOh>e8=4IKD&hS)DuA1g2%NeO^%{*fEb3y=1{ZBhWE5oyR z#-f>?*6Qt0_i(EgZevz#ezAs#t4+M|9gXbG1nTAI^M``H^Lo zi~aWZFManvz&%lYal{+cm$`CqwccgfhYim5-h6khmxLGRH|qENj(5P?tI6R}hh(D9 zFtT2%^K%0mj2~+6$E942p_hUSS5qTXcRX^y)nQ^>QxdP^0b4fFNuYni+iG@FqA|1E zWa{D(v-3f?mx}-eh|c*j%4>S>#gc149v)_@y5VLDGvaePXf2|A=w4p1Z9@sAXqkem zuW>Zs4b*GYTHHtu%$X_pCQ~_wo2one+37uYx|18QH*-Nf#MhR`&^_iE?_Op0c5b{B zfBfftLSPT-wFOh>e8=4IKD&hS)DuA1g2%NeO^%{*fEb3y=1{ZBhWE5oyR z#-f>?*6Qt0_i(EgZevz#ezAs#t4+M|9gXbG1nTAI^M``H^Lo zi~aWZFManvz&%lYal{+cm$`CqwccgfhYim5-h6khmxLGRH|qENj(5P?tI6R}hh(D9 zFtT2%^K%0mj2~+6$E942p_hUSS5qTXcRX^y)nQ^>QxdP^0b4fFNuYni+iG@FqA|1E zWa{D(v-3f?mx}-