backporting...
[dosdemo] / src / audio.h
1 #ifndef AUDIO_H_
2 #define AUDIO_H_
3
4 enum { AU_STOPPED, AU_PLAYING };
5
6 enum {
7         AU_CUR = 0x7000,
8         AU_VOLUP = 0x7100,
9         AU_VOLDN = 0x7200
10 };
11
12 struct au_module {
13         char *name;
14         void *impl;
15 };
16
17 int au_init(void);
18 void au_shutdown(void);
19
20 struct au_module *au_load_module(const char *fname);
21 void au_free_module(struct au_module *mod);
22
23 int au_play_module(struct au_module *mod);
24 void au_update(void);
25 int au_stop_module(struct au_module *mod);
26 int au_module_state(struct au_module *mod);
27
28 int au_volume(int vol);
29 int au_sfx_volume(int vol);
30 int au_music_volume(int vol);
31
32 /* pay no attention to the man behind the curtain */
33 #define AU_VOLADJ(vol, newvol) \
34         do { \
35                 int d; \
36                 switch(newvol & 0xff00) { \
37                 case AU_CUR: \
38                         return (vol); \
39                 case AU_VOLUP: \
40                         d = newvol & 0xff; \
41                         (newvol) = (vol) + (d ? d : 16); \
42                         if((newvol) >= 256) (newvol) = 255; \
43                         break; \
44                 case AU_VOLDN: \
45                         d = newvol & 0xff; \
46                         (newvol) = (vol) - (d ? d : 16); \
47                         if((newvol) < 0) (newvol) = 0; \
48                         break; \
49                 default: \
50                         break; \
51                 } \
52         } while(0)
53
54 #endif  /* AUDIO_H_ */