From: Holger Schemel Date: Fri, 15 Mar 2002 19:40:02 +0000 (+0100) Subject: rnd-20020315-2-src X-Git-Tag: 2.0.1^2~7 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d9ebb78b0e0290d76d3ee3d8f864ac6767cab61e;p=rocksndiamonds.git rnd-20020315-2-src --- diff --git a/CHANGES b/CHANGES index 51901161..50ac3be8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,14 +1,19 @@ Release Version 2.0.1 [?? ??? 2002] ----------------------------------- - bug in explosion code fixed that broke level 24 of "Baby Ghost Mine" - - several Supaplex emulation bugs fixed thanks to Mihail Milushev: + - several Supaplex emulation bugs fixed (thanks to Mihail Milushev): + orange disk does not fall off from slippery elements + infotrons kill electrons and snik snaks and trigger orange disks + explosion chain reactions are now a bit slower than murphy - behaviour of robots adjusted to make them less aggressive + (needed for quite some Emerald Mine Club levels) - icon for Windows executable added - bug when selecting default level series fixed - - Windows fullscreen bug fixed (workaround for bug in SDL) + - bug in storing amoeba content fixed + - nasty tape bugs fixed (completely reworked tape stuff) + - fullscreen mode now works with Windows (workaround for bug in SDL) + - /dev/dsp support for NetBSD added (thanks to Krister Walfridsson) + - some small sound bugs fixed Release Version 2.0.0 [01 JAN 2001] ----------------------------------- diff --git a/src/game.c b/src/game.c index 423fc4c8..32e9e0d6 100644 --- a/src/game.c +++ b/src/game.c @@ -268,7 +268,7 @@ static void InitField(int x, int y, boolean init_game) StorePlayer[x][y] = Feld[x][y]; - if (options.verbose) + if (options.debug) { printf("Player %d activated.\n", player->element_nr); printf("[Local player is %d and currently %s.]\n", @@ -659,7 +659,7 @@ void InitGame() tape.player_participates[i] = TRUE; } - if (options.verbose) + if (options.debug) { for (i=0; i= 0) { if (!playing_sounds) /* we just opened the audio device */ { - unsigned long fragment_spec = 0; - - /* determine logarithm (log2) of the fragment size */ - for (fragment_spec=0; (1 << fragment_spec) < fragment_size; - fragment_spec++); - - /* use two fragments (play one fragment, prepare the other); - one fragment would result in interrupted audio output, more - than two fragments would raise audio output latency to much */ - fragment_spec |= 0x00020000; - - /* Example for fragment specification: - - 2 buffers / 512 bytes (giving 1/16 second resolution for 8 kHz) - - (with stereo the effective buffer size will shrink to 256) - => fragment_size = 0x00020009 */ - - if (ioctl(audio.device_fd,SNDCTL_DSP_SETFRAGMENT,&fragment_spec) < 0) - Error(ERR_EXIT_SOUND_SERVER, - "cannot set fragment size of /dev/dsp - no sounds"); - - /* try if we can use stereo sound */ - if (ioctl(audio.device_fd, SNDCTL_DSP_STEREO, &stereo) < 0) - { -#ifdef DEBUG - static boolean reported = FALSE; - - if (!reported) - { - Error(ERR_RETURN, "cannot get stereo sound on /dev/dsp"); - reported = TRUE; - } +#if defined(AUDIO_LINUX_IOCTL) + stereo = InitAudioDevice_Linux(fragment_size, sample_rate); +#elif defined(PLATFORM_NETBSD) + stereo = InitAudioDevice_NetBSD(fragment_size, sample_rate); #endif - stereo = FALSE; - } - - if (ioctl(audio.device_fd, SNDCTL_DSP_SPEED, &sample_rate) < 0) - Error(ERR_EXIT_SOUND_SERVER, - "cannot set sample rate of /dev/dsp - no sounds"); - - /* get the real fragmentation size; this should return 512 */ - if (ioctl(audio.device_fd, SNDCTL_DSP_GETBLKSIZE,&fragment_size) < 0) - Error(ERR_EXIT_SOUND_SERVER, - "cannot get fragment size of /dev/dsp - no sounds"); - max_sample_size = fragment_size / (stereo ? 2 : 1); } @@ -469,7 +431,6 @@ void SoundServer(void) /* fill the first mixing buffer with original sample */ memcpy(premix_first_buffer,sample_ptr,sample_size); - /* adjust volume of actual sound sample */ if (snd_ctrl.volume != PSND_MAX_VOLUME) for(i=0;i fragment_size = 0x00020009 */ + + if (ioctl(audio.device_fd, SNDCTL_DSP_SETFRAGMENT, &fragment_spec) < 0) + Error(ERR_EXIT_SOUND_SERVER, + "cannot set fragment size of /dev/dsp -- no sounds"); + + /* try if we can use stereo sound */ + if (ioctl(audio.device_fd, SNDCTL_DSP_STEREO, &stereo) < 0) + { +#ifdef DEBUG + static boolean reported = FALSE; + + if (!reported) + { + Error(ERR_RETURN, "cannot get stereo sound on /dev/dsp"); + reported = TRUE; + } +#endif + stereo = FALSE; + } + + if (ioctl(audio.device_fd, SNDCTL_DSP_SPEED, &sample_rate) < 0) + Error(ERR_EXIT_SOUND_SERVER, + "cannot set sample rate of /dev/dsp -- no sounds"); + + /* get the real fragmentation size; this should return 512 */ + if (ioctl(audio.device_fd, SNDCTL_DSP_GETBLKSIZE, &fragment_size) < 0) + Error(ERR_EXIT_SOUND_SERVER, + "cannot get fragment size of /dev/dsp -- no sounds"); + + return (boolean)stereo; +} +#endif /* AUDIO_LINUX_IOCTL */ + +#if defined(PLATFORM_NETBSD) +static boolean InitAudioDevice_NetBSD(long fragment_size, int sample_rate) +{ + audio_info_t a_info; + boolean stereo = TRUE; + + AUDIO_INITINFO(&a_info); + a_info.play.encoding = AUDIO_ENCODING_LINEAR8; + a_info.play.precision = 8; + a_info.play.channels = 2; + a_info.play.sample_rate = sample_rate; + a_info.blocksize = fragment_size; + + if (ioctl(audio.device_fd, AUDIO_SETINFO, &a_info) < 0) + { + /* try to disable stereo */ + a_info.play.channels = 1; + stereo = FALSE; + + if (ioctl(audio.device_fd, AUDIO_SETINFO, &a_info) < 0) + Error(ERR_EXIT_SOUND_SERVER, + "cannot set sample rate of /dev/audio -- no sounds"); + } + + return stereo; +} +#endif /* PLATFORM_NETBSD */ + #if defined(PLATFORM_HPUX) -static void HPUX_Audio_Control() +static boolean InitAudioDevice_HPUX() { struct audio_describe ainfo; int audio_ctl; audio_ctl = open("/dev/audioCtl", O_WRONLY | O_NDELAY); if (audio_ctl == -1) - Error(ERR_EXIT_SOUND_SERVER, "cannot open /dev/audioCtl - no sounds"); + Error(ERR_EXIT_SOUND_SERVER, "cannot open /dev/audioCtl -- no sounds"); if (ioctl(audio_ctl, AUDIO_DESCRIBE, &ainfo) == -1) - Error(ERR_EXIT_SOUND_SERVER, "no audio info - no sounds"); + Error(ERR_EXIT_SOUND_SERVER, "no audio info -- no sounds"); if (ioctl(audio_ctl, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_ULAW) == -1) - Error(ERR_EXIT_SOUND_SERVER, "ulaw audio not available - no sounds"); + Error(ERR_EXIT_SOUND_SERVER, "ulaw audio not available -- no sounds"); ioctl(audio_ctl, AUDIO_SET_CHANNELS, 1); ioctl(audio_ctl, AUDIO_SET_SAMPLE_RATE, 8000); close(audio_ctl); + + return TRUE; /* to provide common interface for InitAudioDevice_...() */ } #endif /* PLATFORM_HPUX */ @@ -855,11 +905,11 @@ static int ulaw_to_linear(unsigned char ulawbyte) } #endif /* PLATFORM_UNIX && !AUDIO_STREAMING_DSP */ -/*** THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/ -/*===========================================================================*/ +/* THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS */ +/* ========================================================================= */ +/* THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS */ -/*** THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS ***/ #define CHUNK_ID_LEN 4 /* IFF style chunk id length */ #define WAV_HEADER_SIZE 20 /* size of WAV file header */ @@ -892,7 +942,7 @@ static boolean LoadSoundExt(char *sound_name, boolean is_music) if ((snd_info->mix_chunk = Mix_LoadWAV(filename)) == NULL) { - Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename); + Error(ERR_WARN, "cannot read sound file '%s' -- no sounds", filename); return FALSE; } @@ -900,7 +950,7 @@ static boolean LoadSoundExt(char *sound_name, boolean is_music) if ((file = fopen(filename, MODE_READ)) == NULL) { - Error(ERR_WARN, "cannot open sound file '%s' - no sounds", filename); + Error(ERR_WARN, "cannot open sound file '%s' -- no sounds", filename); return FALSE; } @@ -942,7 +992,7 @@ static boolean LoadSoundExt(char *sound_name, boolean is_music) if (fread(snd_info->data_ptr, 1, snd_info->data_len, file) != snd_info->data_len) { - Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename); + Error(ERR_WARN, "cannot read sound file '%s' -- no sounds", filename); fclose(file); return FALSE; } @@ -957,7 +1007,7 @@ static boolean LoadSoundExt(char *sound_name, boolean is_music) snd_info->sample_ptr = load_sample(filename); if (!snd_info->sample_ptr) { - Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename); + Error(ERR_WARN, "cannot read sound file '%s' -- no sounds", filename); return FALSE; } @@ -988,7 +1038,7 @@ boolean LoadMod(char *mod_name) if ((mod_info->mix_music = Mix_LoadMUS(filename)) == NULL) { - Error(ERR_WARN, "cannot read music file '%s' - no music", filename); + Error(ERR_WARN, "cannot read music file '%s' -- no music", filename); return FALSE; } @@ -1125,7 +1175,7 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop) #elif defined(PLATFORM_UNIX) if (write(audio.soundserver_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0) { - Error(ERR_WARN, "cannot pipe to child process - no sounds"); + Error(ERR_WARN, "cannot pipe to child process -- no sounds"); audio.sound_available = audio.sound_enabled = FALSE; return; } @@ -1227,7 +1277,7 @@ void StopSoundExt(int nr, int method) #if !defined(PLATFORM_MSDOS) if (write(audio.soundserver_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0) { - Error(ERR_WARN, "cannot pipe to child process - no sounds"); + Error(ERR_WARN, "cannot pipe to child process -- no sounds"); audio.sound_available = audio.sound_enabled = FALSE; return; } @@ -1254,4 +1304,5 @@ void FreeSounds(int num_sounds) #endif } -/*** THE STUFF ABOVE IS ONLY USED BY THE MAIN PROCESS ***/ +/* THE STUFF ABOVE IS ONLY USED BY THE MAIN PROCESS */ +/* ========================================================================= */ diff --git a/src/libgame/sound.h b/src/libgame/sound.h index 939e5a00..07e73550 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -26,6 +26,9 @@ #include #elif defined(PLATFORM_FREEBSD) #include +#elif defined(PLATFORM_NETBSD) +#include +#include #elif defined(PLATFORM_HPUX) #include #endif @@ -34,6 +37,10 @@ #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) || defined(VOXWARE) +#define AUDIO_LINUX_IOCTL +#endif + +#if defined(AUDIO_LINUX_IOCTL) || defined(PLATFORM_NETBSD) #define AUDIO_STREAMING_DSP #endif @@ -132,6 +139,7 @@ #endif #endif +#if 0 struct SoundHeader_SUN { unsigned long magic; @@ -148,6 +156,7 @@ struct SoundHeader_8SVX unsigned long chunk_size; char magic_8SVX[4]; }; +#endif struct SampleInfo { diff --git a/src/screens.c b/src/screens.c index 90225db6..77642b69 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1204,6 +1204,7 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) void DrawHallOfFame(int highlight_position) { UnmapAllGadgets(); + FadeSounds(); CloseDoor(DOOR_CLOSE_2); if (highlight_position < 0)