Removed buggy and LGPL MMX mixing routines.

This commit is contained in:
Sam Lantinga 2011-04-08 13:16:33 -07:00
parent b0660ba5ff
commit 605263ee5f
14 changed files with 39 additions and 1314 deletions

View file

@ -26,9 +26,6 @@
#include "SDL_timer.h"
#include "SDL_audio.h"
#include "SDL_sysaudio.h"
#include "SDL_mixer_MMX.h"
#include "SDL_mixer_MMX_VC.h"
#include "SDL_mixer_m68k.h"
/* This table is used to add two sound values together and pin
* the value to avoid overflow. (used with permission from ARDI)
@ -121,95 +118,55 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
case AUDIO_S8:
{
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
if (SDL_HasMMX()) {
SDL_MixAudio_MMX_S8((char *) dst, (char *) src,
(unsigned int) len, (int) volume);
} else
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
if (SDL_HasMMX()) {
SDL_MixAudio_MMX_S8_VC((char *) dst, (char *) src,
(unsigned int) len, (int) volume);
} else
#endif
#endif
#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES)
SDL_MixAudio_m68k_S8((char *) dst, (char *) src,
(unsigned long) len, (long) volume);
#else
{
Sint8 *dst8, *src8;
Sint8 src_sample;
int dst_sample;
const int max_audioval = ((1 << (8 - 1)) - 1);
const int min_audioval = -(1 << (8 - 1));
Sint8 *dst8, *src8;
Sint8 src_sample;
int dst_sample;
const int max_audioval = ((1 << (8 - 1)) - 1);
const int min_audioval = -(1 << (8 - 1));
src8 = (Sint8 *) src;
dst8 = (Sint8 *) dst;
while (len--) {
src_sample = *src8;
ADJUST_VOLUME(src_sample, volume);
dst_sample = *dst8 + src_sample;
if (dst_sample > max_audioval) {
*dst8 = max_audioval;
} else if (dst_sample < min_audioval) {
*dst8 = min_audioval;
} else {
*dst8 = dst_sample;
}
++dst8;
++src8;
src8 = (Sint8 *) src;
dst8 = (Sint8 *) dst;
while (len--) {
src_sample = *src8;
ADJUST_VOLUME(src_sample, volume);
dst_sample = *dst8 + src_sample;
if (dst_sample > max_audioval) {
*dst8 = max_audioval;
} else if (dst_sample < min_audioval) {
*dst8 = min_audioval;
} else {
*dst8 = dst_sample;
}
++dst8;
++src8;
}
#endif
}
break;
case AUDIO_S16LSB:
{
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
if (SDL_HasMMX()) {
SDL_MixAudio_MMX_S16((char *) dst, (char *) src,
(unsigned int) len, (int) volume);
} else
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
if (SDL_HasMMX()) {
SDL_MixAudio_MMX_S16_VC((char *) dst, (char *) src,
(unsigned int) len, (int) volume);
} else
#endif
#endif
#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES)
SDL_MixAudio_m68k_S16LSB((short *) dst, (short *) src,
(unsigned long) len, (long) volume);
#else
{
Sint16 src1, src2;
int dst_sample;
const int max_audioval = ((1 << (16 - 1)) - 1);
const int min_audioval = -(1 << (16 - 1));
Sint16 src1, src2;
int dst_sample;
const int max_audioval = ((1 << (16 - 1)) - 1);
const int min_audioval = -(1 << (16 - 1));
len /= 2;
while (len--) {
src1 = ((src[1]) << 8 | src[0]);
ADJUST_VOLUME(src1, volume);
src2 = ((dst[1]) << 8 | dst[0]);
src += 2;
dst_sample = src1 + src2;
if (dst_sample > max_audioval) {
dst_sample = max_audioval;
} else if (dst_sample < min_audioval) {
dst_sample = min_audioval;
}
dst[0] = dst_sample & 0xFF;
dst_sample >>= 8;
dst[1] = dst_sample & 0xFF;
dst += 2;
len /= 2;
while (len--) {
src1 = ((src[1]) << 8 | src[0]);
ADJUST_VOLUME(src1, volume);
src2 = ((dst[1]) << 8 | dst[0]);
src += 2;
dst_sample = src1 + src2;
if (dst_sample > max_audioval) {
dst_sample = max_audioval;
} else if (dst_sample < min_audioval) {
dst_sample = min_audioval;
}
dst[0] = dst_sample & 0xFF;
dst_sample >>= 8;
dst[1] = dst_sample & 0xFF;
dst += 2;
}
#endif
}
break;

View file

@ -1,124 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
This code is licensed under the LGPL (see COPYING for details)
Assumes buffer size in bytes is a multiple of 16
Assumes SDL_MIX_MAXVOLUME = 128
*/
/***********************************************
* Mixing for 16 bit signed buffers
***********************************************/
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
void
SDL_MixAudio_MMX_S16(char *dst, char *src, unsigned int size, int volume)
{
__asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */
" movl %2,%%edx\n" /* edx = size */
" shrl $4,%%edx\n" /* process 16 bytes per iteration = 8 samples */
" jz .endS16\n" " pxor %%mm0,%%mm0\n" " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */
".align 8\n" " .mixloopS16:\n" " movq (%1),%%mm1\n" /* mm1 = a|b|c|d */
" movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */
" movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */
/* pré charger le buffer dst dans mm7 */
" movq (%0),%%mm7\n" /* mm7 = dst[0] */
/* multiplier par le volume */
" pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
" pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */
" movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */
" pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
" pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */
" movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
" punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */
" movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
" punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */
" punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */
" punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */
/* pré charger le buffer dst dans mm5 */
" movq 8(%0),%%mm5\n" /* mm5 = dst[1] */
/* diviser par 128 */
" psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */
" add $16,%1\n" " psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */
" psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */
/* mm1 = le sample avec le volume modifié */
" packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */
" psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */
" paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */
/* mm4 = le sample avec le volume modifié */
" packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */
" movq %%mm3,(%0)\n" " paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */
" movq %%mm6,8(%0)\n"
" add $16,%0\n"
" dec %%edx\n"
" jnz .mixloopS16\n"
" emms\n"
".endS16:\n"::"r"(dst), "r"(src),
"m"(size), "m"(volume):"eax", "edx", "memory");
}
/*////////////////////////////////////////////// */
/* Mixing for 8 bit signed buffers */
/*////////////////////////////////////////////// */
void
SDL_MixAudio_MMX_S8(char *dst, char *src, unsigned int size, int volume)
{
__asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */
" movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " movl %2,%%edx\n" /* edx = size */
" shr $3,%%edx\n" /* process 8 bytes per iteration = 8 samples */
" cmp $0,%%edx\n" " je .endS8\n" ".align 8\n" " .mixloopS8:\n" " pxor %%mm2,%%mm2\n" /* mm2 = 0 */
" movq (%1),%%mm1\n" /* mm1 = a|b|c|d|e|f|g|h */
" movq %%mm1,%%mm3\n" /* mm3 = a|b|c|d|e|f|g|h */
/* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */
" pcmpgtb %%mm1,%%mm2\n" /* mm2 = 11111111|00000000|00000000.... */
" punpckhbw %%mm2,%%mm1\n" /* mm1 = 0|a|0|b|0|c|0|d */
" punpcklbw %%mm2,%%mm3\n" /* mm3 = 0|e|0|f|0|g|0|h */
" movq (%0),%%mm2\n" /* mm2 = destination */
" pmullw %%mm0,%%mm1\n" /* mm1 = v*a|v*b|v*c|v*d */
" add $8,%1\n" " pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */
" psraw $7,%%mm1\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128 */
" psraw $7,%%mm3\n" /* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */
" packsswb %%mm1,%%mm3\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */
" paddsb %%mm2,%%mm3\n" /* add to destination buffer */
" movq %%mm3,(%0)\n" /* store back to ram */
" add $8,%0\n"
" dec %%edx\n"
" jnz .mixloopS8\n"
".endS8:\n"
" emms\n"::"r"(dst), "r"(src), "m"(size),
"m"(volume):"eax", "edx", "memory");
}
#endif
#endif /* SDL_BUGGY_MMX_MIXERS */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,17 +0,0 @@
/*
headers for MMX assembler version of SDL_MixAudio
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
This code is licensed under the LGPL (see COPYING for details)
Assumes buffer size in bytes is a multiple of 16
Assumes SDL_MIX_MAXVOLUME = 128
*/
#include "SDL_config.h"
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
void SDL_MixAudio_MMX_S16(char *, char *, unsigned int, int);
void SDL_MixAudio_MMX_S8(char *, char *, unsigned int, int);
#endif
#endif /* SDL_BUGGY_MMX_MIXERS */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,190 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_mixer_MMX_VC.h"
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
// Converted to Intel ASM notation by Cth
// This code is licensed under the LGPL (see COPYING for details)
//
// Assumes buffer size in bytes is a multiple of 16
// Assumes SDL_MIX_MAXVOLUME = 128
////////////////////////////////////////////////
// Mixing for 16 bit signed buffers
////////////////////////////////////////////////
void
SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume)
{
/* *INDENT-OFF* */
__asm
{
push edi
push esi
push ebx
mov edi, dst // edi = dst
mov esi, src // esi = src
mov eax, volume // eax = volume
mov ebx, nSize // ebx = size
shr ebx, 4 // process 16 bytes per iteration = 8 samples
jz endS16
pxor mm0, mm0
movd mm0, eax //%%eax,%%mm0
movq mm1, mm0 //%%mm0,%%mm1
psllq mm0, 16 //$16,%%mm0
por mm0, mm1 //%%mm1,%%mm0
psllq mm0, 16 //$16,%%mm0
por mm0, mm1 //%%mm1,%%mm0
psllq mm0, 16 //$16,%%mm0
por mm0, mm1 //%%mm1,%%mm0 // mm0 = vol|vol|vol|vol
#ifndef __WATCOMC__
align 16
#endif
mixloopS16:
movq mm1, [esi] //(%%esi),%%mm1\n" // mm1 = a|b|c|d
movq mm2, mm1 //%%mm1,%%mm2\n" // mm2 = a|b|c|d
movq mm4, [esi + 8] //8(%%esi),%%mm4\n" // mm4 = e|f|g|h
// pre charger le buffer dst dans mm7
movq mm7, [edi] //(%%edi),%%mm7\n" // mm7 = dst[0]"
// multiplier par le volume
pmullw mm1, mm0 //%%mm0,%%mm1\n" // mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
pmulhw mm2, mm0 //%%mm0,%%mm2\n" // mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v)
movq mm5, mm4 //%%mm4,%%mm5\n" // mm5 = e|f|g|h
pmullw mm4, mm0 //%%mm0,%%mm4\n" // mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
pmulhw mm5, mm0 //%%mm0,%%mm5\n" // mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v)
movq mm3, mm1 //%%mm1,%%mm3\n" // mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
punpckhwd mm1, mm2 //%%mm2,%%mm1\n" // mm1 = a*v|b*v
movq mm6, mm4 //%%mm4,%%mm6\n" // mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
punpcklwd mm3, mm2 //%%mm2,%%mm3\n" // mm3 = c*v|d*v
punpckhwd mm4, mm5 //%%mm5,%%mm4\n" // mm4 = e*f|f*v
punpcklwd mm6, mm5 //%%mm5,%%mm6\n" // mm6 = g*v|h*v
// pre charger le buffer dst dans mm5
movq mm5, [edi + 8] //8(%%edi),%%mm5\n" // mm5 = dst[1]
// diviser par 128
psrad mm1, 7 //$7,%%mm1\n" // mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME
add esi, 16 //$16,%%esi\n"
psrad mm3, 7 //$7,%%mm3\n" // mm3 = c*v/128|d*v/128
psrad mm4, 7 //$7,%%mm4\n" // mm4 = e*v/128|f*v/128
// mm1 = le sample avec le volume modifie
packssdw mm3, mm1 //%%mm1,%%mm3\n" // mm3 = s(a*v|b*v|c*v|d*v)
psrad mm6, 7 //$7,%%mm6\n" // mm6= g*v/128|h*v/128
paddsw mm3, mm7 //%%mm7,%%mm3\n" // mm3 = adjust_volume(src)+dst
// mm4 = le sample avec le volume modifie
packssdw mm6, mm4 //%%mm4,%%mm6\n" // mm6 = s(e*v|f*v|g*v|h*v)
movq [edi], mm3 //%%mm3,(%%edi)\n"
paddsw mm6, mm5 //%%mm5,%%mm6\n" // mm6 = adjust_volume(src)+dst
movq [edi + 8], mm6 //%%mm6,8(%%edi)\n"
add edi, 16 //$16,%%edi\n"
dec ebx //%%ebx\n"
jnz mixloopS16
endS16:
emms
pop ebx
pop esi
pop edi
}
/* *INDENT-ON* */
}
////////////////////////////////////////////////
// Mixing for 8 bit signed buffers
////////////////////////////////////////////////
void
SDL_MixAudio_MMX_S8_VC(char *dst, char *src, unsigned int nSize, int volume)
{
/* *INDENT-OFF* */
_asm
{
push edi
push esi
push ebx
mov edi, dst //movl %0,%%edi // edi = dst
mov esi, src //%1,%%esi // esi = src
mov eax, volume //%3,%%eax // eax = volume
movd mm0, eax //%%eax,%%mm0
movq mm1, mm0 //%%mm0,%%mm1
psllq mm0, 16 //$16,%%mm0
por mm0, mm1 //%%mm1,%%mm0
psllq mm0, 16 //$16,%%mm0
por mm0, mm1 //%%mm1,%%mm0
psllq mm0, 16 //$16,%%mm0
por mm0, mm1 //%%mm1,%%mm0
mov ebx, nSize //%2,%%ebx // ebx = size
shr ebx, 3 //$3,%%ebx // process 8 bytes per iteration = 8 samples
cmp ebx, 0 //$0,%%ebx
je endS8
#ifndef __WATCOMC__
align 16
#endif
mixloopS8:
pxor mm2, mm2 //%%mm2,%%mm2 // mm2 = 0
movq mm1, [esi] //(%%esi),%%mm1 // mm1 = a|b|c|d|e|f|g|h
movq mm3, mm1 //%%mm1,%%mm3 // mm3 = a|b|c|d|e|f|g|h
// on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0
pcmpgtb mm2, mm1 //%%mm1,%%mm2 // mm2 = 11111111|00000000|00000000....
punpckhbw mm1, mm2 //%%mm2,%%mm1 // mm1 = 0|a|0|b|0|c|0|d
punpcklbw mm3, mm2 //%%mm2,%%mm3 // mm3 = 0|e|0|f|0|g|0|h
movq mm2, [edi] //(%%edi),%%mm2 // mm2 = destination
pmullw mm1, mm0 //%%mm0,%%mm1 // mm1 = v*a|v*b|v*c|v*d
add esi, 8 //$8,%%esi
pmullw mm3, mm0 //%%mm0,%%mm3 // mm3 = v*e|v*f|v*g|v*h
psraw mm1, 7 //$7,%%mm1 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128
psraw mm3, 7 //$7,%%mm3 // mm3 = v*e/128|v*f/128|v*g/128|v*h/128
packsswb mm3, mm1 //%%mm1,%%mm3 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128
paddsb mm3, mm2 //%%mm2,%%mm3 // add to destination buffer
movq [edi], mm3 //%%mm3,(%%edi) // store back to ram
add edi, 8 //$8,%%edi
dec ebx //%%ebx
jnz mixloopS8
endS8:
emms
pop ebx
pop esi
pop edi
}
/* *INDENT-ON* */
}
#endif /* SDL_ASSEMBLY_ROUTINES */
#endif /* SDL_BUGGY_MMX_MIXERS */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,39 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
/* headers for MMX assembler version of SDL_MixAudio
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
Converted to Intel ASM notation by Cth
This code is licensed under the LGPL (see COPYING for details)
Assumes buffer size in bytes is a multiple of 16
Assumes SDL_MIX_MAXVOLUME = 128
*/
void SDL_MixAudio_MMX_S16_VC(char *, char *, unsigned int, int);
void SDL_MixAudio_MMX_S8_VC(char *, char *, unsigned int, int);
#endif
#endif /* SDL_BUGGY_MMX_MIXERS */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,140 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
m68k assembly mix routines
Patrice Mandin
*/
#if defined(__M68000__) && !defined(__mcoldfire__) && defined(__GNUC__)
void
SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume, char *mix8)
{
__asm__ __volatile__("tstl %2\n" " beqs stoploop_u8\n" "mixloop_u8:\n"
/* Mix a sample */
" moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */
" sub #128,%%d0\n" /* d0 -= 128 */
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
" moveb %0@,%%d1\n" /* d1 = *dst */
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
" add #128,%%d0\n" /* d0 += 128 */
" add %%d1,%%d0\n"
" moveb %4@(%%d0:w),%0@+\n"
/* Loop till done */
" subql #1,%2\n" " bhis mixloop_u8\n" "stoploop_u8:\n": /* no return value */
: /* input */
"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8): /* clobbered registers */
"d0", "d1", "cc", "memory");
}
void
SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume)
{
__asm__ __volatile__("tstl %2\n"
" beqs stoploop_s8\n"
" moveq #-128,%%d2\n"
" moveq #127,%%d3\n" "mixloop_s8:\n"
/* Mix a sample */
" moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
" moveb %0@,%%d1\n" /* d1 = *dst */
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
" add %%d1,%%d0\n"
" cmp %%d2,%%d0\n"
" bges lower_limit_s8\n"
" move %%d2,%%d0\n"
"lower_limit_s8:\n"
" cmp %%d3,%%d0\n"
" bles upper_limit_s8\n"
" move %%d3,%%d0\n"
"upper_limit_s8:\n" " moveb %%d0,%0@+\n"
/* Loop till done */
" subql #1,%2\n" " bhis mixloop_s8\n" "stoploop_s8:\n": /* no return value */
: /* input */
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
"d0", "d1", "d2", "d3", "cc", "memory");
}
void
SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume)
{
__asm__ __volatile__("tstl %2\n"
" beqs stoploop_s16msb\n"
" movel #-32768,%%d2\n"
" movel #32767,%%d3\n"
" lsrl #1,%2\n" "mixloop_s16msb:\n"
/* Mix a sample */
" move %1@+,%%d0\n" /* d0 = *src++ */
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
" move %0@,%%d1\n" /* d1 = *dst */
" extl %%d1\n" /* extend d1 to 32 bits */
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
" addl %%d1,%%d0\n"
" cmpl %%d2,%%d0\n"
" bges lower_limit_s16msb\n"
" move %%d2,%%d0\n"
"lower_limit_s16msb:\n"
" cmpl %%d3,%%d0\n"
" bles upper_limit_s16msb\n"
" move %%d3,%%d0\n"
"upper_limit_s16msb:\n" " move %%d0,%0@+\n"
/* Loop till done */
" subql #1,%2\n" " bhis mixloop_s16msb\n" "stoploop_s16msb:\n": /* no return value */
: /* input */
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
"d0", "d1", "d2", "d3", "cc", "memory");
}
void
SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume)
{
__asm__ __volatile__("tstl %2\n"
" beqs stoploop_s16lsb\n"
" movel #-32768,%%d2\n"
" movel #32767,%%d3\n"
" lsrl #1,%2\n" "mixloop_s16lsb:\n"
/* Mix a sample */
" move %1@+,%%d0\n" /* d0 = *src++ */
" rorw #8,%%d0\n" " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
" move %0@,%%d1\n" /* d1 = *dst */
" rorw #8,%%d1\n" " extl %%d1\n" /* extend d1 to 32 bits */
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
" addl %%d1,%%d0\n"
" cmpl %%d2,%%d0\n"
" bges lower_limit_s16lsb\n"
" move %%d2,%%d0\n"
"lower_limit_s16lsb:\n"
" cmpl %%d3,%%d0\n"
" bles upper_limit_s16lsb\n"
" move %%d3,%%d0\n"
"upper_limit_s16lsb:\n"
" rorw #8,%%d0\n" " move %%d0,%0@+\n"
/* Loop till done */
" subql #1,%2\n" " bhis mixloop_s16lsb\n" "stoploop_s16lsb:\n": /* no return value */
: /* input */
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
"d0", "d1", "d2", "d3", "cc", "memory");
}
#endif
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,38 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
m68k assembly mix routines
Patrice Mandin
*/
#if defined(__M68000__) && defined(__GNUC__)
void SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume,
char *mix8);
void SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume);
void SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume);
void SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume);
#endif
/* vi: set ts=4 sw=4 expandtab: */