1 /*
2  * Seven Kingdoms: Ancient Adversaries
3  *
4  * Copyright 1997,1998 Enlight Software Ltd.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 // Filename   : OSE.H
22 // Description: Header file of Sound Effect Controller
23 // Owner      : Gilbert
24 
25 #ifndef __OSE_H
26 #define __OSE_H
27 
28 #include <OAUDIO.h>
29 #include <ORESX.h>
30 #include <OVOLUME.h>
31 
32 // ------ Define sound effect no. ------//
33 // note : wave file should be less than 64k in size, otherwise
34 // the offset generated by LIBxxx.EXE is not correct
35 //
36 
37 // ------ Define constant -------//
38 #define MAX_SE_CACHED 32
39 // a no. of sound effect is taken care for those are requested
40 // this cycle or last cycle
41 
42 // ------ Define Struct SERequest ------//
43 
44 #define MAX_SE_STORE 4
45 
46 struct SERequest
47 {
48 	char	*wave_ptr;
49 	short	resx_id;
50 
51 	short	req_used;
52 	RelVolume play_vol[MAX_SE_STORE];
53 
54 	void	add_request(RelVolume);
55 	int	max_entry();
56 	void	remove_request(int slot);
57 	void	clear_request();
58 };
59 
60 // ------ Define Class SECtrl -------//
61 
62 class SECtrl
63 {
64 private:
65 	int	biased_se;
66 	SERequest *req_pool;
67 	char	*last_cycle;
68 
69 	int	cached_size;
70 	short	cached_index[MAX_SE_CACHED];
71 
72 public:
73 	int	init_flag;
74 	int	audio_flag;					// set if audio.wav_init_flag is set during init
75 	int	max_sound_effect;
76 	int	max_supp_effect;
77 	int	total_effect;
78 	Audio *audio_ptr;
79 	ResourceIdx	res_wave;
80 	ResourceIdx &res_supp;
81 
82 public:
83 	SECtrl(Audio *);
84 	~SECtrl();
85 	void	init();
86 	void	deinit();
87 
88 	void	request( int soundEffect, RelVolume );
89 	void	request( char *soundName, RelVolume );
90 		// volume between 0 to 100; pan between -10,000=left, 10,000=right
91 	void	flush();	// output sound effect to volume
92 	void	clear();
93 	char	*get_effect_name(int);
94 	int	search_effect_id(const char *);
95 	int	search_effect_id(char *, int len);
96 
97 	int	immediate_sound( const char *soundName, RelVolume=DEF_REL_VOLUME);	// mainly for button sound, interface
98 
99 //	static long sound_volume(short locX, short locY);
100 //	static long sound_volume(short locX, short locY, short limit, short drop);
101 //	static long sound_pan(short locX, short locY);
102 //	static long sound_pan(short locX, short locY, short drop);
103 
104 private:
105 	void	load_info();
106 };
107 
108 extern SECtrl se_ctrl;
109 
110 #endif
111