From c128739405acf7f7fc4414cb68803e9b966ade69 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 26 Apr 2024 16:19:13 +0200 Subject: [PATCH] added separate 3-state type values for "true" and "false" states --- src/files.c | 10 +++++----- src/game_bd/main_bd.c | 8 ++++---- src/libgame/setup.c | 8 ++++---- src/libgame/types.h | 4 ++++ src/screens.c | 28 ++++++++++++++-------------- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/files.c b/src/files.c index 9db04027..ce671c74 100644 --- a/src/files.c +++ b/src/files.c @@ -11658,8 +11658,8 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->bd_scroll_delay = TRUE; si->bd_show_invisible_outbox = FALSE; si->bd_smooth_movements = MODE_AUTO; - si->bd_pushing_graphics = TRUE; - si->bd_up_down_graphics = TRUE; + si->bd_pushing_graphics = MODE_TRUE; + si->bd_up_down_graphics = MODE_TRUE; si->bd_skip_falling_sounds = MODE_AUTO; si->bd_palette_c64 = GD_DEFAULT_PALETTE_C64; si->bd_palette_c64dtv = GD_DEFAULT_PALETTE_C64DTV; @@ -11676,9 +11676,9 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->sounds_set = getStringCopy(SND_CLASSIC_SUBDIR); si->music_set = getStringCopy(MUS_CLASSIC_SUBDIR); - si->override_level_graphics = FALSE; - si->override_level_sounds = FALSE; - si->override_level_music = FALSE; + si->override_level_graphics = MODE_FALSE; + si->override_level_sounds = MODE_FALSE; + si->override_level_music = MODE_FALSE; si->volume_simple = 100; // percent si->volume_loops = 100; // percent diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index a35f3873..8151af43 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -442,28 +442,28 @@ boolean use_native_bd_graphics_engine(void) // check if smooth game element movements selected in setup menu boolean use_bd_smooth_movements(void) { - return ((setup.bd_smooth_movements == TRUE) || + return ((setup.bd_smooth_movements == MODE_TRUE) || (setup.bd_smooth_movements == MODE_AUTO && !use_native_bd_graphics_engine())); } // check if player pushing graphics selected in setup menu boolean use_bd_pushing_graphics(void) { - return ((setup.bd_pushing_graphics == TRUE) || + return ((setup.bd_pushing_graphics == MODE_TRUE) || (setup.bd_pushing_graphics == MODE_AUTO && !use_native_bd_graphics_engine())); } // check if player up/down graphics selected in setup menu boolean use_bd_up_down_graphics(void) { - return ((setup.bd_up_down_graphics == TRUE) || + return ((setup.bd_up_down_graphics == MODE_TRUE) || (setup.bd_up_down_graphics == MODE_AUTO && !use_native_bd_graphics_engine())); } // check if skipping falling sounds selected in setup menu boolean skip_bd_falling_sounds(void) { - return ((setup.bd_skip_falling_sounds == TRUE) || + return ((setup.bd_skip_falling_sounds == MODE_TRUE) || (setup.bd_skip_falling_sounds == MODE_AUTO && !game.use_native_bd_sound_engine)); } diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 5a984166..a9a62d4e 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -4865,7 +4865,7 @@ char *getSetupValue(int type, void *value) case TYPE_SWITCH_3_STATES: strcpy(value_string, (*(int *)value == MODE_AUTO ? "auto" : *(int *)value == MODE_ASK ? "ask" : - *(int *)value == FALSE ? "off" : "on")); + *(int *)value == MODE_FALSE ? "off" : "on")); break; case TYPE_YES_NO: @@ -4874,12 +4874,12 @@ char *getSetupValue(int type, void *value) case TYPE_YES_NO_AUTO: strcpy(value_string, (*(int *)value == MODE_AUTO ? "auto" : - *(int *)value == FALSE ? "no" : "yes")); + *(int *)value == MODE_FALSE ? "no" : "yes")); break; case TYPE_YES_NO_ASK: - strcpy(value_string, (*(int *)value == MODE_ASK ? "ask" : - *(int *)value == FALSE ? "no" : "yes")); + strcpy(value_string, (*(int *)value == MODE_ASK ? "ask" : + *(int *)value == MODE_FALSE ? "no" : "yes")); break; case TYPE_ECS_AGA: diff --git a/src/libgame/types.h b/src/libgame/types.h index 2c678f70..19a0f870 100644 --- a/src/libgame/types.h +++ b/src/libgame/types.h @@ -40,9 +40,13 @@ typedef unsigned char byte; #undef MODE_ASK #endif +// values for boolean data type #define TRUE 1 #define FALSE 0 +// values for 3-state data type (for "yes/no/auto" or "yes/no/ask") +#define MODE_TRUE 1 +#define MODE_FALSE 0 #define MODE_AUTO -1 #define MODE_ASK -1 diff --git a/src/screens.c b/src/screens.c index 14e6291c..e0a8e334 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1929,7 +1929,7 @@ void DrawMainMenu(void) SetAnimationFirstLevel(leveldir_current->first_level); // level_nr may have been set to value over handicap with level editor - if (setup.allow_skipping_levels != TRUE && level_nr > leveldir_current->handicap_level) + if (setup.allow_skipping_levels != MODE_TRUE && level_nr > leveldir_current->handicap_level) level_nr = leveldir_current->handicap_level; LoadLevel(level_nr); @@ -2286,7 +2286,7 @@ static void HandleMainMenu_SelectLevel(int step, int direction, if (new_level_nr > leveldir_current->last_level) new_level_nr = leveldir_current->last_level; - if (setup.allow_skipping_levels != TRUE && new_level_nr > leveldir_current->handicap_level) + if (setup.allow_skipping_levels != MODE_TRUE && new_level_nr > leveldir_current->handicap_level) { // skipping levels is only allowed when trying to skip single level // (also, skipping BD style intermission levels is always possible) @@ -5720,7 +5720,7 @@ static void HandleHallOfFame_SelectLevel(int step, int direction) if (new_level_nr > leveldir_current->last_level) new_level_nr = leveldir_current->last_level; - if (setup.allow_skipping_levels != TRUE && new_level_nr > leveldir_current->handicap_level) + if (setup.allow_skipping_levels != MODE_TRUE && new_level_nr > leveldir_current->handicap_level) new_level_nr = leveldir_current->handicap_level; if (new_level_nr != old_level_nr) @@ -8387,10 +8387,10 @@ static int getSetupValueFont(int type, void *value) return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF); else if (type & TYPE_YES_NO_AUTO) return (*(int *)value == MODE_AUTO ? FONT_OPTION_ON : - *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON); + *(int *)value == MODE_FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON); else if (type & TYPE_YES_NO_ASK) - return (*(int *)value == MODE_ASK ? FONT_OPTION_ON : - *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON); + return (*(int *)value == MODE_ASK ? FONT_OPTION_ON : + *(int *)value == MODE_FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON); else if (type & TYPE_PLAYER) return FONT_VALUE_1; else @@ -8534,19 +8534,19 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) { *(int *)si->value = (dx == -1 ? - (*(int *)si->value == MODE_AUTO ? TRUE : - *(int *)si->value == TRUE ? FALSE : MODE_AUTO) : - (*(int *)si->value == TRUE ? MODE_AUTO : - *(int *)si->value == MODE_AUTO ? FALSE : TRUE)); + (*(int *)si->value == MODE_AUTO ? MODE_TRUE : + *(int *)si->value == MODE_TRUE ? MODE_FALSE : MODE_AUTO) : + (*(int *)si->value == MODE_TRUE ? MODE_AUTO : + *(int *)si->value == MODE_AUTO ? MODE_FALSE : MODE_TRUE)); } else if (si->type & TYPE_YES_NO_ASK) { *(int *)si->value = (dx == -1 ? - (*(int *)si->value == MODE_ASK ? TRUE : - *(int *)si->value == TRUE ? FALSE : MODE_ASK) : - (*(int *)si->value == TRUE ? MODE_ASK : - *(int *)si->value == MODE_ASK ? FALSE : TRUE)); + (*(int *)si->value == MODE_ASK ? MODE_TRUE : + *(int *)si->value == MODE_TRUE ? MODE_FALSE : MODE_ASK) : + (*(int *)si->value == MODE_TRUE ? MODE_ASK : + *(int *)si->value == MODE_ASK ? MODE_FALSE : MODE_TRUE)); } else if (si->type & TYPE_KEY) { -- 2.34.1