diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16ea61aa..708c44db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -117,13 +117,14 @@ The object file will be linked with and without said flag, respectively; and in ### RGBFIX -Each `.bin` file corresponds to one test, and **must** be accompanied by a `.flags` file and a `.err` file. - -The `.flags` file is a text file whose first line contains flags to pass to RGBFIX. +Each `.flags` file corresponds to one test. +Each one is a text file whose first line contains flags to pass to RGBFIX. (There may be more lines, which will be ignored; they can serve as comments to explain what the test is about.) -RGBFIX will be invoked on the `.bin` file, and its error output must match the contents of the `.err` file. -(If no errors ought to be printed, then the `.err` file should just be empty.) +RGBFIX will be invoked on the `.bin` file if it exists, or else on default-input.bin. + +If no `.err` file exists, RGBFIX is simply expected to be able to process the file normally. +If one *does* exist, RGBFIX's return status is ignored, but its output **must** match the `.err` file's contents. Additionally, if a `.gb` file exists, the output of RGBFIX must match the `.gb`. diff --git a/src/fix/main.cpp b/src/fix/main.cpp index 2311f037..eec8b896 100644 --- a/src/fix/main.cpp +++ b/src/fix/main.cpp @@ -155,6 +155,7 @@ enum MbcType { MBC_BAD, // Specified MBC does not exist / syntax error MBC_WRONG_FEATURES, // MBC incompatible with specified features MBC_BAD_RANGE, // MBC number out of range + MBC_BAD_TPP1, // Invalid TPP1 major or minor revision numbers }; static void printAcceptedMBCNames() { @@ -170,7 +171,7 @@ static void printAcceptedMBCNames() { fputs("\tMBC6 ($20)\n", stderr); fputs("\tMBC7+SENSOR+RUMBLE+RAM+BATTERY ($22)\n", stderr); fputs("\tPOCKET_CAMERA ($FC)\n", stderr); - fputs("\tBANDAI_TAMA5 ($FD)\n", stderr); + fputs("\tBANDAI_TAMA5 ($FD) [aka TAMA5]\n", stderr); fputs("\tHUC3 ($FE)\n", stderr); fputs("\tHUC1+RAM+BATTERY ($FF)\n", stderr); @@ -332,12 +333,12 @@ static MbcType parseMBC(char const *name) { if (endptr == ptr) { report("error: Failed to parse TPP1 major revision number\n"); - return MBC_BAD; + return MBC_BAD_TPP1; } ptr = endptr; if (val != 1) { - report("error: RGBFIX only supports TPP1 versions 1.0\n"); - return MBC_BAD; + report("error: RGBFIX only supports TPP1 version 1.0\n"); + return MBC_BAD_TPP1; } tpp1Rev[0] = val; tryReadSlice("."); @@ -345,12 +346,12 @@ static MbcType parseMBC(char const *name) { val = strtoul(ptr, &endptr, 10); if (endptr == ptr) { report("error: Failed to parse TPP1 minor revision number\n"); - return MBC_BAD; + return MBC_BAD_TPP1; } ptr = endptr; if (val > 0xFF) { report("error: TPP1 minor revision number must be 8-bit\n"); - return MBC_BAD; + return MBC_BAD_TPP1; } tpp1Rev[1] = val; mbc = TPP1; @@ -663,6 +664,7 @@ static char const *mbcName(MbcType type) { case MBC_BAD: case MBC_WRONG_FEATURES: case MBC_BAD_RANGE: + case MBC_BAD_TPP1: unreachable_(); } @@ -686,6 +688,7 @@ static bool hasRAM(MbcType type) { case MBC_BAD: case MBC_WRONG_FEATURES: case MBC_BAD_RANGE: + case MBC_BAD_TPP1: return false; case ROM_RAM: @@ -1324,8 +1327,8 @@ int main(int argc, char *argv[]) { } else if (cartridgeType == ROM_RAM || cartridgeType == ROM_RAM_BATTERY) { fprintf( stderr, - "warning: ROM+RAM / ROM+RAM+BATTERY are under-specified and poorly " - "supported\n" + "warning: MBC \"%s\" is under-specified and poorly supported\n", + musl_optarg ); } break; diff --git a/test/fix/custom-logo.flags b/test/fix/custom-logo.flags index 0fbbe4c4..083d4eef 100644 --- a/test/fix/custom-logo.flags +++ b/test/fix/custom-logo.flags @@ -1 +1 @@ --f l -L custom-logo.1bpp +-f l -L ./custom-logo.1bpp diff --git a/test/fix/default-input.bin b/test/fix/default-input.bin new file mode 100644 index 00000000..e24f07dd Binary files /dev/null and b/test/fix/default-input.bin differ diff --git a/test/fix/incompatible-features.err b/test/fix/incompatible-features.err new file mode 100644 index 00000000..1b6848c7 --- /dev/null +++ b/test/fix/incompatible-features.err @@ -0,0 +1,23 @@ +error: Features incompatible with MBC ("mbc1+multirumble") +Accepted combinations: + ROM ($00) [aka ROM_ONLY] + MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03) + MBC2 ($05), MBC2+BATTERY ($06) + ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated] + MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D) + MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10) + MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13) + MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B) + MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E) + MBC6 ($20) + MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22) + POCKET_CAMERA ($FC) + BANDAI_TAMA5 ($FD) [aka TAMA5] + HUC3 ($FE) + HUC1+RAM+BATTERY ($FF) + + TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER, + TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY, + TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE, + TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE, + TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE diff --git a/test/fix/incompatible-features.flags b/test/fix/incompatible-features.flags new file mode 100644 index 00000000..c6c21d5e --- /dev/null +++ b/test/fix/incompatible-features.flags @@ -0,0 +1 @@ +-m mbc1+multirumble diff --git a/test/fix/list-mbcs.err b/test/fix/list-mbcs.err new file mode 100644 index 00000000..e9b6fb48 --- /dev/null +++ b/test/fix/list-mbcs.err @@ -0,0 +1,22 @@ +Accepted MBC names: + ROM ($00) [aka ROM_ONLY] + MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03) + MBC2 ($05), MBC2+BATTERY ($06) + ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated] + MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D) + MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10) + MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13) + MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B) + MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E) + MBC6 ($20) + MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22) + POCKET_CAMERA ($FC) + BANDAI_TAMA5 ($FD) [aka TAMA5] + HUC3 ($FE) + HUC1+RAM+BATTERY ($FF) + + TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER, + TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY, + TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE, + TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE, + TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE diff --git a/test/fix/list-mbcs.flags b/test/fix/list-mbcs.flags new file mode 100644 index 00000000..f2e86513 --- /dev/null +++ b/test/fix/list-mbcs.flags @@ -0,0 +1 @@ +-m Help diff --git a/test/fix/mbc-bandai-tama5.flags b/test/fix/mbc-bandai-tama5.flags new file mode 100644 index 00000000..2f379718 --- /dev/null +++ b/test/fix/mbc-bandai-tama5.flags @@ -0,0 +1 @@ +-m BANDAI_TAMA5 diff --git a/test/fix/mbc-bandai-tama5.gb b/test/fix/mbc-bandai-tama5.gb new file mode 100644 index 00000000..f39b3fb6 Binary files /dev/null and b/test/fix/mbc-bandai-tama5.gb differ diff --git a/test/fix/mbc-huc1-ram-battery.flags b/test/fix/mbc-huc1-ram-battery.flags new file mode 100644 index 00000000..27c1e077 --- /dev/null +++ b/test/fix/mbc-huc1-ram-battery.flags @@ -0,0 +1 @@ +-m HUC1+RAM+BATTERY diff --git a/test/fix/mbc-huc1-ram-battery.gb b/test/fix/mbc-huc1-ram-battery.gb new file mode 100644 index 00000000..2576c610 Binary files /dev/null and b/test/fix/mbc-huc1-ram-battery.gb differ diff --git a/test/fix/mbc-huc3.flags b/test/fix/mbc-huc3.flags new file mode 100644 index 00000000..407c5827 --- /dev/null +++ b/test/fix/mbc-huc3.flags @@ -0,0 +1 @@ +-m HUC3 diff --git a/test/fix/mbc-huc3.gb b/test/fix/mbc-huc3.gb new file mode 100644 index 00000000..2ad35ca3 Binary files /dev/null and b/test/fix/mbc-huc3.gb differ diff --git a/test/fix/mbc-mbc1-ram-battery.flags b/test/fix/mbc-mbc1-ram-battery.flags new file mode 100644 index 00000000..aff61e68 --- /dev/null +++ b/test/fix/mbc-mbc1-ram-battery.flags @@ -0,0 +1 @@ +-m MBC1+RAM+BATTERY diff --git a/test/fix/mbc-mbc1-ram-battery.gb b/test/fix/mbc-mbc1-ram-battery.gb new file mode 100644 index 00000000..acca4ccb Binary files /dev/null and b/test/fix/mbc-mbc1-ram-battery.gb differ diff --git a/test/fix/mbc-mbc1-ram.flags b/test/fix/mbc-mbc1-ram.flags new file mode 100644 index 00000000..05ca8a55 --- /dev/null +++ b/test/fix/mbc-mbc1-ram.flags @@ -0,0 +1 @@ +-m MBC1+RAM diff --git a/test/fix/mbc-mbc1-ram.gb b/test/fix/mbc-mbc1-ram.gb new file mode 100644 index 00000000..4dbda2ed Binary files /dev/null and b/test/fix/mbc-mbc1-ram.gb differ diff --git a/test/fix/mbc-mbc1.flags b/test/fix/mbc-mbc1.flags new file mode 100644 index 00000000..8a2f84d5 --- /dev/null +++ b/test/fix/mbc-mbc1.flags @@ -0,0 +1 @@ +-m MBC1 diff --git a/test/fix/mbc-mbc1.gb b/test/fix/mbc-mbc1.gb new file mode 100644 index 00000000..128d4c6a Binary files /dev/null and b/test/fix/mbc-mbc1.gb differ diff --git a/test/fix/mbc-mbc2-battery.flags b/test/fix/mbc-mbc2-battery.flags new file mode 100644 index 00000000..36f88c87 --- /dev/null +++ b/test/fix/mbc-mbc2-battery.flags @@ -0,0 +1 @@ +-m MBC2+BATTERY diff --git a/test/fix/mbc-mbc2-battery.gb b/test/fix/mbc-mbc2-battery.gb new file mode 100644 index 00000000..e120b2e0 Binary files /dev/null and b/test/fix/mbc-mbc2-battery.gb differ diff --git a/test/fix/mbc-mbc2.flags b/test/fix/mbc-mbc2.flags new file mode 100644 index 00000000..87c17c02 --- /dev/null +++ b/test/fix/mbc-mbc2.flags @@ -0,0 +1 @@ +-m MBC2 diff --git a/test/fix/mbc-mbc2.gb b/test/fix/mbc-mbc2.gb new file mode 100644 index 00000000..75cce846 Binary files /dev/null and b/test/fix/mbc-mbc2.gb differ diff --git a/test/fix/mbc-mbc3-ram-battery.flags b/test/fix/mbc-mbc3-ram-battery.flags new file mode 100644 index 00000000..1699f3c2 --- /dev/null +++ b/test/fix/mbc-mbc3-ram-battery.flags @@ -0,0 +1 @@ +-m MBC3+RAM+BATTERY diff --git a/test/fix/mbc-mbc3-ram-battery.gb b/test/fix/mbc-mbc3-ram-battery.gb new file mode 100644 index 00000000..82682631 Binary files /dev/null and b/test/fix/mbc-mbc3-ram-battery.gb differ diff --git a/test/fix/mbc-mbc3-ram.flags b/test/fix/mbc-mbc3-ram.flags new file mode 100644 index 00000000..c583fbea --- /dev/null +++ b/test/fix/mbc-mbc3-ram.flags @@ -0,0 +1 @@ +-m MBC3+RAM diff --git a/test/fix/mbc-mbc3-ram.gb b/test/fix/mbc-mbc3-ram.gb new file mode 100644 index 00000000..45e4b986 Binary files /dev/null and b/test/fix/mbc-mbc3-ram.gb differ diff --git a/test/fix/mbc-mbc3-timer-battery.flags b/test/fix/mbc-mbc3-timer-battery.flags new file mode 100644 index 00000000..4d8603f1 --- /dev/null +++ b/test/fix/mbc-mbc3-timer-battery.flags @@ -0,0 +1 @@ +-m MBC3+TIMER+BATTERY diff --git a/test/fix/mbc-mbc3-timer-battery.gb b/test/fix/mbc-mbc3-timer-battery.gb new file mode 100644 index 00000000..a98fe14a Binary files /dev/null and b/test/fix/mbc-mbc3-timer-battery.gb differ diff --git a/test/fix/mbc-mbc3-timer-ram-battery.flags b/test/fix/mbc-mbc3-timer-ram-battery.flags new file mode 100644 index 00000000..a7a89a35 --- /dev/null +++ b/test/fix/mbc-mbc3-timer-ram-battery.flags @@ -0,0 +1 @@ +-m MBC3+TIMER+RAM+BATTERY diff --git a/test/fix/mbc-mbc3-timer-ram-battery.gb b/test/fix/mbc-mbc3-timer-ram-battery.gb new file mode 100644 index 00000000..b5b9696c Binary files /dev/null and b/test/fix/mbc-mbc3-timer-ram-battery.gb differ diff --git a/test/fix/mbc-mbc3.flags b/test/fix/mbc-mbc3.flags new file mode 100644 index 00000000..ddcb0a66 --- /dev/null +++ b/test/fix/mbc-mbc3.flags @@ -0,0 +1 @@ +-m MBC3 diff --git a/test/fix/mbc-mbc3.gb b/test/fix/mbc-mbc3.gb new file mode 100644 index 00000000..3980e352 Binary files /dev/null and b/test/fix/mbc-mbc3.gb differ diff --git a/test/fix/mbc-mbc5-ram-battery.flags b/test/fix/mbc-mbc5-ram-battery.flags new file mode 100644 index 00000000..e9f7b2f0 --- /dev/null +++ b/test/fix/mbc-mbc5-ram-battery.flags @@ -0,0 +1 @@ +-m MBC5+RAM+BATTERY diff --git a/test/fix/mbc-mbc5-ram-battery.gb b/test/fix/mbc-mbc5-ram-battery.gb new file mode 100644 index 00000000..e1c1872b Binary files /dev/null and b/test/fix/mbc-mbc5-ram-battery.gb differ diff --git a/test/fix/mbc-mbc5-ram.flags b/test/fix/mbc-mbc5-ram.flags new file mode 100644 index 00000000..f420f10c --- /dev/null +++ b/test/fix/mbc-mbc5-ram.flags @@ -0,0 +1 @@ +-m MBC5+RAM diff --git a/test/fix/mbc-mbc5-ram.gb b/test/fix/mbc-mbc5-ram.gb new file mode 100644 index 00000000..a73cd5e7 Binary files /dev/null and b/test/fix/mbc-mbc5-ram.gb differ diff --git a/test/fix/mbc-mbc5-rumble-ram-battery.flags b/test/fix/mbc-mbc5-rumble-ram-battery.flags new file mode 100644 index 00000000..a49b31c1 --- /dev/null +++ b/test/fix/mbc-mbc5-rumble-ram-battery.flags @@ -0,0 +1 @@ +-m MBC5+RUMBLE+RAM+BATTERY diff --git a/test/fix/mbc-mbc5-rumble-ram-battery.gb b/test/fix/mbc-mbc5-rumble-ram-battery.gb new file mode 100644 index 00000000..a475c18f Binary files /dev/null and b/test/fix/mbc-mbc5-rumble-ram-battery.gb differ diff --git a/test/fix/mbc-mbc5-rumble-ram.flags b/test/fix/mbc-mbc5-rumble-ram.flags new file mode 100644 index 00000000..475bc203 --- /dev/null +++ b/test/fix/mbc-mbc5-rumble-ram.flags @@ -0,0 +1 @@ +-m MBC5+RUMBLE+RAM diff --git a/test/fix/mbc-mbc5-rumble-ram.gb b/test/fix/mbc-mbc5-rumble-ram.gb new file mode 100644 index 00000000..2ac5e315 Binary files /dev/null and b/test/fix/mbc-mbc5-rumble-ram.gb differ diff --git a/test/fix/mbc-mbc5-rumble.flags b/test/fix/mbc-mbc5-rumble.flags new file mode 100644 index 00000000..4d373fad --- /dev/null +++ b/test/fix/mbc-mbc5-rumble.flags @@ -0,0 +1 @@ +-m MBC5+RUMBLE diff --git a/test/fix/mbc-mbc5-rumble.gb b/test/fix/mbc-mbc5-rumble.gb new file mode 100644 index 00000000..87cbc66c Binary files /dev/null and b/test/fix/mbc-mbc5-rumble.gb differ diff --git a/test/fix/mbc-mbc5.flags b/test/fix/mbc-mbc5.flags new file mode 100644 index 00000000..4992099c --- /dev/null +++ b/test/fix/mbc-mbc5.flags @@ -0,0 +1 @@ +-m MBC5 diff --git a/test/fix/mbc-mbc5.gb b/test/fix/mbc-mbc5.gb new file mode 100644 index 00000000..1aeab1b5 Binary files /dev/null and b/test/fix/mbc-mbc5.gb differ diff --git a/test/fix/mbc-mbc6.flags b/test/fix/mbc-mbc6.flags new file mode 100644 index 00000000..6edf0d58 --- /dev/null +++ b/test/fix/mbc-mbc6.flags @@ -0,0 +1 @@ +-m MBC6 diff --git a/test/fix/mbc-mbc6.gb b/test/fix/mbc-mbc6.gb new file mode 100644 index 00000000..d8004adf Binary files /dev/null and b/test/fix/mbc-mbc6.gb differ diff --git a/test/fix/mbc-mbc7-sensor-rumble-ram-battery.flags b/test/fix/mbc-mbc7-sensor-rumble-ram-battery.flags new file mode 100644 index 00000000..01c463bf --- /dev/null +++ b/test/fix/mbc-mbc7-sensor-rumble-ram-battery.flags @@ -0,0 +1 @@ +-m MBC7+SENSOR+RUMBLE+RAM+BATTERY diff --git a/test/fix/mbc-mbc7-sensor-rumble-ram-battery.gb b/test/fix/mbc-mbc7-sensor-rumble-ram-battery.gb new file mode 100644 index 00000000..c8ffd168 Binary files /dev/null and b/test/fix/mbc-mbc7-sensor-rumble-ram-battery.gb differ diff --git a/test/fix/mbc-mmm01-ram-battery.flags b/test/fix/mbc-mmm01-ram-battery.flags new file mode 100644 index 00000000..e8709e4e --- /dev/null +++ b/test/fix/mbc-mmm01-ram-battery.flags @@ -0,0 +1 @@ +-m MMM01+RAM+BATTERY diff --git a/test/fix/mbc-mmm01-ram-battery.gb b/test/fix/mbc-mmm01-ram-battery.gb new file mode 100644 index 00000000..a37d09e4 Binary files /dev/null and b/test/fix/mbc-mmm01-ram-battery.gb differ diff --git a/test/fix/mbc-mmm01-ram.flags b/test/fix/mbc-mmm01-ram.flags new file mode 100644 index 00000000..807fab02 --- /dev/null +++ b/test/fix/mbc-mmm01-ram.flags @@ -0,0 +1 @@ +-m MMM01+RAM diff --git a/test/fix/mbc-mmm01-ram.gb b/test/fix/mbc-mmm01-ram.gb new file mode 100644 index 00000000..f62337dc Binary files /dev/null and b/test/fix/mbc-mmm01-ram.gb differ diff --git a/test/fix/mbc-mmm01.flags b/test/fix/mbc-mmm01.flags new file mode 100644 index 00000000..4402726d --- /dev/null +++ b/test/fix/mbc-mmm01.flags @@ -0,0 +1 @@ +-m MMM01 diff --git a/test/fix/mbc-mmm01.gb b/test/fix/mbc-mmm01.gb new file mode 100644 index 00000000..54c4a26d Binary files /dev/null and b/test/fix/mbc-mmm01.gb differ diff --git a/test/fix/mbc-pocket-camera.flags b/test/fix/mbc-pocket-camera.flags new file mode 100644 index 00000000..8c96ae44 --- /dev/null +++ b/test/fix/mbc-pocket-camera.flags @@ -0,0 +1 @@ +-m POCKET_CAMERA diff --git a/test/fix/mbc-pocket-camera.gb b/test/fix/mbc-pocket-camera.gb new file mode 100644 index 00000000..026af535 Binary files /dev/null and b/test/fix/mbc-pocket-camera.gb differ diff --git a/test/fix/mbc-rom-only.flags b/test/fix/mbc-rom-only.flags new file mode 100644 index 00000000..faabf7ae --- /dev/null +++ b/test/fix/mbc-rom-only.flags @@ -0,0 +1 @@ +-m ROM_ONLY diff --git a/test/fix/mbc-rom-only.gb b/test/fix/mbc-rom-only.gb new file mode 100644 index 00000000..e24f07dd Binary files /dev/null and b/test/fix/mbc-rom-only.gb differ diff --git a/test/fix/mbc-rom-ram-battery.err b/test/fix/mbc-rom-ram-battery.err new file mode 100644 index 00000000..34bb2606 --- /dev/null +++ b/test/fix/mbc-rom-ram-battery.err @@ -0,0 +1 @@ +warning: MBC "ROM+RAM+BATTERY" is under-specified and poorly supported diff --git a/test/fix/mbc-rom-ram-battery.flags b/test/fix/mbc-rom-ram-battery.flags new file mode 100644 index 00000000..807a62c2 --- /dev/null +++ b/test/fix/mbc-rom-ram-battery.flags @@ -0,0 +1 @@ +-m ROM+RAM+BATTERY diff --git a/test/fix/mbc-rom-ram-battery.gb b/test/fix/mbc-rom-ram-battery.gb new file mode 100644 index 00000000..03cd5394 Binary files /dev/null and b/test/fix/mbc-rom-ram-battery.gb differ diff --git a/test/fix/mbc-rom-ram.err b/test/fix/mbc-rom-ram.err new file mode 100644 index 00000000..22bcb1b2 --- /dev/null +++ b/test/fix/mbc-rom-ram.err @@ -0,0 +1 @@ +warning: MBC "ROM+RAM" is under-specified and poorly supported diff --git a/test/fix/mbc-rom-ram.flags b/test/fix/mbc-rom-ram.flags new file mode 100644 index 00000000..e7c01c0e --- /dev/null +++ b/test/fix/mbc-rom-ram.flags @@ -0,0 +1 @@ +-m ROM+RAM diff --git a/test/fix/mbc-rom-ram.gb b/test/fix/mbc-rom-ram.gb new file mode 100644 index 00000000..6a04a3aa Binary files /dev/null and b/test/fix/mbc-rom-ram.gb differ diff --git a/test/fix/mbc-rom.flags b/test/fix/mbc-rom.flags new file mode 100644 index 00000000..43c754ed --- /dev/null +++ b/test/fix/mbc-rom.flags @@ -0,0 +1 @@ +-m ROM diff --git a/test/fix/mbc-rom.gb b/test/fix/mbc-rom.gb new file mode 100644 index 00000000..e24f07dd Binary files /dev/null and b/test/fix/mbc-rom.gb differ diff --git a/test/fix/mbc-tama5.flags b/test/fix/mbc-tama5.flags new file mode 100644 index 00000000..61a0ff87 --- /dev/null +++ b/test/fix/mbc-tama5.flags @@ -0,0 +1 @@ +-m TAMA5 diff --git a/test/fix/mbc-tama5.gb b/test/fix/mbc-tama5.gb new file mode 100644 index 00000000..f39b3fb6 Binary files /dev/null and b/test/fix/mbc-tama5.gb differ diff --git a/test/fix/mbcless-ram.flags b/test/fix/mbcless-ram.flags index f0fefa77..8d18f255 100644 --- a/test/fix/mbcless-ram.flags +++ b/test/fix/mbcless-ram.flags @@ -1 +1 @@ --m ROM -r 2 +-m rom_only -r 2 diff --git a/test/fix/noop.err b/test/fix/noop.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/overwrite.err b/test/fix/overwrite.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/padding-bigperfect.err b/test/fix/padding-bigperfect.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/padding-imperfect.err b/test/fix/padding-imperfect.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/padding-large.err b/test/fix/padding-large.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/padding-larger.err b/test/fix/padding-larger.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/padding-perfect.err b/test/fix/padding-perfect.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/padding-rom0.err b/test/fix/padding-rom0.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/padding.err b/test/fix/padding.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/plain.bin b/test/fix/plain.bin deleted file mode 100644 index 439862b6..00000000 Binary files a/test/fix/plain.bin and /dev/null differ diff --git a/test/fix/plain.err b/test/fix/plain.err deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/plain.flags b/test/fix/plain.flags deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fix/plain.gb b/test/fix/plain.gb deleted file mode 100644 index 439862b6..00000000 Binary files a/test/fix/plain.gb and /dev/null differ diff --git a/test/fix/ramful-mbc-no-ram.flags b/test/fix/ramful-mbc-no-ram.flags index 33b49433..02036841 100644 --- a/test/fix/ramful-mbc-no-ram.flags +++ b/test/fix/ramful-mbc-no-ram.flags @@ -1 +1 @@ --m MBC3+RAM -r 0 +-m mbc3+ram -r 0 diff --git a/test/fix/ramful-mbc.flags b/test/fix/ramful-mbc.flags index a3c0a495..eb897524 100644 --- a/test/fix/ramful-mbc.flags +++ b/test/fix/ramful-mbc.flags @@ -1 +1 @@ --m MBC3+RAM -r 2 +-m mbc3+ram -r 2 diff --git a/test/fix/ramless-mbc.flags b/test/fix/ramless-mbc.flags index 1801af97..a521c3e8 100644 --- a/test/fix/ramless-mbc.flags +++ b/test/fix/ramless-mbc.flags @@ -1 +1 @@ --m MBC3 -r 0 +-m mbc3 -r 0 diff --git a/test/fix/rom-ram.bin b/test/fix/rom-ram.bin deleted file mode 100644 index 94940f70..00000000 Binary files a/test/fix/rom-ram.bin and /dev/null differ diff --git a/test/fix/rom-ram.err b/test/fix/rom-ram.err deleted file mode 100644 index 327a6903..00000000 --- a/test/fix/rom-ram.err +++ /dev/null @@ -1,2 +0,0 @@ -warning: ROM+RAM / ROM+RAM+BATTERY are under-specified and poorly supported -warning: Overwrote a non-zero byte in the cartridge type diff --git a/test/fix/rom-ram.flags b/test/fix/rom-ram.flags deleted file mode 100644 index 9b9c6112..00000000 --- a/test/fix/rom-ram.flags +++ /dev/null @@ -1 +0,0 @@ --m8 diff --git a/test/fix/rom-ram.gb b/test/fix/rom-ram.gb deleted file mode 100644 index 0d43d717..00000000 Binary files a/test/fix/rom-ram.gb and /dev/null differ diff --git a/test/fix/test.sh b/test/fix/test.sh index 5aa06cbe..360ef758 100755 --- a/test/fix/test.sh +++ b/test/fix/test.sh @@ -42,7 +42,7 @@ tryCmp () { runTest () { flags=$( head -n 1 "$2/$1.flags" | # Allow other lines to serve as comments - sed "s#-L #-L ${src//#/\\#}/#g" # Prepend src directory to logo file + sed "s# ./# ${src//#/\\#}/#g" # Prepend src directory to path arguments ) for variant in '' ' piped'; do @@ -51,26 +51,37 @@ runTest () { if [[ $progress -ne 0 ]]; then echo "${bold}${green}$1${variant}...${rescolors}${resbold}" fi + if [[ -r "$2/$1.bin" ]]; then + desired_input="$2/$1.bin" + else + desired_input="$src/default-input.bin" + fi if [[ -z "$variant" ]]; then - cp "$2/$1.bin" out.gb + cp "$desired_input" out.gb if [[ -n "$(eval "$RGBFIX" $flags out.gb '2>out.err')" ]]; then echo "${bold}${red}Fixing $1 in-place shouldn't output anything on stdout!${rescolors}${resbold}" our_rc=1 fi - subst='out.gb' + subst=out.gb else # Stop! This is not a Useless Use Of Cat. Using cat instead of # stdin redirection makes the input an unseekable pipe - a scenario # that's harder to deal with. # shellcheck disable=SC2002 - cat "$2/$1.bin" | eval $RGBFIX "$flags" - '>out.gb' '2>out.err' + cat "$desired_input" | eval $RGBFIX "$flags" - '>out.gb' '2>out.err' subst='' fi - sed "s/$subst//g" "out.err" | tryDiff "$2/$1.err" - "$1.err${variant}" + if [[ -r "$2/$1.err" ]]; then + desired_errname="$2/$1.err" + else + desired_errname=/dev/null + fi + sed "s/$subst//g" out.err | tryDiff "$desired_errname" - "$1.err${variant}" (( our_rc = our_rc || $? )) + if [[ -r "$2/$1.gb" ]]; then - tryCmp "$2/$1.gb" "out.gb" "$1.gb${variant}" + tryCmp "$2/$1.gb" out.gb "$1.gb${variant}" (( our_rc = our_rc || $? )) fi @@ -85,8 +96,8 @@ runTest () { rm -f padding*_* # Delete padding test cases generated but not deleted (e.g. interrupted) progress=1 -for i in "$src"/*.bin; do - runTest "$(basename "$i" .bin)" "$src" +for i in "$src"/*.flags; do + runTest "$(basename "$i" .flags)" "$src" done # Check the result with all different padding bytes @@ -103,9 +114,7 @@ for (( i=0; i < 10; ++i )); do runTest padding${suffix} . done done -echo "Done!" - -# TODO: check MBC names +echo "${bold}Done checking padding!${resbold}" # Check that RGBFIX errors out when inputting a non-existent file... $RGBFIX noexist 2>out.err diff --git a/test/fix/tpp1-bad-major.err b/test/fix/tpp1-bad-major.err index ea82c99a..48ca9552 100644 --- a/test/fix/tpp1-bad-major.err +++ b/test/fix/tpp1-bad-major.err @@ -1,24 +1 @@ error: Failed to parse TPP1 major revision number -error: Unknown MBC "TPP1_lol" -Accepted MBC names: - ROM ($00) [aka ROM_ONLY] - MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03) - MBC2 ($05), MBC2+BATTERY ($06) - ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated] - MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D) - MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10) - MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13) - MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B) - MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E) - MBC6 ($20) - MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22) - POCKET_CAMERA ($FC) - BANDAI_TAMA5 ($FD) - HUC3 ($FE) - HUC1+RAM+BATTERY ($FF) - - TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER, - TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY, - TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE, - TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE, - TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE diff --git a/test/fix/tpp1-bad-minor.err b/test/fix/tpp1-bad-minor.err index 17e59fb4..e9f99336 100644 --- a/test/fix/tpp1-bad-minor.err +++ b/test/fix/tpp1-bad-minor.err @@ -1,24 +1 @@ error: Failed to parse TPP1 minor revision number -error: Unknown MBC "TPP1_1.lol" -Accepted MBC names: - ROM ($00) [aka ROM_ONLY] - MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03) - MBC2 ($05), MBC2+BATTERY ($06) - ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated] - MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D) - MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10) - MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13) - MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B) - MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E) - MBC6 ($20) - MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22) - POCKET_CAMERA ($FC) - BANDAI_TAMA5 ($FD) - HUC3 ($FE) - HUC1+RAM+BATTERY ($FF) - - TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER, - TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY, - TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE, - TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE, - TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE diff --git a/test/fix/tpp1-features.bin b/test/fix/tpp1-features.bin new file mode 100644 index 00000000..e24dd134 Binary files /dev/null and b/test/fix/tpp1-features.bin differ diff --git a/test/fix/tpp1-features.err b/test/fix/tpp1-features.err new file mode 100644 index 00000000..b696678c --- /dev/null +++ b/test/fix/tpp1-features.err @@ -0,0 +1,5 @@ +warning: Overwrote a non-zero byte in the cartridge type +warning: Overwrote a non-zero byte in the TPP1 identification code +warning: Overwrote a non-zero byte in the TPP1 revision number +warning: Overwrote a non-zero byte in the RAM size +warning: Overwrote a non-zero byte in the TPP1 feature flags diff --git a/test/fix/tpp1-features.flags b/test/fix/tpp1-features.flags new file mode 100644 index 00000000..b24e0564 --- /dev/null +++ b/test/fix/tpp1-features.flags @@ -0,0 +1 @@ +-m TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE -r 8 diff --git a/test/fix/tpp1-features.gb b/test/fix/tpp1-features.gb new file mode 100644 index 00000000..89cd5094 Binary files /dev/null and b/test/fix/tpp1-features.gb differ diff --git a/test/fix/tpp1-unk-major.err b/test/fix/tpp1-unk-major.err index f9337fd7..6dc28b9a 100644 --- a/test/fix/tpp1-unk-major.err +++ b/test/fix/tpp1-unk-major.err @@ -1,24 +1 @@ -error: RGBFIX only supports TPP1 versions 1.0 -error: Unknown MBC "TPP1_2.0" -Accepted MBC names: - ROM ($00) [aka ROM_ONLY] - MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03) - MBC2 ($05), MBC2+BATTERY ($06) - ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated] - MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D) - MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10) - MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13) - MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B) - MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E) - MBC6 ($20) - MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22) - POCKET_CAMERA ($FC) - BANDAI_TAMA5 ($FD) - HUC3 ($FE) - HUC1+RAM+BATTERY ($FF) - - TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER, - TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY, - TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE, - TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE, - TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE +error: RGBFIX only supports TPP1 version 1.0 diff --git a/test/fix/tpp1-unk-minor.err b/test/fix/tpp1-unk-minor.err index e9537382..93c0d5a0 100644 --- a/test/fix/tpp1-unk-minor.err +++ b/test/fix/tpp1-unk-minor.err @@ -1,24 +1 @@ error: TPP1 minor revision number must be 8-bit -error: Unknown MBC "TPP1_1.256" -Accepted MBC names: - ROM ($00) [aka ROM_ONLY] - MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03) - MBC2 ($05), MBC2+BATTERY ($06) - ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated] - MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D) - MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10) - MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13) - MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B) - MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E) - MBC6 ($20) - MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22) - POCKET_CAMERA ($FC) - BANDAI_TAMA5 ($FD) - HUC3 ($FE) - HUC1+RAM+BATTERY ($FF) - - TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER, - TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY, - TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE, - TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE, - TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE diff --git a/test/fix/unknown-mbc.err b/test/fix/unknown-mbc.err new file mode 100644 index 00000000..80ec19a7 --- /dev/null +++ b/test/fix/unknown-mbc.err @@ -0,0 +1,23 @@ +error: Unknown MBC "MBC1337" +Accepted MBC names: + ROM ($00) [aka ROM_ONLY] + MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03) + MBC2 ($05), MBC2+BATTERY ($06) + ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated] + MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D) + MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10) + MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13) + MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B) + MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E) + MBC6 ($20) + MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22) + POCKET_CAMERA ($FC) + BANDAI_TAMA5 ($FD) [aka TAMA5] + HUC3 ($FE) + HUC1+RAM+BATTERY ($FF) + + TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER, + TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY, + TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE, + TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE, + TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE diff --git a/test/fix/unknown-mbc.flags b/test/fix/unknown-mbc.flags new file mode 100644 index 00000000..c2c83ddf --- /dev/null +++ b/test/fix/unknown-mbc.flags @@ -0,0 +1,2 @@ +-m MBC1337 +