[Feature] Implement options menu and reading/writing values from/to the SRAM (#449)
* background * Implement Options button * Update main menu artwork * add options menu tiles * prepare options menu handling * incorporate main menu refactor * toto * add all menu interactions * do not reset selection_x in main_menu * options struct * fix rebase from ricfehr3's repo * Implement high contrast cards * Save/Load options values to SRAM * load options on game_init and validate data within the load_options function * Get changes from ricfehr3's PR * recover fix for glitched ace * clang format * clang format * clang format * Save 500B of image data by using only minimal set of tiles instead of keeping final window in source file * clang format * clang format * Implement Options button * Update main menu artwork * progress, leaving it alone for now until discussion * make game_vars an extern * Move options vars into their own struct * rollback previous commit * Implement save validation. Version check to come * implement data validity + version check for game saves * clang format * Save position in rng sequence for consistent run after load * fix rebase issues * fix rebase issue * remove unused/duplicate define * Oops, made a mistake when testing PR #424 * encode high contrast palette into an image, and load it at game_start * document save.c/h and correct typos * correct alignment * game speed and high contrast buttons working * small cleanup * sliders also work again now * clang format * Moved balatro_version extern declaration to version.h file * removed unsused variable * make showing ROM version a toggle * move ante, round and money to the GameVariables struct * Rename SaveCheckInfo struct to SaveHeader for clarity * Add SaveHeader struct explanation * clang format * Revert unnecessary tileset optimization * SFX now follows the sound volume slider * clang format * Music now follows volume slider * Changed volume slider increment from 5 to 20 to avoid having the music sound too rough under 20% volume * refactor main_menu.c to use SelectionGrid and Button structs * clang format * make a "new" save button so we don't save during the state transition * clang format * Reduced state transition flicker by only changing affine background to a different one * Fix loading game too late in game init sequence * First batch of suggestions from @MeirGavish * Remove unnecessary intermediary buffers for high contrast palette swapping * comment row warp hack for button input * Add some of Copilot's suggestions * rename balatro_version into gbalatro_version for rebranding reasons + version display erase screen fix * remove unnecessary NULL check on `on_selection_changed` method * implement small game speed arrow buttons animation * factorize some code * remove unnecessary data validation in load_game(), since we already checked the header * Implement @MeirGavish 's suggestion regarding splitting the huge `on_update` function * clang format * implement @ricfehr3 's suggestion about keeping last selected button instead of using an obscure `on_boot` boolean * Apply @ricfehr3's suggestions * fix clang-format flags --------- Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
This commit is contained in:
@@ -8,6 +8,19 @@
|
||||
|
||||
#include <tonc.h>
|
||||
|
||||
#define GAME_SPEED_MIN 1
|
||||
#define GAME_SPEED_MAX 4
|
||||
|
||||
// Volume is stored from 0 to 5 but is an increment of 20 so 0 to 100 will be displayed
|
||||
#define VOLUME_OPTION_MIN 0
|
||||
#define VOLUME_OPTION_MAX 5
|
||||
#define VOLUME_OPTION_INCREMENT 20
|
||||
|
||||
#define DEFAULT_GAME_SPEED 1
|
||||
#define DEFAULT_HIGH_CONTRAST false
|
||||
#define DEFAULT_MUSIC_VOLUME VOLUME_OPTION_MAX
|
||||
#define DEFAULT_SOUND_VOLUME VOLUME_OPTION_MAX
|
||||
|
||||
/**
|
||||
* @brief A central location for all game variables.
|
||||
*
|
||||
@@ -16,8 +29,26 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
s32 timer;
|
||||
// Internal variables
|
||||
|
||||
s32 timer; // This might already exist in libtonc but idk so i'm just making my own
|
||||
u32 rng_seed;
|
||||
u32 rng_step; // Position in the rng sequence.
|
||||
|
||||
// Variables visible by the player
|
||||
|
||||
int round;
|
||||
int ante;
|
||||
int money;
|
||||
|
||||
// Options variables
|
||||
|
||||
// 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.
|
||||
u8 game_speed;
|
||||
bool high_contrast;
|
||||
u8 music_volume;
|
||||
u8 sound_volume;
|
||||
} GameVariables;
|
||||
|
||||
extern GameVariables g_game_vars;
|
||||
|
||||
Reference in New Issue
Block a user