src/audio/SDL_mixer_m68k.c
changeset 633 873c2598f969
child 769 b8d311d90021
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/audio/SDL_mixer_m68k.c	Tue Jun 03 19:35:10 2003 +0000
     1.3 @@ -0,0 +1,210 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Library General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Library General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Library General Public
    1.19 +    License along with this library; if not, write to the Free
    1.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +
    1.26 +/*
    1.27 +	m68k assembly mix routines
    1.28 +
    1.29 +	Patrice Mandin
    1.30 +*/
    1.31 +
    1.32 +#if defined(__M68000__) && defined(__GNUC__)
    1.33 +void SDL_MixAudio_m68k_U8(char* dst, char* src, long len, long volume, char* mix8)
    1.34 +{
    1.35 +    __asm__ __volatile__ (
    1.36 +
    1.37 +	"tstl	%2\n"
    1.38 +"	beqs	stoploop_u8\n"
    1.39 +"mixloop_u8:\n"
    1.40 +
    1.41 +	/* Mix a sample */
    1.42 +
    1.43 +"	moveq	#0,%%d0\n"
    1.44 +"	moveq	#0,%%d1\n"
    1.45 +
    1.46 +"	moveb	%1@+,%%d0\n"	/* d0 = *src++ */
    1.47 +"	sub	#128,%%d0\n"	/* d0 -= 128 */
    1.48 +"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
    1.49 +"	moveb	%0@,%%d1\n"	/* d1 = *dst */
    1.50 +"	asr	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
    1.51 +"	add	#128,%%d0\n"	/* d0 += 128 */
    1.52 +
    1.53 +"	add	%%d1,%%d0\n"
    1.54 +
    1.55 +"	moveb	%4@(%%d0:w),%0@+\n"
    1.56 +
    1.57 +	/* Loop till done */
    1.58 +
    1.59 +"	subql	#1,%2\n"
    1.60 +"	bhis	mixloop_u8\n"
    1.61 +"stoploop_u8:\n"
    1.62 +
    1.63 +	 : /* no return value */
    1.64 +	 : /* input */
    1.65 +	 	"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8)	
    1.66 +	 : /* clobbered registers */
    1.67 +	 	"d0", "d1", "cc", "memory" 
    1.68 +	 );
    1.69 +}
    1.70 +
    1.71 +void SDL_MixAudio_m68k_S8(char* dst, char* src, long len, long volume)
    1.72 +{
    1.73 +    __asm__ __volatile__ (
    1.74 +
    1.75 +	"tstl	%2\n"
    1.76 +"	beqs	stoploop_s8\n"
    1.77 +"	moveq	#-128,%%d2\n"
    1.78 +"	moveq	#127,%%d3\n"
    1.79 +"mixloop_s8:\n"
    1.80 +
    1.81 +	/* Mix a sample */
    1.82 +
    1.83 +"	moveq	#0,%%d0\n"
    1.84 +"	moveq	#0,%%d1\n"
    1.85 +
    1.86 +"	moveb	%1@+,%%d0\n"	/* d0 = *src++ */
    1.87 +"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
    1.88 +"	moveb	%0@,%%d1\n"	/* d1 = *dst */
    1.89 +"	asr	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
    1.90 +
    1.91 +"	add	%%d1,%%d0\n"
    1.92 +
    1.93 +"	cmp	%%d2,%%d0\n"
    1.94 +"	bges	lower_limit_s8\n"
    1.95 +"	move	%%d2,%%d0\n"
    1.96 +"lower_limit_s8:\n"
    1.97 +
    1.98 +"	cmp	%%d3,%%d0\n"
    1.99 +"	bles	upper_limit_s8\n"
   1.100 +"	move	%%d3,%%d0\n"
   1.101 +"upper_limit_s8:\n"
   1.102 +"	moveb	%%d0,%0@+\n"
   1.103 +
   1.104 +	/* Loop till done */
   1.105 +
   1.106 +"	subql	#1,%2\n"
   1.107 +"	bhis	mixloop_s8\n"
   1.108 +"stoploop_s8:\n"
   1.109 +
   1.110 +	 : /* no return value */
   1.111 +	 : /* input */
   1.112 +	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   1.113 +	 : /* clobbered registers */
   1.114 +	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   1.115 +	 );
   1.116 +}
   1.117 +
   1.118 +void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume)
   1.119 +{
   1.120 +    __asm__ __volatile__ (
   1.121 +
   1.122 +	"tstl	%2\n"
   1.123 +"	beqs	stoploop_s16msb\n"
   1.124 +"	movel	#-32768,%%d2\n"
   1.125 +"	movel	#32767,%%d3\n"
   1.126 +"	lsrl	#1,%2\n"
   1.127 +"mixloop_s16msb:\n"
   1.128 +
   1.129 +	/* Mix a sample */
   1.130 +
   1.131 +"	move	%1@+,%%d0\n"	/* d0 = *src++ */
   1.132 +"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
   1.133 +"	move	%0@,%%d1\n"	/* d1 = *dst */
   1.134 +"	extl	%%d1\n"		/* extend d1 to 32 bits */
   1.135 +"	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
   1.136 +
   1.137 +"	addl	%%d1,%%d0\n"
   1.138 +
   1.139 +"	cmpl	%%d2,%%d0\n"
   1.140 +"	bges	lower_limit_s16msb\n"
   1.141 +"	move	%%d2,%%d0\n"
   1.142 +"lower_limit_s16msb:\n"
   1.143 +
   1.144 +"	cmpl	%%d3,%%d0\n"
   1.145 +"	bles	upper_limit_s16msb\n"
   1.146 +"	move	%%d3,%%d0\n"
   1.147 +"upper_limit_s16msb:\n"
   1.148 +"	move	%%d0,%0@+\n"
   1.149 +
   1.150 +	/* Loop till done */
   1.151 +
   1.152 +"	subql	#1,%2\n"
   1.153 +"	bhis	mixloop_s16msb\n"
   1.154 +"stoploop_s16msb:\n"
   1.155 +
   1.156 +	 : /* no return value */
   1.157 +	 : /* input */
   1.158 +	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   1.159 +	 : /* clobbered registers */
   1.160 +	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   1.161 +	 );
   1.162 +}
   1.163 +
   1.164 +void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume)
   1.165 +{
   1.166 +    __asm__ __volatile__ (
   1.167 +
   1.168 +	"tstl	%2\n"
   1.169 +"	beqs	stoploop_s16lsb\n"
   1.170 +"	movel	#-32768,%%d2\n"
   1.171 +"	movel	#32767,%%d3\n"
   1.172 +"	lsrl	#1,%2\n"
   1.173 +"mixloop_s16lsb:\n"
   1.174 +
   1.175 +	/* Mix a sample */
   1.176 +
   1.177 +"	move	%1@+,%%d0\n"	/* d0 = *src++ */
   1.178 +"	rorw	#8,%%d0\n"
   1.179 +"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
   1.180 +"	move	%0@,%%d1\n"	/* d1 = *dst */
   1.181 +"	rorw	#8,%%d1\n"
   1.182 +"	extl	%%d1\n"		/* extend d1 to 32 bits */
   1.183 +"	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
   1.184 +
   1.185 +"	addl	%%d1,%%d0\n"
   1.186 +
   1.187 +"	cmpl	%%d2,%%d0\n"
   1.188 +"	bges	lower_limit_s16lsb\n"
   1.189 +"	move	%%d2,%%d0\n"
   1.190 +"lower_limit_s16lsb:\n"
   1.191 +
   1.192 +"	cmpl	%%d3,%%d0\n"
   1.193 +"	bles	upper_limit_s16lsb\n"
   1.194 +"	move	%%d3,%%d0\n"
   1.195 +"upper_limit_s16lsb:\n"
   1.196 +"	rorw	#8,%%d0\n"
   1.197 +"	move	%%d0,%0@+\n"
   1.198 +
   1.199 +	/* Loop till done */
   1.200 +
   1.201 +"	subql	#1,%2\n"
   1.202 +"	bhis	mixloop_s16lsb\n"
   1.203 +"stoploop_s16lsb:\n"
   1.204 +
   1.205 +	 : /* no return value */
   1.206 +	 : /* input */
   1.207 +	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   1.208 +	 : /* clobbered registers */
   1.209 +	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   1.210 +	 );
   1.211 +}
   1.212 +#endif
   1.213 +