1 /* GNU Robbo 2 * Copyright (C) 2002-2010 The GNU Robbo Team (see AUTHORS). 3 * 4 * GNU Robbo is free software - you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2, or (at your option) 7 * any later version. 8 * 9 * GNU Robbo is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the impled warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with GNU CC; see the file COPYING. If not, write to the 16 * Free Software Foundation, 59 Temple Place - Suite 330, 17 * Boston, MA 02111-1307, USA. 18 * 19 */ 20 21 22 23 /* 24 * Defines 25 */ 26 #define SND_FULL 3 27 #define SND_NORM 2 28 #define SND_HALF 1 29 #define SND_MUTE 0 30 #define SND_QUIET 4 31 #define SND_CHANNELS 16 32 33 #define SND_RATE 44100 34 35 /* 36 * sound effects types 37 */ 38 39 #define SFX_BULLET 1 40 #define SFX_SCREW 2 41 #define SFX_BOMB 3 42 #define SFX_BOX 4 43 #define SFX_DOOR 5 44 #define SFX_GUN 6 45 #define SFX_KEY 7 46 #define SFX_SHOOT 8 47 #define SFX_BIRD 9 48 #define SFX_TELEPORT 10 49 #define SFX_ROBBO 11 50 #define SFX_CAPSULE 12 51 #define SFX_KILL 13 52 #define SFX_MAGNET 14 53 #define SFX_EXIT_OPEN 15 54 55 #define MUS_MAXSONGS 40 56 57 #define SND_SFX_DEFAULT_VOLUME 30 58 #define SND_MUS_DEFAULT_VOLUME SND_SFX_DEFAULT_VOLUME 59 60 61 62 struct snd_sample { 63 int initialized; 64 int type; 65 Mix_Chunk *s_sample; 66 char *fname; 67 char *rctag; 68 }; 69 70 struct snd_music { 71 int present; 72 Mix_Music *music; 73 int playing; 74 char fname[128]; 75 }; 76 77 78 /* 79 * Variables 80 */ 81 int sound; 82 int temp_game_sound; 83 int sfx_vol; 84 int temp_sfx_vol; 85 /* 86 * if we do not support music, we assume, that volume is sfx_volume 87 */ 88 #ifdef HAVE_MUSIC 89 int volume; 90 #else 91 #define volume sfx_vol 92 #endif 93 94 95 /* 96 * Function prototypes 97 */ 98 99 100 void volume_up(void); 101 void volume_down(void); 102 103 void load_soundskin(char *fname); 104 105 void audio_init(void); /* this one initializes sound 106 * system - shuld be run only once 107 */ 108 109 void audio_destroy(void); /* this one destroys all audio 110 * content from the memory, and 111 * sets sound variable to 0 */ 112 /* 113 * if you want to use audio again, set sound 114 * variable to 1 and call audio_init 115 */ 116 void load_samples(void); /* loads samples into memory */ 117 118 119 void play_sound(int event, int vol); /* this one plays sounds */ 120 /* 121 * vol can take 3 values: SND_NORM - 122 * sound is played with volume set in 123 * sfx_vol 124 */ 125 /* 126 * SND_HALF which is half of sfx_vol, 127 * and SND_MUTE - which means mute 128 * sound or no sound at all 129 */ 130 int audio_opened(); /* returns 0 if mixer is not initialized */ 131 void audio_open(); /* initializes mixer should be the first 132 * thing before playing any sound */ 133 void audio_close(); /* closes mixer - done befere exit */ 134 135 136 #ifndef HAVE_MUSIC 137 138 #define music_stop() 139 #define make_playlist() 140 #define music_finished() 141 #define destroy_playlist() 142 #define play_music() 143 144 #else 145 void make_playlist(void); 146 void play_music(void); 147 void music_finished(void); 148 void destroy_playlist(void); 149 void music_stop(void); 150 151 #endif 152