X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fsound.c;fp=src%2Fsound.c;h=e89a153fd665db256c4306e1c231632227e83446;hb=41cfe645942062496cd063eb46e17d677a76c645;hp=7839902a50d21f24c7d2080035c3047cc11d6d6d;hpb=0e5a0f487acaed09a34c655b83ea637c83f4a0f0;p=rocksndiamonds.git diff --git a/src/sound.c b/src/sound.c index 7839902a..e89a153f 100644 --- a/src/sound.c +++ b/src/sound.c @@ -715,18 +715,31 @@ boolean LoadSound(struct SoundInfo *snd_info) { char filename[256]; char *sound_ext = "wav"; +#ifndef USE_SDL_LIBRARY #ifndef MSDOS byte sound_header_buffer[WAV_HEADER_SIZE]; char chunk[CHUNK_ID_LEN + 1]; int chunk_length, dummy; FILE *file; int i; +#endif #endif sprintf(filename, "%s/%s/%s.%s", options.ro_base_directory, SOUNDS_DIRECTORY, snd_info->name, sound_ext); +#ifdef USE_SDL_LIBRARY + + snd_info->mix_chunk = Mix_LoadWAV(filename); + if (snd_info->mix_chunk == NULL) + { + Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename); + return FALSE; + } + +#else /* !USE_SDL_LIBRARY */ + #ifndef MSDOS if ((file = fopen(filename, "r")) == NULL) @@ -789,12 +802,13 @@ boolean LoadSound(struct SoundInfo *snd_info) if (!snd_info->sample_ptr) { Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename); - return(FALSE); + return FALSE; } #endif /* MSDOS */ +#endif /* !USE_SDL_LIBRARY */ - return(TRUE); + return TRUE; } void PlaySound(int nr) @@ -816,6 +830,17 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop) { struct SoundControl snd_ctrl = emptySoundControl; +#ifdef USE_SDL_LIBRARY + Mix_PlayChannel(-1, Sound[nr].mix_chunk, 0); + + /* + Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4); + Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4); + */ + + return; +#endif + if (sound_status==SOUND_OFF || !setup.sound) return; @@ -873,6 +898,11 @@ void StopSoundExt(int nr, int method) { struct SoundControl snd_ctrl = emptySoundControl; +#ifdef USE_SDL_LIBRARY + Mix_HaltMusic(); + return; +#endif + if (sound_status==SOUND_OFF) return;