comparison playercode/resample.S @ 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 /* GCC port of mixing code by Barubary (barubary@dal.net)
2 This should work on both Linux and DJGPP... I have confirmed that
3 self-modifying code works just fine in Linux without causing signals.
4 This may change in the future, so I recommend that the Linux MikMod
5 developers look out for new kernel releases. The critical thing is that
6 CS.base = DS.base in Linux, which makes DS an alias for CS, and that the
7 code pages remain writable. */
8
9 .data /* self-modifying code... keep in data segment */
10
11 #define _AsmStereoNormal AsmStereoNormal
12 #define _AsmStereoSurround AsmStereoSurround
13 #define _AsmMonoNormal AsmMonoNormal
14 #define _AsmMix32To16Surround AsmMix32To16Surround
15 #define _AsmMix32To8Surround AsmMix32To8Surround
16 #define _bitshift bitshift
17 #define _lvoltab lvoltab
18 #define _rvoltab rvoltab
19
20 .globl _AsmStereoNormal
21 .globl _AsmStereoSurround
22 .globl _AsmMonoNormal
23 .globl _AsmMix32To16Surround
24 .globl _AsmMix32To8Surround
25
26
27 #define STUBSTART \
28 pushl %eax; \
29 pushl %ebx; \
30 pushl %ecx; \
31 pushl %edx; \
32 pushl %esi; \
33 pushl %edi; \
34 pushl %ebp
35
36 #define STUBEND \
37 popl %ebp; \
38 popl %edi; \
39 popl %esi; \
40 popl %edx; \
41 popl %ecx; \
42 popl %ebx; \
43 popl %eax
44
45 #define SS2F(index,lab1,lab2,lab3,lab4) \
46 movb (%edx),%al; \
47 .byte 0x081,0x0c3; \
48 lab1: .int 0; \
49 .byte 0x081,0x0d2; \
50 lab2: .int 0; \
51 movl index*8(%edi),%esi; \
52 .byte 0x08b,0x0c,0x085; \
53 lab3: .int 0; \
54 movl index*8+4(%edi),%ebp; \
55 addl %ecx,%esi; \
56 .byte 0x08b,0x0c,0x085; \
57 lab4: .int 0; \
58 movl %esi,index*8(%edi); \
59 addl %ecx,%ebp
60
61 #define SS2M(index,lab1,lab2,lab3,lab4) \
62 movb (%edx),%al; \
63 movl %ebp,index*8-4(%edi); \
64 .byte 0x081,0x0c3; \
65 lab1: .int 0; \
66 .byte 0x081,0x0d2; \
67 lab2: .int 0; \
68 movl index*8(%edi),%esi; \
69 .byte 0x08b,0x0c,0x085; \
70 lab3: .int 0; \
71 movl index*8+4(%edi),%ebp; \
72 addl %ecx,%esi; \
73 .byte 0x08b,0x0c,0x085; \
74 lab4: .int 0; \
75 movl %esi,index*8(%edi); \
76 addl %ecx,%ebp
77
78 #define SS3F(index,lab1,lab2,lab3) \
79 movb (%edx),%al; \
80 .byte 0x081,0x0c3; \
81 lab1: .int 0; \
82 .byte 0x081,0x0d2; \
83 lab2: .int 0; \
84 movl index*8(%edi),%esi; \
85 .byte 0x08b,0x0c,0x085; \
86 lab3: .int 0; \
87 movl index*8+4(%edi),%ebp; \
88 addl %ecx,%esi; \
89 subl %ecx,%ebp; \
90 movl %esi,index*8(%edi); \
91
92 #define SS3M(index,lab1,lab2,lab3) \
93 movb (%edx),%al; \
94 movl %ebp,index*8-4(%edi); \
95 .byte 0x081,0x0c3; \
96 lab1: .int 0; \
97 .byte 0x081,0x0d2; \
98 lab2: .int 0; \
99 movl index*8(%edi),%esi; \
100 .byte 0x08b,0x0c,0x085; \
101 lab3: .int 0; \
102 movl index*8+4(%edi),%ebp; \
103 addl %ecx,%esi; \
104 subl %ecx,%ebp; \
105 movl %esi,index*8(%edi); \
106
107 #define SS2L(index) \
108 movl %ebp,index*8-4(%edi)
109
110 #define SM2F(index,lab1,lab2,lab3) \
111 movb (%edx),%al; \
112 .byte 0x081,0x0c3; \
113 lab1: .int 0; \
114 .byte 0x081,0x0d2; \
115 lab2: .int 0; \
116 movl index*4(%edi),%esi; \
117 .byte 0x08b,0x0c,0x085; \
118 lab3: .int 0
119
120 #define SM2M(index,lab1,lab2,lab3) \
121 movb (%edx),%al; \
122 addl %ecx,%esi; \
123 .byte 0x081,0x0c3; \
124 lab1: .int 0; \
125 movl %esi,index*4-4(%edi); \
126 .byte 0x081,0x0d2; \
127 lab2: .int 0; \
128 movl index*4(%edi),%esi; \
129 .byte 0x08b,0x0c,0x085; \
130 lab3: .int 0
131
132 #define SM2L(index) \
133 addl %ecx,%esi; \
134 movl %esi,index*4-4(%edi)
135
136 _AsmStereoNormal:
137 STUBSTART
138 movl 32(%esp),%esi /* get src */
139 movl 36(%esp),%edi /* get dst */
140 movl 40(%esp),%ebx /* get index */
141 movl 44(%esp),%ecx /* get increment */
142 movl 48(%esp),%ebp /* get todo */
143 movl %ecx,%eax
144 movl %ebx,%edx
145 sarl $31,%eax
146 sarl $31,%edx
147 shldl $21,%ecx,%eax /* convert to 32:32 */
148 shll $21,%ecx
149 shldl $21,%ebx,%edx /* convert to 32:32 */
150 shll $21,%ebx
151 addl %esi,%edx
152 movl %eax,shi1
153 movl %eax,shi2
154 movl %eax,shi3
155 movl %eax,shi4
156 movl %eax,shi5
157 movl _lvoltab,%eax
158 movl %ecx,slo1
159 movl %ecx,slo2
160 movl %ecx,slo3
161 movl %ecx,slo4
162 movl %ecx,slo5
163 movl %eax,sltab1
164 movl %eax,sltab2
165 movl %eax,sltab3
166 movl %eax,sltab4
167 movl %eax,sltab5
168 movl _rvoltab,%eax
169 pushl %ebp
170 movl %eax,srtab1
171 movl %eax,srtab2
172 movl %eax,srtab3
173 movl %eax,srtab4
174 movl %eax,srtab5
175 xorl %eax,%eax
176 jmp s1 /* flush code cache */
177 s1:
178 shrl $2,%ebp
179 jz sskip16
180 pushl %ebp
181 sagain16:
182 SS2F(0,slo1,shi1,sltab1,srtab1)
183 SS2M(1,slo2,shi2,sltab2,srtab2)
184 SS2M(2,slo3,shi3,sltab3,srtab3)
185 SS2M(3,slo4,shi4,sltab4,srtab4)
186 SS2L(4)
187 addl $32,%edi
188 decl (%esp)
189 jnz sagain16
190 popl %ebp
191 sskip16:
192 popl %ebp
193 andl $3,%ebp
194 jz sskip1
195 pushl %ebp
196 sagain1:
197 SS2F(0,slo5,shi5,sltab5,srtab5)
198 SS2L(1)
199 addl $8,%edi
200 decl (%esp)
201 jnz sagain1
202 popl %ebp
203 sskip1:
204 STUBEND
205 ret
206
207
208 _AsmStereoSurround:
209 STUBSTART
210 movl 32(%esp),%esi /* get src */
211 movl 36(%esp),%edi /* get dst */
212 movl 40(%esp),%ebx /* get index */
213 movl 44(%esp),%ecx /* get increment */
214 movl 48(%esp),%ebp /* get todo */
215 movl %ecx,%eax
216 movl %ebx,%edx
217 sarl $31,%eax
218 sarl $31,%edx
219 shldl $21,%ecx,%eax /* convert to 32:32 */
220 shll $21,%ecx
221 shldl $21,%ebx,%edx /* convert to 32:32 */
222 shll $21,%ebx
223 addl %esi,%edx
224 movl %eax,s2hi1
225 movl %eax,s2hi2
226 movl %eax,s2hi3
227 movl %eax,s2hi4
228 movl %eax,s2hi5
229 movl _lvoltab,%eax
230 movl %ecx,s2lo1
231 movl %ecx,s2lo2
232 movl %ecx,s2lo3
233 movl %ecx,s2lo4
234 movl %ecx,s2lo5
235 movl %eax,s2ltab1
236 movl %eax,s2ltab2
237 movl %eax,s2ltab3
238 movl %eax,s2ltab4
239 movl %eax,s2ltab5
240 pushl %ebp
241 xorl %eax,%eax
242 jmp s3 /* flush code cache */
243 s3:
244 shrl $2,%ebp
245 jz s2skip16
246 pushl %ebp
247 s2again16:
248 SS3F(0,s2lo1,s2hi1,s2ltab1)
249 SS3M(1,s2lo2,s2hi2,s2ltab2)
250 SS3M(2,s2lo3,s2hi3,s2ltab3)
251 SS3M(3,s2lo4,s2hi4,s2ltab4)
252 SS2L(4)
253 addl $32,%edi
254 decl (%esp)
255 jnz s2again16
256 popl %ebp
257 s2skip16:
258 popl %ebp
259 andl $3,%ebp
260 jz s2skip1
261 pushl %ebp
262 s2again1:
263 SS3F(0,s2lo5,s2hi5,s2ltab5)
264 SS2L(1)
265 addl $8,%edi
266 decl (%esp)
267 jnz s2again1
268 popl %ebp
269 s2skip1:
270 STUBEND
271 ret
272
273
274 _AsmMonoNormal:
275 STUBSTART
276 movl 32(%esp),%esi /* get src */
277 movl 36(%esp),%edi /* get dst */
278 movl 40(%esp),%ebx /* get index */
279 movl 44(%esp),%ecx /* get increment */
280 movl 48(%esp),%ebp /* get todo */
281 movl %ecx,%eax
282 movl %ebx,%edx
283 sarl $31,%eax
284 sarl $31,%edx
285 shldl $21,%ecx,%eax /* convert to 32:32 */
286 shll $21,%ecx
287 shldl $21,%ebx,%edx /* convert to 32:32 */
288 shll $21,%ebx
289 addl %esi,%edx
290 movl %eax,mhi1
291 movl %eax,mhi2
292 movl %eax,mhi3
293 movl %eax,mhi4
294 movl %eax,mhi5
295 movl _lvoltab,%eax
296 movl %ecx,mlo1
297 movl %ecx,mlo2
298 movl %ecx,mlo3
299 movl %ecx,mlo4
300 movl %ecx,mlo5
301 movl %eax,mltab1
302 movl %eax,mltab2
303 movl %eax,mltab3
304 movl %eax,mltab4
305 movl %eax,mltab5
306 xorl %eax,%eax
307
308 jmp m1 /* flush code cache */
309 m1:
310 pushl %ebp
311 shrl $2,%ebp
312 jz mskip16
313 magain16:
314 SM2F(0,mlo1,mhi1,mltab1)
315 SM2M(1,mlo2,mhi2,mltab2)
316