src/audio/SDL_mixer_m68k.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 29 May 2006 04:04:35 +0000
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
permissions -rw-r--r--
more tweaking indent options
patmandin@633
     1
/*
patmandin@633
     2
    SDL - Simple DirectMedia Layer
slouken@769
     3
    Copyright (C) 1997-2004 Sam Lantinga
patmandin@633
     4
patmandin@633
     5
    This library is free software; you can redistribute it and/or
patmandin@633
     6
    modify it under the terms of the GNU Library General Public
patmandin@633
     7
    License as published by the Free Software Foundation; either
patmandin@633
     8
    version 2 of the License, or (at your option) any later version.
patmandin@633
     9
patmandin@633
    10
    This library is distributed in the hope that it will be useful,
patmandin@633
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
patmandin@633
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
patmandin@633
    13
    Library General Public License for more details.
patmandin@633
    14
patmandin@633
    15
    You should have received a copy of the GNU Library General Public
patmandin@633
    16
    License along with this library; if not, write to the Free
patmandin@633
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
patmandin@633
    18
patmandin@633
    19
    Sam Lantinga
patmandin@633
    20
    slouken@libsdl.org
patmandin@633
    21
*/
slouken@1402
    22
#include "SDL_config.h"
patmandin@633
    23
patmandin@633
    24
/*
patmandin@633
    25
	m68k assembly mix routines
patmandin@633
    26
patmandin@633
    27
	Patrice Mandin
patmandin@633
    28
*/
patmandin@633
    29
patmandin@633
    30
#if defined(__M68000__) && defined(__GNUC__)
slouken@1662
    31
void
slouken@1668
    32
SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume, char *mix8)
patmandin@633
    33
{
slouken@1668
    34
    __asm__ __volatile__("tstl	%2\n" "	beqs	stoploop_u8\n" "mixloop_u8:\n"
slouken@1668
    35
                         /* Mix a sample */
slouken@1668
    36
                         "	moveq	#0,%%d0\n" "	moveq	#0,%%d1\n" "	moveb	%1@+,%%d0\n"    /* d0 = *src++ */
slouken@1668
    37
                         "	sub	#128,%%d0\n"    /* d0 -= 128 */
slouken@1668
    38
                         "	muls	%3,%%d0\n"      /* d0 *= volume (0<=volume<=128) */
slouken@1668
    39
                         "	moveb	%0@,%%d1\n"     /* d1 = *dst */
slouken@1668
    40
                         "	asr	#7,%%d0\n"      /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
slouken@1668
    41
                         "	add	#128,%%d0\n"    /* d0 += 128 */
slouken@1668
    42
                         "	add	%%d1,%%d0\n"
slouken@1668
    43
                         "	moveb	%4@(%%d0:w),%0@+\n"
slouken@1668
    44
                         /* Loop till done */
slouken@1668
    45
                         "	subql	#1,%2\n" "	bhis	mixloop_u8\n" "stoploop_u8:\n": /* no return value */
slouken@1668
    46
                         :      /* input */
slouken@1668
    47
                         "a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8):  /* clobbered registers */
slouken@1668
    48
                         "d0", "d1", "cc", "memory");
patmandin@633
    49
}
patmandin@633
    50
slouken@1662
    51
void
slouken@1668
    52
SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume)
patmandin@633
    53
{
slouken@1668
    54
    __asm__ __volatile__("tstl	%2\n"
slouken@1668
    55
                         "	beqs	stoploop_s8\n"
slouken@1668
    56
                         "	moveq	#-128,%%d2\n"
slouken@1668
    57
                         "	moveq	#127,%%d3\n" "mixloop_s8:\n"
slouken@1668
    58
                         /* Mix a sample */
slouken@1668
    59
                         "	moveq	#0,%%d0\n" "	moveq	#0,%%d1\n" "	moveb	%1@+,%%d0\n"    /* d0 = *src++ */
slouken@1668
    60
                         "	muls	%3,%%d0\n"      /* d0 *= volume (0<=volume<=128) */
slouken@1668
    61
                         "	moveb	%0@,%%d1\n"     /* d1 = *dst */
slouken@1668
    62
                         "	asr	#7,%%d0\n"      /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
slouken@1668
    63
                         "	add	%%d1,%%d0\n"
slouken@1668
    64
                         "	cmp	%%d2,%%d0\n"
slouken@1668
    65
                         "	bges	lower_limit_s8\n"
slouken@1668
    66
                         "	move	%%d2,%%d0\n"
slouken@1668
    67
                         "lower_limit_s8:\n"
slouken@1668
    68
                         "	cmp	%%d3,%%d0\n"
slouken@1668
    69
                         "	bles	upper_limit_s8\n"
slouken@1668
    70
                         "	move	%%d3,%%d0\n"
slouken@1668
    71
                         "upper_limit_s8:\n" "	moveb	%%d0,%0@+\n"
slouken@1668
    72
                         /* Loop till done */
slouken@1668
    73
                         "	subql	#1,%2\n" "	bhis	mixloop_s8\n" "stoploop_s8:\n": /* no return value */
slouken@1668
    74
                         :      /* input */
slouken@1668
    75
                         "a"(dst), "a"(src), "d"(len), "d"(volume):     /* clobbered registers */
slouken@1668
    76
                         "d0", "d1", "d2", "d3", "cc", "memory");
patmandin@633
    77
}
patmandin@633
    78
slouken@1662
    79
void
slouken@1668
    80
SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume)
patmandin@633
    81
{
slouken@1668
    82
    __asm__ __volatile__("tstl	%2\n"
slouken@1668
    83
                         "	beqs	stoploop_s16msb\n"
slouken@1668
    84
                         "	movel	#-32768,%%d2\n"
slouken@1668
    85
                         "	movel	#32767,%%d3\n"
slouken@1668
    86
                         "	lsrl	#1,%2\n" "mixloop_s16msb:\n"
slouken@1668
    87
                         /* Mix a sample */
slouken@1668
    88
                         "	move	%1@+,%%d0\n"    /* d0 = *src++ */
slouken@1668
    89
                         "	muls	%3,%%d0\n"      /* d0 *= volume (0<=volume<=128) */
slouken@1668
    90
                         "	move	%0@,%%d1\n"     /* d1 = *dst */
slouken@1668
    91
                         "	extl	%%d1\n" /* extend d1 to 32 bits */
slouken@1668
    92
                         "	asrl	#7,%%d0\n"      /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
slouken@1668
    93
                         "	addl	%%d1,%%d0\n"
slouken@1668
    94
                         "	cmpl	%%d2,%%d0\n"
slouken@1668
    95
                         "	bges	lower_limit_s16msb\n"
slouken@1668
    96
                         "	move	%%d2,%%d0\n"
slouken@1668
    97
                         "lower_limit_s16msb:\n"
slouken@1668
    98
                         "	cmpl	%%d3,%%d0\n"
slouken@1668
    99
                         "	bles	upper_limit_s16msb\n"
slouken@1668
   100
                         "	move	%%d3,%%d0\n"
slouken@1668
   101
                         "upper_limit_s16msb:\n" "	move	%%d0,%0@+\n"
slouken@1668
   102
                         /* Loop till done */
slouken@1668
   103
                         "	subql	#1,%2\n" "	bhis	mixloop_s16msb\n" "stoploop_s16msb:\n": /* no return value */
slouken@1668
   104
                         :      /* input */
slouken@1668
   105
                         "a"(dst), "a"(src), "d"(len), "d"(volume):     /* clobbered registers */
slouken@1668
   106
                         "d0", "d1", "d2", "d3", "cc", "memory");
patmandin@633
   107
}
patmandin@633
   108
slouken@1662
   109
void
slouken@1668
   110
SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume)
patmandin@633
   111
{
slouken@1668
   112
    __asm__ __volatile__("tstl	%2\n"
slouken@1668
   113
                         "	beqs	stoploop_s16lsb\n"
slouken@1668
   114
                         "	movel	#-32768,%%d2\n"
slouken@1668
   115
                         "	movel	#32767,%%d3\n"
slouken@1668
   116
                         "	lsrl	#1,%2\n" "mixloop_s16lsb:\n"
slouken@1668
   117
                         /* Mix a sample */
slouken@1668
   118
                         "	move	%1@+,%%d0\n"    /* d0 = *src++ */
slouken@1668
   119
                         "	rorw	#8,%%d0\n" "	muls	%3,%%d0\n"      /* d0 *= volume (0<=volume<=128) */
slouken@1668
   120
                         "	move	%0@,%%d1\n"     /* d1 = *dst */
slouken@1668
   121
                         "	rorw	#8,%%d1\n" "	extl	%%d1\n" /* extend d1 to 32 bits */
slouken@1668
   122
                         "	asrl	#7,%%d0\n"      /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
slouken@1668
   123
                         "	addl	%%d1,%%d0\n"
slouken@1668
   124
                         "	cmpl	%%d2,%%d0\n"
slouken@1668
   125
                         "	bges	lower_limit_s16lsb\n"
slouken@1668
   126
                         "	move	%%d2,%%d0\n"
slouken@1668
   127
                         "lower_limit_s16lsb:\n"
slouken@1668
   128
                         "	cmpl	%%d3,%%d0\n"
slouken@1668
   129
                         "	bles	upper_limit_s16lsb\n"
slouken@1668
   130
                         "	move	%%d3,%%d0\n"
slouken@1668
   131
                         "upper_limit_s16lsb:\n"
slouken@1668
   132
                         "	rorw	#8,%%d0\n" "	move	%%d0,%0@+\n"
slouken@1668
   133
                         /* Loop till done */
slouken@1668
   134
                         "	subql	#1,%2\n" "	bhis	mixloop_s16lsb\n" "stoploop_s16lsb:\n": /* no return value */
slouken@1668
   135
                         :      /* input */
slouken@1668
   136
                         "a"(dst), "a"(src), "d"(len), "d"(volume):     /* clobbered registers */
slouken@1668
   137
                         "d0", "d1", "d2", "d3", "cc", "memory");
patmandin@633
   138
}
patmandin@633
   139
#endif
slouken@1662
   140
/* vi: set ts=4 sw=4 expandtab: */