#endif
}
-#if 0
-static void ReloadCustomSounds()
-{
- int i;
-
-#if 1
- printf("DEBUG: reloading sounds '%s' ...\n", artwork.sounds_set_current);
-#endif
-
- LoadSoundsInfo();
-
- for(i=0; i<NUM_SOUNDS; i++)
- LoadSoundToList(sound_name[i], i);
-}
-
-static void ReloadCustomMusic()
-{
-#if 1
- printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current);
-#endif
-
- FreeAllMusic();
-
- LoadCustomMusic();
-}
-#endif
-
static void InitSoundServer()
{
OpenAudio();
-#if 0
- SetAudioReloadFunctions(ReloadCustomSounds, ReloadCustomMusic);
-#endif
- InitSoundList(sound_name, NUM_SOUNDS);
+ InitSoundList(sound_effects, NUM_SOUND_EFFECTS);
StartSoundserver();
}
return NULL; /* cannot find image file */
}
+char *getCustomSoundConfigFilename()
+{
+ return getCustomSoundFilename(SOUNDSINFO_FILENAME);
+}
+
char *getCustomMusicDirectory(void)
{
static char *directory = NULL;
#endif
}
-void LoadSoundsInfo()
-{
-#if 0
- char *filename = getCustomSoundFilename(SOUNDSINFO_FILENAME);
- struct SetupFileList *setup_file_list = loadSetupFileList(filename);
-
- if (setup_file_list)
- {
-#if 0
- for (i=0; i<NUM_LEVELINFO_TOKENS; i++)
- setSetupInfo(levelinfo_tokens, i,
- getTokenValue(setup_file_list, levelinfo_tokens[i].text));
-#endif
-
- freeSetupFileList(setup_file_list);
- }
-#endif
-}
-
static void SaveUserLevelInfo()
{
char *filename;
char *getImageFilename(char *);
char *getCustomImageFilename(char *);
char *getCustomSoundFilename(char *);
+char *getCustomSoundConfigFilename(void);
char *getCustomMusicDirectory(void);
void InitTapeDirectory(char *);
void LoadLevelInfo(void);
void LoadArtworkInfo(void);
-void LoadSoundsInfo(void);
void LoadLevelSetup_LastSeries(void);
void SaveLevelSetup_LastSeries(void);
void LoadLevelSetup_SeriesInfo(void);
#include "setup.h"
+struct ListNode
+{
+ char *key;
+ void *content;
+ struct ListNode *next;
+};
+typedef struct ListNode ListNode;
+
+static ListNode *newListNode(void);
+static void addNodeToList(ListNode **, char *, void *);
+static void deleteNodeFromList(ListNode **, char *, void (*function)(void *));
+static ListNode *getNodeFromKey(ListNode *, char *);
+static int getNumNodes(ListNode *);
+
+
+static struct SoundEffectInfo *sound_effect;
+static ListNode *SoundFileList = NULL;
static SoundInfo **Sound = NULL;
static MusicInfo **Music = NULL;
static int num_sounds = 0, num_music = 0;
-static char **sound_name;
/* ========================================================================= */
{
artwork.sounds_set_current = set_name;
ReloadCustomSounds();
-#if 0
- audio.func_reload_sounds();
-#endif
}
else
{
artwork.music_set_current = set_name;
ReloadCustomMusic();
-#if 0
- audio.func_reload_music();
-#endif
}
free(set_name);
if (snd_ctrl.music)
snd_ctrl.nr = snd_ctrl.nr % num_music;
+ else if (snd_ctrl.nr >= num_sounds)
+ return;
/* if playlist is full, remove oldest sound */
if (playing_sounds == MAX_SOUNDS_PLAYING)
return;
}
- if (*snd_info && strcmp(filename, (*snd_info)->source_filename) == 0)
+ if (*snd_info)
{
- /* The old and new sound are the same (have the same filename and path).
- This usually means that this sound does not exist in this sound set
- and a fallback to the existing sound is done. */
+ char *filename_old = (*snd_info)->source_filename;
- return;
- }
+ if (strcmp(filename, filename_old) == 0)
+ {
+ /* The old and new sound are the same (have the same filename and path).
+ This usually means that this sound does not exist in this sound set
+ and a fallback to the existing sound is done. */
- if (*snd_info)
- FreeSound(*snd_info);
+#if 1
+ printf("[sound '%s' already exists]\n", filename);
+#endif
+
+ return;
+ }
+
+ if (--(*snd_info)->num_references <= 0)
+ {
+#if 1
+ printf("[deleting sound '%s']\n", filename_old);
+#endif
+
+ /*
+ FreeSound(*snd_info);
+ */
+ deleteNodeFromList(&SoundFileList, filename_old, FreeSound);
+ }
+ }
*snd_info = Load_WAV(filename);
+ (*snd_info)->num_references = 1;
+
+ addNodeToList(&SoundFileList, (*snd_info)->source_filename, *snd_info);
}
-void InitSoundList(char *sound_name_list[], int num_list_entries)
+void InitSoundList(struct SoundEffectInfo *sounds_list, int num_list_entries)
{
if (Sound == NULL)
Sound = checked_calloc(num_list_entries * sizeof(SoundInfo *));
- sound_name = sound_name_list;
+ sound_effect = sounds_list;
num_sounds = num_list_entries;
}
if (Sound == NULL || list_pos >= num_sounds)
return;
+ printf("loading sound '%s' ... [%d]\n",
+ basename, getNumNodes(SoundFileList));
+
LoadCustomSound(&Sound[list_pos], basename);
+
+ printf("loading sound '%s' done [%d]\n",
+ basename, getNumNodes(SoundFileList));
}
static MusicInfo *Load_MOD(char *filename)
#endif
}
+ListNode *newListNode()
+{
+ return checked_calloc(sizeof(ListNode));
+}
+
+void addNodeToList(ListNode **node_first, char *key, void *content)
+{
+ ListNode *node_new = newListNode();
+
+#if 0
+ printf("LIST: adding node with key '%s'\n", key);
+#endif
+
+ node_new->key = getStringCopy(key);
+ node_new->content = content;
+ node_new->next = *node_first;
+ *node_first = node_new;
+}
+
+void deleteNodeFromList(ListNode **node_first, char *key,
+ void (*destructor_function)(void *))
+{
+ if (node_first == NULL || *node_first == NULL)
+ return;
+
+ printf("[CHECKING LIST KEY '%s' == '%s']\n",
+ (*node_first)->key, key);
+
+ if (strcmp((*node_first)->key, key) == 0)
+ {
+ printf("[DELETING LIST ENTRY]\n");
+
+ free((*node_first)->key);
+ if (destructor_function)
+ destructor_function((*node_first)->content);
+ *node_first = (*node_first)->next;
+ }
+ else
+ deleteNodeFromList(&(*node_first)->next, key, destructor_function);
+}
+
+ListNode *getNodeFromKey(ListNode *node_first, char *key)
+{
+ if (node_first == NULL)
+ return NULL;
+
+ if (strcmp(node_first->key, key) == 0)
+ return node_first;
+ else
+ return getNodeFromKey(node_first->next, key);
+}
+
+int getNumNodes(ListNode *node_first)
+{
+ return (node_first ? 1 + getNumNodes(node_first->next) : 0);
+}
+
+void dumpList(ListNode *node_first)
+{
+ ListNode *node = node_first;
+
+ while (node)
+ {
+ printf("['%s']\n", node->key);
+ node = node->next;
+ }
+
+ printf("[%d nodes]\n", getNumNodes(node_first));
+}
+
+static void LoadSoundsInfo()
+{
+ char *filename = getCustomSoundConfigFilename();
+ struct SetupFileList *setup_file_list;
+ int i;
+
+ /* always start with reliable default values */
+ for (i=0; i<num_sounds; i++)
+ sound_effect[i].filename = NULL;
+
+ if (filename == NULL)
+ return;
+
+ if ((setup_file_list = loadSetupFileList(filename)))
+ {
+ for (i=0; i<num_sounds; i++)
+ sound_effect[i].filename =
+ getStringCopy(getTokenValue(setup_file_list, sound_effect[i].text));
+
+ freeSetupFileList(setup_file_list);
+
+#if 1
+ for (i=0; i<num_sounds; i++)
+ printf("'%s' -> '%s'\n", sound_effect[i].text, sound_effect[i].filename);
+#endif
+ }
+}
+
static void ReloadCustomSounds()
{
int i;
LoadSoundsInfo();
for(i=0; i<num_sounds; i++)
- LoadSoundToList(sound_name[i], i);
+ {
+ if (sound_effect[i].filename)
+ LoadSoundToList(sound_effect[i].filename, i);
+ else
+ LoadSoundToList(sound_effect[i].default_filename, i);
+ }
+
+ /*
+ printf("list size == %d\n", getNumNodes(SoundFileList));
+ */
+ dumpList(SoundFileList);
}
static void ReloadCustomMusic()
#endif
}
+ if (sound->source_filename)
+ free(sound->source_filename);
+
free(sound);
}
int fragment_size; /* audio device fragment size in bytes */
};
-#if 0
-struct SoundsInfo
+struct SoundEffectInfo
{
- int num_sounds;
- char *sound_name;
-
-#if 0
- void (*func_reload_sounds)(void);
- void (*func_reload_music)(void);
-#endif
-}
-#endif
+ char *text;
+ char *default_filename;
+ char *filename;
+};
struct SampleInfo
{
int type;
char *source_filename;
+ int num_references;
long data_len;
void *data_ptr;
void StopSound(int);
void StopSounds(void);
void StopSoundExt(int, int);
-void InitSoundList(char **, int);
+void InitSoundList(struct SoundEffectInfo *, int);
void InitReloadSounds(char *);
void InitReloadMusic(char *);
void FreeAllSounds(void);
audio.sound_enabled = enabled;
}
-#if 0
-inline void SetAudioReloadFunctions(void (*func_reload_sounds)(void),
- void (*func_reload_music)(void))
-{
- audio.func_reload_sounds = func_reload_sounds;
- audio.func_reload_music = func_reload_music;
-}
-#endif
-
/* ========================================================================= */
/* event functions */
inline void OpenAudio(void);
inline void CloseAudio(void);
inline void SetAudioMode(boolean);
-#if 0
-inline void SetAudioReloadFunctions(void (*func_reload_sounds)(void),
- void (*func_reload_music)(void));
-#endif
inline void InitEventFilter(EventFilter);
inline boolean PendingEvent(void);
};
/* sound effects: setup file identifiers and corresponding default filenames */
-struct
+struct SoundEffectInfo sound_effects[NUM_SOUND_EFFECTS] =
{
- char *identifier;
- char *default_filename;
-}
-sound_effect[NUM_SOUND_EFFECTS] =
+ { "infotron_collecting", "infotron.wav" },
+ { "zonk_falling", "zonkdown.wav" },
+ { "zonk_pushing", "zonkpush.wav" }
+};
+
+struct SoundEffectInfo sound_effects_NEW[] =
{
- { "collecting_infotron", "infotron.wav" },
- { "falling_zonk", "zonkdown.wav" },
- { "pushing_zonk", "zonkpush.wav" }
+ { "amoeba_growing", "amoebe.wav" },
+ { "player_screaming", "autsch.wav" },
+ { "acid_splashing", "blurb.wav" },
+ { "mole_eating_amoeba", "blurb.wav" },
+ { "penguin_entering_exit", "buing.wav" },
+ { "player_entering_exit", "buing.wav" },
+ { "player_solving_sokoban", "buing.wav" },
+ { "time_orb_full_impact", "deng.wav" },
+ { "time_orb_empty_impact", "deng.wav" },
+ { "electric_bulb_light", "deng.wav" },
+ { "sokoban_field_filling", "deng.wav" },
+ { "leveltime_running_out", "gong.wav" },
+ { "extra_time_collecting", "gong.wav" },
+ { "time_orb_full_collecting", "gong.wav" },
+ { "menu_hall_of_fame", "halloffame.wav"},
+ { "key_impact", "kink.wav" },
+ { "em_key_impact", "kink.wav" },
+ { "bug_moving", "klapper.wav" },
+ { "butterfly_moving", "klapper.wav" },
+ { "rock_impact", "klopf.wav" },
+ { "bd_rock_impact", "klopf.wav" },
+ { "amoeba_turns_to_rock", "klopf.wav" },
+ { "nut_impact", "klumpf.wav" },
+ { "pearl_breaking", "knack.wav" },
+ { "nut_cracking", "knack.wav" },
+ { "nut_pushing", "knurk.wav" },
+ { "player_laughing_at", "lachen.wav" },
+ { "robot_wheel_running", "miep.wav" },
+ { "timegate_wheel_running", "miep.wav" },
+ { "magic_wall_running", "miep.wav" },
+ { "yamyam_waiting", "njam.wav" },
+ { "menu_door", "oeffnen.wav" },
+ { "switchgate_opening", "oeffnen.wav" },
+ { "switchgate_closing", "oeffnen.wav" },
+ { "timegate_opening", "oeffnen.wav" },
+ { "timegate_closing", "oeffnen.wav" },
+ { "exit_opening", "oeffnen.wav" },
+ { "emerald_impact", "pling.wav" },
+ { "bd_diamond_impact", "pling.wav" },
+ { "diamond_impact", "pling.wav" },
+ { "infotron_impact", "pling.wav" },
+ { "amoeba_turns_to_gem", "pling.wav" },
+ { "emerald_collecting", "pong.wav" },
+ { "bd_diamond_collecting", "pong.wav" },
+ { "diamond_collecting", "pong.wav" },
+ { "pearl_collecting", "pong.wav" },
+ { "crystal_collecting", "pong.wav" },
+ { "speed_pill_collecting", "pong.wav" },
+ { "envelope_collecting", "pong.wav" },
+ { "shield_passive_collecting","pong.wav" },
+ { "shield_active_collecting", "pong.wav" },
+ { "dynamite_collecting", "pong.wav" },
+ { "dynabomb_nr_collecting", "pong.wav" },
+ { "dynabomb_sz_collecting", "pong.wav" },
+ { "dynabomb_xl_collecting", "pong.wav" },
+ { "key_collecting", "pong.wav" },
+ { "em_key_collecting", "pong.wav" },
+ { "rock_pushing", "pusch.wav" },
+ { "bd_rock_pushing", "pusch.wav" },
+ { "bomb_pushing", "pusch.wav" },
+ { "dx_supabomb_pushing", "pusch.wav" },
+ { "time_orb_empty_pushing", "pusch.wav" },
+ { "spring_pushing", "pusch.wav" },
+ { "sokoban_object_pushing", "pusch.wav" },
+ { "satellite_pushing", "pusch.wav" },
+ { "sp_disk_yellow_pushing", "pusch.wav" },
+ { "diamond_smashing", "quirk.wav" },
+ { "magic_wall_activating", "quirk.wav" },
+ { "menu_info_screen", "rhythmloop.wav"},
+ { "explosion", "roaaar.wav" },
+ { "spaceship_moving", "roehr.wav" },
+ { "firefly_moving", "roehr.wav" },
+ { "robot_moving", "schlurf.wav" },
+ { "sand_digging", "schlurf.wav" },
+ { "sand_invisible_digging", "schlurf.wav" },
+ { "trap_inactive_digging", "schlurf.wav" },
+ { "balloon_moving", "schlurf.wav" },
+ { "leveltime_bonus", "sirr.wav" },
+ { "dynamite_burning", "zisch.wav" },
+ { "sp_base_digging", "base.wav" },
+ { "sp_buggy_base_digging", "base.wav" },
+ { "sp_infotron_collecting", "infotron.wav" },
+ { "sp_disk_red_collecting", "infotron.wav" },
+ { "sp_zonk_impact", "zonkdown.wav" },
+ { "sp_zonk_pushing", "zonkpush.wav" },
+ { "sp_disk_orange_pushing", "zonkpush.wav" },
+ { "sp_buggy_base_passing", "bug.wav" },
+ { "sp_explosion", "booom.wav" },
+ { "empty_space_digging", "empty.wav" },
+ { "em_gate_passing", "gate.wav" },
+ { "switchgate_passing", "gate.wav" },
+ { "timegate_passing", "gate.wav" },
+ { "sp_port_passing", "gate.wav" }
+
+#if 0
+ { "[not used]", "antigrav.wav" },
+ { "[not used]", "bong.wav" },
+ { "[not used]", "fuel.wav" },
+ { "[not used]", "holz.wav" },
+ { "[not used]", "hui.wav" },
+ { "[not used]", "kabumm.wav" },
+ { "[not used]", "kling.wav" },
+ { "[not used]", "krach.wav" },
+ { "[not used]", "laser.wav" },
+ { "[not used]", "quiek.wav" },
+ { "[not used]", "rumms.wav" },
+ { "[not used]", "schlopp.wav" },
+ { "[not used]", "schrff.wav" },
+ { "[not used]", "schwirr.wav" },
+ { "[not used]", "slurp.wav" },
+ { "[not used]", "sproing.wav" },
+ { "[not used]", "warnton.wav" },
+ { "[not used]", "whoosh.wav" },
+ { "[not used]", "boom.wav" },
+ { "[not used]", "exit.wav" },
+#endif
};
char *element_info[] =
extern struct GameInfo game;
extern struct GlobalInfo global;
+extern struct SoundEffectInfo sound_effects[];
+
extern char *sound_name[];
extern char *element_info[];
extern int num_element_info;
#define NUM_SOUND_EFFECTS 3
+#define SND_AMOEBA_GROWING 0
+#define SND_PLAYER_SCREAMING 0
+#define SND_ACID_SPLASHING 0
+#define SND_MOLE_EATING_AMOEBA 0
+#define SND_PENGUIN_ENTERING_EXIT 0
+#define SND_PLAYER_ENTERING_EXIT 0
+#define SND_PLAYER_SOLVING_SOKOBAN 0
+#define SND_TIME_ORB_FULL_IMPACT 0
+#define SND_TIME_ORB_EMPTY_IMPACT 0
+#define SND_ELECTRIC_BULB_LIGHT 0
+#define SND_SOKOBAN_FIELD_FILLING 0
+#define SND_LEVELTIME_RUNNING_OUT 0
+#define SND_EXTRA_TIME_COLLECTING 0
+#define SND_TIME_ORB_FULL_COLLECTING 0
+#define SND_MENU_HALL_OF_FAME 0
+#define SND_KEY_IMPACT 0
+#define SND_EM_KEY_IMPACT 0
+#define SND_BUG_MOVING 0
+#define SND_BUTTERFLY_MOVING 0
+#define SND_ROCK_IMPACT 0
+#define SND_BD_ROCK_IMPACT 0
+#define SND_AMOEBA_TURNS_TO_ROCK 0
+#define SND_NUT_IMPACT 0
+#define SND_PEARL_BREAKING 0
+#define SND_NUT_CRACKING 0
+#define SND_NUT_PUSHING 0
+#define SND_PLAYER_LAUGHING_AT 0
+#define SND_ROBOT_WHEEL_RUNNING 0
+#define SND_TIMEGATE_WHEEL_RUNNING 0
+#define SND_MAGIC_WALL_RUNNING 0
+#define SND_YAMYAM_WAITING 0
+#define SND_MENU_DOOR 0
+#define SND_SWITCHGATE_OPENING 0
+#define SND_SWITCHGATE_CLOSING 0
+#define SND_TIMEGATE_OPENING 0
+#define SND_TIMEGATE_CLOSING 0
+#define SND_EXIT_OPENING 0
+#define SND_EMERALD_IMPACT 0
+#define SND_BD_DIAMOND_IMPACT 0
+#define SND_DIAMOND_IMPACT 0
+#define SND_INFOTRON_IMPACT 0
+#define SND_AMOEBA_TURNS_TO_GEM 0
+#define SND_EMERALD_COLLECTING 0
+#define SND_BD_DIAMOND_COLLECTING 0
+#define SND_DIAMOND_COLLECTING 0
+#define SND_PEARL_COLLECTING 0
+#define SND_CRYSTAL_COLLECTING 0
+#define SND_SPEED_PILL_COLLECTING 0
+#define SND_ENVELOPE_COLLECTING 0
+#define SND_SHIELD_PASSIVE_COLLECTING 0
+#define SND_SHIELD_ACTIVE_COLLECTING 0
+#define SND_DYNAMITE_COLLECTING 0
+#define SND_DYNABOMB_NR_COLLECTING 0
+#define SND_DYNABOMB_SZ_COLLECTING 0
+#define SND_DYNABOMB_XL_COLLECTING 0
+#define SND_KEY_COLLECTING 0
+#define SND_EM_KEY_COLLECTING 0
+#define SND_ROCK_PUSHING 0
+#define SND_BD_ROCK_PUSHING 0
+#define SND_BOMB_PUSHING 0
+#define SND_DX_SUPABOMB_PUSHING 0
+#define SND_TIME_ORB_EMPTY_PUSHING 0
+#define SND_SPRING_PUSHING 0
+#define SND_SOKOBAN_OBJECT_PUSHING 0
+#define SND_SATELLITE_PUSHING 0
+#define SND_SP_DISK_YELLOW_PUSHING 0
+#define SND_DIAMOND_SMASHING 0
+#define SND_MAGIC_WALL_ACTIVATING 0
+#define SND_MENU_INFO_SCREEN 0
+#define SND_EXPLOSION 0
+#define SND_SPACESHIP_MOVING 0
+#define SND_FIREFLY_MOVING 0
+#define SND_ROBOT_MOVING 0
+#define SND_SAND_DIGGING 0
+#define SND_SAND_INVISIBLE_DIGGING 0
+#define SND_TRAP_INACTIVE_DIGGING 0
+#define SND_BALLOON_MOVING 0
+#define SND_LEVELTIME_BONUS 0
+#define SND_DYNAMITE_BURNING 0
+#define SND_SP_BASE_DIGGING 0
+#define SND_SP_BUGGY_BASE_DIGGING 0
+#define SND_SP_INFOTRON_COLLECTING 0
+#define SND_SP_DISK_RED_COLLECTING 0
+#define SND_SP_ZONK_IMPACT 0
+#define SND_SP_ZONK_PUSHING 0
+#define SND_SP_DISK_ORANGE_PUSHING 0
+#define SND_SP_BUGGY_BASE_PASSING 0
+#define SND_SP_EXPLOSION 0
+#define SND_EMPTY_SPACE_DIGGING 0
+#define SND_EM_GATE_PASSING 0
+#define SND_SWITCHGATE_PASSING 0
+#define SND_TIMEGATE_PASSING 0
+#define SND_SP_PORT_PASSING 0
+
+#define NUM_SOUND_EFFECTS__NEW 0
+
+
/* values for game_status */
#define EXITGAME 0
#define MAINMENU 1
-#define COMPILE_DATE_STRING "[2002-04-28 23:49]"
+#define COMPILE_DATE_STRING "[2002-04-30 00:42]"