shithub: rgbds

Download patch

ref: 6752b102049e0f75d393c5ed5420c49e87e7bb33
parent: 2d72b12eb89e14338b81d0e37e90ec3f69b16a9e
author: anthony <[email protected]>
date: Mon Jan 4 14:40:01 EST 2010

add -j option for setting 0x14A (region flag)

--- a/src/fix/main.c
+++ b/src/fix/main.c
@@ -23,6 +23,7 @@
 #define OPTF_RAMSIZE	0x040L
 #define OPTF_MBCTYPE	0x080L
 #define OPTF_GBCMODE	0x100L
+#define OPTF_JAPAN	0x200L
 
 unsigned long ulOptions;
 
@@ -55,6 +56,7 @@
 	printf("  -h\t\tThis text\n");
 	printf("  -d\t\tDebug: Don't change image\n");
 	printf("  -m<hx>\tChange RAM size of cartridge\n");
+	printf("  -j\tSet the non-Japanese region flag\n");
 	printf("  -p[<hx>]\tPad image to valid size\n"
 		"\t\tPads to 32/64/128/256/512kB as appropriate\n"
 		"\t\tAn optional hexadecimal pad value can be supplied (default is 0)");
@@ -256,6 +258,9 @@
 					FatalError("Invalid argument for option 'm'");
 				}
 				break;
+			case 'j':
+				ulOptions |= OPTF_JAPAN;
+				break;
 			case 'b':
 				ulOptions |= OPTF_MBCTYPE;
 				if (strlen(argv[argn] + 2) > 0 && strlen(argv[argn] + 2) <= 2) {
@@ -447,6 +452,19 @@
 
 			if (!(ulOptions & OPTF_QUIET)) {
 				printf("\tRAM size set to %#02X\n", ram_size);
+			}
+		}
+		/*
+		 * -j (Set region flag) option code
+		 */
+		if (ulOptions & OPTF_JAPAN) {
+			fflush(f);
+			fseek(f, 0x14A, SEEK_SET);
+			fputc(1, f);
+			fflush(f);
+
+			if (!(ulOptions & OPTF_QUIET)) {
+				printf("\tRegion code set to non-Japan\n");
 			}
 		}
 		/*