Skip to content

Commit

Permalink
Add function to check FPU presence
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Sep 16, 2006
1 parent 5d840c7 commit 5e538d2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/audio/mint/SDL_mintaudio.c
Expand Up @@ -32,6 +32,7 @@
#include <mint/osbind.h>
#include <mint/falcon.h>
#include <mint/mintbind.h>
#include <mint/cookie.h>

#include "SDL_audio.h"
#include "SDL_mintaudio.h"
Expand All @@ -46,6 +47,7 @@ volatile unsigned short SDL_MintAudio_numbuf; /* Buffer to play */
volatile unsigned short SDL_MintAudio_mutex;
volatile unsigned long SDL_MintAudio_clocktics;
cookie_stfa_t *SDL_MintAudio_stfa;
unsigned short SDL_MintAudio_hasfpu;

/* MiNT thread variables */
SDL_bool SDL_MintAudio_mint_present;
Expand Down Expand Up @@ -139,6 +141,26 @@ int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq)
return MINTAUDIO_freqcount-1;
}

/* Check if FPU is present */
void SDL_MintAudio_CheckFpu(void)
{
unsigned long cookie_fpu;

SDL_MintAudio_hasfpu = 0;
if (Getcookie(C__FPU, &cookie_fpu) != C_FOUND) {
return;
}
switch ((cookie_fpu>>16)&0xfffe) {
case 2:
case 4:
case 6:
case 8:
case 16:
SDL_MintAudio_hasfpu = 1;
break;
}
}

/* The thread function, used under MiNT with xbios */
int SDL_MintAudio_Thread(long param)
{
Expand Down
2 changes: 2 additions & 0 deletions src/audio/mint/SDL_mintaudio.h
Expand Up @@ -123,6 +123,7 @@ extern volatile unsigned short SDL_MintAudio_numbuf; /* Buffer to play */
extern volatile unsigned short SDL_MintAudio_mutex;
extern cookie_stfa_t *SDL_MintAudio_stfa;
extern volatile unsigned long SDL_MintAudio_clocktics;
extern unsigned short SDL_MintAudio_hasfpu; /* To preserve fpu registers if needed */

/* MiNT thread variables */
extern SDL_bool SDL_MintAudio_mint_present;
Expand All @@ -135,6 +136,7 @@ void SDL_MintAudio_Callback(void);
void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
Uint32 prediv, int gpio_bits);
int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq);
void SDL_MintAudio_CheckFpu(void);

/* MiNT thread functions */
int SDL_MintAudio_Thread(long param);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/mint/SDL_mintaudio_dma8.c
Expand Up @@ -352,6 +352,8 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1]));

SDL_MintAudio_CheckFpu();

/* Setup audio hardware */
Mint_InitAudio(this, spec);

Expand Down
2 changes: 2 additions & 0 deletions src/audio/mint/SDL_mintaudio_gsxb.c
Expand Up @@ -406,6 +406,8 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1]));

SDL_MintAudio_CheckFpu();

/* Setup audio hardware */
Mint_InitAudio(this, spec);

Expand Down
2 changes: 2 additions & 0 deletions src/audio/mint/SDL_mintaudio_mcsn.c
Expand Up @@ -395,6 +395,8 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1]));

SDL_MintAudio_CheckFpu();

/* Setup audio hardware */
Mint_InitAudio(this, spec);

Expand Down
2 changes: 2 additions & 0 deletions src/audio/mint/SDL_mintaudio_stfa.c
Expand Up @@ -314,6 +314,8 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1]));

SDL_MintAudio_CheckFpu();

/* Setup audio hardware */
Mint_InitAudio(this, spec);

Expand Down
2 changes: 2 additions & 0 deletions src/audio/mint/SDL_mintaudio_xbios.c
Expand Up @@ -486,6 +486,8 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1]));

SDL_MintAudio_CheckFpu();

/* Setup audio hardware */
Mint_InitAudio(this, spec);

Expand Down

0 comments on commit 5e538d2

Please sign in to comment.