SRC_DIR = src
MAKE_CMD = $(MAKE) -C $(SRC_DIR)
+DEFAULT_TARGET = sdl
+
all:
- @$(MAKE_CMD) TARGET=x11
+ @$(MAKE_CMD) TARGET=$(DEFAULT_TARGET)
x11:
@$(MAKE_CMD) TARGET=x11
#-----------------------------------------------------------------------------#
run:
- @$(MAKE_CMD) TARGET=x11 && ./rocksndiamonds --verbose
+ @$(MAKE_CMD) TARGET=$(DEFAULT_TARGET) && ./rocksndiamonds --verbose
backup:
./Scripts/make_backup.sh src
-#define COMPILE_DATE_STRING "[2002-09-06 19:21]"
+#define COMPILE_DATE_STRING "[2002-09-06 22:45]"
{ NULL, 0, 0 },
};
static int element_action_sound[NUM_LEVEL_ELEMENTS][NUM_SND_ACTIONS];
-static boolean is_loop_sound[NUM_SOUND_CONFIG_ENTRIES];
+static boolean is_loop_sound[NUM_SOUND_FILES];
#define IS_LOOP_SOUND(x) (is_loop_sound[x])
void InitGameSound()
{
- int sound_effect_properties[NUM_SOUND_CONFIG_ENTRIES];
+ int sound_effect_properties[NUM_SOUND_FILES];
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_CONFIG_ENTRIES; i++)
+ for (i=0; i<NUM_SOUND_FILES; i++)
{
- int len_effect_text = strlen(sound_config[i].token);
+ int len_effect_text = strlen(sound_files[i].token);
sound_effect_properties[i] = SND_ACTION_UNKNOWN;
is_loop_sound[i] = FALSE;
/* determine all loop sounds and identify certain sound classes */
- j = 0;
- while (sound_action_properties[j].text)
+ for (j=0; sound_action_properties[j].text; j++)
{
int len_action_text = strlen(sound_action_properties[j].text);
if (len_action_text < len_effect_text &&
- strcmp(&sound_config[i].token[len_effect_text - len_action_text],
+ strcmp(&sound_files[i].token[len_effect_text - len_action_text],
sound_action_properties[j].text) == 0)
{
sound_effect_properties[i] = sound_action_properties[j].value;
if (sound_action_properties[j].is_loop)
is_loop_sound[i] = TRUE;
}
-
- j++;
}
/* associate elements and some selected sound actions */
int len_class_text = strlen(element_info[j].sound_class_name);
if (len_class_text + 1 < len_effect_text &&
- strncmp(sound_config[i].token,
+ strncmp(sound_files[i].token,
element_info[j].sound_class_name, len_class_text) == 0 &&
- sound_config[i].token[len_class_text] == '.')
+ sound_files[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_CONFIG_ENTRIES];
- static int loop_sound_volume[NUM_SOUND_CONFIG_ENTRIES];
+ static int loop_sound_frame[NUM_SOUND_FILES];
+ static int loop_sound_volume[NUM_SOUND_FILES];
int sx = SCREENX(x), sy = SCREENY(y);
int volume, stereo_position;
int max_distance = 8;
static void InitImages()
{
- InitImageList(image_config, NUM_IMAGE_CONFIG_ENTRIES);
+ static char *suffix_list[] =
+ {
+ ".frame_xpos",
+ ".frame_ypos",
+ ".num_frames",
+ NULL
+ };
+
+ image_files =
+ getFileListFromConfigList(image_config, suffix_list, NUM_IMAGE_FILES);
+
+ InitImageList(image_files, NUM_IMAGE_FILES);
/* load custom images */
ReloadCustomImages();
static void InitMixer()
{
+ static char *suffix_list[] =
+ {
+ NULL
+ };
+
OpenAudio();
- InitSoundList(sound_config, NUM_SOUND_CONFIG_ENTRIES);
+
+ sound_files =
+ getFileListFromConfigList(sound_config, suffix_list, NUM_SOUND_FILES);
+
+ InitSoundList(sound_files, NUM_SOUND_FILES);
StartMixer();
}
printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
printf("\n");
- for (i=0; i<NUM_IMAGE_CONFIG_ENTRIES; i++)
+ for (i=0; image_config[i].token != NULL; i++)
printf("# %s\n",
getFormattedSetupEntry(image_config[i].token,
- image_config[i].default_filename));
+ image_config[i].value));
}
else if (strcmp(command, "create soundsinfo.conf") == 0)
{
printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
printf("\n");
- for (i=0; i<NUM_SOUND_CONFIG_ENTRIES; i++)
+ for (i=0; sound_config[i].token != NULL; i++)
printf("# %s\n",
getFormattedSetupEntry(sound_config[i].token,
- sound_config[i].default_filename));
+ sound_config[i].value));
}
else if (strcmp(command, "create musicinfo.conf") == 0)
{
FreeAllMusic();
CloseAudio(); /* called after freeing sounds (needed for SDL) */
+ FreeAllImages();
+
FreeTileClipmasks();
for(i=0; i<NUM_BITMAPS; i++)
FreeBitmap(pix[i]);
free(image);
}
-void InitImageList(struct ArtworkConfigInfo *config_list, int num_list_entries)
+void InitImageList(struct FileInfo *file_list, int num_list_entries)
{
if (image_info == NULL)
image_info = checked_calloc(sizeof(struct ArtworkListInfo));
image_info->type = ARTWORK_TYPE_GRAPHICS;
image_info->num_list_entries = num_list_entries;
- image_info->config_list = config_list;
- image_info->file_list = NULL;
+ image_info->file_list = file_list;
+ image_info->content_list = NULL;
image_info->load_artwork = Load_PCX;
image_info->free_artwork = FreeImage;
}
ReloadCustomArtworkList(image_info);
}
+
+void FreeAllImages()
+{
+ FreeCustomArtworkList(image_info);
+}
#endif /* TARGET_X11 */
-void InitImageList(struct ArtworkConfigInfo *, int);
+void InitImageList(struct FileInfo *, int);
void ReloadCustomImages();
+void FreeAllImages();
#endif /* IMAGE_H */
while (node)
{
printf("['%s' (%d)]\n", node->key,
- ((struct ArtworkListNodeInfo *)node->content)->num_references);
+ ((struct ListNodeInfo *)node->content)->num_references);
node = node->next;
}
/* functions for loading artwork configuration information */
/* ========================================================================= */
+struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list,
+ char *suffix_list[],
+ int num_list_entries)
+{
+ struct FileInfo *file_list =
+ checked_calloc(num_list_entries * sizeof(struct FileInfo));
+ int list_pos = 0;
+ int i, j;
+
+ for (i=0; config_list[i].token != NULL; i++)
+ {
+ int len_config_token = strlen(config_list[i].token);
+ boolean is_file_entry = TRUE;
+
+ for (j=0; suffix_list[j] != NULL; j++)
+ {
+ int len_suffix = strlen(suffix_list[j]);
+
+ if (len_suffix < len_config_token &&
+ strcmp(&config_list[i].token[len_config_token - len_suffix],
+ suffix_list[j]) == 0)
+ {
+ is_file_entry = FALSE;
+ break;
+ }
+ }
+
+ if (is_file_entry)
+ {
+ if (list_pos >= num_list_entries)
+ Error(ERR_EXIT, "inconsistant config list information -- please fix");
+
+ file_list[list_pos].token = config_list[i].token;
+ file_list[list_pos].default_filename = config_list[i].value;
+
+ list_pos++;
+ }
+ }
+
+ if (list_pos != num_list_entries)
+ Error(ERR_EXIT, "inconsistant config list information -- please fix");
+
+ return file_list;
+}
+
static void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
{
int num_list_entries = artwork_info->num_list_entries;
- struct ArtworkConfigInfo *config_list = artwork_info->config_list;
+ struct FileInfo *file_list = artwork_info->file_list;
char *filename = getCustomArtworkConfigFilename(artwork_info->type);
struct SetupFileList *setup_file_list;
int i;
/* always start with reliable default values */
for (i=0; i<num_list_entries; i++)
- config_list[i].filename = NULL;
+ file_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));
+ file_list[i].filename =
+ getStringCopy(getTokenValue(setup_file_list, file_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);
+ printf("'%s' ", file_list[i].token);
+ if (file_list[i].filename)
+ printf("-> '%s'\n", file_list[i].filename);
else
- printf("-> UNDEFINED [-> '%s']\n", config_list[i].default_filename);
+ printf("-> UNDEFINED [-> '%s']\n", file_list[i].default_filename);
}
#endif
}
}
-void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info,
- struct ArtworkListNodeInfo **listnode)
+static void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info,
+ struct ListNodeInfo **listnode)
{
if (*listnode)
{
printf("[deleting artwork '%s']\n", filename);
#endif
- deleteNodeFromList(&artwork_info->file_list, filename,
+ deleteNodeFromList(&artwork_info->content_list, filename,
artwork_info->free_artwork);
}
}
static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
- struct ArtworkListNodeInfo **listnode,
+ struct ListNodeInfo **listnode,
char *filename)
{
ListNode *node;
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 ((node = getNodeFromKey(artwork_info->content_list, filename)) != NULL)
{
#if 0
printf("[artwork '%s' already exists (other list entry)]\n", filename);
#endif
- *listnode = (struct ArtworkListNodeInfo *)node->content;
+ *listnode = (struct ListNodeInfo *)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,
+ addNodeToList(&artwork_info->content_list, (*listnode)->source_filename,
*listnode);
}
}
static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info,
- struct ArtworkListNodeInfo **listnode,
+ struct ListNodeInfo **listnode,
char *basename)
{
char *filename = getCustomArtworkFilename(basename, artwork_info->type);
replaceArtworkListEntry(artwork_info, listnode, filename);
}
-void LoadArtworkToList(struct ArtworkListInfo *artwork_info,
- char *basename, int list_pos)
+static void LoadArtworkToList(struct ArtworkListInfo *artwork_info,
+ char *basename, int list_pos)
{
if (artwork_info->artwork_list == NULL ||
list_pos >= artwork_info->num_list_entries)
#if 0
printf("loading artwork '%s' ... [%d]\n",
- basename, getNumNodes(artwork_info->file_list));
+ basename, getNumNodes(artwork_info->content_list));
#endif
LoadCustomArtwork(artwork_info, &artwork_info->artwork_list[list_pos],
#if 0
printf("loading artwork '%s' done [%d]\n",
- basename, getNumNodes(artwork_info->file_list));
+ basename, getNumNodes(artwork_info->content_list));
#endif
}
};
int num_list_entries = artwork_info->num_list_entries;
- struct ArtworkConfigInfo *config_list = artwork_info->config_list;
+ struct FileInfo *file_list = artwork_info->file_list;
int i;
LoadArtworkConfig(artwork_info);
for(i=0; i<num_list_entries; i++)
{
if (draw_init[artwork_info->type].do_it)
- DrawInitText(config_list[i].token, 150, FC_YELLOW);
+ DrawInitText(file_list[i].token, 150, FC_YELLOW);
- if (config_list[i].filename)
- LoadArtworkToList(artwork_info, config_list[i].filename, i);
+ if (file_list[i].filename)
+ LoadArtworkToList(artwork_info, file_list[i].filename, i);
else
- LoadArtworkToList(artwork_info, config_list[i].default_filename, i);
+ LoadArtworkToList(artwork_info, file_list[i].default_filename, i);
}
draw_init[artwork_info->type].do_it = FALSE;
/*
- printf("list size == %d\n", getNumNodes(artwork_info->file_list));
+ printf("list size == %d\n", getNumNodes(artwork_info->content_list));
*/
#if 0
- dumpList(artwork_info->file_list);
+ dumpList(artwork_info->content_list);
#endif
}
boolean FileIsMusic(char *);
boolean FileIsArtworkType(char *, int);
+struct FileInfo *getFileListFromConfigList(struct ConfigInfo *, char **, int);
void ReloadCustomArtworkList(struct ArtworkListInfo *);
void FreeCustomArtworkList(struct ArtworkListInfo *);
return snd_info;
}
-void InitSoundList(struct ArtworkConfigInfo *config_list, int num_list_entries)
+void InitSoundList(struct FileInfo *file_list, int num_list_entries)
{
if (sound_info == NULL)
sound_info = checked_calloc(sizeof(struct ArtworkListInfo));
sound_info->type = ARTWORK_TYPE_SOUNDS;
sound_info->num_list_entries = num_list_entries;
- sound_info->config_list = config_list;
- sound_info->file_list = NULL;
+ sound_info->file_list = file_list;
+ sound_info->content_list = NULL;
sound_info->load_artwork = Load_WAV;
sound_info->free_artwork = FreeSound;
#ifndef SOUND_H
#define SOUND_H
-#include "platform.h"
+#include "system.h"
#if defined(PLATFORM_UNIX) && !defined(TARGET_SDL)
void StopSound(int);
void StopSounds(void);
void StopSoundExt(int, int);
-void InitSoundList(struct ArtworkConfigInfo *, int);
+void InitSoundList(struct FileInfo *, int);
void InitReloadSounds(char *);
void InitReloadMusic(char *);
void FreeAllSounds(void);
char *mus_current_identifier;
};
-struct ArtworkConfigInfo
+struct ConfigInfo
+{
+ char *token;
+ char *value;
+};
+
+struct FileInfo
{
char *token;
char *default_filename;
char *filename;
};
-struct ArtworkListNodeInfo
+struct ListNodeInfo
{
- char *source_filename;
+ char *source_filename; /* primary key for node list */
int num_references;
};
{
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 */
+ struct FileInfo *file_list; /* static artwork file list */
+ struct ListNodeInfo **artwork_list; /* static artwork list */
+ struct ListNode *content_list; /* dynamic artwork list */
void *(*load_artwork)(char *); /* constructor function */
void (*free_artwork)(void *); /* destructor function */
};
"gate.wav"
};
-struct ArtworkConfigInfo image_config[] =
+struct ConfigInfo image_config[] =
{
/* graphics for Boulder Dash style elements and actions */
{ "bd_diamond", "bd_diamond.pcx" },
{ "robot_wheel", "bd_diamond.pcx" },
{ "robot_wheel.frame_xpos", "0" },
{ "robot_wheel.num_frames", "4" },
+
+ { NULL, NULL },
};
-struct ArtworkConfigInfo sound_config[] =
+struct ConfigInfo sound_config[] =
{
/* sounds for Boulder Dash style elements and actions */
{ "bd_empty_space.digging", "empty.wav" },
{ "[not used]", "whoosh.wav" },
{ "[not used]", "boom.wav" },
#endif
+
+ { NULL, NULL },
};
+struct FileInfo *image_files;
+struct FileInfo *sound_files;
+
struct ElementInfo element_info[MAX_ELEMENTS] =
{
{ "empty_space", "empty space" }, /* 0 */
extern struct GlobalInfo global;
extern struct ElementInfo element_info[];
extern struct GraphicInfo graphic_info[];
-extern struct ArtworkConfigInfo image_config[], sound_config[];
+extern struct ConfigInfo image_config[], sound_config[];
+extern struct FileInfo *image_files, *sound_files;
/* often used screen positions */
#define SX 8
/* values for image configuration */
#define GFX_BD_DIAMOND 0
+#define GFX_ROBOT_WHEEL 1
-#define NUM_IMAGE_CONFIG_ENTRIES 1
+#define NUM_IMAGE_FILES 2
/* values for sound configuration */
#define SND_MENU_HALL_OF_FAME 167
#define SND_MENU_INFO_SCREEN 168
-#define NUM_SOUND_CONFIG_ENTRIES 169
+#define NUM_SOUND_FILES 169
/* values for game_status */