X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsound.c;h=a7298a84d811122997367b65cc1bd7637211aec0;hb=ff56a43aa3799aa3357f4deca4d6482fc25a6a41;hp=745e3cd9d9004c64bc92bffbff100ae56c9fb613;hpb=da14f69fd95c7bd5a0d70cdf4935af06f1f20a04;p=rocksndiamonds.git diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 745e3cd9..a7298a84 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -1,23 +1,28 @@ /*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * +* Artsoft Retro-Game Library * *----------------------------------------------------------* -* (c) 1995-98 Artsoft Entertainment * -* Holger Schemel * -* Oststrasse 11a * -* 33604 Bielefeld * -* phone: ++49 +521 290471 * -* email: aeglos@valinor.owl.de * +* (c) 1994-2000 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * *----------------------------------------------------------* -* sound.c * +* sound.c * ***********************************************************/ -#include "libgame.h" - -#include "main_TMP.h" +#include +#include +#include #include "sound.h" #include "misc.h" + +static int num_sounds = 0; +static struct SampleInfo *Sound = NULL; + + /*** THE STUFF BELOW IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/ static int playing_sounds = 0; @@ -101,6 +106,7 @@ void UnixOpenAudio(struct AudioSystemInfo *audio) audio->device_name = audio_device_name[i]; audio->sound_available = TRUE; + audio->sound_enabled = TRUE; #if defined(AUDIO_STREAMING_DSP) audio->loops_available = TRUE; @@ -785,11 +791,18 @@ static int ulaw_to_linear(unsigned char ulawbyte) /*** THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS ***/ +void AllocSoundArray(int num) +{ + num_sounds = num; + Sound = checked_calloc(num_sounds * sizeof(struct SampleInfo)); +} + #define CHUNK_ID_LEN 4 /* IFF style chunk id length */ #define WAV_HEADER_SIZE 20 /* size of WAV file header */ -boolean LoadSound(struct SampleInfo *snd_info) +boolean LoadSound(int sound_nr, char *sound_name) { + struct SampleInfo *snd_info = &Sound[sound_nr]; char filename[256]; char *sound_ext = "wav"; #if !defined(TARGET_SDL) @@ -802,6 +815,8 @@ boolean LoadSound(struct SampleInfo *snd_info) #endif #endif + snd_info->name = sound_name; + sprintf(filename, "%s/%s/%s.%s", options.ro_base_directory, SOUNDS_DIRECTORY, snd_info->name, sound_ext); @@ -907,7 +922,7 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop) { struct SoundControl snd_ctrl = emptySoundControl; - if (!audio.sound_available || !setup.sound) + if (!audio.sound_available || !audio.sound_enabled) return; if (volume