git.y1.nz

gbdk-2020

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

commit ebcfd5ee3fc9fa5a955b895d82360a226d528b19
parent 212b185675a04f5c4c2f68603c28288ca45ff58f
Author: bbbbbr <reg+github@roughhousing.com>
Date:   Thu,  9 Sep 2021 23:34:16 -0700

Merge pull request #255 from bbbbbr/docs_4_0_5

Docs: updates for 4.0.5
Diffstat:
Mgbdk-lib/include/gb/gb.h25+++++++++++++++++++++----
Mgbdk-lib/include/gb/hardware.h111+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Mgbdk-lib/include/sms/gbdecompress.h2++
Mgbdk-lib/include/stdlib.h26+++++++++++++++++---------
4 files changed, 100 insertions(+), 64 deletions(-)

diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -112,7 +112,24 @@ #define DMG_DARK_GRAY 0x02 #define DMG_LITE_GRAY 0x01 #define DMG_WHITE 0x00 -/** DMG palette helper macro. +/** Macro to create a DMG palette from 4 colors + + @param C0 Color for Index 0 + @param C1 Color for Index 1 + @param C2 Color for Index 2 + @param C3 Color for Index 3 + + The resulting format is four greyscale colors + packed into a single unsigned byte. + + Example: + \code{.c} + REG_BGP = DMG_PALETTE(DMG_BLACK, DMG_DARK_GRAY, DMG_LITE_GRAY, DMG_WHITE); + \endcode + + @see REG_OBP0, REG_OBP1, REG_BGP + @see DMG_BLACK, DMG_DARK_GRAY, DMG_LITE_GRAY, DMG_WHITE + */ #define DMG_PALETTE(C0, C1, C2, C3) ((UBYTE)((((C3) & 0x03) << 6) | (((C2) & 0x03) << 4) | (((C1) & 0x03) << 2) | ((C0) & 0x03))) @@ -308,7 +325,7 @@ uint8_t get_mode(void) NONBANKED __preserves_regs(b, c); /** GB CPU type - @see DMG_TYPE, MGB_TYPE, CGB_TYPE, cpu_fast(), cpu_slow() + @see DMG_TYPE, MGB_TYPE, CGB_TYPE, cpu_fast(), cpu_slow(), _is_GBA */ extern uint8_t _cpu; @@ -328,10 +345,10 @@ extern uint8_t _cpu; */ extern uint8_t _is_GBA; -/** Hardware Model: DMG, CGB or MGB. @see _cpu +/** Hardware Model: DMG, CGB or MGB. @see _cpu, _is_GBA */ #define GBA_NOT_DETECTED 0x00 -/** Hardware Model: GBA. @see _cpu +/** Hardware Model: GBA. @see _cpu, _is_GBA */ #define GBA_DETECTED 0x01 diff --git a/gbdk-lib/include/gb/hardware.h b/gbdk-lib/include/gb/hardware.h @@ -178,30 +178,30 @@ __REG LCDC_REG; /** LCD control */ #define LCDCF_B_OBJON 6 #define LCDCF_B_BGON 7 #else -#define LCDCF_OFF 0b00000000 -#define LCDCF_ON 0b10000000 -#define LCDCF_WIN9800 0b00000000 -#define LCDCF_WIN9C00 0b01000000 -#define LCDCF_WINOFF 0b00000000 -#define LCDCF_WINON 0b00100000 -#define LCDCF_BG8800 0b00000000 -#define LCDCF_BG8000 0b00010000 -#define LCDCF_BG9800 0b00000000 -#define LCDCF_BG9C00 0b00001000 -#define LCDCF_OBJ8 0b00000000 -#define LCDCF_OBJ16 0b00000100 -#define LCDCF_OBJOFF 0b00000000 -#define LCDCF_OBJON 0b00000010 -#define LCDCF_BGOFF 0b00000000 -#define LCDCF_BGON 0b00000001 -#define LCDCF_B_ON 7 -#define LCDCF_B_WIN9C00 6 -#define LCDCF_B_WINON 5 -#define LCDCF_B_BG8000 4 -#define LCDCF_B_BG9C00 3 -#define LCDCF_B_OBJ16 2 -#define LCDCF_B_OBJON 1 -#define LCDCF_B_BGON 0 +#define LCDCF_OFF 0b00000000 /**< LCD Control: Off */ +#define LCDCF_ON 0b10000000 /**< LCD Control: On */ +#define LCDCF_WIN9800 0b00000000 /**< Window Tile Map: Use 9800 Region */ +#define LCDCF_WIN9C00 0b01000000 /**< Window Tile Map: Use 9C00 Region */ +#define LCDCF_WINOFF 0b00000000 /**< Window Display: Hidden */ +#define LCDCF_WINON 0b00100000 /**< Window Display: Visible */ +#define LCDCF_BG8800 0b00000000 /**< BG & Window Tile Data: Use 8800 Region */ +#define LCDCF_BG8000 0b00010000 /**< BG & Window Tile Data: Use 8000 Region */ +#define LCDCF_BG9800 0b00000000 /**< BG Tile Map: use 9800 Region */ +#define LCDCF_BG9C00 0b00001000 /**< BG Tile Map: use 9C00 Region */ +#define LCDCF_OBJ8 0b00000000 /**< Sprites Size: 8x8 pixels */ +#define LCDCF_OBJ16 0b00000100 /**< Sprites Size: 8x16 pixels */ +#define LCDCF_OBJOFF 0b00000000 /**< Sprites Display: Hidden */ +#define LCDCF_OBJON 0b00000010 /**< Sprites Display: Visible */ +#define LCDCF_BGOFF 0b00000000 /**< Background Display: Hidden */ +#define LCDCF_BGON 0b00000001 /**< Background Display: Visible */ +#define LCDCF_B_ON 7 /**< Bit for LCD On/Off Select */ +#define LCDCF_B_WIN9C00 6 /**< Bit for Window Tile Map Region Select */ +#define LCDCF_B_WINON 5 /**< Bit for Window Display On/Off Control */ +#define LCDCF_B_BG8000 4 /**< Bit for BG & Window Tile Data Region Select */ +#define LCDCF_B_BG9C00 3 /**< Bit for BG Tile Map Region Select */ +#define LCDCF_B_OBJ16 2 /**< Bit for Sprites Size Select */ +#define LCDCF_B_OBJON 1 /**< Bit for Sprites Display Visible/Hidden Select */ +#define LCDCF_B_BGON 0 /**< Bit for Background Display Visible/Hidden Select */ #endif __REG STAT_REG; /** LCD status */ @@ -227,24 +227,24 @@ __REG STAT_REG; /** LCD status */ #define STATF_B_OAM 6 #define STATF_B_BUSY 6 #else -#define STATF_LYC 0b01000000 -#define STATF_MODE10 0b00100000 -#define STATF_MODE01 0b00010000 -#define STATF_MODE00 0b00001000 -#define STATF_LYCF 0b00000100 -#define STATF_HBL 0b00000000 -#define STATF_VBL 0b00000001 -#define STATF_OAM 0b00000010 -#define STATF_LCD 0b00000011 -#define STATF_BUSY 0b00000010 -#define STATF_B_LYC 6 -#define STATF_B_MODE10 5 -#define STATF_B_MODE01 4 -#define STATF_B_MODE00 3 -#define STATF_B_LYCF 2 -#define STATF_B_VBL 0 -#define STATF_B_OAM 1 -#define STATF_B_BUSY 1 +#define STATF_LYC 0b01000000 /**< STAT Interrupt: LYC=LY Coincidence Source Enable */ +#define STATF_MODE10 0b00100000 /**< STAT Interrupt: Mode 2 OAM Source Enable */ +#define STATF_MODE01 0b00010000 /**< STAT Interrupt: Mode 1 VBlank Source Enable */ +#define STATF_MODE00 0b00001000 /**< STAT Interrupt: Mode 0 HBlank Source Enable */ +#define STATF_LYCF 0b00000100 /**< LYC=LY Coincidence Status Flag, Set when LY contains the same value as LYC */ +#define STATF_HBL 0b00000000 /**< Current LCD Mode is: 0, in H-Blank */ +#define STATF_VBL 0b00000001 /**< Current LCD Mode is: 1, in V-Blank */ +#define STATF_OAM 0b00000010 /**< Current LCD Mode is: 2, in OAM-RAM is used by system (Searching OAM) */ +#define STATF_LCD 0b00000011 /**< Current LCD Mode is: 3, both OAM and VRAM used by system (Transferring Data to LCD Controller) */ +#define STATF_BUSY 0b00000010 /**< When set, VRAM access is unsafe */ +#define STATF_B_LYC 6 /**< Bit for STAT Interrupt: LYC=LY Coincidence Source Enable */ +#define STATF_B_MODE10 5 /**< Bit for STAT Interrupt: Mode 2 OAM Source Enable */ +#define STATF_B_MODE01 4 /**< Bit for STAT Interrupt: Mode 1 VBlank Source Enable */ +#define STATF_B_MODE00 3 /**< Bit for STAT Interrupt: Mode 0 HBlank Source Enable */ +#define STATF_B_LYCF 2 /**< Bit for LYC=LY Coincidence Status Flag */ +#define STATF_B_VBL 0 /**< */ +#define STATF_B_OAM 1 /**< */ +#define STATF_B_BUSY 1 /**< Bit for when VRAM access is unsafe */ #endif __REG SCY_REG; /** Scroll Y */ @@ -351,15 +351,24 @@ __REG IE_REG; /** Interrupt enable */ #define AUDHIGH_LENGTH_OFF 0b00000000 /* OAM attributes flags */ -#define OAMF_PRI 0b10000000 -#define OAMF_YFLIP 0b01000000 -#define OAMF_XFLIP 0b00100000 -#define OAMF_PAL0 0b00000000 -#define OAMF_PAL1 0b00010000 -#define OAMF_BANK0 0b00000000 -#define OAMF_BANK1 0b00001000 - -#define OAMF_PALMASK 0b00000111 +#define OAMF_PRI 0b10000000 /**< BG and Window over Sprite Enabled */ +#define OAMF_YFLIP 0b01000000 /**< Sprite Y axis flip: Vertically mirrored */ +#define OAMF_XFLIP 0b00100000 /**< Sprite X axis flip: Horizontally mirrored */ +#define OAMF_PAL0 0b00000000 /**< Sprite Palette number: use OBP0 (Non-CGB Mode Only) */ +#define OAMF_PAL1 0b00010000 /**< Sprite Palette number: use OBP1 (Non-CGB Mode Only) */ +#define OAMF_BANK0 0b00000000 /**< Sprite Tile VRAM-Bank: Use Bank 0 (CGB Mode Only) */ +#define OAMF_BANK1 0b00001000 /**< Sprite Tile VRAM-Bank: Use Bank 1 (CGB Mode Only) */ + +#define OAMF_CGB_PAL0 0b00000000 /**< Sprite CGB Palette number: use OCP0 (CGB Mode Only) */ +#define OAMF_CGB_PAL1 0b00000001 /**< Sprite CGB Palette number: use OCP1 (CGB Mode Only) */ +#define OAMF_CGB_PAL2 0b00000010 /**< Sprite CGB Palette number: use OCP2 (CGB Mode Only) */ +#define OAMF_CGB_PAL3 0b00000011 /**< Sprite CGB Palette number: use OCP3 (CGB Mode Only) */ +#define OAMF_CGB_PAL4 0b00000100 /**< Sprite CGB Palette number: use OCP4 (CGB Mode Only) */ +#define OAMF_CGB_PAL5 0b00000101 /**< Sprite CGB Palette number: use OCP5 (CGB Mode Only) */ +#define OAMF_CGB_PAL6 0b00000110 /**< Sprite CGB Palette number: use OCP6 (CGB Mode Only) */ +#define OAMF_CGB_PAL7 0b00000111 /**< Sprite CGB Palette number: use OCP7 (CGB Mode Only) */ + +#define OAMF_PALMASK 0b00000111 /**< Mask for Sprite CGB Palette number (CGB Mode Only) */ #define DEVICE_SCREEN_X_OFFSET 0 /**< Offset of visible screen (in tile units) from left edge of hardware map */ #define DEVICE_SCREEN_Y_OFFSET 0 /**< Offset of visible screen (in tile units) from top edge of hardware map */ diff --git a/gbdk-lib/include/sms/gbdecompress.h b/gbdk-lib/include/sms/gbdecompress.h @@ -14,6 +14,8 @@ @param sour Pointer to source gb-compressed data @param dest Pointer to destination buffer/address + @return Return value is number of bytes decompressed + @see gb_decompress_bkg_data, gb_decompress_win_data, gb_decompress_sprite_data */ uint16_t gb_decompress(const uint8_t * sour, uint8_t * dest) __z88dk_callee __preserves_regs(b, c); diff --git a/gbdk-lib/include/stdlib.h b/gbdk-lib/include/stdlib.h @@ -64,39 +64,47 @@ int atoi(const char *s); long atol(const char *s); /** Converts an int into a base 10 ASCII string. - @param n Int to convert to a string - @param s String to store the converted number + @param n Int to convert to a string + @param s String to store the converted number + @param radix Numerical base for converted number, ex: 10 is decimal base + (parameter is required but not utilized on Game Boy and Analogue Pocket) Returns: Pointer to converted string */ char *itoa(int n, char *s, unsigned char radix); /** Converts an unsigned int into a base 10 ASCII string. - @param n Unsigned Int to convert to a string - @param s String to store the converted number + @param n Unsigned Int to convert to a string + @param s String to store the converted number + @param radix Numerical base for converted number, ex: 10 is decimal base + (parameter is required but not utilized on Game Boy and Analogue Pocket) Returns: Pointer to converted string */ char *uitoa(unsigned int n, char *s, unsigned char radix); /** Converts a long into a base 10 ASCII string. - @param n Long int to convert to a string - @param s String to store the converted number + @param n Long int to convert to a string + @param s String to store the converted number + @param radix Numerical base for converted number, ex: 10 is decimal base + (parameter is required but not utilized on Game Boy and Analogue Pocket) Returns: Pointer to converted string */ char *ltoa(long n, char *s, unsigned char radix); /** Converts an unsigned long into a base 10 ASCII string. - @param n Unsigned Long Int to convert to a string - @param s String to store the converted number + @param n Unsigned Long Int to convert to a string + @param s String to store the converted number + @param radix Numerical base for converted number, ex: 10 is decimal base + (parameter is required but not utilized on Game Boy and Analogue Pocket) Returns: Pointer to converted string */ char *ultoa(unsigned long n, char *s, unsigned char radix); -/** Memory allocation functions +/** Memory allocation functions */ void *calloc (size_t nmemb, size_t size); void *malloc (size_t size);

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