GBDK 2020 Docs
4.3.0
API Documentation for GBDK 2020
|
Go to the source code of this file.
Macros | |
#define | RGB(r, g, b) ((uint16_t)((((b) & 0x1f) << 10) | ((uint16_t)(((g) & 0x1f) << 5)) | ((r) & 0x1f))) |
#define | RGB8(r, g, b) (((uint16_t)((((b) >> 3) & 0x1f) << 10)) | ((uint16_t)((((g) >> 3) & 0x1f) << 5)) | (((r) >> 3) & 0x1f)) |
#define | RGBHTML(RGB24bit) (RGB8((((RGB24bit) >> 16) & 0xff), (((RGB24bit) >> 8) & 0xff), ((RGB24bit) & 0xff))) |
#define | RGB_RED RGB(31, 0, 0) |
#define | RGB_DARKRED RGB(15, 0, 0) |
#define | RGB_GREEN RGB( 0, 31, 0) |
#define | RGB_DARKGREEN RGB( 0, 15, 0) |
#define | RGB_BLUE RGB( 0, 0, 31) |
#define | RGB_DARKBLUE RGB( 0, 0, 15) |
#define | RGB_YELLOW RGB(31, 31, 0) |
#define | RGB_DARKYELLOW RGB(21, 21, 0) |
#define | RGB_CYAN RGB( 0, 31, 31) |
#define | RGB_AQUA RGB(28, 5, 22) |
#define | RGB_PINK RGB(31, 0, 31) |
#define | RGB_PURPLE RGB(21, 0, 21) |
#define | RGB_BLACK RGB( 0, 0, 0) |
#define | RGB_DARKGRAY RGB(10, 10, 10) |
#define | RGB_LIGHTGRAY RGB(21, 21, 21) |
#define | RGB_WHITE RGB(31, 31, 31) |
#define | RGB_LIGHTFLESH RGB(30, 20, 15) |
#define | RGB_BROWN RGB(10, 10, 0) |
#define | RGB_ORANGE RGB(30, 20, 0) |
#define | RGB_TEAL RGB(15, 15, 0) |
Typedefs | |
typedef uint16_t | palette_color_t |
Functions | |
void | set_bkg_palette (uint8_t first_palette, uint8_t nb_palettes, const palette_color_t *rgb_data) OLDCALL |
void | set_sprite_palette (uint8_t first_palette, uint8_t nb_palettes, const palette_color_t *rgb_data) OLDCALL |
void | set_bkg_palette_entry (uint8_t palette, uint8_t entry, uint16_t rgb_data) OLDCALL |
void | set_sprite_palette_entry (uint8_t palette, uint8_t entry, uint16_t rgb_data) OLDCALL |
void | cpu_slow (void) |
void | cpu_fast (void) |
void | set_default_palette (void) |
void | cgb_compatibility (void) |
Support for the Color GameBoy (CGB).
Enabling CGB features
To unlock and use CGB features and registers you need to change byte 0143h in the cartridge header. Otherwise, the CGB will operate in monochrome "Non CGB" compatibility mode.
See the Pan Docs for more information CGB features.
#define RGB | ( | r, | |
g, | |||
b | |||
) | ((uint16_t)((((b) & 0x1f) << 10) | ((uint16_t)(((g) & 0x1f) << 5)) | ((r) & 0x1f))) |
Macro to create a CGB palette color entry out of 5-bit color components.
r | 5-bit Red Component, range 0 - 31 (31 brightest) |
g | 5-bit Green Component, range 0 - 31 (31 brightest) |
b | 5-bit Blue Component, range 0 - 31 (31 brightest) |
The resulting format is bitpacked BGR-555 in a uint16_t.
#define RGB8 | ( | r, | |
g, | |||
b | |||
) | (((uint16_t)((((b) >> 3) & 0x1f) << 10)) | ((uint16_t)((((g) >> 3) & 0x1f) << 5)) | (((r) >> 3) & 0x1f)) |
Macro to create a CGB palette color entry out of 8-bit color components.
r | 8-bit Red Component, range 0 - 255 (255 brightest) |
g | 8-bit Green Component, range 0 - 255 (255 brightest) |
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.
#define RGBHTML | ( | RGB24bit | ) | (RGB8((((RGB24bit) >> 16) & 0xff), (((RGB24bit) >> 8) & 0xff), ((RGB24bit) & 0xff))) |
Macro to convert a 24 Bit RGB color to a CGB palette color entry.
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.
#define RGB_RED RGB(31, 0, 0) |
Common colors based on the EGA default palette.
#define RGB_DARKRED RGB(15, 0, 0) |
#define RGB_GREEN RGB( 0, 31, 0) |
#define RGB_DARKGREEN RGB( 0, 15, 0) |
#define RGB_BLUE RGB( 0, 0, 31) |
#define RGB_DARKBLUE RGB( 0, 0, 15) |
#define RGB_YELLOW RGB(31, 31, 0) |
#define RGB_DARKYELLOW RGB(21, 21, 0) |
#define RGB_CYAN RGB( 0, 31, 31) |
#define RGB_AQUA RGB(28, 5, 22) |
#define RGB_PINK RGB(31, 0, 31) |
#define RGB_PURPLE RGB(21, 0, 21) |
#define RGB_BLACK RGB( 0, 0, 0) |
#define RGB_DARKGRAY RGB(10, 10, 10) |
#define RGB_LIGHTGRAY RGB(21, 21, 21) |
#define RGB_WHITE RGB(31, 31, 31) |
#define RGB_LIGHTFLESH RGB(30, 20, 15) |
#define RGB_BROWN RGB(10, 10, 0) |
#define RGB_ORANGE RGB(30, 20, 0) |
#define RGB_TEAL RGB(15, 15, 0) |
typedef uint16_t palette_color_t |
16 bit color entry
void set_bkg_palette | ( | uint8_t | first_palette, |
uint8_t | nb_palettes, | ||
const palette_color_t * | rgb_data | ||
) |
Set CGB background palette(s).
first_palette | Index of the first palette to write (0-7) |
nb_palettes | Number of palettes to write (1-8, max depends on first_palette) |
rgb_data | Pointer to source palette data |
Writes nb_palettes to background palette data starting at first_palette, Palette data is sourced from rgb_data.
void set_sprite_palette | ( | uint8_t | first_palette, |
uint8_t | nb_palettes, | ||
const palette_color_t * | rgb_data | ||
) |
Set CGB sprite palette(s).
first_palette | Index of the first palette to write (0-7) |
nb_palettes | Number of palettes to write (1-8, max depends on first_palette) |
rgb_data | Pointer to source palette data |
Writes nb_palettes to sprite palette data starting at first_palette, Palette data is sourced from rgb_data.
Sets a single color in the specified CGB background palette.
palette | Index of the palette to modify (0-7) |
entry | Index of color in palette to modify (0-3) |
rgb_data | New color data in BGR 15bpp format. |
Sets a single color in the specified CGB sprite palette.
palette | Index of the palette to modify (0-7) |
entry | Index of color in palette to modify (0-3) |
rgb_data | New color data in BGR 15bpp format. |
void cpu_slow | ( | void | ) |
Set CPU speed to slow (Normal Speed) operation.
Interrupts are temporarily disabled and then re-enabled during this call.
In this mode the CGB operates at the same speed as the DMG/Pocket/SGB models.
|
inline |
Set CPU speed to fast (CGB Double Speed) operation.
On startup the CGB operates in Normal Speed Mode and can be switched into Double speed mode (faster processing but also higher power consumption). See the Pan Docs for more information about which hardware features operate faster and which remain at Normal Speed.
void set_default_palette | ( | void | ) |
|
inline |
Obsolete. This function has been replaced by set_default_palette(), which has identical behavior.