added setup option to select default or low-pass sounds for EMC levels
authorHolger Schemel <info@artsoft.org>
Mon, 8 Jun 2020 21:45:06 +0000 (23:45 +0200)
committerHolger Schemel <info@artsoft.org>
Mon, 8 Jun 2020 21:45:06 +0000 (23:45 +0200)
src/files.c
src/init.c
src/libgame/setup.c
src/libgame/setup.h
src/libgame/system.h
src/screens.c

index d34f3fe30b298172ced69349277af3bff81e7845..3162e629cf126ba102c242a32018ccad2074f711 100644 (file)
@@ -8505,6 +8505,10 @@ static struct TokenInfo global_setup_tokens[] =
     TYPE_SWITCH,
     &setup.prefer_aga_graphics,                        "prefer_aga_graphics"
   },
+  {
+    TYPE_SWITCH,
+    &setup.prefer_lowpass_sounds,              "prefer_lowpass_sounds"
+  },
   {
     TYPE_SWITCH,
     &setup.game_speed_extended,                        "game_speed_extended"
@@ -9176,6 +9180,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->quick_switch = FALSE;
   si->input_on_focus = FALSE;
   si->prefer_aga_graphics = TRUE;
+  si->prefer_lowpass_sounds = FALSE;
   si->game_speed_extended = FALSE;
   si->game_frame_delay = GAME_FRAME_DELAY;
   si->sp_show_border_elements = FALSE;
index dca18c4feae03ae7cdf4eca39afaa4d37a084310..04d7f32a228cc26d53b5e85ce8143c3f6b83c194 100644 (file)
@@ -5909,6 +5909,7 @@ void ReloadCustomArtwork(int force_reload)
   InitOverrideArtwork();
 
   force_reload_gfx |= AdjustGraphicsForEMC();
+  force_reload_snd |= AdjustSoundsForEMC();
 
   gfx_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_GRAPHICS);
   snd_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_SOUNDS);
index 8a99557f557e7cb59bf9eb0f8f174804988b14df..7d17464164e4f33f8e09b7fd0e0b45a80c0f9c53 100644 (file)
@@ -1329,6 +1329,39 @@ static boolean adjustTreeGraphicsForEMC(TreeInfo *node)
   return settings_changed;
 }
 
+static boolean adjustTreeSoundsForEMC(TreeInfo *node)
+{
+  boolean settings_changed = FALSE;
+
+  while (node)
+  {
+    boolean want_default = (setup.prefer_lowpass_sounds == FALSE);
+    boolean want_lowpass = (setup.prefer_lowpass_sounds == TRUE);
+    boolean has_only_default = (!node->sounds_set && !node->sounds_set_lowpass);
+    boolean has_only_lowpass = (!node->sounds_set && !node->sounds_set_default);
+    char *sounds_set = NULL;
+
+    if (node->sounds_set_default && (want_default || has_only_default))
+      sounds_set = node->sounds_set_default;
+
+    if (node->sounds_set_lowpass && (want_lowpass || has_only_lowpass))
+      sounds_set = node->sounds_set_lowpass;
+
+    if (sounds_set && !strEqual(node->sounds_set, sounds_set))
+    {
+      setString(&node->sounds_set, sounds_set);
+      settings_changed = TRUE;
+    }
+
+    if (node->node_group != NULL)
+      settings_changed |= adjustTreeSoundsForEMC(node->node_group);
+
+    node = node->next;
+  }
+
+  return settings_changed;
+}
+
 void dumpTreeInfo(TreeInfo *node, int depth)
 {
   int i;
@@ -2319,16 +2352,18 @@ SetupFileHash *loadSetupFileHash(char *filename)
 #define LEVELINFO_TOKEN_GRAPHICS_SET_ECS       17
 #define LEVELINFO_TOKEN_GRAPHICS_SET_AGA       18
 #define LEVELINFO_TOKEN_GRAPHICS_SET           19
-#define LEVELINFO_TOKEN_SOUNDS_SET             20
-#define LEVELINFO_TOKEN_MUSIC_SET              21
-#define LEVELINFO_TOKEN_FILENAME               22
-#define LEVELINFO_TOKEN_FILETYPE               23
-#define LEVELINFO_TOKEN_SPECIAL_FLAGS          24
-#define LEVELINFO_TOKEN_HANDICAP               25
-#define LEVELINFO_TOKEN_SKIP_LEVELS            26
-#define LEVELINFO_TOKEN_USE_EMC_TILES          27
-
-#define NUM_LEVELINFO_TOKENS                   28
+#define LEVELINFO_TOKEN_SOUNDS_SET_DEFAULT     20
+#define LEVELINFO_TOKEN_SOUNDS_SET_LOWPASS     21
+#define LEVELINFO_TOKEN_SOUNDS_SET             22
+#define LEVELINFO_TOKEN_MUSIC_SET              23
+#define LEVELINFO_TOKEN_FILENAME               24
+#define LEVELINFO_TOKEN_FILETYPE               25
+#define LEVELINFO_TOKEN_SPECIAL_FLAGS          26
+#define LEVELINFO_TOKEN_HANDICAP               27
+#define LEVELINFO_TOKEN_SKIP_LEVELS            28
+#define LEVELINFO_TOKEN_USE_EMC_TILES          29
+
+#define NUM_LEVELINFO_TOKENS                   30
 
 static LevelDirTree ldi;
 
@@ -2355,6 +2390,8 @@ static struct TokenInfo levelinfo_tokens[] =
   { TYPE_STRING,       &ldi.graphics_set_ecs,  "graphics_set.ecs"      },
   { TYPE_STRING,       &ldi.graphics_set_aga,  "graphics_set.aga"      },
   { TYPE_STRING,       &ldi.graphics_set,      "graphics_set"          },
+  { TYPE_STRING,       &ldi.sounds_set_default,"sounds_set.default"    },
+  { TYPE_STRING,       &ldi.sounds_set_lowpass,"sounds_set.lowpass"    },
   { TYPE_STRING,       &ldi.sounds_set,        "sounds_set"            },
   { TYPE_STRING,       &ldi.music_set,         "music_set"             },
   { TYPE_STRING,       &ldi.level_filename,    "filename"              },
@@ -2435,6 +2472,8 @@ static void setTreeInfoToDefaults(TreeInfo *ti, int type)
     ti->graphics_set_ecs = NULL;
     ti->graphics_set_aga = NULL;
     ti->graphics_set = NULL;
+    ti->sounds_set_default = NULL;
+    ti->sounds_set_lowpass = NULL;
     ti->sounds_set = NULL;
     ti->music_set = NULL;
     ti->graphics_path = getStringCopy(UNDEFINED_FILENAME);
@@ -2514,6 +2553,8 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ti, TreeInfo *parent)
     ti->graphics_set_ecs = getStringCopy(parent->graphics_set_ecs);
     ti->graphics_set_aga = getStringCopy(parent->graphics_set_aga);
     ti->graphics_set = getStringCopy(parent->graphics_set);
+    ti->sounds_set_default = getStringCopy(parent->sounds_set_default);
+    ti->sounds_set_lowpass = getStringCopy(parent->sounds_set_lowpass);
     ti->sounds_set = getStringCopy(parent->sounds_set);
     ti->music_set = getStringCopy(parent->music_set);
     ti->graphics_path = getStringCopy(UNDEFINED_FILENAME);
@@ -2574,6 +2615,8 @@ static TreeInfo *getTreeInfoCopy(TreeInfo *ti)
   ti_copy->graphics_set_ecs    = getStringCopy(ti->graphics_set_ecs);
   ti_copy->graphics_set_aga    = getStringCopy(ti->graphics_set_aga);
   ti_copy->graphics_set                = getStringCopy(ti->graphics_set);
+  ti_copy->sounds_set_default  = getStringCopy(ti->sounds_set_default);
+  ti_copy->sounds_set_lowpass  = getStringCopy(ti->sounds_set_lowpass);
   ti_copy->sounds_set          = getStringCopy(ti->sounds_set);
   ti_copy->music_set           = getStringCopy(ti->music_set);
   ti_copy->graphics_path       = getStringCopy(ti->graphics_path);
@@ -2643,6 +2686,8 @@ void freeTreeInfo(TreeInfo *ti)
     checked_free(ti->graphics_set_ecs);
     checked_free(ti->graphics_set_aga);
     checked_free(ti->graphics_set);
+    checked_free(ti->sounds_set_default);
+    checked_free(ti->sounds_set_lowpass);
     checked_free(ti->sounds_set);
     checked_free(ti->music_set);
 
@@ -3435,6 +3480,16 @@ boolean AdjustGraphicsForEMC(void)
   return settings_changed;
 }
 
+boolean AdjustSoundsForEMC(void)
+{
+  boolean settings_changed = FALSE;
+
+  settings_changed |= adjustTreeSoundsForEMC(leveldir_first_all);
+  settings_changed |= adjustTreeSoundsForEMC(leveldir_first);
+
+  return settings_changed;
+}
+
 void LoadLevelInfo(void)
 {
   InitUserLevelDirectory(getLoginName());
@@ -3454,6 +3509,7 @@ void LoadLevelInfo(void)
   cloneTree(&leveldir_first, leveldir_first_all, TRUE);
 
   AdjustGraphicsForEMC();
+  AdjustSoundsForEMC();
 
   // before sorting, the first entries will be from the user directory
   leveldir_current = getFirstValidTreeInfoEntry(leveldir_first);
index 3af76ed5fa13b92479da451b6657cc3e0c98738c..690a377926cfb747af3283425dd42d32d8324394 100644 (file)
@@ -324,6 +324,7 @@ int GetZipFileTreeType(char *);
 char *ExtractZipFileIntoDirectory(char *, char *, int);
 
 boolean AdjustGraphicsForEMC(void);
+boolean AdjustSoundsForEMC(void);
 
 void LoadLevelInfo(void);
 void LoadArtworkInfo(void);
index cd8aebee5bcce5c7a45f933c541ec044e94d7545..29f1c28ed708df72cee6c910c26f234762b67562 100644 (file)
@@ -1387,6 +1387,7 @@ struct SetupInfo
   boolean quick_switch;
   boolean input_on_focus;
   boolean prefer_aga_graphics;
+  boolean prefer_lowpass_sounds;
   boolean game_speed_extended;
   int game_frame_delay;
   boolean sp_show_border_elements;
@@ -1455,6 +1456,8 @@ struct TreeInfo
   char *graphics_set_ecs; // special EMC custom graphics set (ECS graphics)
   char *graphics_set_aga; // special EMC custom graphics set (AGA graphics)
   char *graphics_set;  // optional custom graphics set (level tree only)
+  char *sounds_set_default; // default EMC custom sounds set
+  char *sounds_set_lowpass; // special EMC custom sounds set (lowpass filter)
   char *sounds_set;    // optional custom sounds set (level tree only)
   char *music_set;     // optional custom music set (level tree only)
   char *graphics_path; // path to optional custom graphics set (level only)
index 0ec505bdaa693e4b6188b638ffe402dcf9e53c98..9981a17d18d30d9e0f2ea94704b4a617d6ee980c 100644 (file)
@@ -6281,10 +6281,11 @@ static struct TokenInfo setup_info_engines[] =
 {
   { TYPE_HEADLINE,     NULL,                   "Emerald Mine"          },
   { TYPE_SWITCH,       &setup.forced_scroll_delay, "Scroll Delay:"     },
-  { TYPE_ECS_AGA,      &setup.prefer_aga_graphics, "Graphics preference:" },
+  { TYPE_ECS_AGA,      &setup.prefer_aga_graphics, "Amiga Graphics Chipset:" },
+  { TYPE_SWITCH,       &setup.prefer_lowpass_sounds,"Low-Pass Filter Sounds:" },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_HEADLINE,     NULL,                   "Supaplex"              },
-  { TYPE_SWITCH, &setup.sp_show_border_elements,"Border Elements:"     },
+  { TYPE_SWITCH,       &setup.sp_show_border_elements, "Border Elements:" },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },