From b4dbb5093af8dafc9f67ea41130c9ed5d900793c Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Tue, 31 Oct 2023 23:37:55 -0400 Subject: [PATCH] Warn when SGB compatibility is set without old licensee 0x33 --- src/fix/main.c | 4 ++++ test/fix/sgb-old-licensee.bin | Bin 0 -> 512 bytes test/fix/sgb-old-licensee.err | 2 ++ test/fix/sgb-old-licensee.flags | 1 + test/fix/sgb.bin | Bin 512 -> 512 bytes test/fix/sgb.gb | Bin 512 -> 512 bytes 6 files changed, 7 insertions(+) create mode 100644 test/fix/sgb-old-licensee.bin create mode 100644 test/fix/sgb-old-licensee.err create mode 100644 test/fix/sgb-old-licensee.flags diff --git a/src/fix/main.c b/src/fix/main.c index 1a872c96..dc5a3f3c 100644 --- a/src/fix/main.c +++ b/src/fix/main.c @@ -967,6 +967,10 @@ static void processFile(int input, int output, char const *name, off_t fileSize) if (oldLicensee != UNSPECIFIED) overwriteByte(rom0, 0x14B, oldLicensee, "old licensee code"); + else if (sgb && rom0[0x14B] != 0x33) + fprintf(stderr, + "warning: SGB compatibility enabled, but old licensee was %#x, not 0x33\n", + rom0[0x14B]); if (romVersion != UNSPECIFIED) overwriteByte(rom0, 0x14C, romVersion, "mask ROM version number"); diff --git a/test/fix/sgb-old-licensee.bin b/test/fix/sgb-old-licensee.bin new file mode 100644 index 0000000000000000000000000000000000000000..929bea12c6139792b5b133eefcc2e588e39eeca4 GIT binary patch literal 512 zcmV+b0{{KoOvh(fJ}F@{ODPVIdfqF{7hmYnX4XYI%PNmr5P& z$C;WJk`Pj{sG4SG=1q>!u$Q)1I9b^8gnZEuQdUCj{O>44sk0cU%5x*Ef>6xYaR!h2 zs>kYY&vJ-8_42mINFLf&`fK?+??kPjiTjrGxK~P$DfyVGaP3-;W@uuG|NeEDzXn_Y z{8aLW!&V z2$LT-G{Ejgj7)`Z!C$r{;+mnG^zok51wD6m`V2;d-FXok6~>QTo)kHkHpOQg5@ z47u(W*#Y&KI(_AF(ivJa)Yxq@VML=3@u;>O_p3}ETVPNaC_rD`am!S+9@V*ItWizd C#0F>p literal 0 HcmV?d00001 diff --git a/test/fix/sgb-old-licensee.err b/test/fix/sgb-old-licensee.err new file mode 100644 index 00000000..2edaa257 --- /dev/null +++ b/test/fix/sgb-old-licensee.err @@ -0,0 +1,2 @@ +warning: Overwrote a non-zero byte in the SGB flag +warning: SGB compatibility enabled, but old licensee was 0xc5, not 0x33 diff --git a/test/fix/sgb-old-licensee.flags b/test/fix/sgb-old-licensee.flags new file mode 100644 index 00000000..5d9af957 --- /dev/null +++ b/test/fix/sgb-old-licensee.flags @@ -0,0 +1 @@ +-s diff --git a/test/fix/sgb.bin b/test/fix/sgb.bin index 3ab8ec34173c74396cfcc4c5fb1e0f166dbec248..28a680328075752d7c2f22bc33fe89afbd6c285c 100644 GIT binary patch delta 13 UcmZo*X<*sl&B$mx*@tlp02$u{%>V!Z delta 13 UcmZo*X<*sl&B%CSvJc}H0365!VgLXD diff --git a/test/fix/sgb.gb b/test/fix/sgb.gb index 4cf70bb6adfe0397441ef0a528567428537a898a..7816b245b9d22df569cc34f0cbec189def0b4949 100644 GIT binary patch delta 13 UcmZo*X<*sl&B$mx*@tlp02$u{%>V!Z delta 13 UcmZo*X<*sl&B%CSvJc}H0365!VgLXD