comparison src/audio/SDL_mixer.c @ 539:a9e38f3b8e4d

Added MMX audio mixing code for gcc (thanks Stephane!)
author Sam Lantinga <slouken@libsdl.org>
date Sat, 09 Nov 2002 06:13:28 +0000
parents f6ffac90895c
children 64fe373be3dc
comparison
equal deleted inserted replaced
538:d3abe873e3f7 539:a9e38f3b8e4d
33 33
34 #include "SDL_audio.h" 34 #include "SDL_audio.h"
35 #include "SDL_mutex.h" 35 #include "SDL_mutex.h"
36 #include "SDL_timer.h" 36 #include "SDL_timer.h"
37 #include "SDL_sysaudio.h" 37 #include "SDL_sysaudio.h"
38 38 #include "SDL_mixer_MMX.h"
39
40 /* Function to check the CPU flags */
41 #define MMX_CPU 0x800000
42 #ifdef USE_ASMBLIT
43 #define CPU_Flags() Hermes_X86_CPU()
44 #else
45 #define CPU_Flags() 0L
46 #endif
47
48 #ifdef USE_ASMBLIT
49 #define X86_ASSEMBLER
50 #define HermesConverterInterface void
51 #define HermesClearInterface void
52 #define STACKCALL
53
54 #include "HeadX86.h"
55 #endif
39 56
40 /* This table is used to add two sound values together and pin 57 /* This table is used to add two sound values together and pin
41 * the value to avoid overflow. (used with permission from ARDI) 58 * the value to avoid overflow. (used with permission from ARDI)
42 * Changed to use 0xFE instead of 0xFF for better sound quality. 59 * Changed to use 0xFE instead of 0xFF for better sound quality.
43 */ 60 */
128 } 145 }
129 } 146 }
130 break; 147 break;
131 148
132 case AUDIO_S8: { 149 case AUDIO_S8: {
150
151 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
152 if (CPU_Flags() & MMX_CPU)
153 {
154 SDL_MixAudio_MMX_S8((char*)dst,(char*)src,(unsigned int)len,(int)volume);
155 }
156 else
157 #endif
158 {
133 Sint8 *dst8, *src8; 159 Sint8 *dst8, *src8;
134 Sint8 src_sample; 160 Sint8 src_sample;
135 int dst_sample; 161 int dst_sample;
136 const int max_audioval = ((1<<(8-1))-1); 162 const int max_audioval = ((1<<(8-1))-1);
137 const int min_audioval = -(1<<(8-1)); 163 const int min_audioval = -(1<<(8-1));
151 *dst8 = dst_sample; 177 *dst8 = dst_sample;
152 } 178 }
153 ++dst8; 179 ++dst8;
154 ++src8; 180 ++src8;
155 } 181 }
182 }
156 } 183 }
157 break; 184 break;
158 185
159 case AUDIO_S16LSB: { 186 case AUDIO_S16LSB: {
187 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
188 if (CPU_Flags() & MMX_CPU)
189 {
190 SDL_MixAudio_MMX_S16((char*)dst,(char*)src,(unsigned int)len,(int)volume);
191 }
192 else
193 #endif
194 {
160 Sint16 src1, src2; 195 Sint16 src1, src2;
161 int dst_sample; 196 int dst_sample;
162 const int max_audioval = ((1<<(16-1))-1); 197 const int max_audioval = ((1<<(16-1))-1);
163 const int min_audioval = -(1<<(16-1)); 198 const int min_audioval = -(1<<(16-1));
164 199
178 dst[0] = dst_sample&0xFF; 213 dst[0] = dst_sample&0xFF;
179 dst_sample >>= 8; 214 dst_sample >>= 8;
180 dst[1] = dst_sample&0xFF; 215 dst[1] = dst_sample&0xFF;
181 dst += 2; 216 dst += 2;
182 } 217 }
218 }
183 } 219 }
184 break; 220 break;
185 221
186 case AUDIO_S16MSB: { 222 case AUDIO_S16MSB: {
187 Sint16 src1, src2; 223 Sint16 src1, src2;