Mercurial > sdl-ios-xcode
comparison src/audio/SDL_mixer_m68k.c @ 633:873c2598f969
Add m68k assembly mixing routines
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Tue, 03 Jun 2003 19:35:10 +0000 |
parents | |
children | b8d311d90021 |
comparison
equal
deleted
inserted
replaced
632:85e104fe14c2 | 633:873c2598f969 |
---|---|
1 /* | |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 | |
23 /* | |
24 m68k assembly mix routines | |
25 | |
26 Patrice Mandin | |
27 */ | |
28 | |
29 #if defined(__M68000__) && defined(__GNUC__) | |
30 void SDL_MixAudio_m68k_U8(char* dst, char* src, long len, long volume, char* mix8) | |
31 { | |
32 __asm__ __volatile__ ( | |
33 | |
34 "tstl %2\n" | |
35 " beqs stoploop_u8\n" | |
36 "mixloop_u8:\n" | |
37 | |
38 /* Mix a sample */ | |
39 | |
40 " moveq #0,%%d0\n" | |
41 " moveq #0,%%d1\n" | |
42 | |
43 " moveb %1@+,%%d0\n" /* d0 = *src++ */ | |
44 " sub #128,%%d0\n" /* d0 -= 128 */ | |
45 " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ | |
46 " moveb %0@,%%d1\n" /* d1 = *dst */ | |
47 " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ | |
48 " add #128,%%d0\n" /* d0 += 128 */ | |
49 | |
50 " add %%d1,%%d0\n" | |
51 | |
52 " moveb %4@(%%d0:w),%0@+\n" | |
53 | |
54 /* Loop till done */ | |
55 | |
56 " subql #1,%2\n" | |
57 " bhis mixloop_u8\n" | |
58 "stoploop_u8:\n" | |
59 | |
60 : /* no return value */ | |
61 : /* input */ | |
62 "a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8) | |
63 : /* clobbered registers */ | |
64 "d0", "d1", "cc", "memory" | |
65 ); | |
66 } | |
67 | |
68 void SDL_MixAudio_m68k_S8(char* dst, char* src, long len, long volume) | |
69 { | |
70 __asm__ __volatile__ ( | |
71 | |
72 "tstl %2\n" | |
73 " beqs stoploop_s8\n" | |
74 " moveq #-128,%%d2\n" | |
75 " moveq #127,%%d3\n" | |
76 "mixloop_s8:\n" | |
77 | |
78 /* Mix a sample */ | |
79 | |
80 " moveq #0,%%d0\n" | |
81 " moveq #0,%%d1\n" | |
82 | |
83 " moveb %1@+,%%d0\n" /* d0 = *src++ */ | |
84 " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ | |
85 " moveb %0@,%%d1\n" /* d1 = *dst */ | |
86 " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ | |
87 | |
88 " add %%d1,%%d0\n" | |
89 | |
90 " cmp %%d2,%%d0\n" | |
91 " bges lower_limit_s8\n" | |
92 " move %%d2,%%d0\n" | |
93 "lower_limit_s8:\n" | |
94 | |
95 " cmp %%d3,%%d0\n" | |
96 " bles upper_limit_s8\n" | |
97 " move %%d3,%%d0\n" | |
98 "upper_limit_s8:\n" | |
99 " moveb %%d0,%0@+\n" | |
100 | |
101 /* Loop till done */ | |
102 | |
103 " subql #1,%2\n" | |
104 " bhis mixloop_s8\n" | |
105 "stoploop_s8:\n" | |
106 | |
107 : /* no return value */ | |
108 : /* input */ | |
109 "a"(dst), "a"(src), "d"(len), "d"(volume) | |
110 : /* clobbered registers */ | |
111 "d0", "d1", "d2", "d3", "cc", "memory" | |
112 ); | |
113 } | |
114 | |
115 void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume) | |
116 { | |
117 __asm__ __volatile__ ( | |
118 | |
119 "tstl %2\n" | |
120 " beqs stoploop_s16msb\n" | |
121 " movel #-32768,%%d2\n" | |
122 " movel #32767,%%d3\n" | |
123 " lsrl #1,%2\n" | |
124 "mixloop_s16msb:\n" | |
125 | |
126 /* Mix a sample */ | |
127 | |
128 " move %1@+,%%d0\n" /* d0 = *src++ */ | |
129 " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ | |
130 " move %0@,%%d1\n" /* d1 = *dst */ | |
131 " extl %%d1\n" /* extend d1 to 32 bits */ | |
132 " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ | |
133 | |
134 " addl %%d1,%%d0\n" | |
135 | |
136 " cmpl %%d2,%%d0\n" | |
137 " bges lower_limit_s16msb\n" | |
138 " move %%d2,%%d0\n" | |
139 "lower_limit_s16msb:\n" | |
140 | |
141 " cmpl %%d3,%%d0\n" | |
142 " bles upper_limit_s16msb\n" | |
143 " move %%d3,%%d0\n" | |
144 "upper_limit_s16msb:\n" | |
145 " move %%d0,%0@+\n" | |
146 | |
147 /* Loop till done */ | |
148 | |
149 " subql #1,%2\n" | |
150 " bhis mixloop_s16msb\n" | |
151 "stoploop_s16msb:\n" | |
152 | |
153 : /* no return value */ | |
154 : /* input */ | |
155 "a"(dst), "a"(src), "d"(len), "d"(volume) | |
156 : /* clobbered registers */ | |
157 "d0", "d1", "d2", "d3", "cc", "memory" | |
158 ); | |
159 } | |
160 | |
161 void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume) | |
162 { | |
163 __asm__ __volatile__ ( | |
164 | |
165 "tstl %2\n" | |
166 " beqs stoploop_s16lsb\n" | |
167 " movel #-32768,%%d2\n" | |
168 " movel #32767,%%d3\n" | |
169 " lsrl #1,%2\n" | |
170 "mixloop_s16lsb:\n" | |
171 | |
172 /* Mix a sample */ | |
173 | |
174 " move %1@+,%%d0\n" /* d0 = *src++ */ | |
175 " rorw #8,%%d0\n" | |
176 " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ | |
177 " move %0@,%%d1\n" /* d1 = *dst */ | |
178 " rorw #8,%%d1\n" | |
179 " extl %%d1\n" /* extend d1 to 32 bits */ | |
180 " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ | |
181 | |
182 " addl %%d1,%%d0\n" | |
183 | |
184 " cmpl %%d2,%%d0\n" | |
185 " bges lower_limit_s16lsb\n" | |
186 " move %%d2,%%d0\n" | |
187 "lower_limit_s16lsb:\n" | |
188 | |
189 " cmpl %%d3,%%d0\n" | |
190 " bles upper_limit_s16lsb\n" | |
191 " move %%d3,%%d0\n" | |
192 "upper_limit_s16lsb:\n" | |
193 " rorw #8,%%d0\n" | |
194 " move %%d0,%0@+\n" | |
195 | |
196 /* Loop till done */ | |
197 | |
198 " subql #1,%2\n" | |
199 " bhis mixloop_s16lsb\n" | |
200 "stoploop_s16lsb:\n" | |
201 | |
202 : /* no return value */ | |
203 : /* input */ | |
204 "a"(dst), "a"(src), "d"(len), "d"(volume) | |
205 : /* clobbered registers */ | |
206 "d0", "d1", "d2", "d3", "cc", "memory" | |
207 ); | |
208 } | |
209 #endif | |
210 |