From b9781a9921b1ae15f27c737a3da7c00b3f7a9f7e Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 15 Apr 2024 00:41:57 +0200 Subject: [PATCH] added setup option for muting double falling sounds in BD engine --- src/files.c | 5 +++++ src/game_bd/bd_caveengine.c | 10 ++++++++++ src/game_bd/export_bd.h | 1 + src/game_bd/main_bd.c | 7 +++++++ src/libgame/system.h | 1 + src/screens.c | 1 + 6 files changed, 25 insertions(+) diff --git a/src/files.c b/src/files.c index 175efdd5..53c87771 100644 --- a/src/files.c +++ b/src/files.c @@ -10783,6 +10783,10 @@ static struct TokenInfo global_setup_tokens[] = TYPE_SWITCH3, &setup.bd_up_down_graphics, "bd_up_down_graphics" }, + { + TYPE_SWITCH3, + &setup.bd_skip_falling_sounds, "bd_skip_falling_sounds" + }, { TYPE_INTEGER, &setup.bd_palette_c64, "bd_palette_c64" @@ -11630,6 +11634,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->bd_smooth_movements = AUTO; si->bd_pushing_graphics = TRUE; si->bd_up_down_graphics = TRUE; + si->bd_skip_falling_sounds = AUTO; si->bd_palette_c64 = GD_DEFAULT_PALETTE_C64; si->bd_palette_c64dtv = GD_DEFAULT_PALETTE_C64DTV; si->bd_palette_atari = GD_DEFAULT_PALETTE_ATARI; diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index e174f916..2793d26f 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -126,9 +126,19 @@ void gd_cave_set_seconds_sound(GdCave *cave) } } +// returns true if the element can fall +static inline boolean el_can_fall(const int element) +{ + return (gd_elements[element & O_MASK].properties & P_CAN_FALL) != 0; +} + // play diamond or stone sound of given element. static void play_sound_of_element(GdCave *cave, GdElement element, int x, int y) { + // check if sound should be skipped for falling elements (and only be played on impact) + if (el_can_fall(element) && skip_bd_falling_sounds()) + return; + // stone and diamond fall sounds. switch (element) { diff --git a/src/game_bd/export_bd.h b/src/game_bd/export_bd.h index 4ee1e948..60e70c20 100644 --- a/src/game_bd/export_bd.h +++ b/src/game_bd/export_bd.h @@ -116,6 +116,7 @@ boolean use_native_bd_graphics_engine(void); boolean use_bd_smooth_movements(void); boolean use_bd_pushing_graphics(void); boolean use_bd_up_down_graphics(void); +boolean skip_bd_falling_sounds(void); Bitmap **GetTitleScreenBitmaps_BD(void); void CoverScreen_BD(void); diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index d2da72f1..c11022b0 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -460,6 +460,13 @@ boolean use_bd_up_down_graphics(void) (setup.bd_up_down_graphics == 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) || + (setup.bd_skip_falling_sounds == AUTO && !game.use_native_bd_sound_engine)); +} + Bitmap **GetTitleScreenBitmaps_BD(void) { Bitmap **title_screen_bitmaps = gd_get_title_screen_bitmaps(); diff --git a/src/libgame/system.h b/src/libgame/system.h index 15c55f77..19a9747a 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1518,6 +1518,7 @@ struct SetupInfo int bd_smooth_movements; // not boolean -- can also be "AUTO" int bd_pushing_graphics; // not boolean -- can also be "AUTO" int bd_up_down_graphics; // not boolean -- can also be "AUTO" + int bd_skip_falling_sounds; // not boolean -- can also be "AUTO" int bd_palette_c64; int bd_palette_c64dtv; int bd_palette_atari; diff --git a/src/screens.c b/src/screens.c index 241d25f0..7360b9c7 100644 --- a/src/screens.c +++ b/src/screens.c @@ -7975,6 +7975,7 @@ static struct TokenInfo setup_info_engines[] = { TYPE_YES_NO_AUTO, &setup.bd_smooth_movements, "Smooth Element Movement:" }, { TYPE_YES_NO_AUTO, &setup.bd_pushing_graphics, "Use Player Pushing Graphics:" }, { TYPE_YES_NO_AUTO, &setup.bd_up_down_graphics, "Use Player Up/Down Graphics:" }, + { TYPE_YES_NO_AUTO, &setup.bd_skip_falling_sounds, "Mute Double Falling Sounds:" }, { TYPE_ENTER_LIST, &execSetupChoosePaletteC64, "Color Palette (C64):" }, { TYPE_STRING, &bd_palette_c64_text, "" }, { TYPE_ENTER_LIST, &execSetupChoosePaletteC64DTV, "Color Palette (C64DTV):" }, -- 2.34.1