mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Add support for the four‐character game ID.
This commit is contained in:
@@ -24,9 +24,10 @@
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
printf("usage: rgbfix [-Ccjsv] [-k licensee_str] [-l licensee_id] "
|
printf("usage: rgbfix [-Ccjsv] [-i game_id] [-k licensee_str] "
|
||||||
"[-m mbc_type]\n" " [-n rom_version] [-p pad_value] "
|
"[-l licensee_id]\n" " [-m mbc_type] [-n rom_version] "
|
||||||
"[-r ram_size] [-t title_str] file.gb\n");
|
"[-p pad_value] [-r ram_size]\n"
|
||||||
|
" [-t title_str] file.gb\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -56,6 +57,7 @@ main(int argc, char *argv[])
|
|||||||
/* all flags default to false unless options specify otherwise */
|
/* all flags default to false unless options specify otherwise */
|
||||||
bool validate = false;
|
bool validate = false;
|
||||||
bool settitle = false;
|
bool settitle = false;
|
||||||
|
bool setid = false;
|
||||||
bool colorcompatible = false;
|
bool colorcompatible = false;
|
||||||
bool coloronly = false;
|
bool coloronly = false;
|
||||||
bool nonjapan = false;
|
bool nonjapan = false;
|
||||||
@@ -68,6 +70,7 @@ main(int argc, char *argv[])
|
|||||||
bool setversion = false;
|
bool setversion = false;
|
||||||
|
|
||||||
char *title = NULL; /* game title in ASCII */
|
char *title = NULL; /* game title in ASCII */
|
||||||
|
char *id = NULL; /* game ID in ASCII */
|
||||||
char *newlicensee = NULL; /* new licensee ID, two ASCII characters */
|
char *newlicensee = NULL; /* new licensee ID, two ASCII characters */
|
||||||
|
|
||||||
int licensee = -1; /* old licensee ID */
|
int licensee = -1; /* old licensee ID */
|
||||||
@@ -76,7 +79,7 @@ main(int argc, char *argv[])
|
|||||||
int version = -1; /* mask ROM version number */
|
int version = -1; /* mask ROM version number */
|
||||||
int padvalue = -1; /* to pad the rom with if it changes size */
|
int padvalue = -1; /* to pad the rom with if it changes size */
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "Ccjk:l:m:n:p:sr:t:v")) != -1) {
|
while ((ch = getopt(argc, argv, "Cci:jk:l:m:n:p:sr:t:v")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'C':
|
case 'C':
|
||||||
coloronly = true;
|
coloronly = true;
|
||||||
@@ -84,6 +87,17 @@ main(int argc, char *argv[])
|
|||||||
case 'c':
|
case 'c':
|
||||||
colorcompatible = true;
|
colorcompatible = true;
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
setid = true;
|
||||||
|
|
||||||
|
if (strlen(optarg) != 4) {
|
||||||
|
fprintf(stderr, "Game ID %s must be exactly 4 "
|
||||||
|
"characters\n", optarg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
id = optarg;
|
||||||
|
break;
|
||||||
case 'j':
|
case 'j':
|
||||||
nonjapan = true;
|
nonjapan = true;
|
||||||
break;
|
break;
|
||||||
@@ -251,6 +265,11 @@ main(int argc, char *argv[])
|
|||||||
* may conflict.
|
* may conflict.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* See also: Game ID at 0x13F–0x142. These four ASCII
|
||||||
|
* characters may conflict with the title.
|
||||||
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x134, SEEK_SET);
|
fseek(rom, 0x134, SEEK_SET);
|
||||||
fwrite(title, 1, strlen(title) + 1, rom);
|
fwrite(title, 1, strlen(title) + 1, rom);
|
||||||
|
|
||||||
@@ -258,6 +277,17 @@ main(int argc, char *argv[])
|
|||||||
fputc(0, rom);
|
fputc(0, rom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (setid) {
|
||||||
|
/*
|
||||||
|
* Offset 0x13F–0x142: Game ID
|
||||||
|
* This is a four-character game ID in ASCII (no high-bit
|
||||||
|
* characters).
|
||||||
|
*/
|
||||||
|
|
||||||
|
fseek(rom,0x13F,SEEK_SET);
|
||||||
|
fwrite(id, 1, 4, rom);
|
||||||
|
}
|
||||||
|
|
||||||
if (colorcompatible) {
|
if (colorcompatible) {
|
||||||
/*
|
/*
|
||||||
* Offset 0x143: Game Boy Color Flag
|
* Offset 0x143: Game Boy Color Flag
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm rgbfix
|
.Nm rgbfix
|
||||||
.Op Fl Ccjsv
|
.Op Fl Ccjsv
|
||||||
|
.Op Fl i Ar game_id
|
||||||
.Op Fl k Ar licensee_str
|
.Op Fl k Ar licensee_str
|
||||||
.Op Fl l Ar licensee_id
|
.Op Fl l Ar licensee_id
|
||||||
.Op Fl m Ar mbc_type
|
.Op Fl m Ar mbc_type
|
||||||
@@ -38,6 +39,12 @@ If both this and the
|
|||||||
flag are set,
|
flag are set,
|
||||||
.Fl C
|
.Fl C
|
||||||
takes precedence.
|
takes precedence.
|
||||||
|
.It Fl i Ar game_id
|
||||||
|
Set the game ID string
|
||||||
|
.Pq Ad 0x13F No Ns \(en Ns Ad 0x142
|
||||||
|
to a given string of exactly 4 characters.
|
||||||
|
If both this and the title are set, the game ID will overwrite the
|
||||||
|
overlapping portion of the title.
|
||||||
.It Fl j
|
.It Fl j
|
||||||
Set the non-Japanese region flag:
|
Set the non-Japanese region flag:
|
||||||
.Ad 0x14A
|
.Ad 0x14A
|
||||||
@@ -82,6 +89,8 @@ to a given string, truncated to at most 16 characters.
|
|||||||
It is recommended to use 15 characters instead, to avoid clashing with the CGB
|
It is recommended to use 15 characters instead, to avoid clashing with the CGB
|
||||||
flag
|
flag
|
||||||
.Pq Fl c No or Fl C .
|
.Pq Fl c No or Fl C .
|
||||||
|
If both this and the game ID are set, the game ID will overwrite the
|
||||||
|
overlapping portion of the title.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Validate the header and fix checksums: the Nintendo character area
|
Validate the header and fix checksums: the Nintendo character area
|
||||||
.Pq Ad 0x104 No Ns \(en Ns Ad 0x133 ,
|
.Pq Ad 0x104 No Ns \(en Ns Ad 0x133 ,
|
||||||
|
|||||||
Reference in New Issue
Block a user