ref: db0667e54e4674f7ca82c3228420c63f28be6f7f
parent: b7ca2e2b871e1790b6c13c312b1c19e453e13d6d
author: Anthony Bentley <[email protected]>
date: Sun Nov 8 15:28:24 EST 2009
added a command line option -q for quiet mode (suppresses messages except errors) (lmod)
--- a/src/rgbfix/main.c
+++ b/src/rgbfix/main.c
@@ -19,6 +19,7 @@
#define OPTF_VALIDATE 0x04L
#define OPTF_TITLE 0x08L
#define OPTF_TRUNCATE 0x10L
+#define OPTF_QUIET 0x20L
unsigned long ulOptions;
@@ -54,6 +55,7 @@
printf("\t-r\t\ttRuncate image to valid size\n\t\t\tTruncates to 32/64/128/256/512kB as appropriate\n");
printf("\t-t<name>\tChange cartridge title field (16 characters)\n");
printf("\t-v\t\tValidate header\n\t\t\tCorrects - Nintendo Character Area (0x0104)\n\t\t\t\t - ROM type (0x0147)\n\t\t\t\t - ROM size (0x0148)\n\t\t\t\t - Checksums (0x014D-0x014F)\n");
+ printf("\t-q\t\tExecute quietly (suppress all text except errors)\n");
exit(0);
}
@@ -153,6 +155,9 @@
strncpy(cartname, argv[argn - 1] + 2, 16);
ulOptions |= OPTF_TITLE;
break;
+ case 'q':
+ ulOptions|=OPTF_QUIET;
+ break;
}
}
@@ -170,7 +175,7 @@
*
*/
- if (ulOptions & OPTF_DEBUG) {
+ if ((ulOptions & OPTF_DEBUG) && !(ulOptions & OPTF_QUIET)) {
printf("-d (Debug) option enabled...\n");
}
@@ -188,7 +193,9 @@
while (size > padto)
padto *= 2;
- printf("Padding to %ldkB:\n", padto / 1024);
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("Padding to %ldkB:\n", padto / 1024);
+ }
/*
if( padto<=0x80000L )
@@ -206,9 +213,14 @@
}
fflush(f);
- printf("\tAdded %ld bytes\n", bytesadded);
- } else
- printf("\tNo padding needed\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tAdded %ld bytes\n", bytesadded);
+ }
+ } else {
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tNo padding needed\n");
+ }
+ }
/*
}
else
@@ -231,7 +243,9 @@
while (size < padto)
padto /= 2;
- printf("Truncating to %ldkB:\n", padto / 1024);
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("Truncating to %ldkB:\n", padto / 1024);
+ }
mkstemp(tempfile);
@@ -256,7 +270,9 @@
*/
if (ulOptions & OPTF_TITLE) {
- printf("Setting cartridge title:\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("Setting cartridge title:\n");
+ }
if ((ulOptions & OPTF_DEBUG) == 0) {
fflush(f);
fseek(f, 0x0134L, SEEK_SET);
@@ -263,7 +279,9 @@
fwrite(cartname, 16, 1, f);
fflush(f);
}
- printf("\tTitle set to %s\n", cartname);
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tTitle set to %s\n", cartname);
+ }
}
/*
@@ -280,7 +298,9 @@
0;
int ch;
- printf("Validating header:\n");
+ if(!(ulOptions & OPTF_VALIDATE)) {
+ printf("Validating header:\n");
+ }
fflush(stdout);
/* Nintendo Character Area */
@@ -307,12 +327,14 @@
fflush(f);
- if (byteschanged)
- printf
- ("\tChanged %ld bytes in the Nintendo Character Area\n",
- byteschanged);
- else
- printf("\tNintendo Character Area is OK\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ if (byteschanged)
+ printf
+ ("\tChanged %ld bytes in the Nintendo Character Area\n",
+ byteschanged);
+ else
+ printf("\tNintendo Character Area is OK\n");
+ }
/* ROM size */
@@ -331,13 +353,17 @@
fputc(calcromsize, f);
fflush(f);
}
- printf("\tChanged ROM size byte from 0x%02lX (%ldkB) to 0x%02lX (%ldkB)\n",
- cartromsize,
- (0x8000L << cartromsize) / 1024,
- calcromsize,
- (0x8000L << calcromsize) / 1024);
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tChanged ROM size byte from 0x%02lX (%ldkB) to 0x%02lX (%ldkB)\n",
+ cartromsize,
+ (0x8000L << cartromsize) / 1024,
+ calcromsize,
+ (0x8000L << calcromsize) / 1024);
+ }
} else
- printf("\tROM size byte is OK\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tROM size byte is OK\n");
+ }
/* Cartridge type */
@@ -355,13 +381,19 @@
fputc(0x01, f);
fflush(f);
}
- printf
- ("\tCartridge type byte changed to 0x01\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf
+ ("\tCartridge type byte changed to 0x01\n");
+ }
} else
- printf("\tCartridge type byte is OK\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tCartridge type byte is OK\n");
+ }
} else {
/* carttype byte can be anything? */
- printf("\tCartridge type byte is OK\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tCartridge type byte is OK\n");
+ }
}
/* Checksum */
@@ -400,11 +432,16 @@
fputc(calcchecksum & 0xFF, f);
}
fflush(f);
- printf
- ("\tChecksum changed from 0x%04lX to 0x%04lX\n",
- (long)cartchecksum, (long)calcchecksum);
- } else
- printf("\tChecksum is OK\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf
+ ("\tChecksum changed from 0x%04lX to 0x%04lX\n",
+ (long)cartchecksum, (long)calcchecksum);
+ }
+ } else {
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tChecksum is OK\n");
+ }
+ }
if (cartcompchecksum != calccompchecksum) {
fflush(f);
@@ -412,12 +449,17 @@
if ((ulOptions & OPTF_DEBUG) == 0)
fputc(calccompchecksum, f);
fflush(f);
- printf
- ("\tCompChecksum changed from 0x%02lX to 0x%02lX\n",
- (long)cartcompchecksum,
- (long)calccompchecksum);
- } else
- printf("\tCompChecksum is OK\n");
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf
+ ("\tCompChecksum changed from 0x%02lX to 0x%02lX\n",
+ (long)cartcompchecksum,
+ (long)calccompchecksum);
+ }
+ } else {
+ if(!(ulOptions & OPTF_QUIET)) {
+ printf("\tCompChecksum is OK\n");
+ }
+ }
}