gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 2e435bf7c0f0403e300e5add3237e51448f3313d parent 6c4009412867d546a4a4447fb1b75f8e7990884a Author: bbbbbr <bbbbbr@users.noreply.github.com> Date: Mon, 2 Oct 2023 23:52:43 -0700 Merge pull request #486 from Adam-Shea/develop Updated documentation for set_sprite_prop() Diffstat:
| M | gbdk-lib/include/gb/gb.h | 13 | +++++++++++++ |
| M | gbdk-lib/include/nes/nes.h | 44 | ++++++++++++++++++++++++++------------------ |
| M | gbdk-lib/include/sms/sms.h | 5 | +++++ |
3 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -1845,6 +1845,19 @@ inline uint8_t get_sprite_tile(uint8_t nb) { \li Bit 1 - See bit 0. \li Bit 0 - GBC only. Bits 0-2 indicate which of the 7 OBJ colour palettes the sprite is assigned. + + It's recommended to use GBDK constants (eg: S_FLIPY) to configure sprite properties as these are crossplatform. + + \code{.c} + // Load palette data into the first palette + set_sprite_palette(4, 1, exampleSprite_palettes) + // Set the OAM value for the sprite + // These flags tell the sprite to flip both vertically and horizontally. + set_sprite_prop(0, 0b01500000); + set_sprite_prop(0, S_FLIPY + S_FLIPX); + \endcode + + @see S_PALETTE, S_FLIPX, S_FLIPY, S_PRIORITY */ inline void set_sprite_prop(uint8_t nb, uint8_t prop) { shadow_OAM[nb].prop=prop; diff --git a/gbdk-lib/include/nes/nes.h b/gbdk-lib/include/nes/nes.h @@ -1025,29 +1025,37 @@ inline uint8_t get_sprite_tile(uint8_t nb) { @param prop Property setting (see bitfield description) The bits in __prop__ represent: - \li Bit 7 - Priority flag. When this is set the sprites appear behind the - background and window layer. - \n 0: infront - \n 1: behind - \li Bit 6 - Vertical flip. Dictates which way up the sprite is drawn + \li Bit 7 - Vertical flip. Dictates which way up the sprite is drawn vertically. \n 0: normal - \n 1:upside down - \li Bit 5 - Horizontal flip. Dictates which way up the sprite is + \n 1: upside down + \li Bit 6 - Horizontal flip. Dictates which way up the sprite is drawn horizontally. \n 0: normal - \n 1:back to front - \li Bit 4 - DMG/Non-CGB Mode Only. Assigns either one of the two b/w palettes to the sprite. - \n 0: OBJ palette 0 - \n 1: OBJ palette 1 - \li Bit 3 - GBC only. Dictates from which bank of Sprite Tile Patterns the tile - is taken. - \n 0: Bank 0 - \n 1: Bank 1 - \li Bit 2 - See bit 0. + \n 1: back to front + \li Bit 5 - Priority flag. When this is set, the sprites appear behind the + background and window layer. + \n 0: infront + \n 1: behind + \li Bit 4 - Unimplemented + \li Bit 3 - Unimplemented + \li Bit 2 - Unimplemented \li Bit 1 - See bit 0. - \li Bit 0 - GBC only. Bits 0-2 indicate which of the 7 OBJ colour palettes the - sprite is assigned. + \li Bit 0 - Bits 0-1 indicate which color palette the sprite should use. Note: only palettes 4 to 7 will be available for NES sprites. + + It's recommended to use GBDK constants (eg: S_FLIPY) to configure sprite properties as these are crossplatform. + + \code{.c} + // Load palette data into the first palette + set_sprite_palette(4, 1, exampleSprite_palettes) + + // Set the OAM value for the sprite + // These flags tell the sprite to use the first sprite palette (palette 4) and to flip the sprite both vertically and horizontally. + set_sprite_prop(0, 0b11000000); + set_sprite_prop(0, S_FLIPY + S_FLIPX); + \endcode + + @see S_PALETTE, S_FLIPX, S_FLIPY, S_PRIORITY */ inline void set_sprite_prop(uint8_t nb, uint8_t prop) { shadow_OAM[nb].prop=prop; diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -743,6 +743,11 @@ inline uint8_t get_sprite_tile(uint8_t nb) { return shadow_OAM[0x41+(nb << 1)]; } +/** Function has no affect on sms. + + This function is only here to enable game portability +*/ + inline void set_sprite_prop(uint8_t nb, uint8_t prop) { nb; prop; }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.