Mercurial > ~darius > hgwebdir.cgi > mikmod
comparison playercode/resample.asm @ 6:d14fd386d182
Initial entry of mikmod into the CVS tree.
author | darius |
---|---|
date | Fri, 23 Jan 1998 16:05:09 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5:42e11dc15457 | 6:d14fd386d182 |
---|---|
1 .386p | |
2 .model flat | |
3 .data ; self-modifying code... keep in data segment | |
4 | |
5 NAME resample | |
6 EXTRN _rvoltab :DWORD | |
7 EXTRN _lvoltab :DWORD | |
8 EXTRN _bitshift :BYTE | |
9 | |
10 PUBLIC _AsmStereoNormal | |
11 PUBLIC _AsmStereoSurround | |
12 PUBLIC _AsmMonoNormal | |
13 IFDEF __ASMSTUFF__ | |
14 PUBLIC _AsmMix32To16_Normal | |
15 PUBLIC _AsmMix32To8_Normal | |
16 ENDIF | |
17 | |
18 | |
19 STUBSTART macro | |
20 push eax | |
21 push ebx | |
22 push ecx | |
23 push edx | |
24 push esi | |
25 push edi | |
26 push ebp | |
27 endm | |
28 | |
29 | |
30 STUBEND macro | |
31 pop ebp | |
32 pop edi | |
33 pop esi | |
34 pop edx | |
35 pop ecx | |
36 pop ebx | |
37 pop eax | |
38 endm | |
39 | |
40 | |
41 SS2F MACRO index,lab1,lab2,lab3,lab4 ; 486+ | |
42 mov al,[edx] | |
43 db 081h,0c3h | |
44 lab1 dd 0 ; add ebx,lo | |
45 db 081h,0d2h | |
46 lab2 dd 0 ; adc edx,hi | |
47 mov esi,(index*8)[edi] | |
48 db 08bh,0ch,085h | |
49 lab3 dd 0 ; mov ecx,[eax*4+table1] | |
50 mov ebp,(index*8+4)[edi] | |
51 add esi,ecx | |
52 db 08bh,0ch,085h | |
53 lab4 dd 0 ; mov ecx,[eax*4+table2] | |
54 mov (index*8)[edi],esi | |
55 add ebp,ecx | |
56 ENDM | |
57 | |
58 SS2M MACRO index,lab1,lab2,lab3,lab4 ; 486+ | |
59 mov al,[edx] | |
60 mov (index*8-4)[edi],ebp | |
61 db 081h,0c3h | |
62 lab1 dd 0 ; add ebx,lo | |
63 db 081h,0d2h | |
64 lab2 dd 0 ; adc edx,hi | |
65 mov esi,(index*8)[edi] | |
66 db 08bh,0ch,085h | |
67 lab3 dd 0 ; mov ecx,[eax*4+table1] | |
68 mov ebp,(index*8+4)[edi] | |
69 add esi,ecx | |
70 db 08bh,0ch,085h | |
71 lab4 dd 0 ; mov ecx,[eax*4+table2] | |
72 mov (index*8)[edi],esi | |
73 add ebp,ecx | |
74 ENDM | |
75 | |
76 SS3F MACRO index,lab1,lab2,lab3 ; 486+ | |
77 mov al,[edx] | |
78 db 081h,0c3h | |
79 lab1 dd 0 ; add ebx,lo | |
80 db 081h,0d2h | |
81 lab2 dd 0 ; adc edx,hi | |
82 mov esi,(index*8)[edi] | |
83 db 08bh,0ch,085h | |
84 lab3 dd 0 ; mov ecx,[eax*4+table1] | |
85 mov ebp,(index*8+4)[edi] | |
86 add esi,ecx | |
87 sub ebp,ecx | |
88 mov (index*8)[edi],esi | |
89 ENDM | |
90 | |
91 SS3M MACRO index,lab1,lab2,lab3 ; 486+ | |
92 mov al,[edx] | |
93 mov (index*8-4)[edi],ebp | |
94 db 081h,0c3h | |
95 lab1 dd 0 ; add ebx,lo | |
96 db 081h,0d2h | |
97 lab2 dd 0 ; adc edx,hi | |
98 mov esi,(index*8)[edi] | |
99 db 08bh,0ch,085h | |
100 lab3 dd 0 ; mov ecx,[eax*4+table1] | |
101 mov ebp,(index*8+4)[edi] | |
102 add esi,ecx | |
103 sub ebp,ecx | |
104 mov (index*8)[edi],esi | |
105 ENDM | |
106 | |
107 SS2L MACRO index ; 486+ | |
108 mov (index*8-4)[edi],ebp | |
109 ENDM | |
110 | |
111 SM2F MACRO index,lab1,lab2,lab3 ; 486+ | |
112 mov al,[edx] ; AGI-3 | |
113 db 081h,0c3h | |
114 lab1 dd 0 ; add ebx,lo | |
115 db 081h,0d2h | |
116 lab2 dd 0 ; adc edx,hi | |
117 mov esi,(index*4)[edi] | |
118 db 08bh,0ch,085h | |
119 lab3 dd 0 ; mov ecx,[eax*4+table1] | |
120 ENDM | |
121 | |
122 SM2M MACRO index,lab1,lab2,lab3 ; 486+ | |
123 mov al,[edx] ; AGI-3 | |
124 add esi,ecx | |
125 db 081h,0c3h | |
126 lab1 dd 0 ; add ebx,lo | |
127 mov (index*4-4)[edi],esi | |
128 db 081h,0d2h | |
129 lab2 dd 0 ; adc edx,hi | |
130 mov esi,(index*4)[edi] | |
131 db 08bh,0ch,085h | |
132 lab3 dd 0 ; mov ecx,[eax*4+table1] | |
133 ENDM | |
134 | |
135 SM2L MACRO index ; 486+ | |
136 add esi,ecx | |
137 mov (index*4-4)[edi],esi | |
138 ENDM | |
139 | |
140 ;SS2 ; 386 | |
141 ;mov al,[edx+source] | |
142 ;add ebx,lo | |
143 ;adc edx,hi | |
144 ;mov ecx,[eax*4+table1] | |
145 ;mov ebp,[eax*4+table2] | |
146 ;add [edi],ecx | |
147 ;add [edi+4],ebp | |
148 ;ENDM | |
149 | |
150 ;SS2M ; 486+ | |
151 ;mov al,[edx+source] | |
152 ;mov [edi-8+4],ebp | |
153 ;add ebx,lo | |
154 ;adc edx,hi | |
155 ;mov esi,[edi] | |
156 ;mov ecx,[eax*4+table1] | |
157 ;mov ebp,[edi+4] | |
158 ;add esi,ecx | |
159 ;mov ecx,[eax*4+table2] | |
160 ;mov [edi],esi | |
161 ;add ebp,ecx | |
162 ;ENDM | |
163 | |
164 ;SM2M ; 386 | |
165 ;add ebx,lo | |
166 ;adc edx,hi | |
167 ;mov ecx,[eax*4+table1] | |
168 ;mov al,[edx+source] | |
169 ;add [edi],ecx | |
170 ;ENDM | |
171 | |
172 ;SM2M ; 486+ | |
173 ;add ebx,lo | |
174 ;mov [edi-4],esi | |
175 ;adc edx,hi | |
176 ;mov esi,[edi] | |
177 ;mov ecx,[eax*4+table1] | |
178 ;mov al,[edx+source] ; AGI-3 | |
179 ;add esi,ecx | |
180 ;ENDM | |
181 | |
182 | |
183 _AsmStereoNormal: | |
184 STUBSTART | |
185 mov esi,[esp+32] ; get src | |
186 mov edi,[esp+36] ; get dst | |
187 mov ebx,[esp+40] ; get index | |
188 mov ecx,[esp+44] ; get increment | |
189 mov ebp,[esp+48] ; get todo | |
190 mov eax,ecx | |
191 mov edx,ebx | |
192 sar eax,31 | |
193 sar edx,31 | |
194 shld eax,ecx,21 ; convert to 32:32 | |
195 shl ecx,21 | |
196 shld edx,ebx,21 ; convert to 32:32 | |
197 shl ebx,21 | |
198 add edx,esi | |
199 mov shi1,eax | |
200 mov shi2,eax | |
201 mov shi3,eax | |
202 mov shi4,eax | |
203 mov shi5,eax | |
204 mov eax,_lvoltab | |
205 mov slo1,ecx | |
206 mov slo2,ecx | |
207 mov slo3,ecx | |
208 mov slo4,ecx | |
209 mov slo5,ecx | |
210 mov sltab1,eax | |
211 mov sltab2,eax | |
212 mov sltab3,eax | |
213 mov sltab4,eax | |
214 mov sltab5,eax | |
215 mov eax,_rvoltab | |
216 push ebp | |
217 mov srtab1,eax | |
218 mov srtab2,eax | |
219 mov srtab3,eax | |
220 mov srtab4,eax | |
221 mov srtab5,eax | |
222 xor eax,eax | |
223 jmp s1 ; flush code cache | |
224 s1: | |
225 shr ebp,2 | |
226 jz sskip16 | |
227 push ebp | |
228 sagain16: | |
229 SS2F 0,slo1,shi1,sltab1,srtab1 | |
230 SS2M 1,slo2,shi2,sltab2,srtab2 | |
231 SS2M 2,slo3,shi3,sltab3,srtab3 | |
232 SS2M 3,slo4,shi4,sltab4,srtab4 | |
233 SS2L 4 | |
234 add edi,(4*8) | |
235 dec dword ptr [esp] | |
236 jnz sagain16 | |
237 pop ebp | |
238 sskip16: | |
239 pop ebp | |
240 and ebp,3 | |
241 jz sskip1 | |
242 push ebp | |
243 sagain1: | |
244 SS2F 0,slo5,shi5,sltab5,srtab5 | |
245 SS2L 1 | |
246 add edi,8 | |
247 dec dword ptr [esp] | |
248 jnz sagain1 | |
249 pop ebp | |
250 sskip1: | |
251 STUBEND | |
252 ret | |
253 | |
254 | |
255 _AsmStereoSurround: | |
256 STUBSTART | |
257 mov esi,[esp+32] ; get src | |
258 mov edi,[esp+36] ; get dst | |
259 mov ebx,[esp+40] ; get index | |
260 mov ecx,[esp+44] ; get increment | |
261 mov ebp,[esp+48] ; get todo | |
262 mov eax,ecx | |
263 mov edx,ebx | |
264 sar eax,31 | |
265 sar edx,31 | |
266 shld eax,ecx,21 ; convert to 32:32 | |
267 shl ecx,21 | |
268 shld edx,ebx,21 ; convert to 32:32 | |
269 shl ebx,21 | |
270 add edx,esi | |
271 mov s2hi1,eax | |
272 mov s2hi2,eax | |
273 mov s2hi3,eax | |
274 mov s2hi4,eax | |
275 mov s2hi5,eax | |
276 mov eax,_lvoltab | |
277 mov s2lo1,ecx | |
278 mov s2lo2,ecx | |
279 mov s2lo3,ecx | |
280 mov s2lo4,ecx | |
281 mov s2lo5,ecx | |
282 mov s2ltab1,eax | |
283 mov s2ltab2,eax | |
284 mov s2ltab3,eax | |
285 mov s2ltab4,eax | |
286 mov s2ltab5,eax | |
287 ;mov eax,_rvoltab | |
288 push ebp | |
289 ;mov s2rtab1,eax | |
290 ;mov s2rtab2,eax | |
291 ;mov s2rtab3,eax | |
292 ;mov s2rtab4,eax | |
293 ;mov s2rtab5,eax | |
294 xor eax,eax | |
295 jmp s3 ; flush code cache | |
296 s3: | |
297 shr ebp,2 | |
298 jz s2skip16 | |
299 push ebp | |
300 s2again16: | |
301 SS3F 0,s2lo1,s2hi1,s2ltab1 ;,s2rtab1 | |
302 SS3M 1,s2lo2,s2hi2,s2ltab2 ;,s2rtab2 | |
303 SS3M 2,s2lo3,s2hi3,s2ltab3 ;,s2rtab3 | |
304 SS3M 3,s2lo4,s2hi4,s2ltab4 ;,s2rtab4 | |
305 SS2L 4 | |
306 add edi,(4*8) | |
307 dec dword ptr [esp] | |
308 jnz s2again16 | |
309 pop ebp | |
310 s2skip16: | |
311 pop ebp | |
312 and ebp,3 | |
313 jz s2skip1 | |
314 push ebp | |
315 s2again1: | |
316 SS3F 0,s2lo5,s2hi5,s2ltab5 ;,s2rtab5 | |
317 SS2L 1 | |
318 add edi,8 | |
319 dec dword ptr [esp] | |
320 jnz s2again1 | |
321 pop ebp | |
322 s2skip1: | |
323 STUBEND | |
324 ret | |
325 | |
326 | |
327 _AsmMonoNormal: | |
328 STUBSTART | |
329 mov esi,[esp+32] ; get src | |
330 mov edi,[esp+36] ; get dst | |
331 mov ebx,[esp+40] ; get index | |
332 mov ecx,[esp+44] ; get increment | |
333 mov ebp,[esp+48] ; get todo | |
334 mov eax,ecx | |
335 mov edx,ebx | |
336 sar eax,31 | |
337 sar edx,31 | |
338 shld eax,ecx,21 ; convert to 32:32 | |
339 shl ecx,21 | |
340 shld edx,ebx,21 ; convert to 32:32 | |
341 shl ebx,21 | |
342 add edx,esi | |
343 mov mhi1,eax | |
344 mov mhi2,eax | |
345 mov mhi3,eax | |
346 mov mhi4,eax | |
347 mov mhi5,eax | |
348 mov eax,_lvoltab | |
349 mov mlo1,ecx | |
350 mov mlo2,ecx | |
351 mov mlo3,ecx | |
352 mov mlo4,ecx | |
353 mov mlo5,ecx | |
354 mov mltab1,eax | |
355 mov mltab2,eax | |
356 mov mltab3,eax | |
357 mov mltab4,eax | |
358 mov mltab5,eax | |
359 xor eax,eax | |
360 | |
361 jmp m1 ; flush code cache | |
362 m1: | |
363 push ebp | |
364 shr ebp,2 | |
365 jz mskip16 | |
366 magain16: | |
367 SM2F 0,mlo1,mhi1,mltab1 | |
368 SM2M 1,mlo2,mhi2,mltab2 | |
369 SM2M 2,mlo3,mhi3,mltab3 | |
370 SM2M 3,mlo4,mhi4,mltab4 | |
371 SM2L 4 | |
372 add edi,(4*4) | |
373 dec ebp | |
374 jnz magain16 | |
375 mskip16: | |
376 pop ebp | |
377 and ebp,3 | |
378 jz mskip1 | |
379 magain1: | |
380 SM2F 0,mlo5,mhi5,mltab5 | |
381 SM2L 1 | |
382 add edi,4 | |
383 dec ebp | |
384 jnz magain1 | |
385 mskip1: | |
386 STUBEND | |
387 ret | |
388 | |
389 | |
390 | |
391 IFDEF __ASMSTUFF__ | |
392 _AsmMix32To16_Normal: | |
393 STUBSTART | |
394 mov edi,[esp+32] ; get dest | |
395 mov esi,[esp+36] ; get src | |
396 mov edx,[esp+40] ; get count | |
397 mov cl,[_bitshift] | |
398 again: | |
399 mov eax,[esi] | |
400 sar eax,cl | |
401 cmp eax,32767 | |
402 jg toobig | |
403 cmp eax,-32768 | |
404 jl toosmall | |
405 write: | |
406 mov [edi],ax | |
407 add esi,4 | |
408 add edi,2 | |
409 dec edx | |
410 jnz again | |
411 jmp ready | |
412 toobig: | |
413 mov eax,32767 | |
414 jmp write | |
415 toosmall: | |
416 mov eax,-32768 | |
417 jmp write | |
418 ready: | |
419 STUBEND | |
420 ret | |
421 | |
422 | |
423 _AsmMix32To8_Normal: | |
424 STUBSTART | |
425 mov edi,[esp+32] ; get dest | |
426 mov esi,[esp+36] ; get src | |
427 mov edx,[esp+40] ; get count | |
428 mov cl,[_bitshift] | |
429 cagain: | |
430 mov eax,[esi] | |
431 sar eax,cl | |
432 cmp eax,127 | |
433 jg ctoobig | |
434 cmp eax,-128 | |
435 jl ctoosmall | |
436 cwrite: | |
437 add al,080h | |
438 add esi,4 | |
439 mov [edi],al | |
440 inc edi | |
441 dec edx | |
442 jnz cagain | |
443 jmp cready | |
444 ctoobig: | |
445 mov eax,127 | |
446 jmp cwrite | |
447 ctoosmall: | |
448 mov eax,-128 | |
449 jmp cwrite | |
450 cready: | |
451 STUBEND | |
452 ret | |
453 ENDIF | |
454 | |
455 END |