cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

20_toolchain_settings.md (21202B)


      1@page docs_toolchain_settings Toolchain settings
      2@anchor lcc-settings
      3# lcc settings
      4```
      5./lcc [ option | file ]...
      6	except for -l, options are processed left-to-right before files
      7	unrecognized options are taken to be linker options
      8-A	warn about nonANSI usage; 2nd -A warns more
      9-b	emit expression-level profiling code; see bprint(1)
     10-Bdir/	use the compiler named `dir/rcc'
     11-c	compile only
     12-dn	set switch statement density to `n'
     13-debug	Turns on --debug for compiler, -y (.cdb) and -j (.noi) for linker
     14-Dname -Dname=def	define the preprocessor symbol `name'
     15-E	run only the preprocessor on the named C programs and unsuffixed files
     16-g	produce symbol table information for debuggers
     17-help or -?	print this message
     18-Idir	add `dir' to the beginning of the list of #include directories
     19-K don't run ihxcheck test on linker ihx output
     20-lx	search library `x'
     21-m	select port and platform: "-m[port]:[plat]" ports:gbz80,z80 plats:ap,duck,gb,sms,gg
     22-N	do not search the standard directories for #include files
     23-n	emit code to check for dereferencing zero pointers
     24-no-crt do not auto-include the gbdk crt0.o runtime in linker list
     25-no-libs do not auto-include the gbdk libs in linker list
     26-O	is ignored
     27-o file	leave the output in `file'
     28-P	print ANSI-style declarations for globals
     29-p -pg	emit profiling code; see prof(1) and gprof(1)
     30-S	compile to assembly language
     31-autobank auto-assign banks set to 255 (bankpack)
     32-static	specify static libraries (default is dynamic)
     33-t -tname	emit function tracing calls to printf or to `name'
     34-target name	is ignored
     35-tempdir=dir	place temporary files in `dir/'; default=/tmp
     36-Uname	undefine the preprocessor symbol `name'
     37-v	show commands as they are executed; 2nd -v suppresses execution
     38-w	suppress warnings
     39-Woarg	specify system-specific `arg'
     40-W[pfablim]arg	pass `arg' to the preprocessor, compiler, assembler, bankpack, linker, ihxcheck, or makebin
     41```
     42@anchor sdcc-settings
     43# sdcc settings
     44```
     45SDCC : z80/gbz80 4.1.6 #12539 (Linux)
     46published under GNU General Public License (GPL)
     47Usage : sdcc [options] filename
     48Options :-
     49
     50General options:
     51      --help                Display this help
     52  -v  --version             Display sdcc's version
     53      --verbose             Trace calls to the preprocessor, assembler, and linker
     54  -V                        Execute verbosely. Show sub commands as they are run
     55  -d                        Output list of macro definitions in effect. Use with -E
     56  -D                        Define macro as in -Dmacro
     57  -I                        Add to the include (*.h) path, as in -Ipath
     58  -A                        
     59  -U                        Undefine macro as in -Umacro
     60  -M                        Preprocessor option
     61  -W                        Pass through options to the pre-processor (p), assembler (a) or linker (l)
     62  -S                        Compile only; do not assemble or link
     63  -c  --compile-only        Compile and assemble, but do not link
     64  -E  --preprocessonly      Preprocess only, do not compile
     65      --c1mode              Act in c1 mode.  The standard input is preprocessed code, the output is assembly code.
     66  -o                        Place the output into the given path resp. file
     67  -x                        Optional file type override (c, c-header or none), valid until the next -x
     68      --print-search-dirs   display the directories in the compiler's search path
     69      --vc                  messages are compatible with Micro$oft visual studio
     70      --use-stdout          send errors to stdout instead of stderr
     71      --nostdlib            Do not include the standard library directory in the search path
     72      --nostdinc            Do not include the standard include directory in the search path
     73      --less-pedantic       Disable some of the more pedantic warnings
     74      --disable-warning     <nnnn> Disable specific warning
     75      --Werror              Treat the warnings as errors
     76      --debug               Enable debugging symbol output
     77      --cyclomatic          Display complexity of compiled functions
     78      --std-c89             Use ISO C90 (aka ANSI C89) standard (slightly incomplete)
     79      --std-sdcc89          Use ISO C90 (aka ANSI C89) standard with SDCC extensions
     80      --std-c95             Use ISO C95 (aka ISO C94) standard (slightly incomplete)
     81      --std-c99             Use ISO C99 standard (incomplete)
     82      --std-sdcc99          Use ISO C99 standard with SDCC extensions
     83      --std-c11             Use ISO C11 standard (incomplete)
     84      --std-sdcc11          Use ISO C11 standard with SDCC extensions (default)
     85      --std-c2x             Use ISO C2X standard (incomplete)
     86      --std-sdcc2x          Use ISO C2X standard with SDCC extensions
     87      --fdollars-in-identifiers  Permit '$' as an identifier character
     88      --fsigned-char        Make "char" signed by default
     89      --use-non-free        Search / include non-free licensed libraries and header files
     90
     91Code generation options:
     92  -m                        Set the port to use e.g. -mz80.
     93  -p                        Select port specific processor e.g. -mpic14 -p16f84
     94      --stack-auto          Stack automatic variables
     95      --xstack              Use external stack
     96      --int-long-reent      Use reentrant calls on the int and long support functions
     97      --float-reent         Use reentrant calls on the float support functions
     98      --xram-movc           Use movc instead of movx to read xram (xdata)
     99      --callee-saves        <func[,func,...]> Cause the called function to save registers instead of the caller
    100      --profile             On supported ports, generate extra profiling information
    101      --fomit-frame-pointer  Leave out the frame pointer.
    102      --all-callee-saves    callee will always save registers used
    103      --stack-probe         insert call to function __stack_probe at each function prologue
    104      --no-xinit-opt        don't memcpy initialized xram from code
    105      --no-c-code-in-asm    don't include c-code as comments in the asm file
    106      --no-peep-comments    don't include peephole optimizer comments
    107      --codeseg             <name> use this name for the code segment
    108      --constseg            <name> use this name for the const segment
    109      --dataseg             <name> use this name for the data segment
    110
    111Optimization options:
    112      --nooverlay           Disable overlaying leaf function auto variables
    113      --nogcse              Disable the GCSE optimisation
    114      --nolabelopt          Disable label optimisation
    115      --noinvariant         Disable optimisation of invariants
    116      --noinduction         Disable loop variable induction
    117      --noloopreverse       Disable the loop reverse optimisation
    118      --no-peep             Disable the peephole assembly file optimisation
    119      --no-reg-params       On some ports, disable passing some parameters in registers
    120      --peep-asm            Enable peephole optimization on inline assembly
    121      --peep-return         Enable peephole optimization for return instructions
    122      --no-peep-return      Disable peephole optimization for return instructions
    123      --peep-file           <file> use this extra peephole file
    124      --opt-code-speed      Optimize for code speed rather than size
    125      --opt-code-size       Optimize for code size rather than speed
    126      --max-allocs-per-node  Maximum number of register assignments considered at each node of the tree decomposition
    127      --nolospre            Disable lospre
    128      --allow-unsafe-read   Allow optimizations to read any memory location anytime
    129      --nostdlibcall        Disable optimization of calls to standard library
    130
    131Internal debugging options:
    132      --dump-ast            Dump front-end AST before generating i-code
    133      --dump-i-code         Dump the i-code structure at all stages
    134      --dump-graphs         Dump graphs (control-flow, conflict, etc)
    135      --i-code-in-asm       Include i-code as comments in the asm file
    136      --fverbose-asm        Include code generator comments in the asm output
    137
    138Linker options:
    139  -l                        Include the given library in the link
    140  -L                        Add the next field to the library search path
    141      --lib-path            <path> use this path to search for libraries
    142      --out-fmt-ihx         Output in Intel hex format
    143      --out-fmt-s19         Output in S19 hex format
    144      --xram-loc            <nnnn> External Ram start location
    145      --xram-size           <nnnn> External Ram size
    146      --iram-size           <nnnn> Internal Ram size
    147      --xstack-loc          <nnnn> External Stack start location
    148      --code-loc            <nnnn> Code Segment Location
    149      --code-size           <nnnn> Code Segment size
    150      --stack-loc           <nnnn> Stack pointer initial value
    151      --data-loc            <nnnn> Direct data start location
    152      --idata-loc           
    153      --no-optsdcc-in-asm   Do not emit .optsdcc in asm
    154
    155Special options for the z80 port:
    156      --callee-saves-bc     Force a called function to always save BC
    157      --portmode=           Determine PORT I/O mode (z80/z180)
    158      --asm=                Define assembler name (rgbds/asxxxx/isas/z80asm/gas)
    159      --codeseg             <name> use this name for the code segment
    160      --constseg            <name> use this name for the const segment
    161      --dataseg             <name> use this name for the data segment
    162      --no-std-crt0         For the z80/gbz80 do not link default crt0.rel
    163      --reserve-regs-iy     Do not use IY (incompatible with --fomit-frame-pointer)
    164      --oldralloc           Use old register allocator (deprecated)
    165      --fno-omit-frame-pointer  Do not omit frame pointer
    166      --emit-externs        Emit externs list in generated asm
    167      --legacy-banking      Use legacy method to call banked functions
    168      --nmos-z80            Generate workaround for NMOS Z80 when saving IFF2
    169
    170Special options for the gbz80 port:
    171      -bo                   <num> use code bank <num>
    172      -ba                   <num> use data bank <num>
    173      --asm=                Define assembler name (rgbds/asxxxx/isas/z80asm/gas)
    174      --callee-saves-bc     Force a called function to always save BC
    175      --codeseg             <name> use this name for the code segment
    176      --constseg            <name> use this name for the const segment
    177      --dataseg             <name> use this name for the data segment
    178      --no-std-crt0         For the z80/gbz80 do not link default crt0.rel
    179      --legacy-banking      Use legacy method to call banked functions
    180```
    181@anchor sdasgb-settings
    182# sdasgb settings
    183```
    184
    185sdas Assembler V02.00 + NoICE + SDCC mods  (GameBoy Z80-like CPU)
    186
    187
    188Copyright (C) 2012  Alan R. Baldwin
    189This program comes with ABSOLUTELY NO WARRANTY.
    190
    191Usage: [-Options] file
    192Usage: [-Options] outfile file1 [file2 file3 ...]
    193  -d   Decimal listing
    194  -q   Octal   listing
    195  -x   Hex     listing (default)
    196  -g   Undefined symbols made global
    197  -n   Don't resolve global assigned value symbols
    198  -a   All user symbols made global
    199  -b   Display .define substitutions in listing
    200  -bb  and display without .define substitutions
    201  -c   Disable instruction cycle count in listing
    202  -j   Enable NoICE Debug Symbols
    203  -y   Enable SDCC  Debug Symbols
    204  -l   Create list   file/outfile[.lst]
    205  -o   Create object file/outfile[.rel]
    206  -s   Create symbol file/outfile[.sym]
    207  -p   Disable automatic listing pagination
    208  -u   Disable .list/.nlist processing
    209  -w   Wide listing format for symbol table
    210  -z   Disable case sensitivity for symbols
    211  -f   Flag relocatable references by  `   in listing file
    212  -ff  Flag relocatable references by mode in listing file
    213  -I   Add the named directory to the include file
    214       search path.  This option may be used more than once.
    215       Directories are searched in the order given.
    216
    217removing 
    218```
    219@anchor sdasz80-settings
    220# sdasz80 settings
    221```
    222
    223sdas Assembler V02.00 + NoICE + SDCC mods  (GameBoy Z80-like CPU)
    224
    225
    226Copyright (C) 2012  Alan R. Baldwin
    227This program comes with ABSOLUTELY NO WARRANTY.
    228
    229Usage: [-Options] file
    230Usage: [-Options] outfile file1 [file2 file3 ...]
    231  -d   Decimal listing
    232  -q   Octal   listing
    233  -x   Hex     listing (default)
    234  -g   Undefined symbols made global
    235  -n   Don't resolve global assigned value symbols
    236  -a   All user symbols made global
    237  -b   Display .define substitutions in listing
    238  -bb  and display without .define substitutions
    239  -c   Disable instruction cycle count in listing
    240  -j   Enable NoICE Debug Symbols
    241  -y   Enable SDCC  Debug Symbols
    242  -l   Create list   file/outfile[.lst]
    243  -o   Create object file/outfile[.rel]
    244  -s   Create symbol file/outfile[.sym]
    245  -p   Disable automatic listing pagination
    246  -u   Disable .list/.nlist processing
    247  -w   Wide listing format for symbol table
    248  -z   Disable case sensitivity for symbols
    249  -f   Flag relocatable references by  `   in listing file
    250  -ff  Flag relocatable references by mode in listing file
    251  -I   Add the named directory to the include file
    252       search path.  This option may be used more than once.
    253       Directories are searched in the order given.
    254
    255removing 
    256```
    257@anchor bankpack-settings
    258# bankpack settings
    259```
    260bankalloc [options] objfile1 objfile2 etc
    261Use: Read .o files and auto-assign areas with bank=255.
    262     Typically called by Lcc compiler driver before linker.
    263
    264Options
    265-h           : Show this help
    266-lkin=<file> : Load object files specified in linker file <file>
    267-lkout=<file>: Write list of object files out to linker file <file>
    268-yt<mbctype> : Set MBC type per ROM byte 149 in Decimal or Hex (0xNN) (see pandocs)
    269-mbc=N       : Similar to -yt, but sets MBC type directly to N instead
    270               of by intepreting ROM byte 149
    271               mbc1 will exclude banks {0x20,0x40,0x60} max=127, 
    272               mbc2 max=15, mbc3 max=127, mbc5 max=255 (not 511!) 
    273-min=N       : Min assigned ROM bank is N (default 1)
    274-max=N       : Max assigned ROM bank is N, error if exceeded
    275-ext=<.ext>  : Write files out with <.ext> instead of source extension
    276-path=<path> : Write files out to <path> (<path> *MUST* already exist)
    277-sym=<prefix>: Add symbols starting with <prefix> to match + update list.
    278               Default entry is "___bank_" (see below)
    279-cartsize    : Print min required cart size as "autocartsize:<NNN>"
    280-plat=<plat> : Select platform specific behavior (default:gb) (gb,sms)
    281-random      : Distribute banks randomly for testing (honors -min/-max)
    282-v           : Verbose output, show assignments
    283
    284Example: "bankpack -ext=.rel -path=some/newpath/ file1.o file2.o"
    285Unless -ext or -path specify otherwise, input files are overwritten.
    286
    287Default MBC type is not set. It *must* be specified by -mbc= or -yt!
    288
    289The following will have FF and 255 replaced with the assigned bank:
    290A _CODE_255 size <size> flags <flags> addr <address>
    291S b_<function name> Def0000FF
    292S ___bank_<const name> Def0000FF
    293    (Above can be made by: const void __at(255) __bank_<const name>;
    294```
    295@anchor sdldgb-settings
    296# sdldgb settings
    297```
    298
    299sdld Linker V03.00 + NoICE + sdld
    300
    301Usage: [-Options] [-Option with arg] file
    302Usage: [-Options] [-Option with arg] outfile file1 [file2 ...]
    303Startup:
    304  -p   Echo commands to stdout (default)
    305  -n   No echo of commands to stdout
    306Alternates to Command Line Input:
    307  -c                   ASlink >> prompt input
    308  -f   file[.lk]       Command File input
    309Libraries:
    310  -k   Library path specification, one per -k
    311  -l   Library file specification, one per -l
    312Relocation:
    313  -b   area base address = expression
    314  -g   global symbol = expression
    315  -a   (platform) Select platform specific virtual address translation
    316Map format:
    317  -m   Map output generated as (out)file[.map]
    318  -w   Wide listing format for map file
    319  -x   Hexadecimal (default)
    320  -d   Decimal
    321  -q   Octal
    322Output:
    323  -i   Intel Hex as (out)file[.ihx]
    324  -s   Motorola S Record as (out)file[.s19]
    325  -j   NoICE Debug output as (out)file[.noi]
    326  -y   SDCDB Debug output as (out)file[.cdb]
    327List:
    328  -u   Update listing file(s) with link data as file(s)[.rst]
    329Case Sensitivity:
    330  -z   Disable Case Sensitivity for Symbols
    331End:
    332  -e   or null line terminates input
    333
    334```
    335@anchor sdldz80-settings
    336# sdldz80 settings
    337```
    338
    339sdld Linker V03.00 + NoICE + sdld
    340
    341Usage: [-Options] [-Option with arg] file
    342Usage: [-Options] [-Option with arg] outfile file1 [file2 ...]
    343Startup:
    344  -p   Echo commands to stdout (default)
    345  -n   No echo of commands to stdout
    346Alternates to Command Line Input:
    347  -c                   ASlink >> prompt input
    348  -f   file[.lk]       Command File input
    349Libraries:
    350  -k   Library path specification, one per -k
    351  -l   Library file specification, one per -l
    352Relocation:
    353  -b   area base address = expression
    354  -g   global symbol = expression
    355  -a   (platform) Select platform specific virtual address translation
    356Map format:
    357  -m   Map output generated as (out)file[.map]
    358  -w   Wide listing format for map file
    359  -x   Hexadecimal (default)
    360  -d   Decimal
    361  -q   Octal
    362Output:
    363  -i   Intel Hex as (out)file[.ihx]
    364  -s   Motorola S Record as (out)file[.s19]
    365  -j   NoICE Debug output as (out)file[.noi]
    366  -y   SDCDB Debug output as (out)file[.cdb]
    367List:
    368  -u   Update listing file(s) with link data as file(s)[.rst]
    369Case Sensitivity:
    370  -z   Disable Case Sensitivity for Symbols
    371End:
    372  -e   or null line terminates input
    373
    374```
    375@anchor ihxcheck-settings
    376# ihxcheck settings
    377```
    378ihx_check input_file.ihx [options]
    379
    380Options
    381-h : Show this help
    382-e : Treat warnings as errors
    383
    384Use: Read a .ihx and warn about overlapped areas.
    385Example: "ihx_check build/MyProject.ihx"
    386```
    387@anchor makebin-settings
    388# makebin settings
    389Also see @ref setting_mbc_and_rom_ram_banks
    390```
    391makebin: convert a Intel IHX file to binary or GameBoy format binary.
    392Usage: makebin [options] [<in_file> [<out_file>]]
    393Options:
    394  -p             pack mode: the binary file size will be truncated to the last occupied byte
    395  -s romsize     size of the binary file (default: rom banks * 16384)
    396  -Z             generate GameBoy format binary file
    397  -S             generate Sega Master System format binary file
    398SMS format options (applicable only with -S option):
    399  -xo n          rom size (0xa-0x2)
    400  -xj n          set region code (3-7)
    401  -xv n          version number (0-15)
    402GameBoy format options (applicable only with -Z option):
    403  -yo n          number of rom banks (default: 2) (autosize: A)
    404  -ya n          number of ram banks (default: 0)
    405  -yt n          MBC type (default: no MBC)
    406  -yl n          old licensee code (default: 0x33)
    407  -yk cc         new licensee string (default: 00)
    408  -yn name       cartridge name (default: none)
    409  -yc            GameBoy Color compatible
    410  -yC            GameBoy Color only
    411  -ys            Super GameBoy
    412  -yS            Convert .noi file named like input file to .sym
    413  -yj            set non-Japanese region flag
    414  -yN            do not copy big N validation logo into ROM header
    415  -yp addr=value Set address in ROM to given value (address 0x100-0x1FE)
    416Arguments:
    417  <in_file>      optional IHX input file, '-' means stdin. (default: stdin)
    418  <out_file>     optional output file, '-' means stdout. (default: stdout)
    419```
    420@anchor gbcompress-settings
    421# gbcompress settings
    422```
    423gbcompress [options] infile outfile
    424Use: compress a binary file and write it out.
    425
    426Options
    427-h    : Show this help screen
    428-d    : Decompress (default is compress)
    429-v    : Verbose output
    430--cin  : Read input as .c source format (8 bit char ONLY, uses first array found)
    431--cout : Write output in .c / .h source format (8 bit char ONLY) 
    432--varname=<NAME> : specify variable name for c source output
    433--alg=<type>     : specify compression type: 'rle', 'gb' (default)
    434Example: "gbcompress binaryfile.bin compressed.bin"
    435Example: "gbcompress -d compressedfile.bin decompressed.bin"
    436Example: "gbcompress --alg=rle binaryfile.bin compressed.bin"
    437
    438The default compression (gb) is the type used by gbtd/gbmb
    439The rle compression is Amiga IFF style
    440```
    441@anchor png2asset-settings
    442# png2asset settings
    443```
    444usage: png2asset    <file>.png [options]
    445-c                  ouput file (default: <png file>.c)
    446-sw <width>         metasprites width size (default: png width)
    447-sh <height>        metasprites height size (default: png height)
    448-sp <props>         change default for sprite OAM property bytes (in hex) (default: 0x00)
    449-px <x coord>       metasprites pivot x coordinate (default: metasprites width / 2)
    450-py <y coord>       metasprites pivot y coordinate (default: metasprites height / 2)
    451-pw <width>         metasprites collision rect widht (default: metasprites width)
    452-ph <height>        metasprites collision rect height (default: metasprites height)
    453-spr8x8             use SPRITES_8x8 (default: SPRITES_8x16)
    454-spr8x16            use SPRITES_8x16 (default: SPRITES_8x16)
    455-b <bank>           bank (default 0)
    456-keep_palette_order use png palette
    457-noflip             disable tile flip
    458-map                Export as map (tileset + bg)
    459-use_map_attributes Use CGB BG Map attributes (default: palettes are stored for each tile in a separate array)
    460-use_structs        Group the exported info into structs (default: false) (used by ZGB Game Engine)
    461-bpp                bits per pixel: 2, 4 (default: 2)
    462-max_palettes       maximum number of palettes allowed (default: 2)
    463-pack_mode          gb, sgb or sms (default:GB)
    464-tile_origin        tile index offset for maps (instead of zero)
    465```