Skip to content

Commit 7555a16

Browse files
author
lantus360
committed
added xenon controller code, took another stab at audio
1 parent cc9a19e commit 7555a16

File tree

4 files changed

+330
-29
lines changed

4 files changed

+330
-29
lines changed

Makefile.xenon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Makefile to build the SDL library
22

3-
INCLUDE = -I./include -I./src/video -I./src/audio
3+
INCLUDE = -I./include -I./src/video -I./src/audio -I./src/joystick
44
CFLAGS = -g -O2 $(INCLUDE)
55
CC = xenon-gcc
66
AR = xenon-ar
@@ -27,7 +27,7 @@ SOURCES = \
2727
src/audio/xenon/*.c \
2828
src/video/xenon/*.c \
2929
src/video/xenon/*.s \
30-
src/joystick/dummy/*.c \
30+
src/joystick/xenon/*.c \
3131
src/cdrom/dummy/*.c \
3232
src/thread/xenon/*.c \
3333
src/loadso/dummy/*.c \

include/SDL_config_xenon.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ typedef unsigned int size_t;
4040

4141
#define HAVE_MMAP 0
4242

43-
#define SDL_BYTEORDER SDL_BIG_ENDIAN
43+
#define SDL_BYTEORDER SDL_BIG_ENDIAN
4444
#define SDL_CDROM_DISABLED 1
45-
#define SDL_JOYSTICK_DISABLED 1
4645
#define SDL_LOADSO_DISABLED 1
4746
#define SDL_THREADS_DISABLED 1 //ugh
4847
#define SDL_AUDIO_DRIVER_XENON 1

src/audio/xenon/SDL_xenonaudio.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#include "SDL_audio.h"
2929
#include "SDL_audio_c.h"
3030
#include "SDL_xenonaudio.h"
31+
32+
33+
3134

3235
/* Audio driver functions */
3336
static int XENON_OpenAudio(_THIS, SDL_AudioSpec *spec);
@@ -113,11 +116,14 @@ static void XENON_WaitAudio_BusyWait(_THIS)
113116

114117
static void XENON_PlayAudio(_THIS)
115118
{
116-
memcpy(&pAudioBuffers[currentBuffer * mixlen], locked_buf, mixlen);
117119

118-
while(xenon_sound_get_unplayed()>(4*mixlen)) udelay(50);
119120

120-
xenon_sound_submit(&pAudioBuffers[currentBuffer * mixlen], mixlen);
121+
//while(xenon_sound_get_unplayed()>(4*mixlen)) udelay(50);
122+
123+
124+
memcpy(&pAudioBuffers[currentBuffer * mixlen], locked_buf, mixlen);
125+
xenon_sound_submit(&pAudioBuffers[currentBuffer * mixlen], mixlen);
126+
121127

122128
currentBuffer++;
123129
currentBuffer %= (NUM_BUFFERS);
@@ -163,35 +169,21 @@ static void XENON_CloseAudio(_THIS)
163169
static int XENON_OpenAudio(_THIS, SDL_AudioSpec *spec)
164170
{
165171

166-
/* Determine the audio parameters from the AudioSpec */
167-
switch ( spec->format & 0xFF ) {
168-
case 8:
169-
/* Unsigned 8 bit audio data */
170-
spec->format = AUDIO_U8;
171-
silence = 0x80;
172-
break;
173-
case 16:
174-
/* Signed 16 bit audio data */
175-
spec->format = AUDIO_S16;
176-
silence = 0x00;
177-
break;
178-
default:
179-
SDL_SetError("Unsupported audio format");
180-
return(-1);
181-
}
182-
172+
// Set up actual spec.
173+
spec->freq = 48000;
174+
spec->format = AUDIO_S16MSB;
175+
spec->channels = 2;
176+
183177
/* Update the fragment size as size in bytes */
184178
SDL_CalculateAudioSpec(spec);
185179

186-
locked_buf = (unsigned char *)malloc(spec->size);
180+
locked_buf = (unsigned char *)malloc(spec->size * 4);
187181

188182
/* Create the audio buffer to which we write */
189-
NUM_BUFFERS = -1;
183+
NUM_BUFFERS = 2;
190184

191-
if ( NUM_BUFFERS < 0 )
192-
NUM_BUFFERS = 4;
193185

194-
pAudioBuffers = (unsigned char *)malloc(spec->size*NUM_BUFFERS);
186+
pAudioBuffers = (unsigned char *)malloc(spec->size *NUM_BUFFERS * 4);
195187
playing = 0;
196188
mixlen = spec->size;
197189

0 commit comments

Comments
 (0)