src/audio/SDL_mixer_m68k.c
author Sam Lantinga <slouken@libsdl.org>
Tue, 21 Feb 2006 08:46:50 +0000
changeset 1402 d910939febfa
parent 769 b8d311d90021
child 1662 782fd950bd46
child 1895 c121d94672cb
child 4159 a1b03ba2fcd0
permissions -rw-r--r--
Use consistent identifiers for the various platforms we support.
Make sure every source file includes SDL_config.h, so the proper system
headers are chosen.
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__)
patmandin@633
    31
void SDL_MixAudio_m68k_U8(char* dst, char* src, long len, long volume, char* mix8)
patmandin@633
    32
{
patmandin@633
    33
    __asm__ __volatile__ (
patmandin@633
    34
patmandin@633
    35
	"tstl	%2\n"
patmandin@633
    36
"	beqs	stoploop_u8\n"
patmandin@633
    37
"mixloop_u8:\n"
patmandin@633
    38
patmandin@633
    39
	/* Mix a sample */
patmandin@633
    40
patmandin@633
    41
"	moveq	#0,%%d0\n"
patmandin@633
    42
"	moveq	#0,%%d1\n"
patmandin@633
    43
patmandin@633
    44
"	moveb	%1@+,%%d0\n"	/* d0 = *src++ */
patmandin@633
    45
"	sub	#128,%%d0\n"	/* d0 -= 128 */
patmandin@633
    46
"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
patmandin@633
    47
"	moveb	%0@,%%d1\n"	/* d1 = *dst */
patmandin@633
    48
"	asr	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
patmandin@633
    49
"	add	#128,%%d0\n"	/* d0 += 128 */
patmandin@633
    50
patmandin@633
    51
"	add	%%d1,%%d0\n"
patmandin@633
    52
patmandin@633
    53
"	moveb	%4@(%%d0:w),%0@+\n"
patmandin@633
    54
patmandin@633
    55
	/* Loop till done */
patmandin@633
    56
patmandin@633
    57
"	subql	#1,%2\n"
patmandin@633
    58
"	bhis	mixloop_u8\n"
patmandin@633
    59
"stoploop_u8:\n"
patmandin@633
    60
patmandin@633
    61
	 : /* no return value */
patmandin@633
    62
	 : /* input */
patmandin@633
    63
	 	"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8)	
patmandin@633
    64
	 : /* clobbered registers */
patmandin@633
    65
	 	"d0", "d1", "cc", "memory" 
patmandin@633
    66
	 );
patmandin@633
    67
}
patmandin@633
    68
patmandin@633
    69
void SDL_MixAudio_m68k_S8(char* dst, char* src, long len, long volume)
patmandin@633
    70
{
patmandin@633
    71
    __asm__ __volatile__ (
patmandin@633
    72
patmandin@633
    73
	"tstl	%2\n"
patmandin@633
    74
"	beqs	stoploop_s8\n"
patmandin@633
    75
"	moveq	#-128,%%d2\n"
patmandin@633
    76
"	moveq	#127,%%d3\n"
patmandin@633
    77
"mixloop_s8:\n"
patmandin@633
    78
patmandin@633
    79
	/* Mix a sample */
patmandin@633
    80
patmandin@633
    81
"	moveq	#0,%%d0\n"
patmandin@633
    82
"	moveq	#0,%%d1\n"
patmandin@633
    83
patmandin@633
    84
"	moveb	%1@+,%%d0\n"	/* d0 = *src++ */
patmandin@633
    85
"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
patmandin@633
    86
"	moveb	%0@,%%d1\n"	/* d1 = *dst */
patmandin@633
    87
"	asr	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
patmandin@633
    88
patmandin@633
    89
"	add	%%d1,%%d0\n"
patmandin@633
    90
patmandin@633
    91
"	cmp	%%d2,%%d0\n"
patmandin@633
    92
"	bges	lower_limit_s8\n"
patmandin@633
    93
"	move	%%d2,%%d0\n"
patmandin@633
    94
"lower_limit_s8:\n"
patmandin@633
    95
patmandin@633
    96
"	cmp	%%d3,%%d0\n"
patmandin@633
    97
"	bles	upper_limit_s8\n"
patmandin@633
    98
"	move	%%d3,%%d0\n"
patmandin@633
    99
"upper_limit_s8:\n"
patmandin@633
   100
"	moveb	%%d0,%0@+\n"
patmandin@633
   101
patmandin@633
   102
	/* Loop till done */
patmandin@633
   103
patmandin@633
   104
"	subql	#1,%2\n"
patmandin@633
   105
"	bhis	mixloop_s8\n"
patmandin@633
   106
"stoploop_s8:\n"
patmandin@633
   107
patmandin@633
   108
	 : /* no return value */
patmandin@633
   109
	 : /* input */
patmandin@633
   110
	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
patmandin@633
   111
	 : /* clobbered registers */
patmandin@633
   112
	 	"d0", "d1", "d2", "d3", "cc", "memory" 
patmandin@633
   113
	 );
patmandin@633
   114
}
patmandin@633
   115
patmandin@633
   116
void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume)
patmandin@633
   117
{
patmandin@633
   118
    __asm__ __volatile__ (
patmandin@633
   119
patmandin@633
   120
	"tstl	%2\n"
patmandin@633
   121
"	beqs	stoploop_s16msb\n"
patmandin@633
   122
"	movel	#-32768,%%d2\n"
patmandin@633
   123
"	movel	#32767,%%d3\n"
patmandin@633
   124
"	lsrl	#1,%2\n"
patmandin@633
   125
"mixloop_s16msb:\n"
patmandin@633
   126
patmandin@633
   127
	/* Mix a sample */
patmandin@633
   128
patmandin@633
   129
"	move	%1@+,%%d0\n"	/* d0 = *src++ */
patmandin@633
   130
"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
patmandin@633
   131
"	move	%0@,%%d1\n"	/* d1 = *dst */
patmandin@633
   132
"	extl	%%d1\n"		/* extend d1 to 32 bits */
patmandin@633
   133
"	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
patmandin@633
   134
patmandin@633
   135
"	addl	%%d1,%%d0\n"
patmandin@633
   136
patmandin@633
   137
"	cmpl	%%d2,%%d0\n"
patmandin@633
   138
"	bges	lower_limit_s16msb\n"
patmandin@633
   139
"	move	%%d2,%%d0\n"
patmandin@633
   140
"lower_limit_s16msb:\n"
patmandin@633
   141
patmandin@633
   142
"	cmpl	%%d3,%%d0\n"
patmandin@633
   143
"	bles	upper_limit_s16msb\n"
patmandin@633
   144
"	move	%%d3,%%d0\n"
patmandin@633
   145
"upper_limit_s16msb:\n"
patmandin@633
   146
"	move	%%d0,%0@+\n"
patmandin@633
   147
patmandin@633
   148
	/* Loop till done */
patmandin@633
   149
patmandin@633
   150
"	subql	#1,%2\n"
patmandin@633
   151
"	bhis	mixloop_s16msb\n"
patmandin@633
   152
"stoploop_s16msb:\n"
patmandin@633
   153
patmandin@633
   154
	 : /* no return value */
patmandin@633
   155
	 : /* input */
patmandin@633
   156
	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
patmandin@633
   157
	 : /* clobbered registers */
patmandin@633
   158
	 	"d0", "d1", "d2", "d3", "cc", "memory" 
patmandin@633
   159
	 );
patmandin@633
   160
}
patmandin@633
   161
patmandin@633
   162
void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume)
patmandin@633
   163
{
patmandin@633
   164
    __asm__ __volatile__ (
patmandin@633
   165
patmandin@633
   166
	"tstl	%2\n"
patmandin@633
   167
"	beqs	stoploop_s16lsb\n"
patmandin@633
   168
"	movel	#-32768,%%d2\n"
patmandin@633
   169
"	movel	#32767,%%d3\n"
patmandin@633
   170
"	lsrl	#1,%2\n"
patmandin@633
   171
"mixloop_s16lsb:\n"
patmandin@633
   172
patmandin@633
   173
	/* Mix a sample */
patmandin@633
   174
patmandin@633
   175
"	move	%1@+,%%d0\n"	/* d0 = *src++ */
patmandin@633
   176
"	rorw	#8,%%d0\n"
patmandin@633
   177
"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
patmandin@633
   178
"	move	%0@,%%d1\n"	/* d1 = *dst */
patmandin@633
   179
"	rorw	#8,%%d1\n"
patmandin@633
   180
"	extl	%%d1\n"		/* extend d1 to 32 bits */
patmandin@633
   181
"	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
patmandin@633
   182
patmandin@633
   183
"	addl	%%d1,%%d0\n"
patmandin@633
   184
patmandin@633
   185
"	cmpl	%%d2,%%d0\n"
patmandin@633
   186
"	bges	lower_limit_s16lsb\n"
patmandin@633
   187
"	move	%%d2,%%d0\n"
patmandin@633
   188
"lower_limit_s16lsb:\n"
patmandin@633
   189
patmandin@633
   190
"	cmpl	%%d3,%%d0\n"
patmandin@633
   191
"	bles	upper_limit_s16lsb\n"
patmandin@633
   192
"	move	%%d3,%%d0\n"
patmandin@633
   193
"upper_limit_s16lsb:\n"
patmandin@633
   194
"	rorw	#8,%%d0\n"
patmandin@633
   195
"	move	%%d0,%0@+\n"
patmandin@633
   196
patmandin@633
   197
	/* Loop till done */
patmandin@633
   198
patmandin@633
   199
"	subql	#1,%2\n"
patmandin@633
   200
"	bhis	mixloop_s16lsb\n"
patmandin@633
   201
"stoploop_s16lsb:\n"
patmandin@633
   202
patmandin@633
   203
	 : /* no return value */
patmandin@633
   204
	 : /* input */
patmandin@633
   205
	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
patmandin@633
   206
	 : /* clobbered registers */
patmandin@633
   207
	 	"d0", "d1", "d2", "d3", "cc", "memory" 
patmandin@633
   208
	 );
patmandin@633
   209
}
patmandin@633
   210
#endif
patmandin@633
   211