Separate out graphics and add ability change boss

This commit is contained in:
Rickey Fehr
2025-10-13 23:05:25 -07:00
parent f885fa9164
commit ef048791c1
10 changed files with 61 additions and 32 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 597 B

+1
View File
@@ -0,0 +1 @@
-gB4 -Mw4 -Mh4 -p!
Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

+1
View File
@@ -0,0 +1 @@
-gB4 -Mw4 -Mh4 -p!
Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

+8 -6
View File
@@ -5,13 +5,12 @@
#define MAX_ANTE 8 // The GBA's max uint value is around 4 billion, so we're going to not add endless mode for simplicity's sake
#define BLIND_COUNT 3
#define SMALL_BLIND_PB 1
#define BIG_BLIND_PB 2
#define BOSS_BLIND_PB 3
#define BLIND_SPRITE_OFFSET 16
#define BLIND_SPRITE_COPY_SIZE BLIND_SPRITE_OFFSET * 8 // 8 ints per tile
#define SMALL_BLIND_TID 960
#define BIG_BLIND_TID (BLIND_SPRITE_OFFSET + SMALL_BLIND_TID)
#define BOSS_BLIND_TID (BLIND_SPRITE_OFFSET + BIG_BLIND_TID)
@@ -27,7 +26,7 @@ enum BlindColorIndex
BLIND_BACKGROUND_SHADOW_COLOR_INDEX = 7,
};
#define BLIND_INFO_TABLE \
#define BLIND_TYPE_INFO_TABLE \
BLIND_INFO(SMALL, small, FIX_ONE, 3) \
BLIND_INFO(BIG, big, (FIX_ONE * 3) / 2, 4) \
BLIND_INFO(BOSS, boss, FIX_ONE * 2, 5)
@@ -36,7 +35,7 @@ enum BlindType
{
#define BLIND_INFO(NAME, name, multi, reward) \
BLIND_TYPE_##NAME ,
BLIND_INFO_TABLE
BLIND_TYPE_INFO_TABLE
BLIND_TYPE_MAX,
#undef BLIND_INFO
};
@@ -53,21 +52,24 @@ enum BlindState
// TODO: Move this to a common interface for other palettes
typedef struct
{
const unsigned int* tiles;
const u16* palette;
u32 tid;
u32 pb;
} PaletteInfo;
} BlindGfxInfo;
typedef struct
{
enum BlindType type;
PaletteInfo pal_info;
BlindGfxInfo gfx_info;
FIXED score_req_multipler;
s32 reward;
} Blind;
void blind_init();
void blind_set_boss_graphics(const unsigned int* tiles, const u16* palette);
int blind_get_requirement(enum BlindType type, int ante);
int blind_get_reward(enum BlindType type);
u16 blind_get_color(enum BlindType type, enum BlindColorIndex index);
+43 -18
View File
@@ -1,7 +1,9 @@
#include <tonc.h>
#include "blind.h"
#include "blinds_gfx.h"
#include "small_blind_gfx.h"
#include "big_blind_gfx.h"
#include "boss_blind_gfx.h"
#include "graphic_utils.h"
// +1 is added because we'll actually be indexing at 1, but if something causes you to go to ante 0, there will still be a value there.
@@ -13,13 +15,14 @@ static const u16 big_blind_token_palette[PAL_ROW_LEN] = {0x0000, 0x2527, 0x15F5,
static const u16 boss_blind_token_palette[PAL_ROW_LEN] = {0x0000, 0x2CC9, 0x3D0D, 0x5E14, 0x5171, 0x4D0F, 0x2CC8, 0x3089}; // This variable is temporary, each boss blind will have its own unique palette
static const Blind blindMap[BLIND_TYPE_MAX] =
static Blind _blind_type_map[BLIND_TYPE_MAX] =
{
#define BLIND_INFO(NAME, name, multi, _reward) \
{ \
.type = BLIND_TYPE_##NAME , \
.pal_info = \
.gfx_info = \
{ \
.tiles = name##_blind_gfxTiles, \
.palette = name##_blind_token_palette, \
.tid = NAME##_BLIND_TID, \
.pb = NAME##_BLIND_PB, \
@@ -27,48 +30,70 @@ static const Blind blindMap[BLIND_TYPE_MAX] =
.score_req_multipler = multi , \
.reward = _reward , \
},
BLIND_INFO_TABLE
BLIND_TYPE_INFO_TABLE
#undef BLIND_INFO
};
static void blind_gfx_init(enum BlindType type)
{
// TODO: Re-add grit copy. You need to decouple the blind graphics first.
// This will allow this function to change the boss graphics info
//GRIT_CPY(&tile_mem[4][_blind_type_map[type].pal_info.tid], tiles);
BlindGfxInfo* p_gfx = &_blind_type_map[type].gfx_info;
memcpy32(&tile_mem[4][p_gfx->tid], p_gfx->tiles, BLIND_SPRITE_COPY_SIZE);
memcpy16(&pal_obj_bank[p_gfx->pb], p_gfx->palette, PAL_ROW_LEN);
}
__attribute__((unused))
void blind_set_boss_graphics(const unsigned int* tiles, const u16* palette)
{
// TODO: This function is unused and not fully fleshed out.
// We need to support more boss blind graphics in the future.
// The idea here is that we can call this function to set the boss up to
// render new tiles
//
// This will eventually be in it's own map mapping graphic data to
// boss types.
_blind_type_map[BLIND_TYPE_BOSS].gfx_info.tiles = tiles;
_blind_type_map[BLIND_TYPE_BOSS].gfx_info.palette = palette;
blind_gfx_init(BLIND_TYPE_BOSS);
}
void blind_init()
{
// Blind graphics (fighting grit every step of the way as usual)
GRIT_CPY(&tile_mem[4][SMALL_BLIND_TID], blinds_gfxTiles);
for(int i = 0; i < BLIND_COUNT; i++)
for(int i = 0; i < BLIND_TYPE_MAX; i++)
{
const u16* pal = blindMap[i].pal_info.palette;
u32 pb = blindMap[i].pal_info.pb;
u32 pal_offset = PAL_ROW_LEN * pb;
memcpy16(&pal_obj_mem[pal_offset], pal, PAL_ROW_LEN);
blind_gfx_init(i);
}
return;
}
int blind_get_requirement(enum BlindType type, int ante)
{
if (ante < 0 || ante > MAX_ANTE) ante = 0; // Ensure ante is within valid range
return fx2int(blindMap[type].score_req_multipler * ante_lut[ante]);
return fx2int(_blind_type_map[type].score_req_multipler * ante_lut[ante]);
}
int blind_get_reward(enum BlindType type)
{
return blindMap[type].reward;
return _blind_type_map[type].reward;
}
u16 blind_get_color(enum BlindType type, enum BlindColorIndex index)
{
return blindMap[type].pal_info.palette[index];
return _blind_type_map[type].gfx_info.palette[index];
}
Sprite *blind_token_new(enum BlindType type, int x, int y, int sprite_index)
{
u16 a0 = ATTR0_SQUARE | ATTR0_4BPP;
u16 a1 = ATTR1_SIZE_32x32;
u32 tid = blindMap[type].pal_info.tid, pb = blindMap[type].pal_info.pb;
u32 tid = _blind_type_map[type].gfx_info.tid, pb = _blind_type_map[type].gfx_info.pb;
Sprite* sprite = sprite_new(a0, a1, tid, pb, sprite_index);
+8 -8
View File
@@ -78,12 +78,12 @@ static CardObject *main_menu_ace = NULL;
static Sprite *playing_blind_token = NULL; // The sprite that displays the blind when in "GAME_PLAYING/GAME_ROUND_END" state
static Sprite *round_end_blind_token = NULL; // The sprite that displays the blind when in "GAME_ROUND_END" state
static Sprite *blind_select_tokens[BLIND_COUNT] = {NULL}; // The sprites that display the blinds when in "GAME_BLIND_SELECT" state
static Sprite *blind_select_tokens[BLIND_TYPE_MAX] = {NULL}; // The sprites that display the blinds when in "GAME_BLIND_SELECT" state
static int current_blind = BLIND_TYPE_SMALL;
// The current state of the blinds, this is used to determine what the game is doing at any given time
static enum BlindState blinds[BLIND_COUNT] =
static enum BlindState blinds[BLIND_TYPE_MAX] =
{
BLIND_STATE_CURRENT,
BLIND_STATE_UPCOMING,
@@ -708,7 +708,7 @@ void change_background(int id)
int x_to = 9 + (i * 5);
int y_to = 29;
for (int j = 0; j < BLIND_COUNT; j++)
for (int j = 0; j < BLIND_TYPE_MAX; j++)
{
memcpy16(&se_mem[MAIN_BG_SBB][x_to + 32 * y_to], &se_mem[MAIN_BG_SBB][x_from + 32 * y_from], 5);
y_from++;
@@ -1101,7 +1101,7 @@ void deck_shuffle()
void increment_blind(enum BlindState increment_reason)
{
current_blind++;
if (current_blind >= BLIND_COUNT)
if (current_blind >= BLIND_TYPE_MAX)
{
current_blind = 0;
blinds[0] = BLIND_STATE_CURRENT; // Reset the blinds to the first one
@@ -2901,7 +2901,7 @@ void game_blind_select()
change_background(BG_ID_BLIND_SELECT);
main_bg_se_copy_rect_1_tile_vert(POP_MENU_ANIM_RECT, SE_UP);
for (int i = 0; i < BLIND_COUNT; i++)
for (int i = 0; i < BLIND_TYPE_MAX; i++)
{
sprite_position(blind_select_tokens[i], blind_select_tokens[i]->pos.x, blind_select_tokens[i]->pos.y - TILE_SIZE);
}
@@ -2951,7 +2951,7 @@ void game_blind_select()
main_bg_se_copy_rect_1_tile_vert(POP_MENU_ANIM_RECT, SE_UP);
}
for (int i = 0; i < BLIND_COUNT; i++)
for (int i = 0; i < BLIND_TYPE_MAX; i++)
{
sprite_position(blind_select_tokens[i], blind_select_tokens[i]->pos.x, blind_select_tokens[i]->pos.y - (TILE_SIZE * 12));
}
@@ -2982,14 +2982,14 @@ void game_blind_select()
blinds_rect.top -= 1; // Because of the raised blind
main_bg_se_move_rect_1_tile_vert(blinds_rect, SE_DOWN);
for (int i = 0; i < BLIND_COUNT; i++)
for (int i = 0; i < BLIND_TYPE_MAX; i++)
{
sprite_position(blind_select_tokens[i], blind_select_tokens[i]->pos.x, blind_select_tokens[i]->pos.y + TILE_SIZE);
}
}
else if (timer >= MENU_POP_OUT_ANIM_FRAMES)
{
for (int i = 0; i < BLIND_COUNT; i++)
for (int i = 0; i < BLIND_TYPE_MAX; i++)
{
obj_hide(blind_select_tokens[i]->obj);
}