Rev 5264 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5253 | mario79 | 1 | ;------------------------------------------------------------------------------ |
5274 | mario79 | 2 | test_wav_file: |
3 | mov [sound_flag],1 |
||
4 | stdcall _test_wav@4,dword [wav_for_test] ;letter_1a |
||
5 | test eax,eax |
||
6 | jz snd_test_wav_fail |
||
7 | |||
8 | ; or eax,PCM_OUT |
||
9 | or eax,PCM_RING |
||
10 | mov [snd_format],eax |
||
11 | |||
12 | ; DEBUGF 1, "Test wav successful %x\n",eax |
||
13 | |||
14 | call find_data_offset |
||
15 | |||
16 | mov al,[sound_flag] |
||
17 | test al,al |
||
18 | jnz .exit |
||
19 | |||
20 | mov [sound_flag],2 ; close thread |
||
21 | ;-------------------------------------- |
||
22 | .exit: |
||
23 | ret |
||
5253 | mario79 | 24 | ;------------------------------------------------------------------------------ |
5274 | mario79 | 25 | check_init_sound_busy: |
26 | cmp [init_sound_busy_flag],1 |
||
27 | jne @f |
||
28 | |||
29 | mcall 5,1 |
||
30 | mcall 68,1 |
||
31 | jmp check_init_sound_busy |
||
32 | ;-------------------------------------- |
||
33 | @@: |
||
34 | mov [init_sound_busy_flag],1 |
||
35 | ret |
||
36 | ;------------------------------------------------------------------------------ |
||
5253 | mario79 | 37 | initialize_sound_system: |
5274 | mario79 | 38 | cmp [sound_flag],1 |
39 | jne sound_exit |
||
5253 | mario79 | 40 | |
41 | stdcall _InitSound@4,version |
||
5274 | mario79 | 42 | test eax,eax |
43 | jnz snd_init_fail |
||
5253 | mario79 | 44 | |
45 | ; DEBUGF 1, "Sound init successful %x\n",eax |
||
5274 | mario79 | 46 | |
5253 | mario79 | 47 | mov eax,[version] |
48 | and eax,0xffff |
||
49 | cmp eax,SOUND_VERSION |
||
50 | jne snd_version_fail |
||
51 | |||
52 | ; DEBUGF 1, "Sound version successful %x\n",eax |
||
5274 | mario79 | 53 | ;-------------------------------------- |
54 | stdcall _CreateBuffer@12,[snd_format],0,[hBuff_pointer] |
||
5253 | mario79 | 55 | test eax,eax |
5274 | mario79 | 56 | jnz snd_create_buffer_fail |
5253 | mario79 | 57 | |
5274 | mario79 | 58 | ; DEBUGF 1, "Create Buffer successful %x\n",eax |
59 | mov eax,[hBuff_pointer] |
||
60 | mov ebx,[hBuff_buffer_size_pointer] |
||
61 | stdcall _GetBufferSize@8,[eax],ebx ;hBuff1_buffer_size |
||
5253 | mario79 | 62 | |
5274 | mario79 | 63 | test eax,eax |
64 | jnz snd_get_buffer_size_fail |
||
5253 | mario79 | 65 | |
5274 | mario79 | 66 | mov ebx,[hBuff_buffer_size_pointer] |
67 | mov eax,[ebx] |
||
68 | ; DEBUGF 1, "Get Buffer size successful size: %x\n",eax |
||
69 | shr eax,1 |
||
70 | mov [ebx],eax |
||
5253 | mario79 | 71 | |
5274 | mario79 | 72 | mov [init_sound_busy_flag],0 |
5253 | mario79 | 73 | ret |
74 | ;------------------------------------------------------------------------------ |
||
5274 | mario79 | 75 | sound_exit: |
76 | mcall -1 |
||
77 | ;------------------------------------------------------------------------------ |
||
5253 | mario79 | 78 | find_data_offset: |
5274 | mario79 | 79 | mov esi,[wav_for_test] |
5253 | mario79 | 80 | ;-------------------------------------- |
81 | @@: |
||
82 | cmp [esi],dword 'data' |
||
83 | je @f |
||
84 | |||
85 | inc esi |
||
5274 | mario79 | 86 | cmp esi,[wav_for_test_end] |
5253 | mario79 | 87 | jne @b |
88 | |||
89 | ; DEBUGF 1, "find data offset fail\n" |
||
90 | mov [sound_flag],0 |
||
91 | ret |
||
92 | ;-------------------------------------- |
||
93 | @@: |
||
5274 | mario79 | 94 | sub esi,[wav_for_test] |
5253 | mario79 | 95 | add esi,4 |
96 | mov [data_offset],esi |
||
97 | ret |
||
98 | ;------------------------------------------------------------------------------ |
||
5274 | mario79 | 99 | snd_test_wav_fail: |
100 | ; DEBUGF 1, "Test wav fail %x\n",eax |
||
101 | mov [sound_flag],0 |
||
5263 | mario79 | 102 | ret |
5253 | mario79 | 103 | ;------------------------------------------------------------------------------ |
104 | snd_init_fail: |
||
105 | ; DEBUGF 1, "Sound init fail %x\n",eax |
||
5274 | mario79 | 106 | jmp disable_sound |
5253 | mario79 | 107 | ;------------------------------------------------------------------------------ |
108 | snd_version_fail: |
||
109 | ; DEBUGF 1, "Sound version fail %x\n",eax |
||
5274 | mario79 | 110 | jmp disable_sound |
5253 | mario79 | 111 | ;------------------------------------------------------------------------------ |
112 | snd_create_buffer_fail: |
||
113 | ; DEBUGF 1, "Create Buffer fail %x\n",eax |
||
5274 | mario79 | 114 | jmp disable_sound |
5253 | mario79 | 115 | ;------------------------------------------------------------------------------ |
5274 | mario79 | 116 | snd_get_buffer_size_fail: |
117 | ; DEBUGF 1, "Get Buffer size fail %x\n",eax |
||
118 | jmp disable_sound |
||
119 | ;------------------------------------------------------------------------------ |
||
120 | snd_play_buffer_fail: |
||
121 | ; DEBUGF 1, "Play Buffer fail\n" |
||
122 | jmp disable_sound |
||
123 | ;------------------------------------------------------------------------------ |
||
124 | snd_set_buffer_fail: |
||
125 | ; DEBUGF 1, "Set Buffer fail\n" |
||
126 | jmp disable_sound |
||
127 | ;------------------------------------------------------------------------------ |
||
128 | disable_sound: |
||
5253 | mario79 | 129 | mov [sound_flag],0 |
5274 | mario79 | 130 | jmp sound_exit |
5253 | mario79 | 131 | ;------------------------------------------------------------------------------ |
132 | snd_background_music_thread_start: |
||
5274 | mario79 | 133 | call check_init_sound_busy |
134 | ; DEBUGF 1, "snd_background_music_thread_start\n" |
||
135 | mov [hBuff_pointer], dword hBuff1 |
||
136 | mov [hBuff_buffer_size_pointer], dword hBuff1_buffer_size |
||
137 | call initialize_sound_system |
||
138 | ;-------------------------------------- |
||
139 | .1: |
||
140 | cmp [music_flag],2 |
||
141 | je sound_exit |
||
142 | |||
5259 | mario79 | 143 | cmp [music_flag],1 |
5263 | mario79 | 144 | je .start |
5274 | mario79 | 145 | .2: |
146 | mcall 5,1 |
||
5259 | mario79 | 147 | mcall 68,1 |
5274 | mario79 | 148 | jmp .1 |
5259 | mario79 | 149 | ;-------------------------------------- |
5263 | mario79 | 150 | .start: |
5274 | mario79 | 151 | cmp [init_sound_busy_flag],1 |
152 | je .2 |
||
153 | |||
154 | ; DEBUGF 1, "background_music Play Buffer start\n",eax |
||
155 | stdcall _PlayBuffer@8, [hBuff1], 0 |
||
156 | test eax,eax |
||
157 | jnz snd_play_buffer_fail |
||
158 | |||
159 | ; DEBUGF 1, "background_music Play Buffer successful EAX: %x\n",eax |
||
160 | ;-------------------------------------- |
||
161 | .start_1: |
||
5263 | mario79 | 162 | mov eax,[background_music] |
163 | ; check for correct data_offset |
||
164 | push eax |
||
165 | add eax,[data_offset] |
||
166 | sub eax,4 |
||
167 | cmp [eax],dword 'data' |
||
168 | pop eax |
||
169 | je @f |
||
170 | |||
171 | mov [wav_for_test],eax |
||
172 | mov ebx,eax |
||
173 | add ebx,1024 |
||
174 | mov [wav_for_test_end],ebx |
||
175 | call find_data_offset |
||
176 | cmp [sound_flag],0 |
||
5274 | mario79 | 177 | jz .1 |
5263 | mario79 | 178 | ;-------------------------------------- |
5259 | mario79 | 179 | @@: |
5263 | mario79 | 180 | add eax,[data_offset] |
181 | mov ebx,[eax] |
||
182 | add eax,4 |
||
183 | mov ebp,eax |
||
5264 | mario79 | 184 | add ebx,eax |
185 | ; DEBUGF 1, "start EAX: %x\n",eax |
||
5263 | mario79 | 186 | ;-------------------------------------- |
187 | .loop: |
||
5274 | mario79 | 188 | cmp [music_flag],1 |
189 | je @f |
||
190 | |||
191 | stdcall _StopBuffer@4, [hBuff1] |
||
192 | ; DEBUGF 1, "Stop Buffer EAX: %x\n",eax |
||
193 | jmp .1 |
||
194 | ;-------------------------------------- |
||
195 | @@: |
||
196 | ; get event data from the driver |
||
197 | ; DEBUGF 1, "Get driver_notify_struct \n" |
||
198 | push ebx |
||
199 | mcall 68,14,hBuff1_driver_notify_struct |
||
200 | pop ebx |
||
201 | ; DEBUGF 1, "Check to code \n" |
||
202 | ; check to code |
||
203 | cmp [hBuff1_driver_notify_struct], dword 0xFF000001 |
||
204 | jne @b |
||
205 | ; DEBUGF 1, "Check to stream \n" |
||
206 | ; check to stream |
||
207 | mov eax,[hBuff1_driver_notify_struct+8] |
||
208 | cmp eax,[hBuff1] |
||
209 | jne @b |
||
210 | ; DEBUGF 1, "Get buffer_offset \n" |
||
211 | ; get buffer_offset |
||
212 | mov eax,[hBuff1_driver_notify_struct+12] |
||
213 | mov [hBuff1_buffer_offset],eax |
||
5264 | mario79 | 214 | ; DEBUGF 1, "src EBP: %x size EBX: %x\n",ebp,ebx |
5274 | mario79 | 215 | stdcall _SetBuffer@16, [hBuff1], ebp, [hBuff1_buffer_offset], [hBuff1_buffer_size] |
216 | test eax,eax |
||
217 | jnz snd_set_buffer_fail |
||
5263 | mario79 | 218 | |
5274 | mario79 | 219 | ; DEBUGF 1, "Set Buffer successful EAX: %x\n",eax |
220 | add ebp,[hBuff1_buffer_size] |
||
221 | add ebp,[hBuff1_buffer_size] |
||
5263 | mario79 | 222 | cmp ebx,ebp |
5274 | mario79 | 223 | jbe .start_1 |
5263 | mario79 | 224 | |
5274 | mario79 | 225 | sub ebp,[hBuff1_buffer_size] |
5263 | mario79 | 226 | jmp .loop |
5253 | mario79 | 227 | ;------------------------------------------------------------------------------ |
228 | snd_kick_action: |
||
5259 | mario79 | 229 | cmp [sounds_flag],1 |
230 | jne @f |
||
231 | |||
5253 | mario79 | 232 | cmp [snd_kick_flag],1 |
233 | je @f |
||
234 | |||
5274 | mario79 | 235 | mov [snd_kick_flag],1 |
5253 | mario79 | 236 | ;-------------------------------------- |
237 | @@: |
||
238 | ret |
||
239 | ;------------------------------------------------------------------------------ |
||
240 | snd_kick_action_thread_start: |
||
5274 | mario79 | 241 | call check_init_sound_busy |
242 | ; DEBUGF 1, "snd_kick_action_thread_start\n" |
||
243 | mov [hBuff_pointer], dword hBuff2 |
||
244 | mov [hBuff_buffer_size_pointer], dword hBuff2_buffer_size |
||
245 | call initialize_sound_system |
||
246 | ;-------------------------------------- |
||
247 | .1: |
||
248 | cmp [sounds_flag],2 |
||
249 | je sound_exit |
||
250 | |||
251 | cmp [sounds_flag],0 |
||
252 | je @f |
||
253 | |||
254 | cmp [snd_kick_flag],1 |
||
255 | je .start |
||
256 | ;-------------------------------------- |
||
257 | @@: |
||
258 | mcall 5,1 |
||
259 | mcall 68,1 |
||
260 | jmp .1 |
||
261 | ;-------------------------------------- |
||
262 | .start: |
||
263 | ; DEBUGF 1, "kick_action Play Buffer start\n" |
||
264 | stdcall _PlayBuffer@8, [hBuff2], 0 |
||
265 | test eax,eax |
||
266 | jnz snd_play_buffer_fail |
||
267 | |||
268 | ; DEBUGF 1, "kick_action Play Buffer successful EAX: %x\n",eax |
||
269 | |||
270 | mov eax,[sounds_sample] ;[stone_kick_sound] |
||
271 | ; check for correct data_offset |
||
272 | push eax |
||
273 | add eax,[data_offset] |
||
274 | sub eax,4 |
||
275 | cmp [eax],dword 'data' |
||
276 | pop eax |
||
277 | je @f |
||
278 | |||
279 | mov [wav_for_test],eax |
||
280 | mov ebx,eax |
||
281 | add ebx,1024 |
||
282 | mov [wav_for_test_end],ebx |
||
283 | call find_data_offset |
||
284 | cmp [sound_flag],0 |
||
285 | jz .1 |
||
286 | ;-------------------------------------- |
||
287 | @@: |
||
288 | add eax,[data_offset] |
||
289 | mov ebx,[eax] |
||
290 | add eax,4 |
||
291 | mov ebp,eax |
||
292 | add ebx,eax |
||
293 | ; DEBUGF 1, "start EAX: %x\n",eax |
||
294 | ;-------------------------------------- |
||
295 | .loop: |
||
296 | cmp [sounds_flag],1 |
||
297 | je @f |
||
298 | |||
299 | stdcall _StopBuffer@4, [hBuff2] |
||
300 | ; DEBUGF 1, "Stop Buffer EAX: %x\n",eax |
||
301 | jmp .1 |
||
302 | ;-------------------------------------- |
||
303 | @@: |
||
304 | ; get event data from the driver |
||
305 | ; DEBUGF 1, "Get driver_notify_struct \n" |
||
306 | push ebx |
||
307 | mcall 68,14,hBuff2_driver_notify_struct |
||
308 | pop ebx |
||
309 | ; DEBUGF 1, "Check to code \n" |
||
310 | ; check to code |
||
311 | cmp [hBuff2_driver_notify_struct], dword 0xFF000001 |
||
312 | jne @b |
||
313 | ; DEBUGF 1, "Check to stream \n" |
||
314 | ; check to stream |
||
315 | mov eax,[hBuff2_driver_notify_struct+8] |
||
316 | cmp eax,[hBuff2] |
||
317 | jne @b |
||
318 | ; DEBUGF 1, "Get buffer_offset \n" |
||
319 | ; get buffer_offset |
||
320 | mov eax,[hBuff2_driver_notify_struct+12] |
||
321 | mov [hBuff2_buffer_offset],eax |
||
322 | ; DEBUGF 1, "src EBP: %x size EBX: %x\n",ebp,ebx |
||
323 | stdcall _SetBuffer@16, [hBuff2], ebp, [hBuff2_buffer_offset], [hBuff2_buffer_size] |
||
324 | test eax,eax |
||
325 | jnz snd_set_buffer_fail |
||
326 | |||
327 | ; DEBUGF 1, "Set Buffer successful EAX: %x\n",eax |
||
328 | add ebp,[hBuff2_buffer_size] |
||
329 | add ebp,[hBuff2_buffer_size] |
||
330 | cmp ebx,ebp |
||
331 | jbe .exit |
||
332 | |||
333 | sub ebp,[hBuff2_buffer_size] |
||
334 | jmp .loop |
||
335 | ;-------------------------------------- |
||
336 | .exit: |
||
337 | stdcall _StopBuffer@4, [hBuff2] |
||
5253 | mario79 | 338 | mov [snd_kick_flag],0 |
5274 | mario79 | 339 | jmp .1 |
5253 | mario79 | 340 | ;------------------------------------------------------------------------------ |