From 80a5ffad6e6a2e0bb8faab202e101feee9061a06 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Thu, 11 Aug 2022 22:52:30 +0200 Subject: WIP: Add some gameboy tooling --- sdcc-makebin-nogogo-v2-bool.patch | 163 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 sdcc-makebin-nogogo-v2-bool.patch (limited to 'sdcc-makebin-nogogo-v2-bool.patch') diff --git a/sdcc-makebin-nogogo-v2-bool.patch b/sdcc-makebin-nogogo-v2-bool.patch new file mode 100644 index 0000000..816a8b1 --- /dev/null +++ b/sdcc-makebin-nogogo-v2-bool.patch @@ -0,0 +1,163 @@ +diff --git a/support/makebin/makebin.c b/support/makebin/makebin.c +index ed41d3d..ed17286 100644 +--- a/support/makebin/makebin.c ++++ b/support/makebin/makebin.c +@@ -20,20 +20,21 @@ + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + */ + + + #include + #include ++#include + #include + #include + + #if defined(_WIN32) + #include + #include + #else + #include + #endif + +@@ -109,20 +110,21 @@ usage (void) + " -ya n number of ram banks (default: 0)\n" + " -yt n MBC type (default: no MBC)\n" + " -yl n old licensee code (default: 0x33)\n" + " -yk cc new licensee string (default: 00)\n" + " -yn name cartridge name (default: none)\n" + " -yc GameBoy Color compatible\n" + " -yC GameBoy Color only\n" + " -ys Super GameBoy\n" + " -yS Convert .noi file named like input file to .sym\n" + " -yj set non-Japanese region flag\n" ++ " -yN do not copy big N validation logo into ROM header\n" + " -yp addr=value Set address in ROM to given value (address 0x100-0x1FE)\n" + "Arguments:\n" + " optional IHX input file, '-' means stdin. (default: stdin)\n" + " optional output file, '-' means stdout. (default: stdout)\n"); + } + + #define CART_NAME_LEN 16 + + struct gb_opt_s + { +@@ -130,20 +132,21 @@ struct gb_opt_s + char licensee_str[2]; /* new licensee string */ + BYTE mbc_type; /* MBC type (default: no MBC) */ + short nb_rom_banks; /* Number of rom banks (default: 2) */ + BYTE nb_ram_banks; /* Number of ram banks (default: 0) */ + BYTE licensee_id; /* old licensee code */ + BYTE is_gbc; /* 1 if GBC compatible, 2 if GBC only, false for all other*/ + BYTE is_sgb; /* True if SGB, false for all other*/ + BYTE sym_conversion; /* True if .noi file should be converted to .sym (default false)*/ + BYTE non_jp; /* True if non-Japanese region, false for all other*/ + BYTE rom_banks_autosize; /* True if rom banks should be auto-sized (default false)*/ ++ bool do_logo_copy; /* True if the nintendo logo should be copied into the ROM (default true) */ + BYTE address_overwrite[16]; /* For limited compatibility with very old versions */ + }; + + struct sms_opt_s + { + BYTE rom_size; /* Doesn't have to be the real size, needed for checksum */ + BYTE region_code; /* Region code Japan/Export/International and SMS/GG */ + BYTE version; /* Game version */ + }; + +@@ -158,21 +161,24 @@ gb_postproc (BYTE * rom, int size, int *real_size, struct gb_opt_s *o) + 0x00, 0x08, 0x11, 0x1f, 0x88, 0x89, 0x00, 0x0e, + 0xdc, 0xcc, 0x6e, 0xe6, 0xdd, 0xdd, 0xd9, 0x99, + 0xbb, 0xbb, 0x67, 0x63, 0x6e, 0x0e, 0xec, 0xcc, + 0xdd, 0xdc, 0x99, 0x9f, 0xbb, 0xb9, 0x33, 0x3e + }; + + /* $0104-$0133: Nintendo logo + * If missing, an actual Game Boy won't run the ROM. + */ + +- memcpy (&rom[0x104], gb_logo, sizeof (gb_logo)); ++ if (o->do_logo_copy) ++ { ++ memcpy (&rom[0x104], gb_logo, sizeof (gb_logo)); ++ } + + rom[0x144] = o->licensee_str[0]; + rom[0x145] = o->licensee_str[1]; + + /* + * 0134-0142: Title of the game in UPPER CASE ASCII. If it + * is less than 16 characters then the + * remaining bytes are filled with 00's. + */ + +@@ -682,22 +688,38 @@ int + main (int argc, char **argv) + { + int size = 32768, pack = 0, real_size = 0, i = 0; + char *token; + BYTE *rom; + FILE *fin, *fout; + char *filename = NULL; + int ret; + int gb = 0; + int sms = 0; +- struct gb_opt_s gb_opt = { "", {'0', '0'}, 0, 2, 0, 0x33, 0, 0, 0, 0, 0, {0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0}}; +- struct sms_opt_s sms_opt = { 0xa, 7, 0 }; ++ ++ struct gb_opt_s gb_opt = {.cart_name="", ++ .licensee_str={'0', '0'}, ++ .mbc_type=0, ++ .nb_rom_banks=2, ++ .nb_ram_banks=0, ++ .licensee_id=0x33, ++ .is_gbc=0, ++ .is_sgb=0, ++ .sym_conversion=0, ++ .non_jp=0, ++ .rom_banks_autosize=0, ++ .do_logo_copy=true, ++ .address_overwrite={0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0} }; ++ ++ struct sms_opt_s sms_opt = {.rom_size=0xa, ++ .region_code=7, ++ .version=0 }; + + #if defined(_WIN32) + setmode (fileno (stdout), O_BINARY); + #endif + + while (*++argv && '-' == argv[0][0] && '\0' != argv[0][1]) + { + switch (argv[0][1]) + { + case 's': +@@ -794,20 +816,24 @@ main (int argc, char **argv) + break; + + case 'c': + gb_opt.is_gbc = 1; + break; + + case 'C': + gb_opt.is_gbc = 2; + break; + ++ case 'N': ++ gb_opt.do_logo_copy = false; // when switch is present, turn off logo copy ++ break; ++ + case 's': + gb_opt.is_sgb = 1; + break; + + case 'S': + gb_opt.sym_conversion = 1; + break; + + case 'j': + gb_opt.non_jp = 1; + -- cgit v1.2.3