* 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:
co-authored by
Geralt
MathisMartin31
Turro75
parent
cebdebbfd0
commit
221b6d77c0
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1 @@
|
|||||||
|
-gB4 -Mw4 -Mh4 -m! -pn 16
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
+9
-3
@@ -40,6 +40,10 @@
|
|||||||
|
|
||||||
#define IMPOSSIBLY_HIGH_CARD_VALUE 100
|
#define IMPOSSIBLY_HIGH_CARD_VALUE 100
|
||||||
|
|
||||||
|
// Card sprites
|
||||||
|
#define DEFAULT_HIGH_CONTRAST false
|
||||||
|
#define DEFAULT_MORE_READABLE false
|
||||||
|
|
||||||
// Card types
|
// Card types
|
||||||
typedef struct Card
|
typedef struct Card
|
||||||
{
|
{
|
||||||
@@ -54,9 +58,11 @@ typedef struct CardObject
|
|||||||
bool selected;
|
bool selected;
|
||||||
} CardObject;
|
} CardObject;
|
||||||
|
|
||||||
// Card functions
|
// Card sprites accessibility functions
|
||||||
void card_init();
|
void set_cards_high_contrast(bool enable);
|
||||||
void toggle_high_contrast_cards(bool enable);
|
void set_cards_more_readable(bool enable);
|
||||||
|
bool get_cards_high_contrast(void);
|
||||||
|
bool get_cards_more_readable(void);
|
||||||
|
|
||||||
// Card methods
|
// Card methods
|
||||||
Card* card_new(u8 suit, u8 rank);
|
Card* card_new(u8 suit, u8 rank);
|
||||||
|
|||||||
@@ -19,10 +19,9 @@
|
|||||||
#define VOLUME_OPTION_MAX 5
|
#define VOLUME_OPTION_MAX 5
|
||||||
#define VOLUME_OPTION_INCREMENT 20
|
#define VOLUME_OPTION_INCREMENT 20
|
||||||
|
|
||||||
#define DEFAULT_GAME_SPEED 1
|
#define DEFAULT_GAME_SPEED 1
|
||||||
#define DEFAULT_HIGH_CONTRAST false
|
#define DEFAULT_MUSIC_VOLUME VOLUME_OPTION_MAX
|
||||||
#define DEFAULT_MUSIC_VOLUME VOLUME_OPTION_MAX
|
#define DEFAULT_SOUND_VOLUME VOLUME_OPTION_MAX
|
||||||
#define DEFAULT_SOUND_VOLUME VOLUME_OPTION_MAX
|
|
||||||
|
|
||||||
#define MAX_HANDS 4
|
#define MAX_HANDS 4
|
||||||
#define MAX_DISCARDS 4
|
#define MAX_DISCARDS 4
|
||||||
@@ -66,7 +65,6 @@ typedef struct
|
|||||||
// BY DEFAULT IS SET TO 1, but if changed to 2 or more, should speed up all (or most) of the
|
// BY DEFAULT IS SET TO 1, but if changed to 2 or more, should speed up all (or most) of the
|
||||||
// game aspects that should be sped up by speed, as in the original game.
|
// game aspects that should be sped up by speed, as in the original game.
|
||||||
u8 game_speed;
|
u8 game_speed;
|
||||||
bool high_contrast;
|
|
||||||
u8 music_volume;
|
u8 music_volume;
|
||||||
u8 sound_volume;
|
u8 sound_volume;
|
||||||
} GameVariables;
|
} GameVariables;
|
||||||
|
|||||||
+27
-10
@@ -1,8 +1,6 @@
|
|||||||
#include "card.h"
|
#include "card.h"
|
||||||
|
|
||||||
#include "deck_gfx.h"
|
|
||||||
#include "graphic_utils.h"
|
#include "graphic_utils.h"
|
||||||
#include "high_contrast_deck_pal_gfx.h"
|
|
||||||
|
|
||||||
#include <maxmod.h>
|
#include <maxmod.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -11,6 +9,11 @@
|
|||||||
#include "pool.h"
|
#include "pool.h"
|
||||||
#include "soundbank.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
|
// Card sprites lookup table. First index is the suit, second index is the rank. The value is the
|
||||||
// tile index.
|
// tile index.
|
||||||
const static u16 _card_sprite_lut[NUM_SUITS][NUM_RANKS] = {
|
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}
|
{624, 640, 656, 672, 688, 704, 720, 736, 752, 768, 784, 800, 816}
|
||||||
};
|
};
|
||||||
|
|
||||||
void card_init()
|
bool high_contrast = DEFAULT_HIGH_CONTRAST;
|
||||||
{
|
bool more_readable = DEFAULT_MORE_READABLE;
|
||||||
toggle_high_contrast_cards(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
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 methods
|
||||||
Card* card_new(u8 suit, u8 rank)
|
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)
|
void card_object_set_sprite(CardObject* card_object, int layer)
|
||||||
{
|
{
|
||||||
int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
|
int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
|
||||||
|
const unsigned int* card_tiles = more_readable ? deck_big_gfxTiles : deck_gfxTiles;
|
||||||
memcpy32(
|
memcpy32(
|
||||||
&tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][tile_index],
|
&tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][tile_index],
|
||||||
&deck_gfxTiles
|
&card_tiles[_card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE],
|
||||||
[_card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE],
|
|
||||||
TILE_SIZE * CARD_SPRITE_OFFSET
|
TILE_SIZE * CARD_SPRITE_OFFSET
|
||||||
);
|
);
|
||||||
Sprite* sprite = sprite_new(
|
Sprite* sprite = sprite_new(
|
||||||
|
|||||||
@@ -289,7 +289,6 @@ GameVariables g_game_vars = {
|
|||||||
.round_end_blind_token = NULL,
|
.round_end_blind_token = NULL,
|
||||||
|
|
||||||
.game_speed = DEFAULT_GAME_SPEED,
|
.game_speed = DEFAULT_GAME_SPEED,
|
||||||
.high_contrast = DEFAULT_HIGH_CONTRAST,
|
|
||||||
.music_volume = DEFAULT_MUSIC_VOLUME,
|
.music_volume = DEFAULT_MUSIC_VOLUME,
|
||||||
.sound_volume = DEFAULT_SOUND_VOLUME,
|
.sound_volume = DEFAULT_SOUND_VOLUME,
|
||||||
};
|
};
|
||||||
@@ -2599,9 +2598,6 @@ void game_start(void)
|
|||||||
g_game_vars.hands = MAX_HANDS;
|
g_game_vars.hands = MAX_HANDS;
|
||||||
g_game_vars.discards = MAX_DISCARDS;
|
g_game_vars.discards = MAX_DISCARDS;
|
||||||
|
|
||||||
// Activate high contrast palette for cards if loaded settings tell us to
|
|
||||||
toggle_high_contrast_cards(g_game_vars.high_contrast);
|
|
||||||
|
|
||||||
// Fill the deck with all the cards. Later on this can be replaced with a more dynamic system
|
// Fill the deck with all the cards. Later on this can be replaced with a more dynamic system
|
||||||
// that allows for different decks and card types.
|
// that allows for different decks and card types.
|
||||||
for (int suit = 0; suit < NUM_SUITS; suit++)
|
for (int suit = 0; suit < NUM_SUITS; suit++)
|
||||||
|
|||||||
+90
-58
@@ -4,6 +4,7 @@
|
|||||||
#include "audio_utils.h"
|
#include "audio_utils.h"
|
||||||
#include "background_options_menu_gfx.h"
|
#include "background_options_menu_gfx.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
|
#include "card.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "game/common_ui.h"
|
#include "game/common_ui.h"
|
||||||
#include "game_variables.h"
|
#include "game_variables.h"
|
||||||
@@ -39,23 +40,26 @@ enum OptionSpeedButtons
|
|||||||
#define MENU_BUTTON_MAIN_COLOR_PAL_IDX 1
|
#define MENU_BUTTON_MAIN_COLOR_PAL_IDX 1
|
||||||
#define SAVE_BUTTON_MAIN_COLOR_PAL_IDX 3
|
#define SAVE_BUTTON_MAIN_COLOR_PAL_IDX 3
|
||||||
#define BACK_BUTTON_MAIN_COLOR_PAL_IDX 4
|
#define BACK_BUTTON_MAIN_COLOR_PAL_IDX 4
|
||||||
#define SPEED_DOWN_BUTTON_OUTLINE_COLOR_PAL_IDX 5
|
#define SPEED_DOWN_BUTTON_OUTLINE_COLOR_PAL_IDX 16
|
||||||
#define SPEED_BUTTON_OUTLINE_COLOR_PAL_IDX 6
|
#define SPEED_BUTTON_OUTLINE_COLOR_PAL_IDX 17
|
||||||
#define SPEED_UP_BUTTON_OUTLINE_COLOR_PAL_IDX 7
|
#define SPEED_UP_BUTTON_OUTLINE_COLOR_PAL_IDX 18
|
||||||
#define CONTRAST_BUTTON_OUTLINE_COLOR_PAL_IDX 8
|
#define CONTRAST_BUTTON_OUTLINE_COLOR_PAL_IDX 19
|
||||||
#define MUSIC_BUTTON_OUTLINE_COLOR_PAL_IDX 9
|
#define READABLE_BUTTON_OUTLINE_COLOR_PAL_IDX 20
|
||||||
#define SOUND_BUTTON_OUTLINE_COLOR_PAL_IDX 10
|
#define MUSIC_BUTTON_OUTLINE_COLOR_PAL_IDX 21
|
||||||
#define SAVE_BUTTON_OUTLINE_COLOR_PAL_IDX 11
|
#define SOUND_BUTTON_OUTLINE_COLOR_PAL_IDX 22
|
||||||
#define BACK_BUTTON_OUTLINE_COLOR_PAL_IDX 12
|
#define SAVE_BUTTON_OUTLINE_COLOR_PAL_IDX 23
|
||||||
|
#define BACK_BUTTON_OUTLINE_COLOR_PAL_IDX 24
|
||||||
|
|
||||||
// Define selection grid for the menu buttons
|
// Define selection grid for the menu buttons
|
||||||
|
|
||||||
static void game_speed_down_on_pressed(void);
|
static void game_speed_down_on_pressed(void);
|
||||||
static void game_speed_up_on_pressed(void);
|
static void game_speed_up_on_pressed(void);
|
||||||
static void high_contrast_on_pressed(void);
|
static void high_contrast_on_pressed(void);
|
||||||
|
static void more_readable_on_pressed(void);
|
||||||
static void save_on_pressed(void);
|
static void save_on_pressed(void);
|
||||||
static void back_on_pressed(void);
|
static void back_on_pressed(void);
|
||||||
static int options_menu_return_upper_rows_size(void);
|
static int options_menu_return_upper_rows_size(void);
|
||||||
|
static int options_menu_return_card_sprites_row_size(void);
|
||||||
static int options_menu_return_bottom_row_size(void);
|
static int options_menu_return_bottom_row_size(void);
|
||||||
static void options_menu_row_on_key_transit(SelectionGrid* selection_grid, Selection* selection);
|
static void options_menu_row_on_key_transit(SelectionGrid* selection_grid, Selection* selection);
|
||||||
static bool game_speed_row_on_selection_changed(
|
static bool game_speed_row_on_selection_changed(
|
||||||
@@ -95,7 +99,7 @@ static SelectionGridRow options_menu_selection_rows[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
HIGH_CONTRAST_ROW_IDX,
|
HIGH_CONTRAST_ROW_IDX,
|
||||||
options_menu_return_upper_rows_size,
|
options_menu_return_card_sprites_row_size,
|
||||||
regular_button_row_on_selection_changed,
|
regular_button_row_on_selection_changed,
|
||||||
options_menu_row_on_key_transit,
|
options_menu_row_on_key_transit,
|
||||||
{.wrap = false}
|
{.wrap = false}
|
||||||
@@ -125,7 +129,10 @@ static SelectionGridRow options_menu_selection_rows[] = {
|
|||||||
|
|
||||||
static Button options_menu_buttons[NB_OPTIONS_ROWS][2] = {
|
static Button options_menu_buttons[NB_OPTIONS_ROWS][2] = {
|
||||||
{{SPEED_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
|
{{SPEED_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
|
||||||
{{CONTRAST_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, high_contrast_on_pressed, NULL}},
|
{
|
||||||
|
{CONTRAST_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, high_contrast_on_pressed, NULL},
|
||||||
|
{READABLE_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, more_readable_on_pressed, NULL}
|
||||||
|
},
|
||||||
{{MUSIC_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
|
{{MUSIC_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
|
||||||
{{SOUND_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
|
{{SOUND_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
|
||||||
{
|
{
|
||||||
@@ -164,9 +171,12 @@ static const Rect OPTIONS_SPEED_VALUES[GAME_SPEED_MAX] = { { 3, 20, 4, 21
|
|||||||
{ 4, 22, 5, 23} };
|
{ 4, 22, 5, 23} };
|
||||||
static const BG_POINT OPTIONS_SPEED_VALUE_DEST_POS = {14, 3};
|
static const BG_POINT OPTIONS_SPEED_VALUE_DEST_POS = {14, 3};
|
||||||
|
|
||||||
static const Rect OPTIONS_CONTRAST_VALUE_YES_SRC_RECT = { 1, 24, 4, 25};
|
static const Rect OPTIONS_CONTRAST_CHECK_NO_SRC_RECT = { 0, 24, 1, 25};
|
||||||
static const Rect OPTIONS_CONTRAST_VALUE_NO_SRC_RECT = { 6, 24, 9, 25};
|
static const Rect OPTIONS_CONTRAST_CHECK_YES_SRC_RECT = { 2, 24, 3, 25};
|
||||||
static const BG_POINT OPTIONS_CONTRAST_VALUE_DEST_POS = {13, 7};
|
static const BG_POINT OPTIONS_CONTRAST_CHECK_DEST_POS = {14, 7};
|
||||||
|
static const Rect OPTIONS_READABLE_CHECK_NO_SRC_RECT = { 4, 24, 5, 25};
|
||||||
|
static const Rect OPTIONS_READABLE_CHECK_YES_SRC_RECT = { 6, 24, 7, 25};
|
||||||
|
static const BG_POINT OPTIONS_READABLE_CHECK_DEST_POS = {21, 7};
|
||||||
|
|
||||||
static const Rect OPTIONS_MUSIC_SLIDER_FULL_SRC = { 9, 20, 9, 20};
|
static const Rect OPTIONS_MUSIC_SLIDER_FULL_SRC = { 9, 20, 9, 20};
|
||||||
static const Rect OPTIONS_MUSIC_SLIDER_MID_SRC = {10, 20, 10, 20};
|
static const Rect OPTIONS_MUSIC_SLIDER_MID_SRC = {10, 20, 10, 20};
|
||||||
@@ -184,13 +194,13 @@ static const u8 OPTIONS_SOUND_SLIDER_SEGMENT_LENGTH = (OPTIONS_SOUND_
|
|||||||
/ VOLUME_OPTION_MAX;
|
/ VOLUME_OPTION_MAX;
|
||||||
|
|
||||||
// Values in pixels
|
// Values in pixels
|
||||||
static const BG_POINT OPTIONS_GAME_SPEED_TEXT_POS = { 82, 16};
|
static const BG_POINT OPTIONS_GAME_SPEED_TEXT_POS = { 82, 16};
|
||||||
static const BG_POINT OPTIONS_HIGH_CONTRAST_TEXT_POS = { 40, 48};
|
static const BG_POINT OPTIONS_CARD_SPRITES_TEXT_POS = { 72, 48};
|
||||||
static const BG_POINT OPTIONS_MUSIC_VOLUME_TEXT_POS = { 56, 80};
|
static const BG_POINT OPTIONS_MUSIC_VOLUME_TEXT_POS = { 56, 80};
|
||||||
static const BG_POINT OPTIONS_MUSIC_VALUE_TEXT_POS = {160, 80};
|
static const BG_POINT OPTIONS_MUSIC_VALUE_TEXT_POS = {160, 80};
|
||||||
static const BG_POINT OPTIONS_SOUND_VOLUME_TEXT_POS = { 56, 104};
|
static const BG_POINT OPTIONS_SOUND_VOLUME_TEXT_POS = { 56, 104};
|
||||||
static const BG_POINT OPTIONS_SOUND_VALUE_TEXT_POS = {160, 104};
|
static const BG_POINT OPTIONS_SOUND_VALUE_TEXT_POS = {160, 104};
|
||||||
static const BG_POINT OPTIONS_BACK_SAVE_TEXT_POS = { 64, 136};
|
static const BG_POINT OPTIONS_BACK_SAVE_TEXT_POS = { 64, 136};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#define GAME_SPEED_ARROW_HIGHLIGHT_DURATION 10
|
#define GAME_SPEED_ARROW_HIGHLIGHT_DURATION 10
|
||||||
@@ -212,8 +222,21 @@ static void disable_all_outlines_except_self(Selection sel_btn)
|
|||||||
|
|
||||||
for (int j = 0; j < NB_OPTIONS_ROWS; j++)
|
for (int j = 0; j < NB_OPTIONS_ROWS; j++)
|
||||||
{
|
{
|
||||||
int nb_buttons_in_row = (j == SAVE_BACK_ROW_IDX) ? options_menu_return_bottom_row_size()
|
int nb_buttons_in_row;
|
||||||
: options_menu_return_upper_rows_size();
|
|
||||||
|
switch (j)
|
||||||
|
{
|
||||||
|
case HIGH_CONTRAST_ROW_IDX:
|
||||||
|
nb_buttons_in_row = options_menu_return_card_sprites_row_size();
|
||||||
|
break;
|
||||||
|
case SAVE_BACK_ROW_IDX:
|
||||||
|
nb_buttons_in_row = options_menu_return_bottom_row_size();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nb_buttons_in_row = options_menu_return_upper_rows_size();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nb_buttons_in_row; i++)
|
for (int i = 0; i < nb_buttons_in_row; i++)
|
||||||
{
|
{
|
||||||
button_set_highlight(&options_menu_buttons[j][i], i == sel_btn.x && j == sel_btn.y);
|
button_set_highlight(&options_menu_buttons[j][i], i == sel_btn.x && j == sel_btn.y);
|
||||||
@@ -224,29 +247,16 @@ static void disable_all_outlines_except_self(Selection sel_btn)
|
|||||||
static void update_game_speed_button_graphics()
|
static void update_game_speed_button_graphics()
|
||||||
{
|
{
|
||||||
// check if need to disable game speed arrows
|
// check if need to disable game speed arrows
|
||||||
if (g_game_vars.game_speed == GAME_SPEED_MIN)
|
|
||||||
{
|
|
||||||
main_bg_se_copy_rect(
|
|
||||||
OPTIONS_SPEED_DOWN_DISABLED_BTN_SRC_RECT,
|
|
||||||
OPTIONS_SPEED_DOWN_BTN_DEST_POS
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
main_bg_se_copy_rect(
|
|
||||||
OPTIONS_SPEED_DOWN_ACTIVE_BTN_SRC_RECT,
|
|
||||||
OPTIONS_SPEED_DOWN_BTN_DEST_POS
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_game_vars.game_speed == GAME_SPEED_MAX)
|
Rect speed_down_btn_tiles = (g_game_vars.game_speed == GAME_SPEED_MIN)
|
||||||
{
|
? OPTIONS_SPEED_DOWN_DISABLED_BTN_SRC_RECT
|
||||||
main_bg_se_copy_rect(OPTIONS_SPEED_UP_DISABLED_BTN_SRC_RECT, OPTIONS_SPEED_UP_BTN_DEST_POS);
|
: OPTIONS_SPEED_DOWN_ACTIVE_BTN_SRC_RECT;
|
||||||
}
|
main_bg_se_copy_rect(speed_down_btn_tiles, OPTIONS_SPEED_DOWN_BTN_DEST_POS);
|
||||||
else
|
|
||||||
{
|
Rect speed_up_btn_tiles = (g_game_vars.game_speed == GAME_SPEED_MAX)
|
||||||
main_bg_se_copy_rect(OPTIONS_SPEED_UP_ACTIVE_BTN_SRC_RECT, OPTIONS_SPEED_UP_BTN_DEST_POS);
|
? OPTIONS_SPEED_UP_DISABLED_BTN_SRC_RECT
|
||||||
}
|
: OPTIONS_SPEED_UP_ACTIVE_BTN_SRC_RECT;
|
||||||
|
main_bg_se_copy_rect(speed_up_btn_tiles, OPTIONS_SPEED_UP_BTN_DEST_POS);
|
||||||
|
|
||||||
main_bg_se_copy_rect(
|
main_bg_se_copy_rect(
|
||||||
OPTIONS_SPEED_VALUES[g_game_vars.game_speed - 1],
|
OPTIONS_SPEED_VALUES[g_game_vars.game_speed - 1],
|
||||||
@@ -254,16 +264,18 @@ static void update_game_speed_button_graphics()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_high_contrast_button_graphics()
|
static void update_high_contrast_button_graphics(void)
|
||||||
{
|
{
|
||||||
if (g_game_vars.high_contrast)
|
Rect contrast_btn_tiles = (get_cards_high_contrast()) ? OPTIONS_CONTRAST_CHECK_YES_SRC_RECT
|
||||||
{
|
: OPTIONS_CONTRAST_CHECK_NO_SRC_RECT;
|
||||||
main_bg_se_copy_rect(OPTIONS_CONTRAST_VALUE_YES_SRC_RECT, OPTIONS_CONTRAST_VALUE_DEST_POS);
|
main_bg_se_copy_rect(contrast_btn_tiles, OPTIONS_CONTRAST_CHECK_DEST_POS);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
static void update_more_readable_button_graphics(void)
|
||||||
main_bg_se_copy_rect(OPTIONS_CONTRAST_VALUE_NO_SRC_RECT, OPTIONS_CONTRAST_VALUE_DEST_POS);
|
{
|
||||||
}
|
Rect readable_btn_tiles = (get_cards_more_readable()) ? OPTIONS_READABLE_CHECK_YES_SRC_RECT
|
||||||
|
: OPTIONS_READABLE_CHECK_NO_SRC_RECT;
|
||||||
|
main_bg_se_copy_rect(readable_btn_tiles, OPTIONS_READABLE_CHECK_DEST_POS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_volume_slider_graphics(enum OptionButtonRows sel_row)
|
static void update_volume_slider_graphics(enum OptionButtonRows sel_row)
|
||||||
@@ -360,9 +372,9 @@ void game_options_menu_change_background(void)
|
|||||||
TTE_WHITE_PB
|
TTE_WHITE_PB
|
||||||
);
|
);
|
||||||
tte_printf(
|
tte_printf(
|
||||||
"#{P:%d,%d; cx:0x%X000}High Contrast Cards",
|
"#{P:%d,%d; cx:0x%X000}Card Sprites",
|
||||||
OPTIONS_HIGH_CONTRAST_TEXT_POS.x,
|
OPTIONS_CARD_SPRITES_TEXT_POS.x,
|
||||||
OPTIONS_HIGH_CONTRAST_TEXT_POS.y,
|
OPTIONS_CARD_SPRITES_TEXT_POS.y,
|
||||||
TTE_WHITE_PB
|
TTE_WHITE_PB
|
||||||
);
|
);
|
||||||
tte_printf(
|
tte_printf(
|
||||||
@@ -396,6 +408,7 @@ void game_options_menu_on_init(void)
|
|||||||
// Do an update on the first frame
|
// Do an update on the first frame
|
||||||
update_game_speed_button_graphics();
|
update_game_speed_button_graphics();
|
||||||
update_high_contrast_button_graphics();
|
update_high_contrast_button_graphics();
|
||||||
|
update_more_readable_button_graphics();
|
||||||
update_volume_slider_graphics(MUSIC_VOLUME_ROW_IDX);
|
update_volume_slider_graphics(MUSIC_VOLUME_ROW_IDX);
|
||||||
update_volume_slider_graphics(SOUND_VOLUME_ROW_IDX);
|
update_volume_slider_graphics(SOUND_VOLUME_ROW_IDX);
|
||||||
}
|
}
|
||||||
@@ -442,10 +455,19 @@ static void game_speed_up_on_pressed(void)
|
|||||||
*/
|
*/
|
||||||
static void high_contrast_on_pressed(void)
|
static void high_contrast_on_pressed(void)
|
||||||
{
|
{
|
||||||
g_game_vars.high_contrast = (g_game_vars.high_contrast == 1) ? false : true;
|
set_cards_high_contrast(!get_cards_high_contrast());
|
||||||
update_high_contrast_button_graphics();
|
update_high_contrast_button_graphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handles input for the more readable card toggle button and nothing more.
|
||||||
|
*/
|
||||||
|
static void more_readable_on_pressed(void)
|
||||||
|
{
|
||||||
|
set_cards_more_readable(!get_cards_more_readable());
|
||||||
|
update_more_readable_button_graphics();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handles input for the Save button.
|
* @brief Handles input for the Save button.
|
||||||
*/
|
*/
|
||||||
@@ -465,7 +487,7 @@ static void back_on_pressed(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gives the width of upper options menu rows in selection grid.
|
* @brief Gives the width of normal options rows in selection grid.
|
||||||
*
|
*
|
||||||
* @returns 1
|
* @returns 1
|
||||||
*/
|
*/
|
||||||
@@ -474,6 +496,16 @@ static int options_menu_return_upper_rows_size(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gives the width of Card Sprites options row in selection grid.
|
||||||
|
*
|
||||||
|
* @returns 2
|
||||||
|
*/
|
||||||
|
static int options_menu_return_card_sprites_row_size(void)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gives the width of the Save and Back buttons' row.
|
* @brief Gives the width of the Save and Back buttons' row.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ void init()
|
|||||||
load_options();
|
load_options();
|
||||||
affine_background_init();
|
affine_background_init();
|
||||||
sprite_init();
|
sprite_init();
|
||||||
card_init();
|
|
||||||
blind_init();
|
blind_init();
|
||||||
joker_init();
|
joker_init();
|
||||||
game_init();
|
game_init();
|
||||||
|
|||||||
+42
-29
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "audio_utils.h"
|
#include "audio_utils.h"
|
||||||
#include "bitset.h"
|
#include "bitset.h"
|
||||||
|
#include "card.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "joker.h"
|
#include "joker.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
@@ -55,6 +56,16 @@ typedef struct SaveHeader
|
|||||||
u32 valid_sections;
|
u32 valid_sections;
|
||||||
} SaveHeader;
|
} SaveHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default value for the SaveHeader struct.
|
||||||
|
*/
|
||||||
|
static const SaveHeader SaveHeader_default = {
|
||||||
|
.magic = CHECK_MAGIC,
|
||||||
|
.dirty = false,
|
||||||
|
.githash = "fffffff",
|
||||||
|
.valid_sections = SAVE_SECTION_FLAG_NONE
|
||||||
|
};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
/**
|
/**
|
||||||
* @brief SaveOptions will only contain options data set in the Options Menu
|
* @brief SaveOptions will only contain options data set in the Options Menu
|
||||||
@@ -65,8 +76,8 @@ typedef struct SaveHeader
|
|||||||
* 1 | 'T' | 'I' | 'O' | 'N' | - | Spells "- OPTIONS DATA -"
|
* 1 | 'T' | 'I' | 'O' | 'N' | - | Spells "- OPTIONS DATA -"
|
||||||
* 2 | 'S' | ' ' | 'D' | 'A' | - | -
|
* 2 | 'S' | ' ' | 'D' | 'A' | - | -
|
||||||
* 3 | 'T' | 'A' | ' ' | '-' | - | -
|
* 3 | 'T' | 'A' | ' ' | '-' | - | -
|
||||||
* 4 | SPEED | CNTRST | MUSIC | SOUND | OPTN_VALUES | All 4 option values, packed in a single word.
|
* 4 | SPEED | CNTRST | READBL | MUSIC | OPTN_VALUES | All 5 option values, followed by some padding,
|
||||||
* 5 | UNDEF | UNDEF | UNDEF | UNDEF | PADDING | Padding, so that the next section starts at the beginning of the
|
* 5 | SOUND | UNDEF | UNDEF | UNDEF | - | so that the next section starts at the beginning of the
|
||||||
* 6 | UNDEF | UNDEF | UNDEF | UNDEF | - | next 4-word row in a hex viewer
|
* 6 | UNDEF | UNDEF | UNDEF | UNDEF | - | next 4-word row in a hex viewer
|
||||||
* 7 | UNDEF | UNDEF | UNDEF | UNDEF | - | -
|
* 7 | UNDEF | UNDEF | UNDEF | UNDEF | - | -
|
||||||
*/
|
*/
|
||||||
@@ -75,12 +86,33 @@ typedef struct SaveOptions
|
|||||||
{
|
{
|
||||||
char tag_options[SAVE_LABEL_SIZE];
|
char tag_options[SAVE_LABEL_SIZE];
|
||||||
u8 game_speed;
|
u8 game_speed;
|
||||||
bool high_contrast;
|
bool cards_high_contrast;
|
||||||
|
bool cards_more_readable;
|
||||||
u8 music_volume;
|
u8 music_volume;
|
||||||
u8 sound_volume;
|
u8 sound_volume;
|
||||||
u32 padding[3];
|
s8 padding[11];
|
||||||
} SaveOptions;
|
} SaveOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default value for the SaveOptions struct, with tags already set.
|
||||||
|
*/
|
||||||
|
// clang-format off
|
||||||
|
static const SaveOptions SaveOptions_default = {
|
||||||
|
.tag_options = "- OPTIONS DATA -",
|
||||||
|
.game_speed = GAME_SPEED_MIN,
|
||||||
|
.cards_high_contrast = DEFAULT_HIGH_CONTRAST,
|
||||||
|
.cards_more_readable = DEFAULT_MORE_READABLE,
|
||||||
|
.music_volume = VOLUME_OPTION_MAX,
|
||||||
|
.sound_volume = VOLUME_OPTION_MAX,
|
||||||
|
.padding = {
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief JokerObjectSaveData will hold the minimal amount of data necessary to reconstruct a Joker.
|
* @brief JokerObjectSaveData will hold the minimal amount of data necessary to reconstruct a Joker.
|
||||||
* The `id` is a u8 in the base Joker struct, but I made it a u32 here to keep
|
* The `id` is a u8 in the base Joker struct, but I made it a u32 here to keep
|
||||||
@@ -131,7 +163,7 @@ typedef struct SaveGame
|
|||||||
int round;
|
int round;
|
||||||
int ante;
|
int ante;
|
||||||
int money;
|
int money;
|
||||||
u32 padding[2];
|
s32 padding[2];
|
||||||
|
|
||||||
char tag_jokers[SAVE_LABEL_SIZE];
|
char tag_jokers[SAVE_LABEL_SIZE];
|
||||||
JokerObjectSaveData jokers_data[MAX_JOKERS_HELD_SIZE];
|
JokerObjectSaveData jokers_data[MAX_JOKERS_HELD_SIZE];
|
||||||
@@ -139,28 +171,6 @@ typedef struct SaveGame
|
|||||||
char tag_end[4];
|
char tag_end[4];
|
||||||
} SaveGame;
|
} SaveGame;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Default value for the SaveHeader struct.
|
|
||||||
*/
|
|
||||||
static const SaveHeader SaveHeader_default = {
|
|
||||||
.magic = CHECK_MAGIC,
|
|
||||||
.dirty = false,
|
|
||||||
.githash = "fffffff",
|
|
||||||
.valid_sections = SAVE_SECTION_FLAG_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Default value for the SaveOptions struct, with tags already set.
|
|
||||||
*/
|
|
||||||
static const SaveOptions SaveOptions_default = {
|
|
||||||
.tag_options = "- OPTIONS DATA -",
|
|
||||||
.game_speed = GAME_SPEED_MIN,
|
|
||||||
.high_contrast = DEFAULT_HIGH_CONTRAST,
|
|
||||||
.music_volume = VOLUME_OPTION_MAX,
|
|
||||||
.sound_volume = VOLUME_OPTION_MAX,
|
|
||||||
.padding = {UNDEFINED, UNDEFINED, UNDEFINED},
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default value for the SaveGame struct, with tags already set.
|
* @brief Default value for the SaveGame struct, with tags already set.
|
||||||
*/
|
*/
|
||||||
@@ -293,7 +303,8 @@ void save_options(void)
|
|||||||
SaveOptions options = SaveOptions_default;
|
SaveOptions options = SaveOptions_default;
|
||||||
|
|
||||||
options.game_speed = g_game_vars.game_speed;
|
options.game_speed = g_game_vars.game_speed;
|
||||||
options.high_contrast = g_game_vars.high_contrast;
|
options.cards_high_contrast = get_cards_high_contrast();
|
||||||
|
options.cards_more_readable = get_cards_more_readable();
|
||||||
options.music_volume = g_game_vars.music_volume;
|
options.music_volume = g_game_vars.music_volume;
|
||||||
options.sound_volume = g_game_vars.sound_volume;
|
options.sound_volume = g_game_vars.sound_volume;
|
||||||
|
|
||||||
@@ -312,10 +323,12 @@ void load_options(void)
|
|||||||
read_sram(OPTIONS_ADDRESS, (u8*)&options, sizeof(options));
|
read_sram(OPTIONS_ADDRESS, (u8*)&options, sizeof(options));
|
||||||
|
|
||||||
g_game_vars.game_speed = options.game_speed;
|
g_game_vars.game_speed = options.game_speed;
|
||||||
g_game_vars.high_contrast = options.high_contrast;
|
|
||||||
g_game_vars.music_volume = options.music_volume;
|
g_game_vars.music_volume = options.music_volume;
|
||||||
g_game_vars.sound_volume = options.sound_volume;
|
g_game_vars.sound_volume = options.sound_volume;
|
||||||
|
|
||||||
|
set_cards_high_contrast(options.cards_high_contrast);
|
||||||
|
set_cards_more_readable(options.cards_more_readable);
|
||||||
|
|
||||||
mmSetModuleVolume(MM_MODULE_FULL_VOLUME * g_game_vars.music_volume / VOLUME_OPTION_MAX);
|
mmSetModuleVolume(MM_MODULE_FULL_VOLUME * g_game_vars.music_volume / VOLUME_OPTION_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user