20#define NORMAL_BLIND_PB 2
21#define BOSS_BLIND_PB 3
23#define BLIND_BASE_LAYER (MAX_HAND_SIZE + MAX_SELECTION_SIZE)
25#define BLIND_SPRITE_OFFSET 16
26#define BLIND_SPRITE_COPY_SIZE (BLIND_SPRITE_OFFSET * TILE_SIZE)
28#define BLIND_TOKENS_PER_SPRITESHEET 2
29#define BLIND_TOKEN_PALETTE_SIZE 8
31#define SMALL_BLIND_REWARD 3
32#define BIG_BLIND_REWARD 4
33#define BOSS_BLIND_REWARD 5
34#define SHOWDOWN_BLIND_REWARD 8
36static const unsigned int* blind_gfxTiles[] = {
37#define DEF_BLIND_GFX(idx) blind_gfx##idx##Tiles,
38#include "../include/def_blind_gfx_table.h"
42static const unsigned short* blind_gfxPal[] = {
43#define DEF_BLIND_GFX(idx) blind_gfx##idx##Pal,
44#include "../include/def_blind_gfx_table.h"
55static const u32 ANTE_LUT[] = {100, 300, 800, 2000, 5000, 11000, 20000, 35000, 50000};
64 {BLIND_TYPE_SMALL, FIX_ONE },
65 {BLIND_TYPE_BIG, (FIX_ONE * 3) / 2},
66 {BLIND_TYPE_HOOK, FIX_ONE * 2 },
67 {BLIND_TYPE_OX, FIX_ONE * 2 },
68 {BLIND_TYPE_HOUSE, FIX_ONE * 2 },
69 {BLIND_TYPE_WHEEL, FIX_ONE * 2 },
70 {BLIND_TYPE_WALL, FIX_ONE * 2 },
71 {BLIND_TYPE_ARM, FIX_ONE * 2 },
72 {BLIND_TYPE_CLUB, FIX_ONE * 2 },
73 {BLIND_TYPE_FISH, FIX_ONE * 2 },
74 {BLIND_TYPE_PSYCHIC, FIX_ONE * 2 },
75 {BLIND_TYPE_GOAD, FIX_ONE * 2 },
76 {BLIND_TYPE_WATER, FIX_ONE * 2 },
77 {BLIND_TYPE_WINDOW, FIX_ONE * 2 },
78 {BLIND_TYPE_MANACLE, FIX_ONE * 2 },
79 {BLIND_TYPE_EYE, FIX_ONE * 2 },
80 {BLIND_TYPE_MOUTH, FIX_ONE * 2 },
81 {BLIND_TYPE_PLANT, FIX_ONE * 2 },
82 {BLIND_TYPE_SERPENT, FIX_ONE * 2 },
83 {BLIND_TYPE_PILLAR, FIX_ONE * 2 },
84 {BLIND_TYPE_NEEDLE, FIX_ONE * 2 },
85 {BLIND_TYPE_HEAD, FIX_ONE * 2 },
86 {BLIND_TYPE_TOOTH, FIX_ONE * 2 },
87 {BLIND_TYPE_FLINT, FIX_ONE * 2 },
88 {BLIND_TYPE_MARK, FIX_ONE * 2 },
89 {BLIND_TYPE_ACORN, FIX_ONE * 2 },
90 {BLIND_TYPE_LEAF, FIX_ONE * 2 },
91 {BLIND_TYPE_VESSEL, FIX_ONE * 2 },
92 {BLIND_TYPE_HEART, FIX_ONE * 2 },
93 {BLIND_TYPE_BELL, FIX_ONE * 2 }
101 memcpy16(&pal_obj_bank[NORMAL_BLIND_PB], blind_gfxPal[0],
NUM_ELEM_IN_ARR(blind_gfx0Pal));
109 if (ante < 0 || ante > MAX_ANTE)
112 return fx2int(
s_blind_type_map[type].score_req_multiplier * ANTE_LUT[ante]);
119 case BLIND_TYPE_SMALL:
120 return SMALL_BLIND_REWARD;
122 return BIG_BLIND_REWARD;
123 case BLIND_TYPE_BOSS ...(BLIND_TYPE_SHOWDOWN - 1):
124 return BOSS_BLIND_REWARD;
126 return SHOWDOWN_BLIND_REWARD;
142 List* p_unbeaten_blinds = showdown ? &s_unbeaten_showdown_blinds : &s_unbeaten_boss_blinds;
147 int lower_blind = showdown ? BLIND_TYPE_SHOWDOWN : BLIND_TYPE_BOSS;
148 int upper_blind = showdown ? BLIND_TYPE_MAX - 1 : BLIND_TYPE_SHOWDOWN - 1;
150 for (
int i = lower_blind; i <= upper_blind; i++)
164 List* p_unbeaten_blinds = showdown ? &s_unbeaten_showdown_blinds : &s_unbeaten_boss_blinds;
177 return random_blind->type;
182 bool showdown = (type >= BLIND_TYPE_SHOWDOWN);
183 List* p_unbeaten_blinds = showdown ? &s_unbeaten_showdown_blinds : &s_unbeaten_boss_blinds;
187 Blind* beaten_blind = NULL;
192 if (beaten_blind->type == type)
205static u32 get_blind_pb(
enum BlindType type)
207 return (type <= BLIND_TYPE_BIG) ? NORMAL_BLIND_PB : BOSS_BLIND_PB;
210static u32 get_blind_spritesheet_idx(
enum BlindType type)
213 return (type < BLIND_TYPE_MARK)
214 ? type / BLIND_TOKENS_PER_SPRITESHEET
215 : BLIND_TYPE_MARK / BLIND_TOKENS_PER_SPRITESHEET + type - BLIND_TYPE_MARK;
226 u32 color_idx = index + ((type < BLIND_TYPE_MARK)
227 ? BLIND_TOKEN_PALETTE_SIZE * (type % BLIND_TOKENS_PER_SPRITESHEET)
229 return blind_gfxPal[get_blind_spritesheet_idx(type)][color_idx];
235 static u32 active_boss_spritesheet = BLIND_TYPE_MAX;
236 u32 new_spritesheet = get_blind_spritesheet_idx(type);
239 if (type < BLIND_TYPE_BOSS || active_boss_spritesheet == new_spritesheet)
244 active_boss_spritesheet = new_spritesheet;
248 &pal_obj_bank[BOSS_BLIND_PB],
249 blind_gfxPal[active_boss_spritesheet],
265 return (BLIND_BASE_LAYER + layer) * BLIND_SPRITE_OFFSET;
270 u32 spritesheet_idx = get_blind_spritesheet_idx(type);
271 u32 sprite_idx = (type < BLIND_TYPE_MARK) ? type % BLIND_TOKENS_PER_SPRITESHEET : 0;
274 &blind_gfxTiles[spritesheet_idx][sprite_idx * BLIND_SPRITE_COPY_SIZE],
275 BLIND_SPRITE_COPY_SIZE
286 ATTR0_SQUARE | ATTR0_4BPP,
290 BLIND_BASE_LAYER + layer
void apply_blind_tiles(enum BlindType type, enum BlindTokenLayers layer)
Change the tiles of the BlindToken Sprite at a given layer to that of the given BlindType.
static u32 get_layer_tile_index(enum BlindTokenLayers layer)
Get the starting tile index in tiles memory for the given BlindToken sprite layer.
enum BlindType roll_blind_type(bool showdown)
Choose a random Blind among the ones that haven't been beaten yet.
void apply_blind_colors(enum BlindType type)
Copy the palette associated with the given Blind and copy it in the right spot in the palette memory.
static void init_unbeaten_blinds_list(bool showdown)
Fill Lists of unbeaten Boss and Showdown Blinds.
Sprite * blind_token_new(enum BlindType type, int x, int y, enum BlindTokenLayers layer)
Create a new BlindToken sprite.
static Blind s_blind_type_map[BLIND_TYPE_MAX]
Stores an instance of the Blind struct for each BlindType value, ordered in the same way....
u16 blind_get_color(enum BlindType type, enum BlindColorIndex index)
Get the color associated with a given Blind.
u32 blind_get_requirement(enum BlindType type, int ante)
Get the score required to beat a certain blind (either the Small, Big, or any Boss/Showdown blind) at...
void set_blind_beaten(enum BlindType type)
Remove the given Blind from the corresponding List so that we don't roll it again in the future.
void init_unbeaten_blinds_lists(void)
Initialize Boss and Showdown Blinds lists to roll from.
int blind_get_reward(enum BlindType type)
Get the amount of money gained from beating a certain Blind.
Data structures and functions relative to the behaviour and graphics of Blinds.
BlindType
All Blind types in the game are listed here.
BlindTokenLayers
Sprite IDs of the various Blind Tokens used in the game, expressed as an offset relative to BLIND_BAS...
BlindColorIndex
Indices of the Blind sprites' colors as encoded in the files' palettes with Aseprite.
Graphic utility functions.
#define TILE_MEM_OBJ_CHARBLOCK0_IDX
The index for the first charblock of the object memory in tonc's tile_mem.
Functions relative to manipulating and analyzing the contents of the Hand, a.k.a. the Cards we hold a...
bool list_is_empty(const List *list)
void * list_get_at_idx(List *list, unsigned int idx)
int list_get_len(const List *list)
void list_clear(List *list)
void * list_itr_next(ListItr *itr)
bool list_remove_at_idx(List *list, unsigned int idx)
#define LIST_DEFAULT
Default list declaration for empty lists.
void list_push_back(List *list, void *data)
ListItr list_itr_create(List *list)
Common functions to handle RNG manipulation. Using this interface has three goals:
u32 rng_get_u32(enum RngSequence key)
Get the next "randomly" generated number in the sequence corresponding to the given type.
INLINE void sprite_position(Sprite *sprite, int x, int y)
Set sprite position. Inlined for efficiency.
Sprite * sprite_new(u16 a0, u16 a1, u32 tid, u32 pb, s16 sprite_index)
Allocate and retrieve a pointer to a valid Sprite.
Data structure containing data about a BlindType.
Sprite struct for GBA hardware specifics.
Utilities relating around number string representation and protected arithmatic helper functions.
#define NUM_ELEM_IN_ARR(arr)
Get the number of elements in an array.