comparison src/audio/SDL_mixer_MMX_VC.c @ 746:72ef7ce609ef

Greatly simplified the SDL CPU info code
author Sam Lantinga <slouken@libsdl.org>
date Mon, 24 Nov 2003 09:22:12 +0000
parents 64fe373be3dc
children b4117292e587
comparison
equal deleted inserted replaced
745:71ee03909f42 746:72ef7ce609ef
1 #if defined(USE_ASM_MIXER_VC)
1 // MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples 2 // MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
2 // Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) 3 // Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
3 // Converted to Intel ASM notation by Cth 4 // Converted to Intel ASM notation by Cth
4 // This code is licensed under the LGPL (see COPYING for details) 5 // This code is licensed under the LGPL (see COPYING for details)
5 // 6 //
9 10
10 //////////////////////////////////////////////// 11 ////////////////////////////////////////////////
11 // Mixing for 16 bit signed buffers 12 // Mixing for 16 bit signed buffers
12 //////////////////////////////////////////////// 13 ////////////////////////////////////////////////
13 14
14 #if defined(USE_ASM_MIXER_VC)
15 #include <windows.h> 15 #include <windows.h>
16 #include <stdio.h> 16 #include <stdio.h>
17 17
18 void SDL_MixAudio_MMX_S16_VC(char* dst,char* src,unsigned int nSize,int volume) 18 void SDL_MixAudio_MMX_S16_VC(char* dst,char* src,unsigned int nSize,int volume)
19 { 19 {
150 pop esi 150 pop esi
151 pop edi 151 pop edi
152 } 152 }
153 } 153 }
154 154
155 int _SDL_IsMMX_VC() 155 #endif /* USE_ASM_MIXER_VC */
156 {
157 // This bit flag can get set on calling cpuid
158 // with register eax set to 1
159 const int _MMX_FEATURE_BIT = 0x00800000;
160 DWORD dwFeature = 0;
161 __try {
162 _asm {
163 mov eax,1
164 cpuid
165 mov dwFeature,edx
166 }
167 } __except ( EXCEPTION_EXECUTE_HANDLER) {
168 return 0;
169 }
170 if (dwFeature & _MMX_FEATURE_BIT) {
171 __try {
172 __asm {
173 pxor mm0, mm0
174 emms
175 }
176 } __except (EXCEPTION_EXECUTE_HANDLER) {
177 return(0);
178 }
179 return 1;
180 }
181
182 return 0;
183 }
184
185 static int _notTwice = 2;
186
187 int SDL_IsMMX_VC()
188 {
189 if (_notTwice > 1)
190 {
191 _notTwice = _SDL_IsMMX_VC();
192 /*
193 #ifdef _DEBUG
194 if (_notTwice)
195 MessageBox( NULL, "Using MMX!!!", "Error", MB_OK | MB_ICONINFORMATION );
196 else
197 MessageBox( NULL, "Not sing MMX!!!", "Error", MB_OK | MB_ICONINFORMATION );
198 #endif
199 */
200 }
201 return _notTwice;
202 }
203
204 #endif
205