-#define COMPILE_DATE_STRING "[2002-08-25 02:44]"
+#define COMPILE_DATE_STRING "[2002-09-03 21:23]"
{ NULL, 0, 0 },
};
static int element_action_sound[NUM_LEVEL_ELEMENTS][NUM_SND_ACTIONS];
-static boolean is_loop_sound[NUM_SOUND_EFFECTS];
+static boolean is_loop_sound[NUM_SOUND_CONFIG_ENTRIES];
#define IS_LOOP_SOUND(x) (is_loop_sound[x])
void InitGameSound()
{
- int sound_effect_properties[NUM_SOUND_EFFECTS];
+ int sound_effect_properties[NUM_SOUND_CONFIG_ENTRIES];
int i, j;
#if 0
for (j=0; j<NUM_LEVEL_ELEMENTS; j++)
element_action_sound[j][i] = -1;
- for (i=0; i<NUM_SOUND_EFFECTS; i++)
+ for (i=0; i<NUM_SOUND_CONFIG_ENTRIES; i++)
{
- int len_effect_text = strlen(sound_effects[i].text);
+ int len_effect_text = strlen(sound_config[i].token);
sound_effect_properties[i] = SND_ACTION_UNKNOWN;
is_loop_sound[i] = FALSE;
int len_action_text = strlen(sound_action_properties[j].text);
if (len_action_text < len_effect_text &&
- strcmp(&sound_effects[i].text[len_effect_text - len_action_text],
+ strcmp(&sound_config[i].token[len_effect_text - len_action_text],
sound_action_properties[j].text) == 0)
{
sound_effect_properties[i] = sound_action_properties[j].value;
int len_class_text = strlen(element_info[j].sound_class_name);
if (len_class_text + 1 < len_effect_text &&
- strncmp(sound_effects[i].text,
+ strncmp(sound_config[i].token,
element_info[j].sound_class_name, len_class_text) == 0 &&
- sound_effects[i].text[len_class_text] == '.')
+ sound_config[i].token[len_class_text] == '.')
{
int sound_action_value = sound_effect_properties[i];
void PlaySoundLevel(int x, int y, int nr)
{
- static int loop_sound_frame[NUM_SOUND_EFFECTS];
- static int loop_sound_volume[NUM_SOUND_EFFECTS];
+ static int loop_sound_frame[NUM_SOUND_CONFIG_ENTRIES];
+ static int loop_sound_volume[NUM_SOUND_CONFIG_ENTRIES];
int sx = SCREENX(x), sy = SCREENY(y);
int volume, stereo_position;
int max_distance = 8;
static void InitArtworkInfo(void);
static void InitLevelArtworkInfo(void);
static void InitNetworkServer(void);
+static void InitImageConfig();
static void InitMixer(void);
static void InitSound(void);
static void InitGfx(void);
static void InitGfxBackground(void);
static void InitGadgets(void);
-static void InitElementInfo(void);
static void InitElementProperties(void);
+static void InitElementInfo(void);
+static void InitGraphicInfo(void);
static void Execute_Debug_Command(char *);
void OpenAll(void)
InitArtworkInfo(); /* needed before loading gfx, sound & music */
InitCounter();
+ InitImageConfig();
InitMixer();
InitJoysticks();
InitRND(NEW_RANDOMIZE);
InitEventFilter(FilterMouseMotionEvents);
InitGfx();
- InitElementInfo();
InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */
+ InitElementInfo();
+ InitGraphicInfo();
InitLevelInfo();
InitLevelArtworkInfo();
#endif
}
+static void InitImageConfig()
+{
+ InitImageList(image_config, NUM_IMAGE_CONFIG_ENTRIES);
+}
+
static void InitMixer()
{
OpenAudio();
- InitSoundList(sound_effects, NUM_SOUND_EFFECTS);
+ InitSoundList(sound_config, NUM_SOUND_CONFIG_ENTRIES);
StartMixer();
}
printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
printf("\n");
- for (i=0; i<NUM_SOUND_EFFECTS; i++)
+ for (i=0; i<NUM_SOUND_CONFIG_ENTRIES; i++)
printf("# %s\n",
- getFormattedSetupEntry(sound_effects[i].text,
- sound_effects[i].default_filename));
+ getFormattedSetupEntry(sound_config[i].token,
+ sound_config[i].default_filename));
}
else if (strcmp(command, "create musicinfo.conf") == 0)
{
#include "misc.h"
+/* ========================================================================= */
+/* PLATFORM SPECIFIC IMAGE FUNCTIONS */
+/* ========================================================================= */
+
#if defined(TARGET_X11)
/* for MS-DOS/Allegro, exclude all except newImage() and freeImage() */
#endif /* PLATFORM_UNIX */
#endif /* TARGET_X11 */
+
+
+/* ========================================================================= */
+/* PLATFORM INDEPENDANT IMAGE FUNCTIONS */
+/* ========================================================================= */
+
+struct ImageInfo
+{
+ char *source_filename;
+ int num_references;
+};
+typedef struct ImageInfo ImageInfo;
+
+static ImageInfo **ImageList = NULL;
+static struct ArtworkConfigInfo *image_config = NULL;
+static int num_images = 0;
+
+void InitImageList(struct ArtworkConfigInfo *config_list, int num_list_entries)
+{
+ if (ImageList == NULL)
+ ImageList = checked_calloc(num_list_entries * sizeof(ImageInfo *));
+
+ image_config = config_list;
+ num_images = num_list_entries;
+}
#endif /* TARGET_X11 */
+
+void InitImageList(struct ArtworkConfigInfo *, int);
+
#endif /* IMAGE_H */
#include "misc.h"
#include "setup.h"
#include "random.h"
+#include "text.h"
#if defined(PLATFORM_MSDOS)
}
+/* ========================================================================= */
+/* functions for generic lists */
+/* ========================================================================= */
+
+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;
+
+#if 0
+ printf("[CHECKING LIST KEY '%s' == '%s']\n",
+ (*node_first)->key, key);
+#endif
+
+ if (strcmp((*node_first)->key, key) == 0)
+ {
+#if 0
+ printf("[DELETING LIST ENTRY]\n");
+#endif
+
+ 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' (%d)]\n", node->key,
+ ((struct ArtworkListNodeInfo *)node->content)->num_references);
+ node = node->next;
+ }
+
+ printf("[%d nodes]\n", getNumNodes(node_first));
+}
+
+
/* ========================================================================= */
/* functions for checking filenames */
/* ========================================================================= */
return FALSE;
}
+/* ========================================================================= */
+/* functions for loading artwork configuration information */
+/* ========================================================================= */
+
+static void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
+{
+ int num_list_entries = artwork_info->num_list_entries;
+ struct ArtworkConfigInfo *config_list = artwork_info->config_list;
+ char *filename = getCustomArtworkConfigFilename(artwork_info->type);
+ struct SetupFileList *setup_file_list;
+ int i;
+
+#if 0
+ printf("GOT CUSTOM ARTWORK CONFIG FILE '%s'\n", filename);
+#endif
+
+ /* always start with reliable default values */
+ for (i=0; i<num_list_entries; i++)
+ config_list[i].filename = NULL;
+
+ if (filename == NULL)
+ return;
+
+ if ((setup_file_list = loadSetupFileList(filename)))
+ {
+ for (i=0; i<num_list_entries; i++)
+ config_list[i].filename =
+ getStringCopy(getTokenValue(setup_file_list, config_list[i].token));
+
+ freeSetupFileList(setup_file_list);
+
+#if 0
+ for (i=0; i<num_list_entries; i++)
+ {
+ printf("'%s' ", config_list[i].token);
+ if (config_list[i].filename)
+ printf("-> '%s'\n", config_list[i].filename);
+ else
+ printf("-> UNDEFINED [-> '%s']\n", config_list[i].default_filename);
+ }
+#endif
+ }
+}
+
+void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info,
+ struct ArtworkListNodeInfo **listnode)
+{
+ if (*listnode)
+ {
+ char *filename = (*listnode)->source_filename;
+
+#if 0
+ printf("[decrementing reference counter of artwork '%s']\n", filename);
+#endif
+
+ if (--(*listnode)->num_references <= 0)
+ {
+#if 0
+ printf("[deleting artwork '%s']\n", filename);
+#endif
+
+ deleteNodeFromList(&artwork_info->file_list, filename,
+ artwork_info->free_artwork);
+ }
+
+ *listnode = NULL;
+ }
+}
+
+static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
+ struct ArtworkListNodeInfo **listnode,
+ char *filename)
+{
+ ListNode *node;
+
+ /* check if the old and the new artwork file are the same */
+ if (*listnode && strcmp((*listnode)->source_filename, filename) == 0)
+ {
+ /* The old and new artwork are the same (have the same filename and path).
+ This usually means that this artwork does not exist in this artwork set
+ and a fallback to the existing artwork is done. */
+
+#if 0
+ printf("[artwork '%s' already exists (same list entry)]\n", filename);
+#endif
+
+ return;
+ }
+
+ /* delete existing artwork file entry */
+ deleteArtworkListEntry(artwork_info, listnode);
+
+ /* check if the new artwork file already exists in the list of artworks */
+ if ((node = getNodeFromKey(artwork_info->file_list, filename)) != NULL)
+ {
+#if 0
+ printf("[artwork '%s' already exists (other list entry)]\n", filename);
+#endif
+
+ *listnode = (struct ArtworkListNodeInfo *)node->content;
+ (*listnode)->num_references++;
+ }
+ else if ((*listnode = artwork_info->load_artwork(filename)) != NULL)
+ {
+ (*listnode)->num_references = 1;
+ addNodeToList(&artwork_info->file_list, (*listnode)->source_filename,
+ *listnode);
+ }
+}
+
+static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info,
+ struct ArtworkListNodeInfo **listnode,
+ char *basename)
+{
+ char *filename = getCustomArtworkFilename(basename, artwork_info->type);
+
+#if 0
+ printf("GOT CUSTOM ARTWORK FILE '%s'\n", filename);
+#endif
+
+ if (strcmp(basename, UNDEFINED_FILENAME) == 0)
+ {
+ deleteArtworkListEntry(artwork_info, listnode);
+ return;
+ }
+
+ if (filename == NULL)
+ {
+ Error(ERR_WARN, "cannot find artwork file '%s'", basename);
+ return;
+ }
+
+ replaceArtworkListEntry(artwork_info, listnode, filename);
+}
+
+void LoadArtworkToList(struct ArtworkListInfo *artwork_info,
+ char *basename, int list_pos)
+{
+ if (artwork_info->artwork_list == NULL ||
+ list_pos >= artwork_info->num_list_entries)
+ return;
+
+#if 0
+ printf("loading artwork '%s' ... [%d]\n",
+ basename, getNumNodes(artwork_info->file_list));
+#endif
+
+ LoadCustomArtwork(artwork_info, &artwork_info->artwork_list[list_pos],
+ basename);
+
+#if 0
+ printf("loading artwork '%s' done [%d]\n",
+ basename, getNumNodes(artwork_info->file_list));
+#endif
+}
+
+void ReloadCustomArtworkFiles(struct ArtworkListInfo *artwork_info)
+{
+ static struct
+ {
+ char *text;
+ boolean do_it;
+ }
+ draw_init[] =
+ {
+ { "", FALSE },
+ { "Loading graphics:", TRUE },
+ { "Loading sounds:", TRUE },
+ { "Loading music:", TRUE }
+ };
+
+ int num_list_entries = artwork_info->num_list_entries;
+ struct ArtworkConfigInfo *config_list = artwork_info->config_list;
+ int i;
+
+#if 0
+ Delay(5000);
+#endif
+
+#if 0
+ printf("DEBUG: reloading sounds '%s' ...\n",artwork.snd_current_identifier);
+#endif
+
+ LoadArtworkConfig(artwork_info);
+
+ if (draw_init[artwork_info->type].do_it)
+ DrawInitText(draw_init[artwork_info->type].text, 120, FC_GREEN);
+
+#if 0
+ printf("DEBUG: reloading %d sounds ...\n", num_list_entries);
+#endif
+
+ for(i=0; i<num_list_entries; i++)
+ {
+ if (draw_init[artwork_info->type].do_it)
+ DrawInitText(config_list[i].token, 150, FC_YELLOW);
+
+ if (config_list[i].filename)
+ LoadArtworkToList(artwork_info, config_list[i].filename, i);
+ else
+ LoadArtworkToList(artwork_info, config_list[i].default_filename, i);
+ }
+
+ draw_init[artwork_info->type].do_it = FALSE;
+
+ /*
+ printf("list size == %d\n", getNumNodes(artwork_info->file_list));
+ */
+
+#if 0
+ dumpList(artwork_info->file_list);
+#endif
+}
+
/* ========================================================================= */
/* functions only needed for non-Unix (non-command-line) systems */
Key getKeyFromX11KeyName(char *);
char getCharFromKey(Key);
+
+ListNode *newListNode(void);
+void addNodeToList(ListNode **, char *, void *);
+void deleteNodeFromList(ListNode **, char *, void (*function)(void *));
+ListNode *getNodeFromKey(ListNode *, char *);
+int getNumNodes(ListNode *);
+
+
boolean FileIsGraphic(char *);
boolean FileIsSound(char *);
boolean FileIsMusic(char *);
boolean FileIsArtworkType(char *, int);
+/*
+void LoadArtworkConfig(struct ArtworkListInfo *);
+*/
+void ReloadCustomArtworkFiles(struct ArtworkListInfo *);
+
+
#if !defined(PLATFORM_UNIX)
void initErrorFile();
FILE *openErrorFile();
char *artwork_path;
if (leveldir_current == NULL)
- return NOT_AVAILABLE;
+ return UNDEFINED_FILENAME;
artwork_path =
(type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_path :
type == TREE_TYPE_SOUNDS_DIR ? leveldir_current->sounds_path :
type == TREE_TYPE_MUSIC_DIR ? leveldir_current->music_path :
- NOT_AVAILABLE);
+ UNDEFINED_FILENAME);
return artwork_path;
}
return NULL; /* cannot find specified artwork file anywhere */
}
-char *getCustomSoundConfigFilename()
+char *getCustomArtworkFilename(char *basename, int type)
{
- return getCustomSoundFilename(SOUNDSINFO_FILENAME);
+ if (type == ARTWORK_TYPE_GRAPHICS)
+ return getCustomImageFilename(basename);
+ else if (type == ARTWORK_TYPE_SOUNDS)
+ return getCustomSoundFilename(basename);
+ else
+ return UNDEFINED_FILENAME;
+}
+
+char *getCustomArtworkConfigFilename(int type)
+{
+ return getCustomArtworkFilename(ARTWORKINFO_FILENAME(type), type);
}
char *getCustomMusicDirectory(void)
ldi->graphics_set = NULL;
ldi->sounds_set = NULL;
ldi->music_set = NULL;
- ldi->graphics_path = getStringCopy(NOT_AVAILABLE);
- ldi->sounds_path = getStringCopy(NOT_AVAILABLE);
- ldi->music_path = getStringCopy(NOT_AVAILABLE);
+ ldi->graphics_path = getStringCopy(UNDEFINED_FILENAME);
+ ldi->sounds_path = getStringCopy(UNDEFINED_FILENAME);
+ ldi->music_path = getStringCopy(UNDEFINED_FILENAME);
ldi->levels = 0;
ldi->first_level = 0;
ldi->last_level = 0;
setTreeInfoToDefaults(artwork_new, type);
- artwork_new->filename = getStringCopy(NOT_AVAILABLE);
- artwork_new->fullpath = getStringCopy(NOT_AVAILABLE);
- artwork_new->basepath = getStringCopy(NOT_AVAILABLE);
+ artwork_new->filename = getStringCopy(UNDEFINED_FILENAME);
+ artwork_new->fullpath = getStringCopy(UNDEFINED_FILENAME);
+ artwork_new->basepath = getStringCopy(UNDEFINED_FILENAME);
if (artwork_new->name != NULL)
free(artwork_new->name);
- artwork_new->identifier = getStringCopy(NOT_AVAILABLE);
- artwork_new->name = getStringCopy(NOT_AVAILABLE);
- artwork_new->name_sorting = getStringCopy(NOT_AVAILABLE);
+ artwork_new->identifier = getStringCopy(UNDEFINED_FILENAME);
+ artwork_new->name = getStringCopy(UNDEFINED_FILENAME);
+ artwork_new->name_sorting = getStringCopy(UNDEFINED_FILENAME);
return artwork_new;
}
char *getImageFilename(char *);
char *getCustomImageFilename(char *);
char *getCustomSoundFilename(char *);
-char *getCustomSoundConfigFilename(void);
+char *getCustomArtworkFilename(char *, int);
+char *getCustomArtworkConfigFilename(int);
char *getCustomMusicDirectory(void);
void InitTapeDirectory(char *);
};
typedef struct SoundControl SoundControl;
-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 ArtworkListInfo sound_info;
-
-static struct SoundEffectInfo *sound_effect;
+static struct ArtworkConfigInfo *sound_config = NULL;
static ListNode *SoundFileList = NULL;
static SoundInfo **Sound = NULL;
static MusicInfo **Music = NULL;
#define CHUNK_ID_LEN 4 /* IFF style chunk id length */
#define WAV_HEADER_SIZE 16 /* size of WAV file header */
-static SoundInfo *Load_WAV(char *filename)
+static void *Load_WAV(char *filename)
{
SoundInfo *snd_info;
#if defined(AUDIO_UNIX_NATIVE)
replaceSoundEntry(snd_info, filename);
}
-void InitSoundList(struct SoundEffectInfo *sounds_list, int num_list_entries)
+void InitSoundList(struct ArtworkConfigInfo *config_list, int num_list_entries)
{
if (Sound == NULL)
Sound = checked_calloc(num_list_entries * sizeof(SoundInfo *));
- sound_effect = sounds_list;
+ sound_config = config_list;
num_sounds = num_list_entries;
+
+ sound_info.type = ARTWORK_TYPE_SOUNDS;
+ sound_info.num_list_entries = num_list_entries;
+ sound_info.config_list = config_list;
+ sound_info.artwork_list = (struct ArtworkListNodeInfo **)Sound;
+ sound_info.file_list = NULL;
+ sound_info.load_artwork = Load_WAV;
+ sound_info.free_artwork = FreeSound;
}
void LoadSoundToList(char *basename, int list_pos)
HandleSoundRequest(snd_ctrl);
}
-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;
-
-#if 0
- printf("[CHECKING LIST KEY '%s' == '%s']\n",
- (*node_first)->key, key);
-#endif
-
- if (strcmp((*node_first)->key, key) == 0)
- {
-#if 0
- printf("[DELETING LIST ENTRY]\n");
-#endif
-
- 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' (%d)]\n", node->key,
- ((SoundInfo *)node->content)->num_references);
- node = node->next;
- }
-
- printf("[%d nodes]\n", getNumNodes(node_first));
-}
-
-static void LoadSoundsInfo()
+#if 1
+static void ReloadCustomSounds()
{
- char *filename = getCustomSoundConfigFilename();
- struct SetupFileList *setup_file_list;
- int i;
-
-#if 0
- printf("GOT CUSTOM SOUND CONFIG FILE '%s'\n", filename);
-#endif
-
- /* 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 0
- for (i=0; i<num_sounds; i++)
- {
- printf("'%s' ", sound_effect[i].text);
- if (sound_effect[i].filename)
- printf("-> '%s'\n", sound_effect[i].filename);
- else
- printf("-> UNDEFINED [-> '%s']\n", sound_effect[i].default_filename);
- }
-#endif
- }
+ ReloadCustomArtworkFiles(&sound_info);
}
-
+#else
static void ReloadCustomSounds()
{
static boolean draw_init_text = TRUE; /* only draw at startup */
printf("DEBUG: reloading sounds '%s' ...\n",artwork.snd_current_identifier);
#endif
- LoadSoundsInfo();
+ LoadArtworkConfig(&sound_info);
if (draw_init_text)
DrawInitText("Loading sounds:", 120, FC_GREEN);
for(i=0; i<num_sounds; i++)
{
if (draw_init_text)
- DrawInitText(sound_effect[i].text, 150, FC_YELLOW);
+ DrawInitText(sound_config[i].token, 150, FC_YELLOW);
- if (sound_effect[i].filename)
- LoadSoundToList(sound_effect[i].filename, i);
+ if (sound_config[i].filename)
+ LoadSoundToList(sound_config[i].filename, i);
else
- LoadSoundToList(sound_effect[i].default_filename, i);
+ LoadSoundToList(sound_config[i].default_filename, i);
}
draw_init_text = FALSE;
dumpList(SoundFileList);
#endif
}
+#endif
static void ReloadCustomMusic()
{
#define SOUND_MIDDLE (SOUND_MAX_LEFT2RIGHT / 2)
/* value for undefined sound effect filename */
-#define SND_FILE_UNDEFINED "NONE"
-
-
-struct SoundEffectInfo
-{
- char *text;
- char *default_filename;
-
- char *filename;
-};
+#define SND_FILE_UNDEFINED UNDEFINED_FILENAME
/* general sound functions */
void StopSound(int);
void StopSounds(void);
void StopSoundExt(int, int);
-void InitSoundList(struct SoundEffectInfo *, int);
+void InitSoundList(struct ArtworkConfigInfo *, int);
void InitReloadSounds(char *);
void InitReloadMusic(char *);
void FreeAllSounds(void);
/* default text for non-existant artwork */
#define NOT_AVAILABLE "(not available)"
+/* default value for undefined filename */
+#define UNDEFINED_FILENAME "[NONE]"
+
/* default name for new levels */
#define NAMELESS_LEVEL_NAME "nameless level"
};
#define TREE_TYPE_GENERIC 0
-#define TREE_TYPE_LEVEL_DIR 1
-#define TREE_TYPE_GRAPHICS_DIR 2
-#define TREE_TYPE_SOUNDS_DIR 3
-#define TREE_TYPE_MUSIC_DIR 4
+#define TREE_TYPE_GRAPHICS_DIR 1
+#define TREE_TYPE_SOUNDS_DIR 2
+#define TREE_TYPE_MUSIC_DIR 3
+#define TREE_TYPE_LEVEL_DIR 4
+
+#define ARTWORK_TYPE_GRAPHICS TREE_TYPE_GRAPHICS_DIR
+#define ARTWORK_TYPE_SOUNDS TREE_TYPE_SOUNDS_DIR
+#define ARTWORK_TYPE_MUSIC TREE_TYPE_MUSIC_DIR
struct TreeInfo
{
char *mus_current_identifier;
};
+struct ArtworkConfigInfo
+{
+ char *token;
+ char *default_filename;
+
+ char *filename;
+};
+
+struct ArtworkListNodeInfo
+{
+ char *source_filename;
+ int num_references;
+};
+
+struct ArtworkListInfo
+{
+ int type; /* type of artwork */
+ int num_list_entries;
+ struct ArtworkConfigInfo *config_list; /* static config list */
+ struct ArtworkListNodeInfo **artwork_list; /* static artwork list */
+ ListNode *file_list; /* dynamic artwork list */
+ void *(*load_artwork)(char *); /* constructor function */
+ void (*free_artwork)(void *); /* destructor function */
+};
+
/* ========================================================================= */
/* exported variables */
#define SIZEOF_ARRAY(array, type) (sizeof(array) / sizeof(type))
#define SIZEOF_ARRAY_INT(array) SIZEOF_ARRAY(array, int)
+
+struct ListNode
+{
+ char *key;
+ void *content;
+ struct ListNode *next;
+};
+typedef struct ListNode ListNode;
+
#endif /* TYPES_H */
"gate.wav"
};
-struct SoundEffectInfo sound_effects[] =
+struct ArtworkConfigInfo image_config[] =
+{
+ /* graphics for Boulder Dash style elements and actions */
+ { "bd_empty_space.digging", "empty.pcx" },
+ { "bd_sand.digging", "schlurf.pcx" },
+ { "bd_diamond.collecting", "pong.pcx" },
+ { "bd_diamond.impact", "pling.pcx" },
+ { "bd_rock.pushing", "pusch.pcx" },
+ { "bd_rock.impact", "klopf.pcx" },
+ { "bd_magic_wall.activating", "quirk.pcx" },
+ { "bd_magic_wall.changing", "quirk.pcx" },
+ { "bd_magic_wall.running", "miep.pcx" },
+ { "bd_amoeba.waiting", "amoebe.pcx" },
+ { "bd_amoeba.creating", "amoebe.pcx" },
+ { "bd_amoeba.turning_to_gem", "pling.pcx" },
+ { "bd_amoeba.turning_to_rock", "klopf.pcx" },
+ { "bd_butterfly.moving", "klapper.pcx" },
+ { "bd_butterfly.waiting", "klapper.pcx" },
+ { "bd_firefly.moving", "roehr.pcx" },
+ { "bd_firefly.waiting", "roehr.pcx" },
+ { "bd_exit.entering", "buing.pcx" },
+};
+
+struct ArtworkConfigInfo sound_config[] =
{
/* sounds for Boulder Dash style elements and actions */
{ "bd_empty_space.digging", "empty.wav" },
extern struct GlobalInfo global;
extern struct ElementInfo element_info[];
extern struct GraphicInfo graphic_info[];
-extern struct SoundEffectInfo sound_effects[];
+extern struct ArtworkConfigInfo image_config[], sound_config[];
/* often used screen positions */
#define SX 8
#define NUM_SOUNDS 55
-/* values for sound effects */
+/* values for image configuration */
+#define GFX_BD_EMPTY_SPACE_DIGGING 0
+#define GFX_BD_SAND_DIGGING 1
+#define GFX_BD_DIAMOND_COLLECTING 2
+#define GFX_BD_DIAMOND_IMPACT 3
+#define GFX_BD_ROCK_PUSHING 4
+#define GFX_BD_ROCK_IMPACT 5
+#define GFX_BD_MAGIC_WALL_ACTIVATING 6
+#define GFX_BD_MAGIC_WALL_CHANGING 7
+#define GFX_BD_MAGIC_WALL_RUNNING 8
+#define GFX_BD_AMOEBA_WAITING 9
+#define GFX_BD_AMOEBA_CREATING 10
+#define GFX_BD_AMOEBA_TURNING_TO_GEM 11
+#define GFX_BD_AMOEBA_TURNING_TO_ROCK 12
+#define GFX_BD_BUTTERFLY_MOVING 13
+#define GFX_BD_BUTTERFLY_WAITING 14
+#define GFX_BD_FIREFLY_MOVING 15
+#define GFX_BD_FIREFLY_WAITING 16
+#define GFX_BD_EXIT_ENTERING 17
+
+#define NUM_IMAGE_CONFIG_ENTRIES 18
+
+
+/* values for sound configuration */
#define SND_BD_EMPTY_SPACE_DIGGING 0
#define SND_BD_SAND_DIGGING 1
#define SND_BD_DIAMOND_COLLECTING 2
#define SND_MENU_HALL_OF_FAME 167
#define SND_MENU_INFO_SCREEN 168
-#define NUM_SOUND_EFFECTS 169
+#define NUM_SOUND_CONFIG_ENTRIES 169
/* values for game_status */