ref: 7e4104cabe8d995e40e552da2078fea87ff4ada6
parent: ecae948371454d7fd03d1e31c5f3e6d5304b64cb
author: anthony <[email protected]>
date: Wed Dec 30 10:55:00 EST 2009
add option to change memory size (from lmod)
--- a/src/fix/main.c
+++ b/src/fix/main.c
@@ -20,6 +20,7 @@
#define OPTF_TITLE 0x08L
#define OPTF_TRUNCATE 0x10L
#define OPTF_QUIET 0x20L
+#define OPTF_RAMSIZE 0x40L
unsigned long ulOptions;
@@ -51,7 +52,8 @@
printf("Options:\n");
printf(" -h\t\tThis text\n");
printf(" -d\t\tDebug: Don't change image\n");
- printf(" -p[XX]\t\tPad image to valid size\n"
+ printf(" -m<hx>\tChange RAM size of cartridge\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)");
printf(" -r\t\ttRuncate image to valid size\n\t\t\tTruncates to 32/64/128/256/512kB as appropriate\n");
@@ -139,6 +141,7 @@
char cartname[32];
FILE *f;
int pad_value = 0;
+ int ram_size = 0;
ulOptions = 0;
@@ -155,6 +158,20 @@
case 'd':
ulOptions |= OPTF_DEBUG;
break;
+ case 'm':
+ ulOptions |= OPTF_RAMSIZE;
+ if (strlen(argv[argn] + 2) > 0 && strlen(argv[argn] + 2) <= 2) {
+ int result;
+ result = sscanf(argv[argn] + 2,"%x", &ram_size);
+ if (!((result == EOF) || (result == 1))) {
+ FatalError("Invalid argument for option 'm'");
+ }
+ } else if (strlen(argv[argn] + 2) > 0) {
+ FatalError("RAM size must be between 0 and FF");
+ } else {
+ FatalError("Invalid argument for option 'm'");
+ }
+ break;
case 'p':
ulOptions |= OPTF_PAD;
if (strlen(argv[argn] + 2) > 0 && strlen(argv[argn] + 2) <= 2) {
@@ -300,6 +317,24 @@
}
if (!(ulOptions & OPTF_QUIET)) {
printf("\tTitle set to %s\n", cartname);
+ }
+ }
+ /*
+ * -m (Set ram size) option code
+ *
+ */
+ if (ulOptions & OPTF_RAMSIZE) {
+ /* carttype byte can be anything? */
+ if (!(ulOptions & OPTF_QUIET)) {
+ printf("Setting RAM size\n");
+ }
+ fflush(f);
+ fseek(f, 0x149L, SEEK_SET);
+ fputc(ram_size, f);
+ fflush(f);
+
+ if (!(ulOptions & OPTF_QUIET)) {
+ printf("\tRAM size set to %#02X\n", ram_size);
}
}
/*