Sprite system for Gbalatro. More...
#include <maxmod.h>#include <tonc.h>Go to the source code of this file.
Data Structures | |
| struct | Sprite |
| Sprite struct for GBA hardware specifics. More... | |
| struct | SpriteObject |
| A sprite object is a sprite that is focusable and movable in animation. More... | |
Macros | |
Sprite system constants | |
| #define | CARD_SPRITE_SIZE 32 |
| #define | MAX_AFFINES 32 |
| #define | MAX_SPRITES 128 |
| #define | MAX_SPRITE_OBJECTS 16 |
| #define | SPRITE_FOCUS_RAISE_PX 10 |
| #define | CARD_FOCUS_SFX_PITCH_OFFSET_RANGE 512 |
Functions | |
| Sprite * | sprite_new (u16 a0, u16 a1, u32 tid, u32 pb, s16 sprite_index) |
| Allocate and retrieve a pointer to a valid Sprite. | |
| void | sprite_destroy (Sprite **sprite) |
| Destroy Sprite. | |
| s16 | sprite_get_layer (Sprite *sprite) |
| Get index of Sprite in the GBA object buffer. | |
| bool | sprite_get_dimensions (Sprite *sprite, int *width, int *height) |
| Get a Sprite's width and height. | |
| bool | sprite_get_height (Sprite *sprite, int *height) |
| Get a Sprites's height. | |
| bool | sprite_get_width (Sprite *sprite, int *width) |
| Get a Sprite's width. | |
| int | sprite_get_pb (const Sprite *sprite) |
| Get the palette bank of a Sprite. | |
| void | sprite_hide (Sprite *sprite) |
| Hides the sprite by manipulating ATTR0_HIDE in OAM. | |
| void | sprite_unhide (Sprite *sprite) |
| Unhides the sprite by manipulating ATTR0_HIDE in OAM. The sprite's ATTR0_MODE is maintained from the sprite's creation with sprite_new() | |
| void | sprite_init (void) |
| Initialize GBAlatro sprite system. | |
| void | sprite_draw (void) |
| Draw Sprites to screen, to be called once per frame. | |
| void | sprite_object_init (SpriteObject *sprite_object) |
| Initialize a SpriteObject to a default state. Must be called only once per SpriteObject when it is created. | |
| void | sprite_object_destroy (SpriteObject *sprite_object) |
| Destroy SpriteObject. | |
| void | sprite_object_set_sprite (SpriteObject *sprite_object, Sprite *sprite) |
| Register a Sprite to an associated SpriteObject. | |
| void | sprite_object_hide (SpriteObject *sprite_object) |
| Hides the SpriteObject by manipulating ATTR0_HIDE in OAM. | |
| void | sprite_object_unhide (SpriteObject *sprite_object) |
| Unhides the SpriteObject by manipulating ATTR0_HIDE in OAM. The sprite's ATTR0_MODE is maintained from the sprite's creation with sprite_new() | |
| void | sprite_object_reset_transform (SpriteObject *sprite_object) |
| Reset SpriteObject's transform back to default values. | |
| IWRAM_CODE void | sprite_object_update (SpriteObject *sprite_object) |
| Update a SpriteObject, to be called once per frame per active SpriteObject. | |
| void | sprite_object_update_all (void) |
| Update all SpriteObjects, to be called once per frame in the main update loop. | |
| void | sprite_object_shake (SpriteObject *sprite_object, mm_word sound_id) |
| Shake SpriteObject on screen and play a sound. | |
| Sprite * | sprite_object_get_sprite (SpriteObject *sprite_object) |
| Get a SpriteObject's registered Sprite. | |
| void | sprite_object_set_focus (SpriteObject *sprite_object, bool focus) |
| Set the focus for SpriteObject Raises the object by SPRITE_FOCUS_RAISE_PX. | |
| bool | sprite_object_get_dimensions (SpriteObject *sprite_object, int *width, int *height) |
| Get the width and height of SpriteObject's registered Sprite. | |
| bool | sprite_object_get_height (SpriteObject *sprite_object, int *height) |
| Get a SpriteObject's height. | |
| bool | sprite_object_get_width (SpriteObject *sprite_object, int *width) |
| Get a SpriteObject's width. | |
| bool | sprite_object_is_focused (SpriteObject *sprite_object) |
Get the focused variable from a SpriteObject. | |
| void | sprite_object_print_text_under (SpriteObject *sprite_object, const char text[]) |
| Print the given string directly beneath a SpriteObject. This is used only for Cards for now. | |
| void | sprite_object_print_price_under (SpriteObject *sprite_object, int price) |
Print the price string directly beneath a SpriteObject. More specialized version of sprite_object_print_text_under, automatically formats the price to $d. | |
| void | sprite_object_erase_text_under (SpriteObject *sprite_object) |
| Erase the text within the Rect directly beneath a SpriteObject. This is used only for Cards for now. | |
| INLINE void | sprite_position (Sprite *sprite, int x, int y) |
| Set sprite position. Inlined for efficiency. | |
| INLINE void | sprite_object_position (SpriteObject *sprite_object, int x, int y) |
| Set sprite_object position. Inlined for efficiency. | |
| void sprite_destroy | ( | Sprite ** | sprite | ) |
| void sprite_draw | ( | void | ) |
| bool sprite_get_dimensions | ( | Sprite * | sprite, |
| int * | width, | ||
| int * | height | ||
| ) |
Get a Sprite's width and height.
| sprite | pointer to Sprite, cannot be NULL |
| width | pointer to variable to be set, cannot be NULL |
| height | pointer to variable to be set, cannot be NULL |
width and height contain valid data, otherwise, the variables are unchanged. | bool sprite_get_height | ( | Sprite * | sprite, |
| int * | height | ||
| ) |
| s16 sprite_get_layer | ( | Sprite * | sprite | ) |
| int sprite_get_pb | ( | const Sprite * | sprite | ) |
| bool sprite_get_width | ( | Sprite * | sprite, |
| int * | width | ||
| ) |
| void sprite_hide | ( | Sprite * | sprite | ) |
| void sprite_init | ( | void | ) |
| Sprite * sprite_new | ( | u16 | a0, |
| u16 | a1, | ||
| u32 | tid, | ||
| u32 | pb, | ||
| s16 | sprite_index | ||
| ) |
| void sprite_object_destroy | ( | SpriteObject * | sprite_object | ) |
Destroy SpriteObject.
Destroy a SpriteObject by releasing its associated resources (e.g. the sprite). This invalidates the SpriteObject and it should not be used after destroyed, a new one should be created instead.
| sprite_object | pointer to a SpriteObject to destroy. Cannot be NULL. |
| void sprite_object_erase_text_under | ( | SpriteObject * | sprite_object | ) |
Erase the text within the Rect directly beneath a SpriteObject. This is used only for Cards for now.
| sprite_object | valid pointer to SpriteObject to check |
| bool sprite_object_get_dimensions | ( | SpriteObject * | sprite_object, |
| int * | width, | ||
| int * | height | ||
| ) |
Get the width and height of SpriteObject's registered Sprite.
| sprite_object | pointer to SpriteObject to get the dimensions of. Cannot be NULL. |
| width | pointer to variable to be set, cannot be NULL |
| height | pointer to variable to be set, cannot be NULL |
width and height contain valid data, otherwise, the variables are unchanged. | bool sprite_object_get_height | ( | SpriteObject * | sprite_object, |
| int * | height | ||
| ) |
Get a SpriteObject's height.
| sprite_object | pointer to SpriteObject to get the height of. Cannot be NULL. |
| height | pointer to variable to be set, cannot be NULL |
height contains valid data, otherwise, the variable is unchanged. | Sprite * sprite_object_get_sprite | ( | SpriteObject * | sprite_object | ) |
Get a SpriteObject's registered Sprite.
| sprite_object | pointer to SpriteObject's registered Sprite. Cannot be NULL. |
sprite_object if successful, otherwise return NULL. May be successful and NULL if there is no Sprite registered to the SpriteObject. | bool sprite_object_get_width | ( | SpriteObject * | sprite_object, |
| int * | width | ||
| ) |
Get a SpriteObject's width.
| sprite_object | pointer to SpriteObject to get the width of. Cannot be NULL. |
| width | pointer to variable to be set, cannot be NULL |
width contains valid data, otherwise, the variable is unchanged. | void sprite_object_hide | ( | SpriteObject * | sprite_object | ) |
Hides the SpriteObject by manipulating ATTR0_HIDE in OAM.
| sprite_object | The SpriteObject to hide |
| void sprite_object_init | ( | SpriteObject * | sprite_object | ) |
Initialize a SpriteObject to a default state. Must be called only once per SpriteObject when it is created.
| sprite_object | - The SpriteObject to initialize |
| bool sprite_object_is_focused | ( | SpriteObject * | sprite_object | ) |
Get the focused variable from a SpriteObject.
| sprite_object | valid pointer to SpriteObject to check |
true if the SpriteObject is focused, false otherwise | INLINE void sprite_object_position | ( | SpriteObject * | sprite_object, |
| int | x, | ||
| int | y | ||
| ) |
Set sprite_object position. Inlined for efficiency.
| sprite_object | poitner to a SpriteObject to adjust the position of. A NULL check is not performed, though the value cannot be NULL. |
| x | horizontal position in pixels |
| y | vertical position in pixels |
| void sprite_object_print_price_under | ( | SpriteObject * | sprite_object, |
| int | price | ||
| ) |
Print the price string directly beneath a SpriteObject. More specialized version of sprite_object_print_text_under, automatically formats the price to $d.
| sprite_object | valid pointer to SpriteObject to check |
| price | the price of the card to be printed |
| void sprite_object_print_text_under | ( | SpriteObject * | sprite_object, |
| const char | text[] | ||
| ) |
Print the given string directly beneath a SpriteObject. This is used only for Cards for now.
| sprite_object | valid pointer to SpriteObject to check |
| text | the string to be printed below the sprite |
| void sprite_object_reset_transform | ( | SpriteObject * | sprite_object | ) |
Reset SpriteObject's transform back to default values.
| sprite_object | pointer to SpriteObject to reset transform. Cannot be NULL. |
| void sprite_object_set_focus | ( | SpriteObject * | sprite_object, |
| bool | focus | ||
| ) |
Set the focus for SpriteObject Raises the object by SPRITE_FOCUS_RAISE_PX.
Note: This is currently unused by CardObject as their focus is handled in cards_in_hand_update_loop() but we may want to extract it from there and refactor them use this instead.
| sprite_object | pointer to SpriteObject to set the focus of. Cannot be NULL. |
| focus | true to focus, false to unfocus |
| void sprite_object_set_sprite | ( | SpriteObject * | sprite_object, |
| Sprite * | sprite | ||
| ) |
Register a Sprite to an associated SpriteObject.
| sprite_object | pointer to SpriteObject to associate Sprite with. Cannot be NULL. |
| sprite | pointer to Sprite to associate SpriteObject with. Cannot be NULL. |
| void sprite_object_shake | ( | SpriteObject * | sprite_object, |
| mm_word | sound_id | ||
| ) |
Shake SpriteObject on screen and play a sound.
| SpriteObject | pointer to SpriteObject to shake. Cannot be NULL. |
| sound_id | ID of sound from maxmod to play on executing shake. If UNDEFINED no sound will play. |
| void sprite_object_unhide | ( | SpriteObject * | sprite_object | ) |
Unhides the SpriteObject by manipulating ATTR0_HIDE in OAM. The sprite's ATTR0_MODE is maintained from the sprite's creation with sprite_new()
| sprite_object | The SpriteObject to unhide |
| IWRAM_CODE void sprite_object_update | ( | SpriteObject * | sprite_object | ) |
Update a SpriteObject, to be called once per frame per active SpriteObject.
| sprite_object | pointer to SpriteObject to update. Cannot be NULL. |
| void sprite_object_update_all | ( | void | ) |
| INLINE void sprite_position | ( | Sprite * | sprite, |
| int | x, | ||
| int | y | ||
| ) |
| void sprite_unhide | ( | Sprite * | sprite | ) |
Unhides the sprite by manipulating ATTR0_HIDE in OAM. The sprite's ATTR0_MODE is maintained from the sprite's creation with sprite_new()
| sprite | The sprite to unhide |