1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
21 #include <linux/soundcard.h>
25 /* where is the right declaration for 'ioctl'? */
26 extern void ioctl(long, long, void *);
30 #include <machine/soundcard.h>
33 #define SND_BLOCKSIZE 4096
36 #include <sys/audio.h>
38 #define SND_BLOCKSIZE 32768
40 #endif /* _HPUX_SOURCE */
43 #define MAX_SOUNDS_PLAYING 16
45 #define MAX_SOUNDS_PLAYING 8
48 /* some values for PlaySound(), StopSound() and friends */
50 #define PSND_SILENCE 0
51 #define PSND_MAX_VOLUME_BITS 7
52 #define PSND_MIN_VOLUME 0
53 #define PSND_MAX_VOLUME (1 << PSND_MAX_VOLUME_BITS)
54 #define PSND_NO_LOOP 0
57 #define PSND_MAX_STEREO_BITS 7
58 #define PSND_MAX_STEREO (1 << PSND_MAX_STEREO_BITS)
59 #define PSND_MAX_LEFT (-PSND_MAX_STEREO)
60 #define PSND_MAX_RIGHT (+PSND_MAX_STEREO)
61 #define PSND_MAX_LEFT2RIGHT_BITS (PSND_MAX_STEREO_BITS+1)
62 #define PSND_MAX_LEFT2RIGHT (1 << PSND_MAX_LEFT2RIGHT_BITS)
64 #define PSND_SILENCE 0
65 #define PSND_MIN_VOLUME 0
66 #define PSND_MAX_VOLUME 255
67 #define PSND_NO_LOOP 0
69 #define PSND_MAX_LEFT 0
70 #define PSND_MAX_RIGHT 255
71 #define PSND_MIDDLE 128
74 #define SSND_FADE_SOUND (1<<0)
75 #define SSND_FADE_ALL_SOUNDS (1<<1)
76 #define SSND_FADING(x) (x & (SSND_FADE_SOUND | SSND_FADE_ALL_SOUNDS))
77 #define SSND_STOP_SOUND (1<<2)
78 #define SSND_STOP_ALL_SOUNDS (1<<3)
79 #define SSND_STOPPING(x) (x & (SSND_STOP_SOUND | SSND_STOP_ALL_SOUNDS))
80 #define SSND_ALL(x) (x&(SSND_FADE_ALL_SOUNDS|SSND_STOP_ALL_SOUNDS))
85 /* settings for sound path, sound device, etc. */
87 #define SND_PATH "./sounds"
90 #define DEV_AUDIO "/dev/audio"
91 #define DEV_DSP "/dev/dsp"
94 #define SOUND_DEVICE DEV_DSP
96 #define SOUND_DEVICE DEV_AUDIO
100 #define SOUND_AVAILABLE 1
103 #define SOUND_STATUS SOUND_OFF
105 #define SOUND_STATUS SOUND_AVAILABLE
108 struct SoundHeader_SUN
111 unsigned long hdr_size;
112 unsigned long data_size;
113 unsigned long encoding;
114 unsigned long sample_rate;
115 unsigned long channels;
118 struct SoundHeader_8SVX
121 unsigned long chunk_size;
125 struct SoundHeader_WAV
128 unsigned long header_size;
132 unsigned long data_size;
138 unsigned char *file_ptr;
140 long file_len, data_len;
155 boolean stop_all_sounds;
165 /* sound server functions */
166 void SoundServer(void);
167 void SoundServer_InsertNewSound(struct SoundControl);
168 void SoundServer_StopSound(int);
169 void SoundServer_StopAllSounds(void);
170 void HPUX_Audio_Control(void);
171 unsigned char linear_to_ulaw(int);
172 int ulaw_to_linear(unsigned char);
174 /* application functions */
175 boolean LoadSound(struct SoundInfo *);
177 void PlaySoundStereo(int, int);
178 void PlaySoundLoop(int);
179 void PlaySoundExt(int, int, int, boolean);
181 void FadeSounds(void);
183 void StopSounds(void);
184 void StopSoundExt(int, int);
185 void FreeSounds(int);