-#define COMPILE_DATE_STRING "[2003-01-18 13:34]"
+#define COMPILE_DATE_STRING "[2003-01-18 14:21]"
static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS];
-#define IS_ANIMATED(g) (graphic_info[g].anim_frames > 1)
-
-
-/* ------------------------------------------------------------------------- */
-/* sound definitions */
-/* ------------------------------------------------------------------------- */
-
-static struct
-{
- char *text;
- int value;
- boolean is_loop;
-} sound_action_properties[] =
-{
- /* insert _all_ loop sound actions here */
- { ".waiting", ACTION_WAITING, TRUE },
- { ".moving", ACTION_MOVING, TRUE }, /* continuos moving */
- { ".active", ACTION_ACTIVE, TRUE },
- { ".growing", ACTION_GROWING, TRUE },
- { ".attacking", ACTION_ATTACKING, TRUE },
-
- /* other (non-loop) sound actions are optional */
- { ".stepping", ACTION_MOVING, FALSE }, /* discrete moving */
- { ".digging", ACTION_DIGGING, FALSE },
- { ".collecting", ACTION_COLLECTING, FALSE },
- { ".passing", ACTION_PASSING, FALSE },
- { ".impact", ACTION_IMPACT, FALSE },
- { ".pushing", ACTION_PUSHING, FALSE },
- { ".activating", ACTION_ACTIVATING, FALSE },
- { NULL, 0, 0 },
-};
-static int element_action_sound[MAX_NUM_ELEMENTS][NUM_ACTIONS];
-static boolean is_loop_sound[NUM_SOUND_FILES];
-
-#define IS_LOOP_SOUND(x) (is_loop_sound[x])
+#define IS_ANIMATED(g) (graphic_info[g].anim_frames > 1)
+#define IS_LOOP_SOUND(s) (sound_info[s].loop)
/* -------------------------------------------------------------------------
}
-/*
- =============================================================================
- InitGameSound()
- -----------------------------------------------------------------------------
- initialize sound effect lookup table for element actions
- =============================================================================
-*/
-
-void InitGameSound()
-{
- int sound_effect_properties[NUM_SOUND_FILES];
- int i, j;
-
-#if 0
- debug_print_timestamp(0, NULL);
-#endif
-
- /* initialize sound effect for all elements to "no sound" */
- for (i=0; i<MAX_NUM_ELEMENTS; i++)
- for (j=0; j<NUM_ACTIONS; j++)
- element_action_sound[i][j] = -1;
-
- for (i=0; i<NUM_SOUND_FILES; i++)
- {
- int len_effect_text = strlen(sound_files[i].token);
-
- sound_effect_properties[i] = ACTION_OTHER;
- is_loop_sound[i] = FALSE;
-
- /* determine all loop sounds and identify certain sound classes */
-
- 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_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;
- }
- }
-
- /* associate elements and some selected sound actions */
-
- for (j=0; j<MAX_NUM_ELEMENTS; j++)
- {
- if (element_info[j].sound_class_name)
- {
- int len_class_text = strlen(element_info[j].sound_class_name);
-
- if (len_class_text + 1 < len_effect_text &&
- strncmp(sound_files[i].token,
- element_info[j].sound_class_name, len_class_text) == 0 &&
- sound_files[i].token[len_class_text] == '.')
- {
- int sound_action_value = sound_effect_properties[i];
-
- element_action_sound[j][sound_action_value] = i;
- }
- }
- }
- }
-
-#if 0
- debug_print_timestamp(0, "InitGameEngine");
-#endif
-
-#if 0
- /* TEST ONLY */
- {
- int element = EL_SAND;
- int sound_action = ACTION_DIGGING;
- int j = 0;
-
- while (sound_action_properties[j].text)
- {
- if (sound_action_properties[j].value == sound_action)
- printf("element %d, sound action '%s' == %d\n",
- element, sound_action_properties[j].text,
- element_action_sound[element][sound_action]);
- j++;
- }
- }
-#endif
-}
-
-
/*
=============================================================================
InitGameEngine()
static void PlaySoundLevelElementAction(int x, int y, int element,
int sound_action)
{
- int sound_effect = element_action_sound[element][sound_action];
+ int sound_effect = element_info[element].sound[sound_action];
- if (sound_effect != -1)
+ if (sound_effect != SND_UNDEFINED)
PlaySoundLevel(x, y, sound_effect);
}
static void InitSoundInfo()
{
+ int sound_effect_properties[NUM_SOUND_FILES];
+ int i, j;
+
sound_files = getCurrentSoundList();
- /* initialize sound effect lookup table for element actions */
- InitGameSound();
+ /* initialize sound effect for all elements to "no sound" */
+ for (i=0; i<MAX_NUM_ELEMENTS; i++)
+ for (j=0; j<NUM_ACTIONS; j++)
+ element_info[i].sound[j] = SND_UNDEFINED;
+
+ for (i=0; i<NUM_SOUND_FILES; i++)
+ {
+ int len_effect_text = strlen(sound_files[i].token);
+
+ sound_effect_properties[i] = ACTION_OTHER;
+ sound_info[i].loop = FALSE;
+
+ /* determine all loop sounds and identify certain sound classes */
+
+ 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_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)
+ sound_info[i].loop = TRUE;
+ }
+ }
+
+ /* associate elements and some selected sound actions */
+
+ for (j=0; j<MAX_NUM_ELEMENTS; j++)
+ {
+ if (element_info[j].sound_class_name)
+ {
+ int len_class_text = strlen(element_info[j].sound_class_name);
+
+ if (len_class_text + 1 < len_effect_text &&
+ strncmp(sound_files[i].token,
+ element_info[j].sound_class_name, len_class_text) == 0 &&
+ sound_files[i].token[len_class_text] == '.')
+ {
+ int sound_action_value = sound_effect_properties[i];
+
+ element_info[j].sound[sound_action_value] = i;
+ }
+ }
+ }
+ }
+
+#if 0
+ /* TEST ONLY */
+ {
+ int element = EL_SAND;
+ int sound_action = ACTION_DIGGING;
+ int j = 0;
+
+ while (sound_action_properties[j].text)
+ {
+ if (sound_action_properties[j].value == sound_action)
+ printf("element %d, sound action '%s' == %d\n",
+ element, sound_action_properties[j].text,
+ element_info_[element].sound[sound_action]);
+ j++;
+ }
+ }
+#endif
}
void InitElementProperties()
}
};
-struct NewGraphicInfo graphic_info[NUM_IMAGE_FILES];
+
+/* ------------------------------------------------------------------------- */
+/* sound definitions */
+/* ------------------------------------------------------------------------- */
+
+struct SoundActionProperties sound_action_properties[] =
+{
+ /* insert _all_ loop sound actions here */
+ { ".waiting", ACTION_WAITING, TRUE },
+ { ".moving", ACTION_MOVING, TRUE }, /* continuos moving */
+ { ".active", ACTION_ACTIVE, TRUE },
+ { ".growing", ACTION_GROWING, TRUE },
+ { ".attacking", ACTION_ATTACKING, TRUE },
+
+ /* other (non-loop) sound actions are optional */
+ { ".stepping", ACTION_MOVING, FALSE }, /* discrete moving */
+ { ".digging", ACTION_DIGGING, FALSE },
+ { ".collecting", ACTION_COLLECTING, FALSE },
+ { ".passing", ACTION_PASSING, FALSE },
+ { ".impact", ACTION_IMPACT, FALSE },
+ { ".pushing", ACTION_PUSHING, FALSE },
+ { ".activating", ACTION_ACTIVATING, FALSE },
+ { NULL, 0, 0 },
+};
+
+
+struct GraphicInfo graphic_info[NUM_IMAGE_FILES];
+struct SoundInfo sound_info[NUM_SOUND_FILES];
/* ========================================================================= */
#define IMG_CHAR_START IMG_CHAR_SPACE
#define IMG_CUSTOM_START IMG_CUSTOM_1
+#define SND_UNDEFINED (-1)
+
#define WIN_XSIZE 672
#define WIN_YSIZE 560
char *sound_class_name; /* classification for custom sound effects */
char *editor_description; /* short description for level editor */
- /* default graphics for several actions */
- int graphic[NUM_ACTIONS];
-
+ int graphic[NUM_ACTIONS]; /* default graphics for several actions */
/* special graphics for left/right/up/down */
int direction_graphic[NUM_ACTIONS][NUM_DIRECTIONS];
-};
-struct GraphicInfo
-{
- Bitmap *bitmap;
- int src_x, src_y;
+ int sound[NUM_ACTIONS]; /* default sounds for several actions */
};
-struct NewGraphicInfo
+struct GraphicInfo
{
Bitmap *bitmap;
int src_x, src_y; /* derived from (tile sized) .xpos/.ypos */
#endif
};
+struct SoundInfo
+{
+ boolean loop;
+};
+
+struct SoundActionProperties
+{
+ char *text;
+ int value;
+ boolean is_loop;
+};
+
+
#if 0
extern GC tile_clip_gc;
extern Bitmap *pix[];
extern struct GameInfo game;
extern struct GlobalInfo global;
extern struct ElementInfo element_info[];
-extern struct NewGraphicInfo graphic_info[];
+extern struct GraphicInfo graphic_info[];
+extern struct SoundInfo sound_info[];
+extern struct SoundActionProperties sound_action_properties[];
extern struct ConfigInfo image_config[], sound_config[];
extern struct ConfigInfo image_config_suffix[], sound_config_suffix[];
extern struct FileInfo *image_files, *sound_files;