Add m68k assembly mixing routines
authorPatrice Mandin <patmandin@gmail.com>
Tue, 03 Jun 2003 19:35:10 +0000
changeset 633873c2598f969
parent 632 85e104fe14c2
child 634 44d574ed4780
Add m68k assembly mixing routines
src/audio/Makefile.am
src/audio/SDL_mixer.c
src/audio/SDL_mixer_m68k.c
src/audio/SDL_mixer_m68k.h
     1.1 --- a/src/audio/Makefile.am	Mon Jun 02 14:50:22 2003 +0000
     1.2 +++ b/src/audio/Makefile.am	Tue Jun 03 19:35:10 2003 +0000
     1.3 @@ -26,7 +26,9 @@
     1.4  	SDL_mixer_MMX.c         \
     1.5  	SDL_mixer_MMX.h		\
     1.6  	SDL_mixer_MMX_VC.c	\
     1.7 -	SDL_mixer_MMX_VC.h
     1.8 +	SDL_mixer_MMX_VC.h	\
     1.9 +	SDL_mixer_m68k.c	\
    1.10 +	SDL_mixer_m68k.h
    1.11  
    1.12  libaudio_la_SOURCES = $(COMMON_SRCS)
    1.13  libaudio_la_LIBADD = $(DRIVERS)
     2.1 --- a/src/audio/SDL_mixer.c	Mon Jun 02 14:50:22 2003 +0000
     2.2 +++ b/src/audio/SDL_mixer.c	Tue Jun 03 19:35:10 2003 +0000
     2.3 @@ -37,6 +37,7 @@
     2.4  #include "SDL_sysaudio.h"
     2.5  #include "SDL_mixer_MMX.h"
     2.6  #include "SDL_mixer_MMX_VC.h"
     2.7 +#include "SDL_mixer_m68k.h"
     2.8  
     2.9  /* Function to check the CPU flags */
    2.10  #define MMX_CPU		0x800000
    2.11 @@ -135,6 +136,9 @@
    2.12  	switch (format) {
    2.13  
    2.14  		case AUDIO_U8: {
    2.15 +#if defined(__M68000__) && defined(__GNUC__)
    2.16 +			SDL_MixAudio_m68k_U8((char*)dst,(char*)src,(unsigned long)len,(long)volume,(char *)mix8);
    2.17 +#else
    2.18  			Uint8 src_sample;
    2.19  
    2.20  			while ( len-- ) {
    2.21 @@ -144,6 +148,7 @@
    2.22  				++dst;
    2.23  				++src;
    2.24  			}
    2.25 +#endif
    2.26  		}
    2.27  		break;
    2.28  
    2.29 @@ -162,6 +167,9 @@
    2.30  			}
    2.31  			else
    2.32  #endif
    2.33 +#if defined(__M68000__) && defined(__GNUC__)
    2.34 +			SDL_MixAudio_m68k_S8((char*)dst,(char*)src,(unsigned long)len,(long)volume);
    2.35 +#else
    2.36  			{
    2.37  			Sint8 *dst8, *src8;
    2.38  			Sint8 src_sample;
    2.39 @@ -187,6 +195,7 @@
    2.40  				++src8;
    2.41  			}
    2.42  			}
    2.43 +#endif
    2.44  		}
    2.45  		break;
    2.46  
    2.47 @@ -204,6 +213,9 @@
    2.48  			}
    2.49  			else
    2.50  #endif
    2.51 +#if defined(__M68000__) && defined(__GNUC__)
    2.52 +			SDL_MixAudio_m68k_S16LSB((short*)dst,(short*)src,(unsigned long)len,(long)volume);
    2.53 +#else
    2.54  			{
    2.55  			Sint16 src1, src2;
    2.56  			int dst_sample;
    2.57 @@ -229,10 +241,14 @@
    2.58  				dst += 2;
    2.59  			}
    2.60  			}
    2.61 +#endif
    2.62  		}
    2.63  		break;
    2.64  
    2.65  		case AUDIO_S16MSB: {
    2.66 +#if defined(__M68000__) && defined(__GNUC__)
    2.67 +			SDL_MixAudio_m68k_S16MSB((short*)dst,(short*)src,(unsigned long)len,(long)volume);
    2.68 +#else
    2.69  			Sint16 src1, src2;
    2.70  			int dst_sample;
    2.71  			const int max_audioval = ((1<<(16-1))-1);
    2.72 @@ -256,6 +272,7 @@
    2.73  				dst[0] = dst_sample&0xFF;
    2.74  				dst += 2;
    2.75  			}
    2.76 +#endif
    2.77  		}
    2.78  		break;
    2.79  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/audio/SDL_mixer_m68k.c	Tue Jun 03 19:35:10 2003 +0000
     3.3 @@ -0,0 +1,210 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Library General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Library General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Library General Public
    3.19 +    License along with this library; if not, write to the Free
    3.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +*/
    3.25 +
    3.26 +/*
    3.27 +	m68k assembly mix routines
    3.28 +
    3.29 +	Patrice Mandin
    3.30 +*/
    3.31 +
    3.32 +#if defined(__M68000__) && defined(__GNUC__)
    3.33 +void SDL_MixAudio_m68k_U8(char* dst, char* src, long len, long volume, char* mix8)
    3.34 +{
    3.35 +    __asm__ __volatile__ (
    3.36 +
    3.37 +	"tstl	%2\n"
    3.38 +"	beqs	stoploop_u8\n"
    3.39 +"mixloop_u8:\n"
    3.40 +
    3.41 +	/* Mix a sample */
    3.42 +
    3.43 +"	moveq	#0,%%d0\n"
    3.44 +"	moveq	#0,%%d1\n"
    3.45 +
    3.46 +"	moveb	%1@+,%%d0\n"	/* d0 = *src++ */
    3.47 +"	sub	#128,%%d0\n"	/* d0 -= 128 */
    3.48 +"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
    3.49 +"	moveb	%0@,%%d1\n"	/* d1 = *dst */
    3.50 +"	asr	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
    3.51 +"	add	#128,%%d0\n"	/* d0 += 128 */
    3.52 +
    3.53 +"	add	%%d1,%%d0\n"
    3.54 +
    3.55 +"	moveb	%4@(%%d0:w),%0@+\n"
    3.56 +
    3.57 +	/* Loop till done */
    3.58 +
    3.59 +"	subql	#1,%2\n"
    3.60 +"	bhis	mixloop_u8\n"
    3.61 +"stoploop_u8:\n"
    3.62 +
    3.63 +	 : /* no return value */
    3.64 +	 : /* input */
    3.65 +	 	"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8)	
    3.66 +	 : /* clobbered registers */
    3.67 +	 	"d0", "d1", "cc", "memory" 
    3.68 +	 );
    3.69 +}
    3.70 +
    3.71 +void SDL_MixAudio_m68k_S8(char* dst, char* src, long len, long volume)
    3.72 +{
    3.73 +    __asm__ __volatile__ (
    3.74 +
    3.75 +	"tstl	%2\n"
    3.76 +"	beqs	stoploop_s8\n"
    3.77 +"	moveq	#-128,%%d2\n"
    3.78 +"	moveq	#127,%%d3\n"
    3.79 +"mixloop_s8:\n"
    3.80 +
    3.81 +	/* Mix a sample */
    3.82 +
    3.83 +"	moveq	#0,%%d0\n"
    3.84 +"	moveq	#0,%%d1\n"
    3.85 +
    3.86 +"	moveb	%1@+,%%d0\n"	/* d0 = *src++ */
    3.87 +"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
    3.88 +"	moveb	%0@,%%d1\n"	/* d1 = *dst */
    3.89 +"	asr	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
    3.90 +
    3.91 +"	add	%%d1,%%d0\n"
    3.92 +
    3.93 +"	cmp	%%d2,%%d0\n"
    3.94 +"	bges	lower_limit_s8\n"
    3.95 +"	move	%%d2,%%d0\n"
    3.96 +"lower_limit_s8:\n"
    3.97 +
    3.98 +"	cmp	%%d3,%%d0\n"
    3.99 +"	bles	upper_limit_s8\n"
   3.100 +"	move	%%d3,%%d0\n"
   3.101 +"upper_limit_s8:\n"
   3.102 +"	moveb	%%d0,%0@+\n"
   3.103 +
   3.104 +	/* Loop till done */
   3.105 +
   3.106 +"	subql	#1,%2\n"
   3.107 +"	bhis	mixloop_s8\n"
   3.108 +"stoploop_s8:\n"
   3.109 +
   3.110 +	 : /* no return value */
   3.111 +	 : /* input */
   3.112 +	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   3.113 +	 : /* clobbered registers */
   3.114 +	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   3.115 +	 );
   3.116 +}
   3.117 +
   3.118 +void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume)
   3.119 +{
   3.120 +    __asm__ __volatile__ (
   3.121 +
   3.122 +	"tstl	%2\n"
   3.123 +"	beqs	stoploop_s16msb\n"
   3.124 +"	movel	#-32768,%%d2\n"
   3.125 +"	movel	#32767,%%d3\n"
   3.126 +"	lsrl	#1,%2\n"
   3.127 +"mixloop_s16msb:\n"
   3.128 +
   3.129 +	/* Mix a sample */
   3.130 +
   3.131 +"	move	%1@+,%%d0\n"	/* d0 = *src++ */
   3.132 +"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
   3.133 +"	move	%0@,%%d1\n"	/* d1 = *dst */
   3.134 +"	extl	%%d1\n"		/* extend d1 to 32 bits */
   3.135 +"	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
   3.136 +
   3.137 +"	addl	%%d1,%%d0\n"
   3.138 +
   3.139 +"	cmpl	%%d2,%%d0\n"
   3.140 +"	bges	lower_limit_s16msb\n"
   3.141 +"	move	%%d2,%%d0\n"
   3.142 +"lower_limit_s16msb:\n"
   3.143 +
   3.144 +"	cmpl	%%d3,%%d0\n"
   3.145 +"	bles	upper_limit_s16msb\n"
   3.146 +"	move	%%d3,%%d0\n"
   3.147 +"upper_limit_s16msb:\n"
   3.148 +"	move	%%d0,%0@+\n"
   3.149 +
   3.150 +	/* Loop till done */
   3.151 +
   3.152 +"	subql	#1,%2\n"
   3.153 +"	bhis	mixloop_s16msb\n"
   3.154 +"stoploop_s16msb:\n"
   3.155 +
   3.156 +	 : /* no return value */
   3.157 +	 : /* input */
   3.158 +	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   3.159 +	 : /* clobbered registers */
   3.160 +	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   3.161 +	 );
   3.162 +}
   3.163 +
   3.164 +void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume)
   3.165 +{
   3.166 +    __asm__ __volatile__ (
   3.167 +
   3.168 +	"tstl	%2\n"
   3.169 +"	beqs	stoploop_s16lsb\n"
   3.170 +"	movel	#-32768,%%d2\n"
   3.171 +"	movel	#32767,%%d3\n"
   3.172 +"	lsrl	#1,%2\n"
   3.173 +"mixloop_s16lsb:\n"
   3.174 +
   3.175 +	/* Mix a sample */
   3.176 +
   3.177 +"	move	%1@+,%%d0\n"	/* d0 = *src++ */
   3.178 +"	rorw	#8,%%d0\n"
   3.179 +"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
   3.180 +"	move	%0@,%%d1\n"	/* d1 = *dst */
   3.181 +"	rorw	#8,%%d1\n"
   3.182 +"	extl	%%d1\n"		/* extend d1 to 32 bits */
   3.183 +"	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
   3.184 +
   3.185 +"	addl	%%d1,%%d0\n"
   3.186 +
   3.187 +"	cmpl	%%d2,%%d0\n"
   3.188 +"	bges	lower_limit_s16lsb\n"
   3.189 +"	move	%%d2,%%d0\n"
   3.190 +"lower_limit_s16lsb:\n"
   3.191 +
   3.192 +"	cmpl	%%d3,%%d0\n"
   3.193 +"	bles	upper_limit_s16lsb\n"
   3.194 +"	move	%%d3,%%d0\n"
   3.195 +"upper_limit_s16lsb:\n"
   3.196 +"	rorw	#8,%%d0\n"
   3.197 +"	move	%%d0,%0@+\n"
   3.198 +
   3.199 +	/* Loop till done */
   3.200 +
   3.201 +"	subql	#1,%2\n"
   3.202 +"	bhis	mixloop_s16lsb\n"
   3.203 +"stoploop_s16lsb:\n"
   3.204 +
   3.205 +	 : /* no return value */
   3.206 +	 : /* input */
   3.207 +	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   3.208 +	 : /* clobbered registers */
   3.209 +	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   3.210 +	 );
   3.211 +}
   3.212 +#endif
   3.213 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/audio/SDL_mixer_m68k.h	Tue Jun 03 19:35:10 2003 +0000
     4.3 @@ -0,0 +1,35 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Library General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Library General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Library General Public
    4.19 +    License along with this library; if not, write to the Free
    4.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +
    4.26 +/*
    4.27 +	m68k assembly mix routines
    4.28 +
    4.29 +	Patrice Mandin
    4.30 +*/
    4.31 +
    4.32 +#if defined(__M68000__) && defined(__GNUC__)
    4.33 +void SDL_MixAudio_m68k_U8(char* dst,char* src, long len, long volume, char* mix8);
    4.34 +void SDL_MixAudio_m68k_S8(char* dst,char* src, long len, long volume);
    4.35 +
    4.36 +void SDL_MixAudio_m68k_S16MSB(short* dst,short* src, long len, long volume);
    4.37 +void SDL_MixAudio_m68k_S16LSB(short* dst,short* src, long len, long volume);
    4.38 +#endif