src/audio/SDL_mixer_m68k.c
author Ozkan Sezer <sezeroz@gmail.com>
Sat, 24 Mar 2018 22:41:17 +0300
branchSDL-1.2
changeset 11972 0b5ac2b90ab1
parent 9013 7f4407040fbd
permissions -rw-r--r--
backfort fix for bug #3739: handle %lu, %li and %ld in SDL_SetError.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2012 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 #include "SDL_config.h"
    23 
    24 /*
    25 	m68k assembly mix routines
    26 
    27 	Patrice Mandin
    28 */
    29 
    30 #if (defined(__m68k__) && !defined(__mcoldfire__)) && defined(__GNUC__)
    31 void SDL_MixAudio_m68k_U8(char* dst, char* src, long len, long volume, char* mix8)
    32 {
    33     __asm__ __volatile__ (
    34 
    35 	"tstl	%2\n"
    36 "	beqs	stoploop_u8\n"
    37 "mixloop_u8:\n"
    38 
    39 	/* Mix a sample */
    40 
    41 "	moveq	#0,%%d0\n"
    42 "	moveq	#0,%%d1\n"
    43 
    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 */
    50 
    51 "	add	%%d1,%%d0\n"
    52 
    53 "	moveb	%4@(%%d0:w),%0@+\n"
    54 
    55 	/* Loop till done */
    56 
    57 "	subql	#1,%2\n"
    58 "	bhis	mixloop_u8\n"
    59 "stoploop_u8:\n"
    60 
    61 	 : /* no return value */
    62 	 : /* input */
    63 	 	"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8)	
    64 	 : /* clobbered registers */
    65 	 	"d0", "d1", "cc", "memory" 
    66 	 );
    67 }
    68 
    69 void SDL_MixAudio_m68k_S8(char* dst, char* src, long len, long volume)
    70 {
    71     __asm__ __volatile__ (
    72 
    73 	"tstl	%2\n"
    74 "	beqs	stoploop_s8\n"
    75 "	moveq	#-128,%%d2\n"
    76 "	moveq	#127,%%d3\n"
    77 "mixloop_s8:\n"
    78 
    79 	/* Mix a sample */
    80 
    81 "	moveq	#0,%%d0\n"
    82 "	moveq	#0,%%d1\n"
    83 
    84 "	moveb	%1@+,%%d0\n"	/* d0 = *src++ */
    85 "	extw	%%d0\n"
    86 "	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
    87 "	moveb	%0@,%%d1\n"	/* d1 = *dst */
    88 "	asr	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
    89 
    90 "	add	%%d1,%%d0\n"
    91 
    92 "	cmp	%%d2,%%d0\n"
    93 "	bges	lower_limit_s8\n"
    94 "	move	%%d2,%%d0\n"
    95 "lower_limit_s8:\n"
    96 
    97 "	cmp	%%d3,%%d0\n"
    98 "	bles	upper_limit_s8\n"
    99 "	move	%%d3,%%d0\n"
   100 "upper_limit_s8:\n"
   101 "	moveb	%%d0,%0@+\n"
   102 
   103 	/* Loop till done */
   104 
   105 "	subql	#1,%2\n"
   106 "	bhis	mixloop_s8\n"
   107 "stoploop_s8:\n"
   108 
   109 	 : /* no return value */
   110 	 : /* input */
   111 	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   112 	 : /* clobbered registers */
   113 	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   114 	 );
   115 }
   116 
   117 void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume)
   118 {
   119     __asm__ __volatile__ (
   120 
   121 	"tstl	%2\n"
   122 "	beqs	stoploop_s16msb\n"
   123 "	movel	#-32768,%%d2\n"
   124 "	movel	#32767,%%d3\n"
   125 "	lsrl	#1,%2\n"
   126 "mixloop_s16msb:\n"
   127 
   128 	/* Mix a sample */
   129 
   130 "	move	%1@+,%%d0\n"	/* d0 = *src++ */
   131 "	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
   132 "	move	%0@,%%d1\n"	/* d1 = *dst */
   133 "	extl	%%d1\n"		/* extend d1 to 32 bits */
   134 "	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
   135 
   136 "	addl	%%d1,%%d0\n"
   137 
   138 "	cmpl	%%d2,%%d0\n"
   139 "	bges	lower_limit_s16msb\n"
   140 "	move	%%d2,%%d0\n"
   141 "lower_limit_s16msb:\n"
   142 
   143 "	cmpl	%%d3,%%d0\n"
   144 "	bles	upper_limit_s16msb\n"
   145 "	move	%%d3,%%d0\n"
   146 "upper_limit_s16msb:\n"
   147 "	move	%%d0,%0@+\n"
   148 
   149 	/* Loop till done */
   150 
   151 "	subql	#1,%2\n"
   152 "	bhis	mixloop_s16msb\n"
   153 "stoploop_s16msb:\n"
   154 
   155 	 : /* no return value */
   156 	 : /* input */
   157 	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   158 	 : /* clobbered registers */
   159 	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   160 	 );
   161 }
   162 
   163 void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume)
   164 {
   165     __asm__ __volatile__ (
   166 
   167 	"tstl	%2\n"
   168 "	beqs	stoploop_s16lsb\n"
   169 "	movel	#-32768,%%d2\n"
   170 "	movel	#32767,%%d3\n"
   171 "	lsrl	#1,%2\n"
   172 "mixloop_s16lsb:\n"
   173 
   174 	/* Mix a sample */
   175 
   176 "	move	%1@+,%%d0\n"	/* d0 = *src++ */
   177 "	rorw	#8,%%d0\n"
   178 "	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
   179 "	move	%0@,%%d1\n"	/* d1 = *dst */
   180 "	rorw	#8,%%d1\n"
   181 "	extl	%%d1\n"		/* extend d1 to 32 bits */
   182 "	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
   183 
   184 "	addl	%%d1,%%d0\n"
   185 
   186 "	cmpl	%%d2,%%d0\n"
   187 "	bges	lower_limit_s16lsb\n"
   188 "	move	%%d2,%%d0\n"
   189 "lower_limit_s16lsb:\n"
   190 
   191 "	cmpl	%%d3,%%d0\n"
   192 "	bles	upper_limit_s16lsb\n"
   193 "	move	%%d3,%%d0\n"
   194 "upper_limit_s16lsb:\n"
   195 "	rorw	#8,%%d0\n"
   196 "	move	%%d0,%0@+\n"
   197 
   198 	/* Loop till done */
   199 
   200 "	subql	#1,%2\n"
   201 "	bhis	mixloop_s16lsb\n"
   202 "stoploop_s16lsb:\n"
   203 
   204 	 : /* no return value */
   205 	 : /* input */
   206 	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
   207 	 : /* clobbered registers */
   208 	 	"d0", "d1", "d2", "d3", "cc", "memory" 
   209 	 );
   210 }
   211 #endif