rgbfix
Game Boy header utility and checksum fixer
- Provided by: rgbds (Version: 1.0.1-1)
- Report a bug
Game Boy header utility and checksum fixer
rgbfix |
[-hjsVvw] [-C |
-c] [--color
when] [-f
fix_spec] [-i
game_id] [-k
licensee_str] [-L
logo_file] [-l
licensee_id] [-m
mbc_type] [-n
rom_version] [-o
out_file] [-p
pad_value] [-r
ram_size] [-t
title_str] [-W
warning] file ... |
The rgbfix program changes headers of Game
Boy ROM images, typically generated by rgblink(1), though
it will work with
any Game Boy
ROM. It also performs other correctness operations, such as padding.
rgbfix only changes the fields for which it has
values specified. Developers are advised to fill those fields with 0x00
bytes in their source code before running rgbfix,
and to have already populated whichever fields they don't specify using
rgbfix.
rgbfix accepts the usual short and long
options, such as -V and
--version. Options later in the command line
override those set earlier, except for when duplicate options are considered
an error. Options can be abbreviated as long as the abbreviation is
unambiguous: --ver is
--version, but --v is
invalid because it could also be --validate.
Unless otherwise noted, passing
‘-’ (a single dash) as a file name
makes rgbfix use standard input (for input files) or
standard output (for output files). To suppress this behavior, and open a
file in the current directory actually called
‘-’, pass
‘./-’ instead. Using standard input or
output for more than one file in a single command may produce unexpected
results.
rgbfix accepts decimal, hexadecimal,
octal, and binary for numeric option arguments. Decimal numbers are written
as usual; hexadecimal numbers must be prefixed with either
‘$’ or
‘0x’; octal numbers must be prefixed
with either ‘&’ or
‘0o’; and binary numbers must be
prefixed with either ‘%’ or
‘0b’. (The prefixes
‘$’ and
‘&’ will likely need escaping or
quoting to avoid being interpreted by the shell.) Leading zeros (after the
base prefix, if any) are accepted, and letters are not case-sensitive. For
example, all of these are equivalent:
‘42’,
‘042’,
‘0x2A’,
‘0X2A’,
‘0x2a’,
‘&52’,
‘0o52’,
‘0O052’,
‘0b00101010’,
‘0B101010’.
The following options are accepted:
-C,
--color-only-c if it was set prior.-c,
--color-compatible-c if it was set prior.--color
whenalways’,
‘never’, or
‘auto’.
‘auto’ determines whether to use
colors based on the
‘NO_COLOR’
or
‘FORCE_COLOR’
environment variables, or whether the output is to a TTY.-f
fix_spec, --fix-spec
fix_spec-h,
--help-i
game_id, --game-id
game_id-j,
--non-japanese-k
licensee_str, --new-licensee
licensee_str-L
logo_file, --logo
logo_file-l
licensee_id, --old-licensee
licensee_id-m
mbc_type, --mbc-type
mbc_typeThis value may also be an MBC name. The list of accepted names
can be obtained by passing
‘’ or
‘help’ as
the argument. Any amount of whitespace (space and tabs) is allowed
around plus signs, and the order of "components" is free, as
long as the MBC name is first. There are special considerations to take
for the TPP1 mapper; see the TPP1 section
below.list
-n
rom_version, --rom-version
rom_version-o
out_file, --output
out_file-p
pad_value, --pad-value
pad_valuergbfix will automatically pick a size from
32 KiB, 64 KiB, 128 KiB, ..., 8192 KiB. The cartridge size byte
(0x148) will be changed to reflect this new size.
The recommended padding value is 0xFF, to speed up writing the ROM to
flash chips, and to avoid "nop slides" into VRAM.-r
ram_size, --ram-size
ram_size-s,
--sgb-compatible-l) is 0x33!-t
title, --title
title-i) is specified, 15 characters if the CGB flag
(-c or -C) is specified
but the game ID is not, and 16 characters otherwise.-V,
--version-v,
--validate-f lhg.-W
warning, --warning
warning-w#’) are considered comments and
ignored.
No shell processing is performed, such as wildcard
or variable expansion. There is no support for escaping or quoting
whitespace to be included in arguments. The standard
‘--’ to stop option processing
also disables at-file processing. Note that while
‘--’ can be used
inside an
at-file, it only disables option processing within that at-file, and
processing continues in the parent scope.
Warnings are diagnostic messages that indicate possibly erroneous behavior that does not necessarily compromise the header-fixing process. The following options alter the way warnings are processed.
-Werror-Wno-error to prevent turning all warnings into
errors.-Werror=-Werror=obsolete), and this
warning is implicitly enabled and turned into an error. This can be
negated as -Wno-error= to prevent turning a
specified warning into an error, even if -Werror
is in effect.The following warnings are “meta” warnings, that enable a collection of other warnings. If a specific warning is toggled via a meta flag and a specific one, the more specific one takes priority. The position on the command-line acts as a tie breaker, the last one taking effect.
-Wall-WeverythingThe following warnings are actual warning flags; with each
description, the corresponding warning flag is included. Note that each of
these flags also has a negation (for example,
-Wobsolete enables the warning that
-Wno-obsolete disables; and
-Wall enables every warning that
-Wno-all disables). Only the non-default flag is
listed here. Ignoring the “no-” prefix, entries are listed
alphabetically.
-Wno-mbc-Wno-obsolete-Wno-overwrite-Wno-sgb-s) conflicts with the old
licensee code (-l).-Wno-truncationMost values in the ROM header do not matter to the actual console, and most are seldom useful anyway. The bare minimum requirements for a workable program are the header checksum, the Nintendo logo, and (if needed) the CGB/SGB flags. It is a good idea to pad the image to a valid size as well (“valid” meaning a power of 2, times 32 KiB).
The following will make a plain, non-color Game Boy game without checking for a valid size:
The following will make a SGB-enabled, color-enabled game with a title of “foobar”, and pad it to a valid size. (The Game Boy itself does not use the title, but some emulators or ROM managers do.)
The following will duplicate the header of the game “Survival Kids”, sans global checksum:
TPP1 is a homebrew mapper designed as a functional superset of the common traditional MBCs, allowing larger ROM and RAM sizes combined with other hardware features. Its specification, as well as more resources, can be found online at https://github.com/aaaaaa123456789/tpp1.
The MBC name for TPP1 is more complex than standard mappers. It
must be followed with the revision number, of the form
‘major.minor’, where both
‘major’ and
‘minor’ are decimal, 8-bit integers.
There may be any amount of spaces or underscores between
‘TPP1’ and the revision number.
rgbfix only supports 1.x revisions, and will reject
everything else.
Like other mappers, the name may be followed with a list of
optional, ‘+’-separated features;
however, ‘RAM’ should not be
specified, as the TPP1 mapper implicitly requests RAM if a non-zero RAM size
is specified. Therefore, rgbfix will ignore the
‘RAM’ feature on a TPP1 mapper.
TPP1 overwrites the byte at 0x14A, usually
indicating the region destination (see -j), with one
of its three identification bytes. Therefore, rgbfix
will warn about and ignore -j if used in combination
with TPP1.
Please report bugs or mistakes in this documentation on GitHub.
rgbfix was originally written by
Carsten Sørensen as a standalone program
called GBFix, which was then packaged in ASMotor, and was later repackaged
in RGBDS by Justin Lloyd. It is now maintained by a
number of contributors at
https://github.com/gbdev/rgbds.