GBDK 2020 Docs
4.3.0
API Documentation for GBDK 2020
|
GBDK 2020 uses the SDCC compiler along with some custom tools to build Game Boy ROMs.
bin/
To see individual arguments and options for a tool, run that tool from the command line with either no arguments or with -h
.
For data types and special C keywords, see asm/sm83/types.h and asm/types.h.
Also see the SDCC manual (scroll down a little on the linked page): http://sdcc.sourceforge.net/doc/sdccman.pdf#section.1.1
It is possible to change some of the important addresses used by the toolchain at link time using the -Wl-g XXX=YYY and =Wl-b XXX=YYY flags (where XXX is the name of the data, and YYY is the new address).
lcc will include the following linker defaults for sdldgb if they are not defined by the user.
_shadow_OAM
-Wl-g _shadow_OAM=0xC000
.STACK
-Wl-g .STACK=0xE000
.refresh_OAM
-Wl-g .refresh_OAM=0xFF80
_DATA
-Wl-b _DATA=0xc0A0
_CODE
-Wl-b _CODE=0x0200
The lcc program is the front end compiler driver for the actual compiler, assembler and linker. It works out what you want to do based on command line options and the extensions of the files you give it, computes the order in which the various programs must be called and then executes them in order. Some examples are:
lcc -o image.gb source.c
lcc -o image.gb source.s
lcc -c -o object1.o source1.c
lcc -c -o object2.o source2.s
lcc -o image.gb object1.o object2.o
lcc -o image.gb source1.c source2.sArguments to the assembler, linker, etc can be passed via lcc using -Wp..., -Wf..., -Wa... and -Wl... to pass options to the pre-processor, compiler, assembler and linker respectively. Some common options are:
-Wa-l
-Wl-m
-Wl-gvar=addrFor example, to compile the example in the memory section and to generate a listing and map file you would use the following. Note the leading underscore that C adds to symbol names.
lcc -Wa-l -Wl-m -Wl-g_snd_stat=0xff26 -o image.gb hardware.c
Please see the sample projects included with GBDK-2020 for a couple different examples of how to use Makefiles.
You may also want to read a tutorial on Makefiles. For example:
https://makefiletutorial.com/
https://www.tutorialspoint.com/makefile/index.htm
When bankpack is called through lcc it will now always use linkerfile output (-lkout=
) for passing files to the linker (all input object files and linkerfiles will get get consolidated to a single linkerfile).
Bankpack:
lkin=<filename>
: Adds a input linkerfile (can specify multiple ones)-lkout=<filename>
: Enables linkerfile output and sets name (only one can be specified). ALL loaded object files, both from the command line and any loaded from linkerfiles will have their names written to this single output.LCC + Bankpack:
lcc
passes all input linkerfiles (from -Wl-f<name>
) to bankpack (-lkin=
)bankpack
(-lkout=
)lcc
clears out the linker object file and linkerfile lists, then uses the single linkerfile generated by bankpack
Also see the linkerfile
example project.
lcc is the compiler driver (front end) for the GBDK/sdcc toolchain.
For detailed settings see lcc-settings
It can be used to invoke all the tools needed for building a rom. If preferred, the individual tools can be called directly.
-v
flag can be used to show the exact steps lcc executes for a buildlcc -o somerom.gb somesource.c
-debug
flag that will turn on the following recommended flags for debugging
SDCC C Source compiler.
For detailed settings see sdcc-settings
-Wf-<argument>
and -Wp-<argument>
(pre-processor)SDCC Assembler for the Game Boy.
For detailed settings see sdasgb-settings
-Wa-<argument>
Automatic Bank packer.
For detailed settings see bankpack-settings
When enabled, automatically assigns banks for object files where bank has been set to 255
, see rom_autobanking. Unless an alternative output is specified the given object files are updated with the new bank numbers.
-autobank
argument with lcc.-Wb-<argument>
The SDCC linker for the gameboy.
For detailed settings see sdldgb-settings
Links object files (.o) into a .ihx file which can be processed by makebin
-Wl-<argument>
IHX file validator.
For detailed settings see ihxcheck-settings
Checks .ihx files produced by sdldgb for correctness.
-Wi-<argument>
IHX to ROM converter.
-yt
MBC values see setting_mbc_and_rom_ram_banksConverts .ihx files produced by sdldgb into ROM files (.gb, .gbc). Also used for setting some ROM header data.
-Wm-<argument>
Compression utility.
For detailed settings see gbcompress-settings
Compresses (and decompresses) binary file data with the gbcompress algorithm (also used in GBTD/GBMB). Decompression support is available in GBDK:
cross-platform/gbdecompress
example demonstrates how to use this compressionThe utility can also compress (and decompress) using block style RLE encoding with the --alg=rle
flag. Decompression support is available in GBDK:
cross-platform/rle_map
example demonstrates how to use this compressionTool for converting PNGs into GBDK format MetaSprites and Tile Maps.
-map
is used, converts images into Tile Maps and matching Tile SetsFor detailed settings see png2asset-settings
For working with sprite properties (including cgb palettes), see metasprite_and_sprite_properties
For API support see move_metasprite() and related functions in metasprites.h
-px
and -py
.-spr8x8
) and SPRITES_8x16 mode (-spr8x16
). If 8x16 mode is used then the height of the metasprite must be a multiple of 16.The following abbreviations are used in this section:
DMG
CGB
png2asset accepts any png as input, although that does not mean any image will be valid. The program will follow the next steps:
DMG
devices).With all this, the program will generate a new indexed image (with palette), where each 4 colors define a palette and all colors within a tile can only have colors from one of these palettes
It is also posible to pass a indexed 8-bit png with the palette properly sorted out, using -keep_palette_order
For indexed color images, sometimes RGB paint programs mix up indexed colors in tiles if the same color exists in multiple palettes.
-repair_indexed_pal
can be used to fix this problem, though tiles must still follow the rule of using only one palette per tile.Using this image a tileset will be created
-noflip
to turn off matching mirrored tiles).Passing -map
the png can be converted to a map that can be used in both the background and the window. In this case, png2asset will generate:
DMG
and CGB
devices.-use_map_attributes
will create an array of map attributes. It will also add mirroring info for each tile and because of that maps created with this won't be compatible with DMG
.-noflip
to make background maps which are compatible with DMG
devices.By default the png will be converted to metasprites. The image will be subdivided into meta sprites of -sw
x -sh
. In this case png2asset will generate:
Screen border assets for the Super Game Boy can be generated using png2asset.
The following flags should be used to perform the conversion:
<input_border_file.png> -map -bpp 4 -max_palettes 4 -pack_mode sgb -use_map_attributes -c <output_border_data.c>
<input_border_file.png>
is the image of the SGB border (256x224) and <output_border_data.c>
is the name of the source file to write the assets out to.See the sgb_border
example project for more details.
Converts a binary .rom file to .msxdos com format, including splitting the banks up into separate files.
An updated version of Glen Cook's Windows GUI "hicolour.exe" 1.2 conversion tool for the Game Boy Color. The starting code base was the 1.2 release.
For the current GBDK example ISR implementation there is a limit of 6 sprites per line before the hi-color timing breaks down and there start to be background artifacts.
Example: png2hicolorgb myimage.png --csource -o=my_output_filename
Example with higher quality (slower conversion): png2hicolorgb myimage.png --csource -o=my_output_filename --type=3 -L=2 -R=2
For technical details about the conversion process and rendering, see: https://github.com/bbbbbr/png2hicolorgb
A utility for estimating usage of Game Boy and SMS/GG ROMs from .noi and .map files, binary ROMs and more.
Example: romusage myprogram.noi -g