git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

docs/pages/08_faq.md

      1 @page docs_faq Frequently Asked Questions (FAQ)
      2 
      3 @anchor toolchain_faq 
      4 
      5 # General
      6   - How can sound effects be made?
      7     - The simplest way is to use the Game Boy sound hardware directly. See the @ref examples_sound_sample "Sound Example" for a way to test out sounds on the hardware.
      8     - Further discussion on using the Sound Example rom can be found in the ZGB wiki. Note that some example code there is ZGB specific and not part of the base GBDK API: https://github.com/Zal0/ZGB/wiki/Sounds <!-- -->
      9 
     10 # Licensing
     11   - What license information is required when distributing the compiled ROM (binary) of my game or program?
     12     - There is no requirement to include or credit any of the GBDK-2020 licenses or authors, although credit of GBDK-2020 is appreciated.
     13     - This is different and separate from redistributing the GBDK-2020 dev environment itself (or the GBDK-2020 sources) which does require the licenses. <!-- -->
     14 
     15 # Graphics and Resources
     16   - How do I use a tile map when its tiles don't start at index zero?
     17     - The two main options are:
     18       - Use @ref set_bkg_based_tiles(), @ref set_bkg_based_submap(), @ref set_win_based_tiles(), @ref set_win_based_submap() and provide a tile origin offset.
     19       - Use @ref utility_png2asset with `-tile_origin` to create a map with the tile index offsets built in.
     20 
     21   - Is it normal for sprites to disappear when they reach the left border of the screen? (NES/SMS/MSX)
     22     - You can hide the leftmost column using @ref HIDE_LEFT_COLUMN to work around this.
     23     - The behavior is due to NES/SMS/MSX having 8-bit Sprite x coordinates while the screen width is also 256 pixels. GB/GG don't have this problem since their screen is smaller and the x-coordinates are larger than the visible screen.
     24       <!-- -->  
     25 
     26 # ROM Header Settings
     27   - How do I set the ROM's title?
     28     - Use the @ref makebin `-yn` flag. For example with @ref lcc `-Wm-yn"MYTITLE"` or with @ref makebin directly `-yn "MYTITLE"`. The maximum length is up to 15 characters, but may be shorter.
     29     - See "0134-0143 - Title" in @ref Pandocs for more details. <!-- -->  
     30 
     31   @anchor faq_gb_type_header_setting
     32   - How do I set SGB, Color only and Color compatibility in the ROM header?
     33     - Use the following @ref makebin flags. Prefix them with `-Wm` if using @ref lcc.
     34       - `-yc` : GameBoy Color compatible
     35       - `-yC` : GameBoy Color only
     36       - `-ys` : Super GameBoy compatible <!-- -->  
     37 
     38   - How do I set the ROM @ref MBC type, and what MBC values are available to use with the `-yt` @ref makebin flag?
     39     - See @ref setting_mbc_and_rom_ram_banks <!-- -->  
     40 
     41 # Editors
     42   - Why is VSCode flagging some GBDK types or functions as unidentified or giving warnings about them?
     43     - See @ref code_editors_hinting
     44     - GBDK platform constants can be declared so that header files are parsed more completely in VSCode.
     45 
     46 # Errors and Warnings
     47   @anchor faq_gbz80_sm83_old_port_name_error
     48   - What does the error `old "gbz80" SDCC PORT name specified (in "-mgbz80:gb"). Use "sm83" instead. You must update your build settings.` mean?
     49     - The `PORT` name for the Game Boy and related clones changed from `gbz80` to `sm83` in the SDCC version used in GBDK-2020 4.1.0 and later. You must change your Makefile, Build settings, etc to use the new name. Additional details in the @ref console_port_plat_settings "Console Port and Platform Settings" section.  <!-- -->  
     50 
     51   @anchor faq_linker_conflicting_sdcc_options
     52   - What does the warning `?ASlink-Warning-Conflicting sdcc options: "-msm83" in module "_____" and
     53    "-mgbz80" in module "_____".` mean?
     54     - One object file was compiled with the PORT setting as `gbz80` (meaning a version of SDCC / GBDK-2020 __OLDER than GBDK-2020 4.1.0__).
     55     - The other had the PORT setting as `sm83` (meaning __GBDK-2020 4.1.0 or LATER__).
     56     - You must rebuild the object files using `sm83` with GBDK-2020 4.1.0 or later so that the linker is able to use them with the other object files. Additional details in the @ref console_port_plat_settings "Console Port and Platform Settings" section.  <!-- -->  
     57 
     58   @anchor faq_linker_undefined_global
     59   - What does the warning `?ASlink-Warning-Undefined Global ...` mean?
     60     - The linker is unable to find a variable or function that is referenced by some part of the program. This usually means a required source file is not being passed to the linker stage. Make sure all of your project source files are getting compiled and passed to the linker. <!-- -->  
     61 
     62   @anchor faq_sdcc_peephole_instruction_error
     63   - What does `z80instructionSize() failed to parse line node, assuming 999 bytes` mean?
     64     - This is a known issue with SDCC Peephole Optimizer parsing and can be ignored. A bug report has been filed for it. <!-- -->  
     65 
     66   @anchor faq_bank_overflow_errors
     67   - What do these kinds of warnings / errors mean?
     68     `WARNING: possibly wrote twice at addr 4000 (93->3E)`
     69     `Warning: Write from one bank spans into the next. 7ff7 -> 8016 (bank 1 -> 2)`
     70     - You may have a overflow in one of your ROM banks. If there is more data allocated to a bank than it can hold it then will spill over into the next bank.
     71 
     72       A common problem is when there is too much data in ROM0 (the lower 16K unbanked region) and it spills over into ROM1 (the first upper 16K banked region). Make sure ROM0 has 16K or less in it.
     73 
     74       The warnings are generated by @ref ihxcheck during conversion of an .ihx file into a ROM file.
     75 
     76       See the section @ref docs_rombanking_mbcs for more details about how banks work and what their size is. You may want to use a tool such as @ref romusage to calculate the amount of free and used space. <!-- -->  
     77 
     78   @anchor faq_error_mbc_size
     79   - What do these errors mean?
     80     `error: size of the buffer is too small`
     81     `error: ROM is too large for number of banks specified`
     82     - Your program is using more banks than you have configured in the toolchain.
     83       Either the MBC type was not set, or the number of banks or MBC type should be changed to provide more banks. 
     84 
     85       See the section @ref setting_mbc_and_rom_ram_banks for more details. <!-- -->  
     86 
     87   @anchor faq_sdcc_function_declarator_missing_prototype
     88   - What does `warning 283: function declarator with no prototype` mean?
     89     - Function forward declarations and definitions which have no arguments should be changed from `func()` to `func(void)`.
     90     - In C `func()` and `func(void)` do not mean the same thing. `()` means any number of parameters, `(void)` means no parameters. For example if a function with no arguments is declared with `()` then there may not be an error or warning when mistakenly trying to pass arguments to it.   <!-- -->  
     91 
     92   @anchor faq_sdcc_unreachable_code
     93   - What do these warnings mean?
     94     `warning 126: unreachable code`
     95     `warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG`
     96     - The compiler is indicating that some branches of the code will never get executed or will have no effect, and so have been removed during optimization. There may be a logical error, unnecessary logic or unused variables.
     97     - If this is due to a variable which gets modified outside of normal execution (such as during an interrupt) then the `volatile` keyword can be added to it's declaration. This removes some optimizations and tells the compiler the variable's value may change unexpectedly and cannot be predicted only based on the surrounding code. <!-- -->  
     98 
     99   @anchor faq_sdcc_overflow_implicit_constant_conversion
    100   - What does this warning mean?
    101     `WARNING: overflow in implicit constant conversion`
    102     - See @ref docs_constant_signedness "Constants, Signed-ness and Overflows"
    103 
    104   @anchor faq_macos_security_warning
    105   - On macOS, what does `... developer cannot be verified, macOS cannot verify that this app is free from malware` mean?
    106     - It does not mean that GBDK is malware. It just means the GBDK toolchain binaries are not signed by Apple, so it won't run them without an additional step.
    107 
    108     - For the workaround, see the @ref macos_unsigned_security_workaround "macOS unsigned binary workaround" for details. <!-- -->  
    109 
    110   @anchor faq_sdcc_z80_failed_to_parse
    111   - What do the following kinds of warnings / errors mean?
    112     `info 218: z80instructionSize() failed to parse line node, assuming 999 bytes`
    113     - This is a known issue with SDCC, it should not cause actual problems and you can ignore the warning. <!-- -->  
    114 
    115 
    116 # Debugging / Compiling / Toolchain
    117   - What flags should be enabled for debugging?
    118     - You can use the @ref lcc_debug "lcc debug flag" `-debug`to turn on debug output. It covers most uses and removes the need to specify multiple flags such as `-Wa-l -Wl-m -Wl-j`. Also see @ref tools_debug. <!-- -->  
    119 
    120   - Is it possible to generate a debug symbol file (`.sym`) compatible with an emulator?
    121     - Yes, turn on `.noi` output (LCC argument: `-Wl-j` or `-debug` and then use `-Wm-yS` with LCC (or `-yS` with makebin directly).
    122     - Also see additional information about using @ref tools_debug "debugging tools".<!-- -->  
    123 
    124   - How do I move the start of the `DATA` section and the `Shadow OAM` location?
    125     - The default locations are: `_shadow_OAM=0xC000` and 240 bytes after it `_DATA=0xC0A0`
    126     - So, for example, if you wanted to move them both to start 256(0x100) bytes later, use these command line arguments for LCC:
    127       - To change the Shadow OAM address: `-Wl-g_shadow_OAM=0xC100`
    128       - To change the DATA address (again, 240 bytes after the Shadow OAM): `-Wl-b_DATA=0xc1a0` <!-- -->  
    129 
    130   @anchor faq_sdcc_slow_compiling
    131   - Why is the compiler so slow, or why did it suddenly get much slower?
    132     - This may happen if you have large initialized arrays declared without the `const` keyword. It's important to use the const keyword for read-only data. See @ref const_gbtd_gbmb and @ref const_array_data
    133     - It can also happen if C source files are `#included` into other C source files, or if there is a very large source file.  <!-- -->  
    134 
    135   - Known issue: SDCC may fail on Windows when @ref windows_sdcc_non_c_drive_path_spaces "run from folder names with spaces on non-C drives".
    136     <!-- -->  
    137 
    138 # API / Utilities
    139   - Is there a list of all functions in the API?
    140     - [Functions](globals_func.html)
    141     - [Variables](globals_vars.html) <!-- -->  
    142 
    143   - Can I use the `float` type to do floating point math?
    144     - There is no support for 'float' in GBDK-2020.
    145     - Instead consider some form of `fixed point` math (including the @ref fixed_point_type "fixed" type included in GBDK). <!-- -->  
    146 
    147   - Why are 8 bit numbers not printing correctly with printf()?
    148     - To correctly pass chars/uint8s for printing, they must be explicitly re-cast as such when calling the function. See @ref docs_chars_varargs for more details.  <!-- -->  
    149 
    150   - How can maps larger than 32x32 tiles be scrolled? & Why is the map wrapping around to the left side when setting a map wider than 32 tiles with set_bkg_data()?
    151     - The hardware Background map is 32 x 32 tiles. The screen viewport that can be scrolled around that map is 20 x 18 tiles. In order to scroll around within a much larger map, new tiles must be loaded at the edges of the screen viewport in the direction that it is being scrolled. @ref set_bkg_submap can be used to load those rows and columns of tiles from the desired sub-region of the large map.
    152     - See the "Large Map" example program and @ref set_bkg_submap().
    153     - Writes that exceed coordinate 31 of the Background tile map on the x or y axis will wrap around to the Left and Top edges. <!-- -->  
    154 
    155   - When using gbt_player with music in banks, how can the current bank be restored after calling gbt_update()? (since it changes the currently active bank without restoring it).
    156     - See @ref banking_current_bank "restoring the current bank" <!-- -->  
    157 
    158   - How can CGB palettes and other sprite properties be used with metasprites?
    159     - See @ref metasprite_and_sprite_properties "Metasprites and sprite properties" <!-- -->  
    160 
    161   - Weird things are happening to my sprite colors when I use png2asset and metasprites. What's going on and how does it work?
    162     - See @ref utility_png2asset for details of how the conversion process works.
    163 

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.