rgblink |
[-dhMtVvwx] [-B
param] [--color
when] [-l
linker_script] [-m
map_file] [-n
sym_file] [-O
overlay_file] [-o
out_file] [-p
pad_value] [-S
spec] [-W
warning] file ... |
The rgblink program links RGB object
files, typically created by rgbasm(1), into a single Game
Boy ROM file. The object file format is documented in
rgbds(5).
ROM0 sections are placed in the first 16 KiB of the output ROM,
and ROMX sections are placed in any 16 KiB “bank” except the
first. If your ROM will only be 32 KiB, you can use the
-t option to change this.
Similarly, WRAM0 sections are placed in the first 4 KiB of WRAM
(“bank 0”), and WRAMX sections are placed in any bank of the
last 4 KiB. If your ROM doesn't use banked WRAM, you can use the
-w option to change this.
Also, if your ROM is designed for a monochrome Game Boy, you can
make sure that you don't use any incompatible section by using the
-d option, which implies -w
but also prohibits the use of banked VRAM.
rgblink 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: --verb is
--verbose, but --ver is
invalid because it could also be --version.
Unless otherwise noted, passing
‘-’ (a single dash) as a file name
makes rgblink 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.
rgblink 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:
-B
param, --backtrace
param0allno-allcollapseno-collapse--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.-d,
--dmg-w.-h,
--help-l
linker_script, --linkerscript
linker_script-M,
--no-sym-in-map-m
map_file, --map
map_file-n
sym_file, --sym
sym_file-O
overlay_file, --overlay
overlay_file-o
out_file, --output
out_file-p
pad_value, --pad
pad_value-S
spec, --scramble
spec-t,
--tiny-V,
--version-v,
--verbosergblink configuration before taking
actions.Note that verbose output is only intended to be consumed by humans, and may change without notice between RGBDS releases; relying on those for scripts is not advised.
-W
warning, --warning
warning-w,
--wramx-x,
--nopad-t. You can use this to make binary files
that are not a ROM. When making a ROM, note that not using this is not a
replacement for rgbfix(1)'s -p
option!#’) 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.
The default section placement algorithm tries to place sections
into as few banks as possible. (It turns out that section placement is an
NP-complete problem known as "bin packing", so
rgblink does not attempt to find the optimal
solution, but instead uses a "first-fit" heuristic to find a good
one in a reasonable amount of time. There are no guarantees about where this
algorithm will place sections, apart from the bank, address, and alignment
constraints manually specified for the sections.)
“Scrambling” instead places sections into a given pool of banks, trying to minimize the number of sections sharing a given bank. This is useful to catch broken bank assumptions, such as expecting two different sections to land in the same bank (that is not guaranteed unless both are manually assigned the same bank number).
A scrambling spec is a comma-separated list of region specs. A trailing comma is allowed, as well as whitespace between all specs and their components. Each region spec has the following form:
| Region name | Max size | Size optional |
romx |
65535 | No |
sram |
255 | No |
wramx |
7 | Yes |
A size of 0 disables scrambling for that region.
For example,
‘romx=64,wramx=4’ will scramble
ROMX sections among ROM banks 1 to 64,
WRAMX sections among RAM banks 1 to 4, and will not
scramble SRAM sections.
Later region specs override earlier ones; for example,
‘romx=42, Romx=0’ disables scrambling
for romx.
wramx scrambling is silently ignored if
-w is passed (including if implied by
-d), as WRAMX sections will
be treated as WRAM0.
Warnings are diagnostic messages that indicate possibly erroneous behavior that does not necessarily compromise the linking 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-assertWARN-type
assertions fail. (See “Aborting the assembly process” in
rgbasm(5) for ASSERT).-Wdiv-Wall.-Wno-obsolete-Wshift-Wall.-Wshift-amount-Wall.-Wtruncation=db
to an 8-bit value) loses some bits. -Wtruncation=0
or -Wno-truncation disables this warning.
-Wtruncation=1 or just
-Wtruncation warns when an N-bit value is 2**N or
greater, or less than -2**N. -Wtruncation=2 also
warns when an N-bit value is less than -2**(N-1), which will not fit in
two's complement encoding.All you need for a basic ROM is an object file, which can be made into a ROM image like so:
$ rgblink -o bar.gb
foo.oThe resulting bar.gb will not have correct checksums (unless you put them in the assembly source). You should use rgbfix(1) to fix these so that the program will actually run in a Game Boy:
$ rgbfix -v bar.gbHere is a more complete example:
$ rgblink -o bin/game.gb -n
bin/game.sym -p 0xFF obj/title.o obj/engine.oPlease report bugs or mistakes in this documentation on GitHub.
rgbasm(1), rgblink(5), rgbfix(1), rgbgfx(1), gbz80(7), rgbds(5), rgbds(7)
rgblink was originally written by
Carsten Sørensen as part of the ASMotor
package, and was later repackaged in RGBDS by Justin
Lloyd. It is now maintained by a number of contributors at
https://github.com/gbdev/rgbds.