mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
Make gbafix silent
This commit is contained in:
parent
d9941cd1a8
commit
aa0782c40b
2
Makefile
2
Makefile
@ -173,5 +173,5 @@ $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS)
|
|||||||
|
|
||||||
$(ROM): $(ELF)
|
$(ROM): $(ELF)
|
||||||
$(OBJCOPY) -O binary $< $@
|
$(OBJCOPY) -O binary $< $@
|
||||||
$(FIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION)
|
$(FIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) -silent
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ int main(int argc, char *argv[])
|
|||||||
int arg;
|
int arg;
|
||||||
char *argfile = 0;
|
char *argfile = 0;
|
||||||
FILE *infile;
|
FILE *infile;
|
||||||
|
int silent = 0;
|
||||||
|
|
||||||
int size,bit;
|
int size,bit;
|
||||||
|
|
||||||
@ -142,7 +143,7 @@ int main(int argc, char *argv[])
|
|||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
{
|
{
|
||||||
printf("GBA ROM fixer v"VER" by Dark Fader / BlackThunder / WinterMute / Diegoisawesome \n");
|
printf("GBA ROM fixer v"VER" by Dark Fader / BlackThunder / WinterMute / Diegoisawesome \n");
|
||||||
printf("Syntax: gbafix <rom.gba> [-p] [-t[title]] [-c<game_code>] [-m<maker_code>] [-r<version>] [-d<debug>]\n");
|
printf("Syntax: gbafix <rom.gba> [-p] [-t[title]] [-c<game_code>] [-m<maker_code>] [-r<version>] [-d<debug>] [-silent]\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("parameters:\n");
|
printf("parameters:\n");
|
||||||
printf(" -p Pad to next exact power of 2. No minimum size!\n");
|
printf(" -p Pad to next exact power of 2. No minimum size!\n");
|
||||||
@ -151,25 +152,27 @@ int main(int argc, char *argv[])
|
|||||||
printf(" -m<maker_code> Patch maker code (two characters)\n");
|
printf(" -m<maker_code> Patch maker code (two characters)\n");
|
||||||
printf(" -r<version> Patch game version (number)\n");
|
printf(" -r<version> Patch game version (number)\n");
|
||||||
printf(" -d<debug> Enable debugging handler and set debug entry point (0 or 1)\n");
|
printf(" -d<debug> Enable debugging handler and set debug entry point (0 or 1)\n");
|
||||||
|
printf(" -silent Silence non-error output\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get filename
|
// get filename
|
||||||
for (arg=1; arg<argc; arg++)
|
for (arg=1; arg<argc; arg++)
|
||||||
{
|
{
|
||||||
if ((ARGV[0] != '-')) { argfile=ARGV; break; }
|
if ((ARGV[0] != '-')) { argfile=ARGV; }
|
||||||
|
if (strncmp("-silent", &ARGV[0], 6) == 0) { silent = 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// check filename
|
// check filename
|
||||||
if (!argfile)
|
if (!argfile)
|
||||||
{
|
{
|
||||||
printf("Filename needed!\n");
|
fprintf(stderr, "Filename needed!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read file
|
// read file
|
||||||
infile = fopen(argfile, "r+b");
|
infile = fopen(argfile, "r+b");
|
||||||
if (!infile) { printf("Error opening input file!\n"); return -1; }
|
if (!infile) { fprintf(stderr, "Error opening input file!\n"); return -1; }
|
||||||
fseek(infile, 0, SEEK_SET);
|
fseek(infile, 0, SEEK_SET);
|
||||||
fread(&header, sizeof(header), 1, infile);
|
fread(&header, sizeof(header), 1, infile);
|
||||||
|
|
||||||
@ -183,6 +186,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if ((ARGV[0] == '-'))
|
if ((ARGV[0] == '-'))
|
||||||
{
|
{
|
||||||
|
if (strncmp("-silent", &ARGV[0], 6) == 0) { continue; }
|
||||||
|
|
||||||
switch (ARGV[1])
|
switch (ARGV[1])
|
||||||
{
|
{
|
||||||
case 'p': // pad
|
case 'p': // pad
|
||||||
@ -215,7 +220,7 @@ int main(int argc, char *argv[])
|
|||||||
t = strrchr(s, '/'); if (t) begin = t+1;
|
t = strrchr(s, '/'); if (t) begin = t+1;
|
||||||
t = strrchr(s, '.'); if (t) *t = 0;
|
t = strrchr(s, '.'); if (t) *t = 0;
|
||||||
strncpy(title, begin, sizeof(header.title));
|
strncpy(title, begin, sizeof(header.title));
|
||||||
printf("%s\n",begin);
|
if (!silent) printf("%s\n",begin);
|
||||||
}
|
}
|
||||||
memcpy(header.title, title, sizeof(header.title)); // copy
|
memcpy(header.title, title, sizeof(header.title)); // copy
|
||||||
break;
|
break;
|
||||||
@ -223,7 +228,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'c': // game code
|
case 'c': // game code
|
||||||
{
|
{
|
||||||
//if (!VALUE[0]) { printf("Need value for %s\n", ARGV); break; }
|
//if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
|
||||||
//header.game_code = NUMBER;
|
//header.game_code = NUMBER;
|
||||||
header.game_code = VALUE[0] | VALUE[1]<<8 | VALUE[2]<<16 | VALUE[3]<<24;
|
header.game_code = VALUE[0] | VALUE[1]<<8 | VALUE[2]<<16 | VALUE[3]<<24;
|
||||||
break;
|
break;
|
||||||
@ -231,7 +236,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'm': // maker code
|
case 'm': // maker code
|
||||||
{
|
{
|
||||||
//if (!VALUE[0]) { printf("Need value for %s\n", ARGV); break; }
|
//if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
|
||||||
//header.maker_code = (unsigned short)NUMBER;
|
//header.maker_code = (unsigned short)NUMBER;
|
||||||
header.maker_code = VALUE[0] | VALUE[1]<<8;
|
header.maker_code = VALUE[0] | VALUE[1]<<8;
|
||||||
break;
|
break;
|
||||||
@ -244,14 +249,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'r': // version
|
case 'r': // version
|
||||||
{
|
{
|
||||||
if (!VALUE[0]) { printf("Need value for %s\n", ARGV); break; }
|
if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
|
||||||
header.game_version = (unsigned char)NUMBER;
|
header.game_version = (unsigned char)NUMBER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'd': // debug
|
case 'd': // debug
|
||||||
{
|
{
|
||||||
if (!VALUE[0]) { printf("Need value for %s\n", ARGV); break; }
|
if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
|
||||||
header.logo[0x9C-0x04] = 0xA5; // debug enable
|
header.logo[0x9C-0x04] = 0xA5; // debug enable
|
||||||
header.device_type = (unsigned char)((NUMBER & 1) << 7); // debug handler entry point
|
header.device_type = (unsigned char)((NUMBER & 1) << 7); // debug handler entry point
|
||||||
break;
|
break;
|
||||||
@ -275,7 +280,7 @@ int main(int argc, char *argv[])
|
|||||||
fwrite(&header, sizeof(header), 1, infile);
|
fwrite(&header, sizeof(header), 1, infile);
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
|
||||||
printf("ROM fixed!\n");
|
if (!silent) printf("ROM fixed!\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user