Add option to enable a more readable deck, suggestion by @Turro75 (#495) (#511)

* Options menu revamp

* Implement readable card sprites

* redraw characters to fix the original style

* clang format

* remove usage of UNDEFINED (-1) for unsigned values

* typo

* change save fix for something cleaner

* remove dependency to game_variables.h from card.c

* Make the palette look less silly ^^'

* Address @ricfehr3's comments

* clang format

* quick rename

* clang format

---------

Co-authored-by: Geralt <84459734+MathisMartin31@users.noreply.github.com>
Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: Turro75 <valerio.turrini@gmail.com>
This commit is contained in:
Rickey
2026-05-25 11:11:33 -07:00
committed by GitHub
co-authored by Geralt MathisMartin31 Turro75
parent cebdebbfd0
commit 221b6d77c0
10 changed files with 172 additions and 110 deletions
+27 -10
View File
@@ -1,8 +1,6 @@
#include "card.h"
#include "deck_gfx.h"
#include "graphic_utils.h"
#include "high_contrast_deck_pal_gfx.h"
#include <maxmod.h>
#include <stdlib.h>
@@ -11,6 +9,11 @@
#include "pool.h"
#include "soundbank.h"
// Card Sprites and Palettes
#include "deck_big_gfx.h"
#include "deck_gfx.h"
#include "high_contrast_deck_pal_gfx.h"
// Card sprites lookup table. First index is the suit, second index is the rank. The value is the
// tile index.
const static u16 _card_sprite_lut[NUM_SUITS][NUM_RANKS] = {
@@ -20,14 +23,13 @@ const static u16 _card_sprite_lut[NUM_SUITS][NUM_RANKS] = {
{624, 640, 656, 672, 688, 704, 720, 736, 752, 768, 784, 800, 816}
};
void card_init()
{
toggle_high_contrast_cards(false);
}
bool high_contrast = DEFAULT_HIGH_CONTRAST;
bool more_readable = DEFAULT_MORE_READABLE;
void toggle_high_contrast_cards(bool enable)
void set_cards_high_contrast(bool enable)
{
if (enable)
high_contrast = enable;
if (high_contrast)
{
GRIT_CPY(&pal_obj_mem[CARD_PB], high_contrast_deck_pal_gfxPal);
}
@@ -37,6 +39,21 @@ void toggle_high_contrast_cards(bool enable)
}
}
void set_cards_more_readable(bool enable)
{
more_readable = enable;
}
bool get_cards_high_contrast(void)
{
return high_contrast;
}
bool get_cards_more_readable(void)
{
return more_readable;
}
// Card methods
Card* card_new(u8 suit, u8 rank)
{
@@ -103,10 +120,10 @@ void card_object_update(CardObject* card_object)
void card_object_set_sprite(CardObject* card_object, int layer)
{
int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
const unsigned int* card_tiles = more_readable ? deck_big_gfxTiles : deck_gfxTiles;
memcpy32(
&tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][tile_index],
&deck_gfxTiles
[_card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE],
&card_tiles[_card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE],
TILE_SIZE * CARD_SPRITE_OFFSET
);
Sprite* sprite = sprite_new(