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.
patmandin@633
     1
/*
patmandin@633
     2
    SDL - Simple DirectMedia Layer
slouken@6137
     3
    Copyright (C) 1997-2012 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@5657
    30
#if (defined(__m68k__) && !defined(__mcoldfire__)) && 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@9013
    85
"	extw	%%d0\n"
patmandin@633
    86
"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
patmandin@633
    87
"	moveb	%0@,%%d1\n"	/* d1 = *dst */
patmandin@633
    88
"	asr	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
patmandin@633
    89
patmandin@633
    90
"	add	%%d1,%%d0\n"
patmandin@633
    91
patmandin@633
    92
"	cmp	%%d2,%%d0\n"
patmandin@633
    93
"	bges	lower_limit_s8\n"
patmandin@633
    94
"	move	%%d2,%%d0\n"
patmandin@633
    95
"lower_limit_s8:\n"
patmandin@633
    96
patmandin@633
    97
"	cmp	%%d3,%%d0\n"
patmandin@633
    98
"	bles	upper_limit_s8\n"
patmandin@633
    99
"	move	%%d3,%%d0\n"
patmandin@633
   100
"upper_limit_s8:\n"
patmandin@633
   101
"	moveb	%%d0,%0@+\n"
patmandin@633
   102
patmandin@633
   103
	/* Loop till done */
patmandin@633
   104
patmandin@633
   105
"	subql	#1,%2\n"
patmandin@633
   106
"	bhis	mixloop_s8\n"
patmandin@633
   107
"stoploop_s8:\n"
patmandin@633
   108
patmandin@633
   109
	 : /* no return value */
patmandin@633
   110
	 : /* input */
patmandin@633
   111
	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
patmandin@633
   112
	 : /* clobbered registers */
patmandin@633
   113
	 	"d0", "d1", "d2", "d3", "cc", "memory" 
patmandin@633
   114
	 );
patmandin@633
   115
}
patmandin@633
   116
patmandin@633
   117
void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume)
patmandin@633
   118
{
patmandin@633
   119
    __asm__ __volatile__ (
patmandin@633
   120
patmandin@633
   121
	"tstl	%2\n"
patmandin@633
   122
"	beqs	stoploop_s16msb\n"
patmandin@633
   123
"	movel	#-32768,%%d2\n"
patmandin@633
   124
"	movel	#32767,%%d3\n"
patmandin@633
   125
"	lsrl	#1,%2\n"
patmandin@633
   126
"mixloop_s16msb:\n"
patmandin@633
   127
patmandin@633
   128
	/* Mix a sample */
patmandin@633
   129
patmandin@633
   130
"	move	%1@+,%%d0\n"	/* d0 = *src++ */
patmandin@633
   131
"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
patmandin@633
   132
"	move	%0@,%%d1\n"	/* d1 = *dst */
patmandin@633
   133
"	extl	%%d1\n"		/* extend d1 to 32 bits */
patmandin@633
   134
"	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
patmandin@633
   135
patmandin@633
   136
"	addl	%%d1,%%d0\n"
patmandin@633
   137
patmandin@633
   138
"	cmpl	%%d2,%%d0\n"
patmandin@633
   139
"	bges	lower_limit_s16msb\n"
patmandin@633
   140
"	move	%%d2,%%d0\n"
patmandin@633
   141
"lower_limit_s16msb:\n"
patmandin@633
   142
patmandin@633
   143
"	cmpl	%%d3,%%d0\n"
patmandin@633
   144
"	bles	upper_limit_s16msb\n"
patmandin@633
   145
"	move	%%d3,%%d0\n"
patmandin@633
   146
"upper_limit_s16msb:\n"
patmandin@633
   147
"	move	%%d0,%0@+\n"
patmandin@633
   148
patmandin@633
   149
	/* Loop till done */
patmandin@633
   150
patmandin@633
   151
"	subql	#1,%2\n"
patmandin@633
   152
"	bhis	mixloop_s16msb\n"
patmandin@633
   153
"stoploop_s16msb:\n"
patmandin@633
   154
patmandin@633
   155
	 : /* no return value */
patmandin@633
   156
	 : /* input */
patmandin@633
   157
	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
patmandin@633
   158
	 : /* clobbered registers */
patmandin@633
   159
	 	"d0", "d1", "d2", "d3", "cc", "memory" 
patmandin@633
   160
	 );
patmandin@633
   161
}
patmandin@633
   162
patmandin@633
   163
void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume)
patmandin@633
   164
{
patmandin@633
   165
    __asm__ __volatile__ (
patmandin@633
   166
patmandin@633
   167
	"tstl	%2\n"
patmandin@633
   168
"	beqs	stoploop_s16lsb\n"
patmandin@633
   169
"	movel	#-32768,%%d2\n"
patmandin@633
   170
"	movel	#32767,%%d3\n"
patmandin@633
   171
"	lsrl	#1,%2\n"
patmandin@633
   172
"mixloop_s16lsb:\n"
patmandin@633
   173
patmandin@633
   174
	/* Mix a sample */
patmandin@633
   175
patmandin@633
   176
"	move	%1@+,%%d0\n"	/* d0 = *src++ */
patmandin@633
   177
"	rorw	#8,%%d0\n"
patmandin@633
   178
"	muls	%3,%%d0\n"	/* d0 *= volume (0<=volume<=128) */
patmandin@633
   179
"	move	%0@,%%d1\n"	/* d1 = *dst */
patmandin@633
   180
"	rorw	#8,%%d1\n"
patmandin@633
   181
"	extl	%%d1\n"		/* extend d1 to 32 bits */
patmandin@633
   182
"	asrl	#7,%%d0\n"	/* d0 /= 128 (SDL_MIX_MAXVOLUME) */
patmandin@633
   183
patmandin@633
   184
"	addl	%%d1,%%d0\n"
patmandin@633
   185
patmandin@633
   186
"	cmpl	%%d2,%%d0\n"
patmandin@633
   187
"	bges	lower_limit_s16lsb\n"
patmandin@633
   188
"	move	%%d2,%%d0\n"
patmandin@633
   189
"lower_limit_s16lsb:\n"
patmandin@633
   190
patmandin@633
   191
"	cmpl	%%d3,%%d0\n"
patmandin@633
   192
"	bles	upper_limit_s16lsb\n"
patmandin@633
   193
"	move	%%d3,%%d0\n"
patmandin@633
   194
"upper_limit_s16lsb:\n"
patmandin@633
   195
"	rorw	#8,%%d0\n"
patmandin@633
   196
"	move	%%d0,%0@+\n"
patmandin@633
   197
patmandin@633
   198
	/* Loop till done */
patmandin@633
   199
patmandin@633
   200
"	subql	#1,%2\n"
patmandin@633
   201
"	bhis	mixloop_s16lsb\n"
patmandin@633
   202
"stoploop_s16lsb:\n"
patmandin@633
   203
patmandin@633
   204
	 : /* no return value */
patmandin@633
   205
	 : /* input */
patmandin@633
   206
	 	"a"(dst), "a"(src), "d"(len), "d"(volume)	
patmandin@633
   207
	 : /* clobbered registers */
patmandin@633
   208
	 	"d0", "d1", "d2", "d3", "cc", "memory" 
patmandin@633
   209
	 );
patmandin@633
   210
}
patmandin@633
   211
#endif