15#include "deck_big_gfx.h"
17#include "decks_face_down_gfx.h"
18#include "high_contrast_deck_pal_gfx.h"
22const static u16 CARD_SPRITE_LUT[NUM_SUITS][NUM_RANKS] = {
23 {0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192},
24 {208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400},
25 {416, 432, 448, 464, 480, 496, 512, 528, 544, 560, 576, 592, 608},
26 {624, 640, 656, 672, 688, 704, 720, 736, 752, 768, 784, 800, 816}
29const static u16 DECK_SPRITE_LUT[DECK_TYPE_MAX] = {0, 16, 32, 48, 64, 80};
31static bool s_high_contrast = DEFAULT_HIGH_CONTRAST;
32static bool s_more_readable = DEFAULT_MORE_READABLE;
36 GRIT_CPY(&pal_obj_mem[DECK_SPRITES_PB * PAL_ROW_LEN], decks_face_down_gfxPal);
39void set_cards_high_contrast(
bool enable)
41 s_high_contrast = enable;
44 GRIT_CPY(&pal_obj_mem[CARD_PB * PAL_ROW_LEN], high_contrast_deck_pal_gfxPal);
48 GRIT_CPY(&pal_obj_mem[CARD_PB * PAL_ROW_LEN], deck_gfxPal);
52void set_cards_more_readable(
bool enable)
54 s_more_readable = enable;
57bool get_cards_high_contrast(
void)
59 return s_high_contrast;
62bool get_cards_more_readable(
void)
64 return s_more_readable;
68Card* card_new(u8 suit, u8 rank)
78void card_destroy(
Card** card)
80 POOL_FREE(
Card, *card);
84u8 card_get_value(
Card* card)
86 if (card->rank == JACK || card->rank == QUEEN || card->rank == KING)
90 else if (card->rank == ACE)
96 return card->rank + RANK_OFFSET;
107 card_object->card = card;
109 card_object->type = ITEM_TYPE_PLAYING_CARD;
110 card_object->selected =
false;
115void card_object_destroy(
CardObject** card_object)
117 if (*card_object == NULL)
124void card_object_set_sprite(
CardObject* card_object, s16 layer)
126 int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
127 const unsigned int* card_tiles = s_more_readable ? deck_big_gfxTiles : deck_gfxTiles;
130 &card_tiles[CARD_SPRITE_LUT[card_object->card->suit][card_object->card->rank] *
TILE_SIZE],
134 ATTR0_SQUARE | ATTR0_4BPP | ATTR0_AFF,
138 layer + CARD_STARTING_LAYER
143void card_object_set_sprite_face_down(
CardObject* card_object,
enum DeckType deck, s16 layer)
145 int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
148 &decks_face_down_gfxTiles[DECK_SPRITE_LUT[deck] *
TILE_SIZE],
152 ATTR0_SQUARE | ATTR0_4BPP | ATTR0_AFF,
156 layer + CARD_STARTING_LAYER
161void card_object_shake(
CardObject* card_object, mm_word sound_id)
166void card_object_set_selected(
CardObject* card_object,
bool selected)
168 if (card_object == NULL)
170 card_object->selected = selected;
173bool card_object_is_selected(
CardObject* card_object)
175 if (card_object == NULL)
177 return card_object->selected;
182 if (card_object == NULL)
187int card_object_get_buy_price(
Item* card_object)
195void card_object_dispose(
Item** card_object_item)
202 card_object_destroy(&card_object);
203 *card_object_item = NULL;
Graphic utility functions.
#define TILE_SIZE
Tile size in pixels, both height and width as tiles are square.
#define TILE_MEM_OBJ_CHARBLOCK0_IDX
The index for the first charblock of the object memory in tonc's tile_mem.
The core structure for items in the shop and inventory. Provides a common API for the shop and invent...
#define ITEM_RETURN_IF_UNEXPECTED_TYPE_RET(item, expected_type, ret_val)
Checks if item is of type expected_type - logs error message and returns otherwise.
#define ITEM_RETURN_IF_UNEXPECTED_TYPE_VOID(item, expected_type)
Checks if item is of type expected_type - logs error message and returns otherwise.
void sprite_object_init(SpriteObject *sprite_object)
Initialize a SpriteObject to a default state. Must be called only once per SpriteObject when it is cr...
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_shake(SpriteObject *sprite_object, mm_word sound_id)
Shake SpriteObject on screen and play a sound.
Sprite * sprite_new(u16 a0, u16 a1, u32 tid, u32 pb, s16 sprite_index)
Allocate and retrieve a pointer to a valid Sprite.
Sprite * sprite_object_get_sprite(SpriteObject *sprite_object)
Get a SpriteObject's registered Sprite.
A generic interface for all items that can appear in the shop or be in the inventory....
A sprite object is a sprite that is focusable and movable in animation.
Sprite struct for GBA hardware specifics.
Utilities relating around number string representation and protected arithmatic helper functions.
#define GBAL_RETURN_IF_NULL_RET(param, ret_val)
Checks if param is equal to NULL and prints error message and returns in case it is....
#define GBAL_RETURN_IF_NULL_VOID(param)
Checks if param is NULL and prints error message and returns in case it is. Useful for checking argum...