git.y1.nz

gbdk-2020

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

commit 820a36d7ce6e12b5d44d5d4788591b344b434fca
parent ed1f7d590e3e8ccca15b0ae28f384769ccfbe9d1
Author: bbbbbr <reg+github@roughhousing.com>
Date:   Wed,  8 Sep 2021 22:31:39 -0700

Merge pull request #252 from bbbbbr/docs_4_0_5

Docs: 4.0.5 updates
Diffstat:
Mdocs/pages/04_coding_guidelines.md6+++++-
Mdocs/pages/10_release_notes.md5++++-
Mgbdk-lib/include/gb/cgb.h42+++++++++++++++++++++++++++++++++---------
Mgbdk-lib/include/gb/isr.h8++++----
4 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/docs/pages/04_coding_guidelines.md b/docs/pages/04_coding_guidelines.md @@ -70,7 +70,11 @@ If you wish to use the original tools, you must add the `const` keyword every ti - NOTE: In SDCC 3.6.0, the default for char changed from signed to unsigned. The manual says to use `--fsigned-char` for the old behavior, this option flag is included by default when compiling through @ref lcc. @anchor fixed_point_type - - A fixed point type (`fixed`) is included with GBDK when precision greater than whole numbers is required for 8 bit range values (since floating point is not included in GBDK). For example: + - A fixed point type (`fixed`) is included with GBDK when precision greater than whole numbers is required for 8 bit range values (since floating point is not included in GBDK). + + See the "Simple Physics" sub-pixel example project. + + Code example: fixed player[2]; ... diff --git a/docs/pages/10_release_notes.md b/docs/pages/10_release_notes.md @@ -26,7 +26,10 @@ https://github.com/gbdk-2020/gbdk-2020/releases - Updated bgb debug output. Added @ref BGB_printf() - Examples - Added cross-platform examples (builds for multiple consoles: gb, ap, sms, gg) - - Improved `bgb_debug` example + - Added sms, gg, pocket examples + - Added incbin example + - Added simple physics sub-pixel / fixed point math example + - Bug fixes and updates for existing examples - Toolchain / Utilities - @ref utility_png2asset "png2asset" - @ref utility_png2asset "png2asset" is the new name for the `png2mtspr` utility diff --git a/gbdk-lib/include/gb/cgb.h b/gbdk-lib/include/gb/cgb.h @@ -20,18 +20,42 @@ #include <types.h> #include <stdint.h> -/** Macro to create a CGB palette color entry out of the color components. +/** Macro to create a CGB palette color entry out of 5-bit color components. - @param r Red Component, range 0 - 31 (31 brightest) - @param g Green Component, range 0 - 31 (31 brightest) - @param b Blue Component, range 0 - 31 (31 brightest) + @param r 5-bit Red Component, range 0 - 31 (31 brightest) + @param g 5-bit Green Component, range 0 - 31 (31 brightest) + @param b 5-bit Blue Component, range 0 - 31 (31 brightest) - The resulting format is BGR 15bpp. + The resulting format is bitpacked BGR-555 in a uint16_t. - @see set_bkg_palette(), set_sprite_palette() + @see set_bkg_palette(), set_sprite_palette(), RGB8(), RGBHTML() */ #define RGB(r, g, b) ((((uint16_t)(b) & 0x1f) << 10) | (((uint16_t)(g) & 0x1f) << 5) | (((uint16_t)(r) & 0x1f) << 0)) + +/** Macro to create a CGB palette color entry out of 8-bit color components. + + @param r 8-bit Red Component, range 0 - 255 (255 brightest) + @param g 8-bit Green Component, range 0 - 255 (255 brightest) + @param b 8-bit Blue Component, range 0 - 255 (255 brightest) + + The resulting format is bitpacked BGR-555 in a uint16_t. + + The lowest 3 bits of each color component are dropped during conversion. + + @see set_bkg_palette(), set_sprite_palette(), RGB(), RGBHTML() + */ #define RGB8(r, g, b) ((uint16_t)((r) >> 3) | ((uint16_t)((g) >> 3) << 5) | ((uint16_t)((b) >> 3) << 10)) + +/** Macro to convert a 24 Bit RGB color to a CGB palette color entry. + + @param RGB24bit Bit packed RGB-888 color (0-255 for each color component). + + The resulting format is bitpacked BGR-555 in a uint16_t. + + The lowest 3 bits of each color component are dropped during conversion. + + @see set_bkg_palette(), set_sprite_palette(), RGB(), RGB8() + */ #define RGBHTML(RGB24bit) (RGB8((((RGB24bit) >> 16) & 0xFF), (((RGB24bit) >> 8) & 0xFF), ((RGB24bit) & 0xFF))) /** Common colors based on the EGA default palette. @@ -58,7 +82,7 @@ #define RGB_ORANGE RGB(30, 20, 0) #define RGB_TEAL RGB(15, 15, 0) -typedef uint16_t palette_entry_t; +typedef uint16_t palette_entry_t; /**< 16 bit color entry */ /** Set CGB background palette(s). @@ -70,7 +94,7 @@ typedef uint16_t palette_entry_t; at __first_palette__, Palette data is sourced from __rgb_data__. \li Each Palette is 8 bytes in size: 4 colors x 2 bytes per palette color entry. - \li Each color (4 per palette) is packed as BGR 15bpp format (1:5:5:5, MSBit [15] is unused). + \li Each color (4 per palette) is packed as BGR-555 format (1:5:5:5, MSBit [15] is unused). \li Each component (R, G, B) may have values from 0 - 31 (5 bits), 31 is brightest. @see RGB(), set_bkg_palette_entry() @@ -90,7 +114,7 @@ set_bkg_palette(uint8_t first_palette, at __first_palette__, Palette data is sourced from __rgb_data__. \li Each Palette is 8 bytes in size: 4 colors x 2 bytes per palette color entry. - \li Each color (4 per palette) is packed as BGR 15bpp format (1:5:5:5, MSBit [15] is unused). + \li Each color (4 per palette) is packed as BGR-555 format (1:5:5:5, MSBit [15] is unused). \li Each component (R, G, B) may have values from 0 - 31 (5 bits), 31 is brightest. @see RGB(), set_sprite_palette_entry() diff --git a/gbdk-lib/include/gb/isr.h b/gbdk-lib/include/gb/isr.h @@ -12,10 +12,10 @@ #include <stdint.h> // #define VECTOR_VBL 0x40 // you can not define raw vector for VBlank interrupt -#define VECTOR_STAT 0x48 /** Address for the STAT interrupt vector */ -#define VECTOR_TIMER 0x50 /** Address for the TIMER interrupt vector */ -#define VECTOR_SERIAL 0x58 /** Address for the SERIAL interrupt vector */ -#define VECTOR_JOYPAD 0x60 /** Address for the JOYPAD interrupt vector */ +#define VECTOR_STAT 0x48 /**< Address for the STAT interrupt vector */ +#define VECTOR_TIMER 0x50 /**< Address for the TIMER interrupt vector */ +#define VECTOR_SERIAL 0x58 /**< Address for the SERIAL interrupt vector */ +#define VECTOR_JOYPAD 0x60 /**< Address for the JOYPAD interrupt vector */ typedef struct isr_vector_t { uint8_t opcode;

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