diff --git a/SDL/Makefile b/SDL/Makefile index c28bd38..af63183 100644 --- a/SDL/Makefile +++ b/SDL/Makefile @@ -87,7 +87,7 @@ $(BIN_DIR)/%.dol: $(TEST_OBJ_DIR)/%.elf # Compilation flags. COMMON_FLAGS := -g -O2 -mrvl -Wall -mcpu=750 -meabi -mhard-float $(MACHDEP) INCLUDES := -Iinclude -I$(DEVKITPRO)/libogc/include -DEFINES := -DGEKKO -DSDL_AUDIO_DRIVER_WII +DEFINES := -DGEKKO CFLAGS := $(COMMON_FLAGS) $(INCLUDES) $(DEFINES) # Test link flags. diff --git a/SDL/include/SDL_config_wii.h b/SDL/include/SDL_config_wii.h index 987d20a..5f2872e 100644 --- a/SDL/include/SDL_config_wii.h +++ b/SDL/include/SDL_config_wii.h @@ -88,11 +88,10 @@ typedef unsigned int uintptr_t; #define HAVE_SETJMP 1 /* Supported audio drivers. */ -/* #define SDL_AUDIO_DRIVER_WII 1 */ -#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_WII 1 /* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ -#define SDL_CDROM_DISABLED 1 +#define SDL_CDROM_DUMMY 1 /* Enable the wii joystick driver */ #define SDL_JOYSTICK_WII 1 @@ -102,10 +101,8 @@ typedef unsigned int uintptr_t; /* Enable thread support */ #define SDL_THREAD_WII 1 -/*#define SDL_THREADS_DISABLED */ /* Supported video drivers. */ #define SDL_VIDEO_DRIVER_WII 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 #endif /* _SDL_config_minimal_h */ diff --git a/SDL/src/audio/wii/SDL_wiiaudio.c b/SDL/src/audio/wii/SDL_wiiaudio.c index d56e744..b00a573 100644 --- a/SDL/src/audio/wii/SDL_wiiaudio.c +++ b/SDL/src/audio/wii/SDL_wiiaudio.c @@ -140,11 +140,6 @@ static int WIIAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) spec->padding = 0; SDL_CalculateAudioSpec(spec); - // Initialise the Wii side of the audio system. - AUDIO_Init(0); - AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); - AUDIO_RegisterDMACallback(DMACallback); - memset(dma_buffers[0], 0, SAMPLES_PER_DMA_BUFFER); memset(dma_buffers[1], 0, SAMPLES_PER_DMA_BUFFER); @@ -174,9 +169,6 @@ static Uint8 *WIIAUD_GetAudioBuf(_THIS) static void WIIAUD_CloseAudio(_THIS) { - // Forget the DMA callback - AUDIO_RegisterDMACallback(0); - // Stop any DMA going on AUDIO_StopDMA(); @@ -192,6 +184,9 @@ static void WIIAUD_DeleteDevice(SDL_AudioDevice *device) // Stop any DMA going on AUDIO_StopDMA(); + // terminate conversion thread + LWP_ThreadSignal(audioqueue); + SDL_free(device->hidden); SDL_free(device); } @@ -216,6 +211,11 @@ static SDL_AudioDevice *WIIAUD_CreateDevice(int devindex) } SDL_memset(this->hidden, 0, (sizeof *this->hidden)); + // Initialise the Wii side of the audio system + AUDIO_Init(0); + AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); + AUDIO_RegisterDMACallback(DMACallback); + /* Set the function pointers */ this->OpenAudio = WIIAUD_OpenAudio; this->WaitAudio = WIIAUD_WaitAudio; diff --git a/SDL/src/joystick/wii/SDL_sysjoystick.c b/SDL/src/joystick/wii/SDL_sysjoystick.c index aaffabd..974b2cb 100644 --- a/SDL/src/joystick/wii/SDL_sysjoystick.c +++ b/SDL/src/joystick/wii/SDL_sysjoystick.c @@ -87,17 +87,16 @@ static int __jspad_enabled = 1; static int __numwiijoysticks = 4; static int __numgcjoysticks = 4; -static int __scan_pads_callback_set = 0; +static int __num_joysticks_open = 0; /* Function to scan the system for joysticks. - * This function should set SDL_numjoysticks to the number of available + * This function should return the number of available * joysticks. Joystick 0 should be the system default joystick. - * It should return 0, or -1 on an unrecoverable fatal error. + * It should return -1 on an unrecoverable fatal error. */ int SDL_SYS_JoystickInit(void) { - SDL_numjoysticks = 8; - return 0; + return 8; } static char joy_name[] = "Gamecube 0"; @@ -159,8 +158,9 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) } /* Update pads at vertical retrace */ - VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB); - __scan_pads_callback_set++; + if(__num_joysticks_open == 0) + VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB); + __num_joysticks_open++; return(0); } @@ -398,8 +398,8 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick) SDL_free(joystick->hwdata); /* Clear callback again */ - __scan_pads_callback_set--; - if ( __scan_pads_callback_set == 0 ) + __num_joysticks_open--; + if (__num_joysticks_open == 0) VIDEO_SetPostRetraceCallback (NULL); }