Skip to content
Permalink
Browse files

Greatly simplified the SDL CPU info code

  • Loading branch information
slouken committed Nov 24, 2003
1 parent 03c29e6 commit 83e36e7aad82b05924432690ce04bcc390d81738
Showing with 5 additions and 58 deletions.
  1. +2 −2 src/audio/SDL_mixer.c
  2. +2 −52 src/audio/SDL_mixer_MMX_VC.c
  3. +1 −4 src/audio/SDL_mixer_MMX_VC.h
@@ -146,7 +146,7 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
else
#endif
#if defined(USE_ASM_MIXER_VC)
if (SDL_IsMMX_VC())
if (SDL_HasMMX())
{
SDL_MixAudio_MMX_S8_VC((char*)dst,(char*)src,(unsigned int)len,(int)volume);
}
@@ -192,7 +192,7 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
}
else
#elif defined(USE_ASM_MIXER_VC)
if (SDL_IsMMX_VC())
if (SDL_HasMMX())
{
SDL_MixAudio_MMX_S16_VC((char*)dst,(char*)src,(unsigned int)len,(int)volume);
}
@@ -1,3 +1,4 @@
#if defined(USE_ASM_MIXER_VC)
// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
// Converted to Intel ASM notation by Cth
@@ -11,7 +12,6 @@
// Mixing for 16 bit signed buffers
////////////////////////////////////////////////

#if defined(USE_ASM_MIXER_VC)
#include <windows.h>
#include <stdio.h>

@@ -152,54 +152,4 @@ void SDL_MixAudio_MMX_S8_VC(char* dst,char* src,unsigned int nSize,int volume)
}
}

int _SDL_IsMMX_VC()
{
// This bit flag can get set on calling cpuid
// with register eax set to 1
const int _MMX_FEATURE_BIT = 0x00800000;
DWORD dwFeature = 0;
__try {
_asm {
mov eax,1
cpuid
mov dwFeature,edx
}
} __except ( EXCEPTION_EXECUTE_HANDLER) {
return 0;
}
if (dwFeature & _MMX_FEATURE_BIT) {
__try {
__asm {
pxor mm0, mm0
emms
}
} __except (EXCEPTION_EXECUTE_HANDLER) {
return(0);
}
return 1;
}

return 0;
}

static int _notTwice = 2;

int SDL_IsMMX_VC()
{
if (_notTwice > 1)
{
_notTwice = _SDL_IsMMX_VC();
/*
#ifdef _DEBUG
if (_notTwice)
MessageBox( NULL, "Using MMX!!!", "Error", MB_OK | MB_ICONINFORMATION );
else
MessageBox( NULL, "Not sing MMX!!!", "Error", MB_OK | MB_ICONINFORMATION );
#endif
*/
}
return _notTwice;
}

#endif

#endif /* USE_ASM_MIXER_VC */
@@ -1,3 +1,4 @@
#if defined(USE_ASM_MIXER_VC)
// headers for MMX assembler version of SDL_MixAudio
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
// Converted to Intel ASM notation by Cth
@@ -6,10 +7,6 @@
// Assumes buffer size in bytes is a multiple of 16
// Assumes SDL_MIX_MAXVOLUME = 128

#if defined(USE_ASM_MIXER_VC)
void SDL_MixAudio_MMX_S16_VC(char* ,char* ,unsigned int ,int );
void SDL_MixAudio_MMX_S8_VC(char* ,char* ,unsigned int ,int );
int SDL_IsMMX_VC();
#endif


0 comments on commit 83e36e7

Please sign in to comment.