2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2004 Sam Lantinga
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.
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.
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
22 #include "SDL_config.h"
25 m68k assembly mix routines
30 #if defined(__M68000__) && defined(__GNUC__)
31 void SDL_MixAudio_m68k_U8(char* dst
, char* src
, long len
, long volume
, char* mix8
)
33 __asm__
__volatile__ (
44 " moveb %1@+,%%d0\n" /* d0 = *src++ */
45 " sub #128,%%d0\n" /* d0 -= 128 */
46 " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
47 " moveb %0@,%%d1\n" /* d1 = *dst */
48 " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
49 " add #128,%%d0\n" /* d0 += 128 */
53 " moveb %4@(%%d0:w),%0@+\n"
61 : /* no return value */
63 "a"(dst
), "a"(src
), "d"(len
), "d"(volume
), "a"(mix8
)
64 : /* clobbered registers */
65 "d0", "d1", "cc", "memory"
69 void SDL_MixAudio_m68k_S8(char* dst
, char* src
, long len
, long volume
)
71 __asm__
__volatile__ (
84 " moveb %1@+,%%d0\n" /* d0 = *src++ */
85 " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
86 " moveb %0@,%%d1\n" /* d1 = *dst */
87 " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
92 " bges lower_limit_s8\n"
97 " bles upper_limit_s8\n"
108 : /* no return value */
110 "a"(dst
), "a"(src
), "d"(len
), "d"(volume
)
111 : /* clobbered registers */
112 "d0", "d1", "d2", "d3", "cc", "memory"
116 void SDL_MixAudio_m68k_S16MSB(short* dst
, short* src
, long len
, long volume
)
118 __asm__
__volatile__ (
121 " beqs stoploop_s16msb\n"
122 " movel #-32768,%%d2\n"
123 " movel #32767,%%d3\n"
129 " move %1@+,%%d0\n" /* d0 = *src++ */
130 " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
131 " move %0@,%%d1\n" /* d1 = *dst */
132 " extl %%d1\n" /* extend d1 to 32 bits */
133 " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
138 " bges lower_limit_s16msb\n"
140 "lower_limit_s16msb:\n"
143 " bles upper_limit_s16msb\n"
145 "upper_limit_s16msb:\n"
151 " bhis mixloop_s16msb\n"
154 : /* no return value */
156 "a"(dst
), "a"(src
), "d"(len
), "d"(volume
)
157 : /* clobbered registers */
158 "d0", "d1", "d2", "d3", "cc", "memory"
162 void SDL_MixAudio_m68k_S16LSB(short* dst
, short* src
, long len
, long volume
)
164 __asm__
__volatile__ (
167 " beqs stoploop_s16lsb\n"
168 " movel #-32768,%%d2\n"
169 " movel #32767,%%d3\n"
175 " move %1@+,%%d0\n" /* d0 = *src++ */
177 " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
178 " move %0@,%%d1\n" /* d1 = *dst */
180 " extl %%d1\n" /* extend d1 to 32 bits */
181 " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
186 " bges lower_limit_s16lsb\n"
188 "lower_limit_s16lsb:\n"
191 " bles upper_limit_s16lsb\n"
193 "upper_limit_s16lsb:\n"
200 " bhis mixloop_s16lsb\n"
203 : /* no return value */
205 "a"(dst
), "a"(src
), "d"(len
), "d"(volume
)
206 : /* clobbered registers */
207 "d0", "d1", "d2", "d3", "cc", "memory"