forked from KolibriOS/kolibrios
wolf3d:
- Now used standart SDL timer functions; - Removed old files and useless functions. git-svn-id: svn://kolibrios.org@9790 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2f26d486e6
commit
9ba1adb152
@ -1,14 +1,18 @@
|
||||
CC = kos32-gcc
|
||||
LD = kos32-ld
|
||||
OBJCOPY = kos32-objcopy
|
||||
KPACK = kpack
|
||||
|
||||
SDK_DIR = $(abspath ../../sdk)
|
||||
|
||||
CFLAGS = -c -fno-ident -O2 -fomit-frame-pointer -fno-ident -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -D_KOLIBRI
|
||||
LDFLAGS = -static -S -nostdlib -T $(SDK_DIR)/sources/newlib/app.lds --image-base 0
|
||||
LDFLAGS = -static -S -nostdlib -T $(SDK_DIR)/sources/newlib/app.lds --image-base 0 --subsystem native
|
||||
|
||||
INCLUDES = -I$(SDK_DIR)/sources/newlib/libc/include -I$(SDK_DIR)/sources/SDL-1.2.2_newlib/include -I. -I SDL_mixer
|
||||
LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib -L $(SDK_DIR)/lib
|
||||
|
||||
TARGET = bin/wolf3d
|
||||
|
||||
OBJECTS += wl_cloudsky.o
|
||||
OBJECTS += wl_debug.o
|
||||
OBJECTS += id_sd.o
|
||||
@ -40,10 +44,6 @@ OBJECTS += joystick_stub.o
|
||||
OBJECTS += kolibri.o
|
||||
OBJECTS += mame/fmopl.o
|
||||
|
||||
SDL_OBJ += SDL/SDL_wave.o
|
||||
SDL_OBJ += SDL/SDL_audiocvt.o
|
||||
SDL_OBJ += SDL/SDL_mixer.o
|
||||
SDL_OBJ += SDL/uSDL.o
|
||||
|
||||
SDL_MIX_OBJ += SDL_mixer/mixer.o
|
||||
SDL_MIX_OBJ += SDL_mixer/music.o
|
||||
@ -52,10 +52,12 @@ SDL_MIX_OBJ += SDL_mixer/load_voc.o
|
||||
SDL_MIX_OBJ += SDL_mixer/effects_internal.o
|
||||
SDL_MIX_OBJ += SDL_mixer/effect_position.o
|
||||
|
||||
default: $(OBJECTS) $(SDL_MIX_OBJ) $(SDL_OBJ)
|
||||
kos32-ld $(LDFLAGS) $(LIBPATH) --subsystem native -o bin/wolf3d $(OBJECTS) $(SDL_MIX_OBJ) $(SDL_OBJ) -lSDLn -lsound -lstdc++ -lsupc++ -lgcc -lc.dll
|
||||
objcopy bin/wolf3d -O binary
|
||||
kpack --nologo bin/wolf3d
|
||||
LIBS = -lSDLn -lsound -lgcc -lc.dll
|
||||
|
||||
$(TARGET): $(OBJECTS) $(SDL_MIX_OBJ) $(SDL_OBJ)
|
||||
$(LD) $(LDFLAGS) $(LIBPATH) -o $(TARGET) $(OBJECTS) $(SDL_MIX_OBJ) $(SDL_OBJ) $(LIBS)
|
||||
$(OBJCOPY) $(TARGET) -O binary
|
||||
$(KPACK) --nologo $(TARGET)
|
||||
|
||||
%.o : %.cpp
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $<
|
||||
@ -64,4 +66,4 @@ default: $(OBJECTS) $(SDL_MIX_OBJ) $(SDL_OBJ)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm *.o SDL_mixer/*.o mame/*.o SDL/*.o *.d SDL_mixer/*.d mame/*.d SDL/*.d
|
||||
rm -f $(OBJECTS)
|
||||
|
@ -1,642 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_audiocvt.c,v 1.2 2001/04/26 16:50:17 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* Functions for audio drivers to perform runtime conversion of audio format */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_audio.h"
|
||||
|
||||
|
||||
/* Effectively mix right and left channels into a single channel */
|
||||
void SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Sint32 sample;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting to mono\n");
|
||||
#endif
|
||||
switch (format&0x8018) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
dst = cvt->buf;
|
||||
for ( i=cvt->len_cvt/2; i; --i ) {
|
||||
sample = src[0] + src[1];
|
||||
if ( sample > 255 ) {
|
||||
*dst = 255;
|
||||
} else {
|
||||
*dst = sample;
|
||||
}
|
||||
src += 2;
|
||||
dst += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
Sint8 *src, *dst;
|
||||
|
||||
src = (Sint8 *)cvt->buf;
|
||||
dst = (Sint8 *)cvt->buf;
|
||||
for ( i=cvt->len_cvt/2; i; --i ) {
|
||||
sample = src[0] + src[1];
|
||||
if ( sample > 127 ) {
|
||||
*dst = 127;
|
||||
} else
|
||||
if ( sample < -128 ) {
|
||||
*dst = -128;
|
||||
} else {
|
||||
*dst = sample;
|
||||
}
|
||||
src += 2;
|
||||
dst += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_U16: {
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
dst = cvt->buf;
|
||||
if ( (format & 0x1000) == 0x1000 ) {
|
||||
for ( i=cvt->len_cvt/4; i; --i ) {
|
||||
sample = (Uint16)((src[0]<<8)|src[1])+
|
||||
(Uint16)((src[2]<<8)|src[3]);
|
||||
if ( sample > 65535 ) {
|
||||
dst[0] = 0xFF;
|
||||
dst[1] = 0xFF;
|
||||
} else {
|
||||
dst[1] = (sample&0xFF);
|
||||
sample >>= 8;
|
||||
dst[0] = (sample&0xFF);
|
||||
}
|
||||
src += 4;
|
||||
dst += 2;
|
||||
}
|
||||
} else {
|
||||
for ( i=cvt->len_cvt/4; i; --i ) {
|
||||
sample = (Uint16)((src[1]<<8)|src[0])+
|
||||
(Uint16)((src[3]<<8)|src[2]);
|
||||
if ( sample > 65535 ) {
|
||||
dst[0] = 0xFF;
|
||||
dst[1] = 0xFF;
|
||||
} else {
|
||||
dst[0] = (sample&0xFF);
|
||||
sample >>= 8;
|
||||
dst[1] = (sample&0xFF);
|
||||
}
|
||||
src += 4;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16: {
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
dst = cvt->buf;
|
||||
if ( (format & 0x1000) == 0x1000 ) {
|
||||
for ( i=cvt->len_cvt/4; i; --i ) {
|
||||
sample = (Sint16)((src[0]<<8)|src[1])+
|
||||
(Sint16)((src[2]<<8)|src[3]);
|
||||
if ( sample > 32767 ) {
|
||||
dst[0] = 0x7F;
|
||||
dst[1] = 0xFF;
|
||||
} else
|
||||
if ( sample < -32768 ) {
|
||||
dst[0] = 0x80;
|
||||
dst[1] = 0x00;
|
||||
} else {
|
||||
dst[1] = (sample&0xFF);
|
||||
sample >>= 8;
|
||||
dst[0] = (sample&0xFF);
|
||||
}
|
||||
src += 4;
|
||||
dst += 2;
|
||||
}
|
||||
} else {
|
||||
for ( i=cvt->len_cvt/4; i; --i ) {
|
||||
sample = (Sint16)((src[1]<<8)|src[0])+
|
||||
(Sint16)((src[3]<<8)|src[2]);
|
||||
if ( sample > 32767 ) {
|
||||
dst[1] = 0x7F;
|
||||
dst[0] = 0xFF;
|
||||
} else
|
||||
if ( sample < -32768 ) {
|
||||
dst[1] = 0x80;
|
||||
dst[0] = 0x00;
|
||||
} else {
|
||||
dst[0] = (sample&0xFF);
|
||||
sample >>= 8;
|
||||
dst[1] = (sample&0xFF);
|
||||
}
|
||||
src += 4;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
cvt->len_cvt /= 2;
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Duplicate a mono channel to both stereo channels */
|
||||
void SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting to stereo\n");
|
||||
#endif
|
||||
if ( (format & 0xFF) == 16 ) {
|
||||
Uint16 *src, *dst;
|
||||
|
||||
src = (Uint16 *)(cvt->buf+cvt->len_cvt);
|
||||
dst = (Uint16 *)(cvt->buf+cvt->len_cvt*2);
|
||||
for ( i=cvt->len_cvt/2; i; --i ) {
|
||||
dst -= 2;
|
||||
src -= 1;
|
||||
dst[0] = src[0];
|
||||
dst[1] = src[0];
|
||||
}
|
||||
} else {
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf+cvt->len_cvt;
|
||||
dst = cvt->buf+cvt->len_cvt*2;
|
||||
for ( i=cvt->len_cvt; i; --i ) {
|
||||
dst -= 2;
|
||||
src -= 1;
|
||||
dst[0] = src[0];
|
||||
dst[1] = src[0];
|
||||
}
|
||||
}
|
||||
cvt->len_cvt *= 2;
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert 8-bit to 16-bit - LSB */
|
||||
void SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting to 16-bit LSB\n");
|
||||
#endif
|
||||
src = cvt->buf+cvt->len_cvt;
|
||||
dst = cvt->buf+cvt->len_cvt*2;
|
||||
for ( i=cvt->len_cvt; i; --i ) {
|
||||
src -= 1;
|
||||
dst -= 2;
|
||||
dst[1] = *src;
|
||||
dst[0] = 0;
|
||||
}
|
||||
format = ((format & ~0x0008) | AUDIO_U16LSB);
|
||||
cvt->len_cvt *= 2;
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
/* Convert 8-bit to 16-bit - MSB */
|
||||
void SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting to 16-bit MSB\n");
|
||||
#endif
|
||||
src = cvt->buf+cvt->len_cvt;
|
||||
dst = cvt->buf+cvt->len_cvt*2;
|
||||
for ( i=cvt->len_cvt; i; --i ) {
|
||||
src -= 1;
|
||||
dst -= 2;
|
||||
dst[0] = *src;
|
||||
dst[1] = 0;
|
||||
}
|
||||
format = ((format & ~0x0008) | AUDIO_U16MSB);
|
||||
cvt->len_cvt *= 2;
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert 16-bit to 8-bit */
|
||||
void SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting to 8-bit\n");
|
||||
#endif
|
||||
src = cvt->buf;
|
||||
dst = cvt->buf;
|
||||
if ( (format & 0x1000) != 0x1000 ) { /* Little endian */
|
||||
++src;
|
||||
}
|
||||
for ( i=cvt->len_cvt/2; i; --i ) {
|
||||
*dst = *src;
|
||||
src += 2;
|
||||
dst += 1;
|
||||
}
|
||||
format = ((format & ~0x9010) | AUDIO_U8);
|
||||
cvt->len_cvt /= 2;
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Toggle signed/unsigned */
|
||||
void SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *data;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting audio signedness\n");
|
||||
#endif
|
||||
data = cvt->buf;
|
||||
if ( (format & 0xFF) == 16 ) {
|
||||
if ( (format & 0x1000) != 0x1000 ) { /* Little endian */
|
||||
++data;
|
||||
}
|
||||
for ( i=cvt->len_cvt/2; i; --i ) {
|
||||
*data ^= 0x80;
|
||||
data += 2;
|
||||
}
|
||||
} else {
|
||||
for ( i=cvt->len_cvt; i; --i ) {
|
||||
*data++ ^= 0x80;
|
||||
}
|
||||
}
|
||||
format = (format ^ 0x8000);
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Toggle endianness */
|
||||
void SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *data, tmp;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting audio endianness\n");
|
||||
#endif
|
||||
data = cvt->buf;
|
||||
for ( i=cvt->len_cvt/2; i; --i ) {
|
||||
tmp = data[0];
|
||||
data[0] = data[1];
|
||||
data[1] = tmp;
|
||||
data += 2;
|
||||
}
|
||||
format = (format ^ 0x1000);
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert rate up by multiple of 2 */
|
||||
void SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting audio rate * 2\n");
|
||||
#endif
|
||||
src = cvt->buf+cvt->len_cvt;
|
||||
dst = cvt->buf+cvt->len_cvt*2;
|
||||
switch (format & 0xFF) {
|
||||
case 8:
|
||||
for ( i=cvt->len_cvt; i; --i ) {
|
||||
src -= 1;
|
||||
dst -= 2;
|
||||
dst[0] = src[0];
|
||||
dst[1] = src[0];
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for ( i=cvt->len_cvt/2; i; --i ) {
|
||||
src -= 2;
|
||||
dst -= 4;
|
||||
dst[0] = src[0];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
dst[3] = src[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
cvt->len_cvt *= 2;
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert rate down by multiple of 2 */
|
||||
void SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting audio rate / 2\n");
|
||||
#endif
|
||||
src = cvt->buf;
|
||||
dst = cvt->buf;
|
||||
switch (format & 0xFF) {
|
||||
case 8:
|
||||
for ( i=cvt->len_cvt/2; i; --i ) {
|
||||
dst[0] = src[0];
|
||||
src += 2;
|
||||
dst += 1;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for ( i=cvt->len_cvt/4; i; --i ) {
|
||||
dst[0] = src[0];
|
||||
dst[1] = src[1];
|
||||
src += 4;
|
||||
dst += 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
cvt->len_cvt /= 2;
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Very slow rate conversion routine */
|
||||
void SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
|
||||
{
|
||||
double ipos;
|
||||
int i, clen;
|
||||
|
||||
#ifdef DEBUG_CONVERT
|
||||
fprintf(stderr, "Converting audio rate * %4.4f\n", 1.0/cvt->rate_incr);
|
||||
#endif
|
||||
clen = (int)((double)cvt->len_cvt / cvt->rate_incr);
|
||||
if ( cvt->rate_incr > 1.0 ) {
|
||||
switch (format & 0xFF) {
|
||||
case 8: {
|
||||
Uint8 *output;
|
||||
|
||||
output = cvt->buf;
|
||||
ipos = 0.0;
|
||||
for ( i=clen; i; --i ) {
|
||||
*output = cvt->buf[(int)ipos];
|
||||
ipos += cvt->rate_incr;
|
||||
output += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 16: {
|
||||
Uint16 *output;
|
||||
|
||||
clen &= ~1;
|
||||
output = (Uint16 *)cvt->buf;
|
||||
ipos = 0.0;
|
||||
for ( i=clen/2; i; --i ) {
|
||||
*output=((Uint16 *)cvt->buf)[(int)ipos];
|
||||
ipos += cvt->rate_incr;
|
||||
output += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (format & 0xFF) {
|
||||
case 8: {
|
||||
Uint8 *output;
|
||||
|
||||
output = cvt->buf+clen;
|
||||
ipos = (double)cvt->len_cvt;
|
||||
for ( i=clen; i; --i ) {
|
||||
ipos -= cvt->rate_incr;
|
||||
output -= 1;
|
||||
*output = cvt->buf[(int)ipos];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 16: {
|
||||
Uint16 *output;
|
||||
|
||||
clen &= ~1;
|
||||
output = (Uint16 *)(cvt->buf+clen);
|
||||
ipos = (double)cvt->len_cvt/2;
|
||||
for ( i=clen/2; i; --i ) {
|
||||
ipos -= cvt->rate_incr;
|
||||
output -= 1;
|
||||
*output=((Uint16 *)cvt->buf)[(int)ipos];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
cvt->len_cvt = clen;
|
||||
if ( cvt->filters[++cvt->filter_index] ) {
|
||||
cvt->filters[cvt->filter_index](cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_ConvertAudio(SDL_AudioCVT *cvt)
|
||||
{
|
||||
/* Make sure there's data to convert */
|
||||
if ( cvt->buf == NULL ) {
|
||||
SDL_SetError("No buffer allocated for conversion");
|
||||
return(-1);
|
||||
}
|
||||
/* Return okay if no conversion is necessary */
|
||||
cvt->len_cvt = cvt->len;
|
||||
if ( cvt->filters[0] == NULL ) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Set up the conversion and go! */
|
||||
cvt->filter_index = 0;
|
||||
cvt->filters[0](cvt, cvt->src_format);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Creates a set of audio filters to convert from one format to another.
|
||||
Returns -1 if the format conversion is not supported, or 1 if the
|
||||
audio filter is set up.
|
||||
*/
|
||||
|
||||
int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
Uint16 src_format, Uint8 src_channels, int src_rate,
|
||||
Uint16 dst_format, Uint8 dst_channels, int dst_rate)
|
||||
{
|
||||
/* Start off with no conversion necessary */
|
||||
cvt->needed = 0;
|
||||
cvt->filter_index = 0;
|
||||
cvt->filters[0] = NULL;
|
||||
cvt->len_mult = 1;
|
||||
cvt->len_ratio = 1.0;
|
||||
|
||||
/* First filter: Endian conversion from src to dst */
|
||||
if ( (src_format & 0x1000) != (dst_format & 0x1000)
|
||||
&& ((src_format & 0xff) != 8) ) {
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertEndian;
|
||||
}
|
||||
|
||||
/* Second filter: Sign conversion -- signed/unsigned */
|
||||
if ( (src_format & 0x8000) != (dst_format & 0x8000) ) {
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertSign;
|
||||
}
|
||||
|
||||
/* Next filter: Convert 16 bit <--> 8 bit PCM */
|
||||
if ( (src_format & 0xFF) != (dst_format & 0xFF) ) {
|
||||
switch (dst_format&0x10FF) {
|
||||
case AUDIO_U8:
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_Convert8;
|
||||
cvt->len_ratio /= 2;
|
||||
break;
|
||||
case AUDIO_U16LSB:
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_Convert16LSB;
|
||||
cvt->len_mult *= 2;
|
||||
cvt->len_ratio *= 2;
|
||||
break;
|
||||
case AUDIO_U16MSB:
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_Convert16MSB;
|
||||
cvt->len_mult *= 2;
|
||||
cvt->len_ratio *= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Last filter: Mono/Stereo conversion */
|
||||
if ( src_channels != dst_channels ) {
|
||||
while ( (src_channels*2) <= dst_channels ) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertStereo;
|
||||
cvt->len_mult *= 2;
|
||||
src_channels *= 2;
|
||||
cvt->len_ratio *= 2;
|
||||
}
|
||||
/* This assumes that 4 channel audio is in the format:
|
||||
Left {front/back} + Right {front/back}
|
||||
so converting to L/R stereo works properly.
|
||||
*/
|
||||
while ( ((src_channels%2) == 0) &&
|
||||
((src_channels/2) >= dst_channels) ) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertMono;
|
||||
src_channels /= 2;
|
||||
cvt->len_ratio /= 2;
|
||||
}
|
||||
if ( src_channels != dst_channels ) {
|
||||
/* Uh oh.. */;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do rate conversion */
|
||||
cvt->rate_incr = 0.0;
|
||||
if ( (src_rate/100) != (dst_rate/100) ) {
|
||||
Uint32 hi_rate, lo_rate;
|
||||
int len_mult;
|
||||
double len_ratio;
|
||||
void (*rate_cvt)(SDL_AudioCVT *cvt, Uint16 format);
|
||||
|
||||
if ( src_rate > dst_rate ) {
|
||||
hi_rate = src_rate;
|
||||
lo_rate = dst_rate;
|
||||
rate_cvt = SDL_RateDIV2;
|
||||
len_mult = 1;
|
||||
len_ratio = 0.5;
|
||||
} else {
|
||||
hi_rate = dst_rate;
|
||||
lo_rate = src_rate;
|
||||
rate_cvt = SDL_RateMUL2;
|
||||
len_mult = 2;
|
||||
len_ratio = 2.0;
|
||||
}
|
||||
/* If hi_rate = lo_rate*2^x then conversion is easy */
|
||||
while ( ((lo_rate*2)/100) <= (hi_rate/100) ) {
|
||||
cvt->filters[cvt->filter_index++] = rate_cvt;
|
||||
cvt->len_mult *= len_mult;
|
||||
lo_rate *= 2;
|
||||
cvt->len_ratio *= len_ratio;
|
||||
}
|
||||
/* We may need a slow conversion here to finish up */
|
||||
if ( (lo_rate/100) != (hi_rate/100) ) {
|
||||
#if 1
|
||||
/* The problem with this is that if the input buffer is
|
||||
say 1K, and the conversion rate is say 1.1, then the
|
||||
output buffer is 1.1K, which may not be an acceptable
|
||||
buffer size for the audio driver (not a power of 2)
|
||||
*/
|
||||
/* For now, punt and hope the rate distortion isn't great.
|
||||
*/
|
||||
#else
|
||||
if ( src_rate < dst_rate ) {
|
||||
cvt->rate_incr = (double)lo_rate/hi_rate;
|
||||
cvt->len_mult *= 2;
|
||||
cvt->len_ratio /= cvt->rate_incr;
|
||||
} else {
|
||||
cvt->rate_incr = (double)hi_rate/lo_rate;
|
||||
cvt->len_ratio *= cvt->rate_incr;
|
||||
}
|
||||
cvt->filters[cvt->filter_index++] = SDL_RateSLOW;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up the filter information */
|
||||
if ( cvt->filter_index != 0 ) {
|
||||
cvt->needed = 1;
|
||||
cvt->src_format = src_format;
|
||||
cvt->dst_format = dst_format;
|
||||
cvt->len = 0;
|
||||
cvt->buf = NULL;
|
||||
cvt->filters[cvt->filter_index] = NULL;
|
||||
}
|
||||
return(cvt->needed);
|
||||
}
|
@ -1,218 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_mixer.c,v 1.2 2001/04/26 16:50:17 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* This provides the default mixing callback for the SDL audio routines */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_sysaudio.h"
|
||||
|
||||
SDL_AudioDevice *current_audio = NULL;
|
||||
|
||||
/* This table is used to add two sound values together and pin
|
||||
* the value to avoid overflow. (used with permission from ARDI)
|
||||
* Changed to use 0xFE instead of 0xFF for better sound quality.
|
||||
*/
|
||||
static const Uint8 mix8[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
|
||||
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
|
||||
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
|
||||
0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
|
||||
0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
|
||||
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
|
||||
0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
|
||||
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
|
||||
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C,
|
||||
0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92,
|
||||
0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D,
|
||||
0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8,
|
||||
0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
|
||||
0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9,
|
||||
0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4,
|
||||
0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
|
||||
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
|
||||
0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
|
||||
0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE
|
||||
};
|
||||
|
||||
/* The volume ranges from 0 - 128 */
|
||||
#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME)
|
||||
#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
|
||||
|
||||
void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
||||
{
|
||||
Uint16 format;
|
||||
|
||||
if ( volume == 0 ) {
|
||||
return;
|
||||
}
|
||||
/* Mix the user-level audio format */
|
||||
if ( current_audio ) {
|
||||
if ( current_audio->convert.needed ) {
|
||||
format = current_audio->convert.src_format;
|
||||
} else {
|
||||
format = current_audio->spec.format;
|
||||
}
|
||||
} else {
|
||||
format = AUDIO_S16;
|
||||
}
|
||||
format = AUDIO_S16;
|
||||
switch (format) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
Uint8 src_sample;
|
||||
|
||||
while ( len-- ) {
|
||||
src_sample = *src;
|
||||
ADJUST_VOLUME_U8(src_sample, volume);
|
||||
*dst = mix8[*dst+src_sample];
|
||||
++dst;
|
||||
++src;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
Sint8 *dst8, *src8;
|
||||
Sint8 src_sample;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(8-1))-1);
|
||||
const int min_audioval = -(1<<(8-1));
|
||||
|
||||
src8 = (Sint8 *)src;
|
||||
dst8 = (Sint8 *)dst;
|
||||
while ( len-- ) {
|
||||
src_sample = *src8;
|
||||
ADJUST_VOLUME(src_sample, volume);
|
||||
dst_sample = *dst8 + src_sample;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
*dst8 = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
*dst8 = min_audioval;
|
||||
} else {
|
||||
*dst8 = dst_sample;
|
||||
}
|
||||
++dst8;
|
||||
++src8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16LSB: {
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(16-1))-1);
|
||||
const int min_audioval = -(1<<(16-1));
|
||||
|
||||
len /= 2;
|
||||
while ( len-- ) {
|
||||
src1 = ((src[1])<<8|src[0]);
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = ((dst[1])<<8|dst[0]);
|
||||
src += 2;
|
||||
dst_sample = src1+src2;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
dst_sample = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[0] = dst_sample&0xFF;
|
||||
dst_sample >>= 8;
|
||||
dst[1] = dst_sample&0xFF;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16MSB: {
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(16-1))-1);
|
||||
const int min_audioval = -(1<<(16-1));
|
||||
|
||||
len /= 2;
|
||||
while ( len-- ) {
|
||||
src1 = ((src[0])<<8|src[1]);
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = ((dst[0])<<8|dst[1]);
|
||||
src += 2;
|
||||
dst_sample = src1+src2;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
dst_sample = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[1] = dst_sample&0xFF;
|
||||
dst_sample >>= 8;
|
||||
dst[0] = dst_sample&0xFF;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* If this happens... FIXME! */
|
||||
SDL_SetError("SDL_MixAudio(): unknown audio format");
|
||||
return;
|
||||
}
|
||||
}
|
@ -1,150 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_sysaudio.h,v 1.8 2001/07/23 02:58:42 slouken Exp $";
|
||||
#endif
|
||||
|
||||
#ifndef _SDL_sysaudio_h
|
||||
#define _SDL_sysaudio_h
|
||||
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_thread.h"
|
||||
|
||||
/* The SDL audio driver */
|
||||
typedef struct SDL_AudioDevice SDL_AudioDevice;
|
||||
|
||||
/* Define the SDL audio driver structure */
|
||||
#define _THIS SDL_AudioDevice *_this
|
||||
#ifndef _STATUS
|
||||
#define _STATUS SDL_status *status
|
||||
#endif
|
||||
struct SDL_AudioDevice {
|
||||
/* * * */
|
||||
/* The name of this audio driver */
|
||||
const char *name;
|
||||
|
||||
/* * * */
|
||||
/* The description of this audio driver */
|
||||
const char *desc;
|
||||
|
||||
/* * * */
|
||||
/* Public driver functions */
|
||||
int (*OpenAudio)(_THIS, SDL_AudioSpec *spec);
|
||||
void (*ThreadInit)(_THIS); /* Called by audio thread at start */
|
||||
void (*WaitAudio)(_THIS);
|
||||
void (*PlayAudio)(_THIS);
|
||||
Uint8 *(*GetAudioBuf)(_THIS);
|
||||
void (*WaitDone)(_THIS);
|
||||
void (*CloseAudio)(_THIS);
|
||||
|
||||
/* * * */
|
||||
/* Data common to all devices */
|
||||
|
||||
/* The current audio specification (shared with audio thread) */
|
||||
SDL_AudioSpec spec;
|
||||
|
||||
/* An audio conversion block for audio format emulation */
|
||||
SDL_AudioCVT convert;
|
||||
|
||||
/* Current state flags */
|
||||
int enabled;
|
||||
int paused;
|
||||
int opened;
|
||||
|
||||
/* Fake audio buffer for when the audio hardware is busy */
|
||||
Uint8 *fake_stream;
|
||||
|
||||
/* A semaphore for locking the mixing buffers */
|
||||
SDL_mutex *mixer_lock;
|
||||
|
||||
/* A thread to feed the audio device */
|
||||
SDL_Thread *thread;
|
||||
Uint32 threadid;
|
||||
|
||||
/* * * */
|
||||
/* Data private to this driver */
|
||||
struct SDL_PrivateAudioData *hidden;
|
||||
|
||||
/* * * */
|
||||
/* The function used to dispose of this structure */
|
||||
void (*free)(_THIS);
|
||||
};
|
||||
#undef _THIS
|
||||
|
||||
typedef struct AudioBootStrap {
|
||||
const char *name;
|
||||
const char *desc;
|
||||
int (*available)(void);
|
||||
SDL_AudioDevice *(*create)(int devindex);
|
||||
} AudioBootStrap;
|
||||
|
||||
#ifdef OPENBSD_AUDIO_SUPPORT
|
||||
extern AudioBootStrap OPENBSD_AUDIO_bootstrap;
|
||||
#endif
|
||||
#ifdef OSS_SUPPORT
|
||||
extern AudioBootStrap DSP_bootstrap;
|
||||
extern AudioBootStrap DMA_bootstrap;
|
||||
#endif
|
||||
#ifdef ALSA_SUPPORT
|
||||
extern AudioBootStrap ALSA_bootstrap;
|
||||
#endif
|
||||
#if (defined(unix) && !defined(__CYGWIN32__)) && \
|
||||
!defined(OSS_SUPPORT) && !defined(ALSA_SUPPORT)
|
||||
extern AudioBootStrap AUDIO_bootstrap;
|
||||
#endif
|
||||
#ifdef ARTSC_SUPPORT
|
||||
extern AudioBootStrap ARTSC_bootstrap;
|
||||
#endif
|
||||
#ifdef ESD_SUPPORT
|
||||
extern AudioBootStrap ESD_bootstrap;
|
||||
#endif
|
||||
#ifdef NAS_SUPPORT
|
||||
extern AudioBootStrap NAS_bootstrap;
|
||||
#endif
|
||||
#ifdef ENABLE_DIRECTX
|
||||
extern AudioBootStrap DSOUND_bootstrap;
|
||||
#endif
|
||||
#ifdef ENABLE_WINDIB
|
||||
extern AudioBootStrap WAVEOUT_bootstrap;
|
||||
#endif
|
||||
#ifdef _AIX
|
||||
extern AudioBootStrap Paud_bootstrap;
|
||||
#endif
|
||||
#ifdef __BEOS__
|
||||
extern AudioBootStrap BAUDIO_bootstrap;
|
||||
#endif
|
||||
#if defined(macintosh) || TARGET_API_MAC_CARBON
|
||||
extern AudioBootStrap SNDMGR_bootstrap;
|
||||
#endif
|
||||
#ifdef ENABLE_AHI
|
||||
extern AudioBootStrap AHI_bootstrap;
|
||||
#endif
|
||||
#ifdef DISKAUD_SUPPORT
|
||||
extern AudioBootStrap DISKAUD_bootstrap;
|
||||
#endif
|
||||
|
||||
/* This is the current audio device */
|
||||
extern SDL_AudioDevice *current_audio;
|
||||
|
||||
#endif /* _SDL_sysaudio_h */
|
@ -1,591 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_wave.c,v 1.2 2001/04/26 16:50:17 hercules Exp $";
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_FILE
|
||||
|
||||
/* Microsoft WAVE file loading routines */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_wave.h"
|
||||
#include "SDL_endian.h"
|
||||
|
||||
#ifndef NELEMS
|
||||
#define NELEMS(array) ((sizeof array)/(sizeof array[0]))
|
||||
#endif
|
||||
|
||||
static int ReadChunk(SDL_RWops *src, Chunk *chunk);
|
||||
|
||||
struct MS_ADPCM_decodestate {
|
||||
Uint8 hPredictor;
|
||||
Uint16 iDelta;
|
||||
Sint16 iSamp1;
|
||||
Sint16 iSamp2;
|
||||
};
|
||||
static struct MS_ADPCM_decoder {
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
Uint16 wNumCoef;
|
||||
Sint16 aCoeff[7][2];
|
||||
/* * * */
|
||||
struct MS_ADPCM_decodestate state[2];
|
||||
} MS_ADPCM_state;
|
||||
|
||||
static int InitMS_ADPCM(WaveFMT *format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
Uint16 extra_info;
|
||||
int i;
|
||||
|
||||
/* Set the rogue pointer to the MS_ADPCM specific data */
|
||||
MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||||
MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||||
MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||||
MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
|
||||
MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
|
||||
MS_ADPCM_state.wavefmt.bitspersample =
|
||||
SDL_SwapLE16(format->bitspersample);
|
||||
rogue_feel = (Uint8 *)format+sizeof(*format);
|
||||
if ( sizeof(*format) == 16 ) {
|
||||
extra_info = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
MS_ADPCM_state.wNumCoef = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
if ( MS_ADPCM_state.wNumCoef != 7 ) {
|
||||
SDL_SetError("Unknown set of MS_ADPCM coefficients");
|
||||
return(-1);
|
||||
}
|
||||
for ( i=0; i<MS_ADPCM_state.wNumCoef; ++i ) {
|
||||
MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
||||
Uint8 nybble, Sint16 *coeff)
|
||||
{
|
||||
const Sint32 max_audioval = ((1<<(16-1))-1);
|
||||
const Sint32 min_audioval = -(1<<(16-1));
|
||||
const Sint32 adaptive[] = {
|
||||
230, 230, 230, 230, 307, 409, 512, 614,
|
||||
768, 614, 512, 409, 307, 230, 230, 230
|
||||
};
|
||||
Sint32 new_sample, delta;
|
||||
|
||||
new_sample = ((state->iSamp1 * coeff[0]) +
|
||||
(state->iSamp2 * coeff[1]))/256;
|
||||
if ( nybble & 0x08 ) {
|
||||
new_sample += state->iDelta * (nybble-0x10);
|
||||
} else {
|
||||
new_sample += state->iDelta * nybble;
|
||||
}
|
||||
if ( new_sample < min_audioval ) {
|
||||
new_sample = min_audioval;
|
||||
} else
|
||||
if ( new_sample > max_audioval ) {
|
||||
new_sample = max_audioval;
|
||||
}
|
||||
delta = ((Sint32)state->iDelta * adaptive[nybble])/256;
|
||||
if ( delta < 16 ) {
|
||||
delta = 16;
|
||||
}
|
||||
state->iDelta = delta;
|
||||
state->iSamp2 = state->iSamp1;
|
||||
state->iSamp1 = new_sample;
|
||||
return(new_sample);
|
||||
}
|
||||
|
||||
static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
struct MS_ADPCM_decodestate *state[2];
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
Sint8 nybble, stereo;
|
||||
Sint16 *coeff[2];
|
||||
Sint32 new_sample;
|
||||
|
||||
/* Allocate the proper sized output buffer */
|
||||
encoded_len = *audio_len;
|
||||
encoded = *audio_buf;
|
||||
freeable = *audio_buf;
|
||||
*audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) *
|
||||
MS_ADPCM_state.wSamplesPerBlock*
|
||||
MS_ADPCM_state.wavefmt.channels*sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *)malloc(*audio_len);
|
||||
if ( *audio_buf == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
/* Get ready... Go! */
|
||||
stereo = (MS_ADPCM_state.wavefmt.channels == 2);
|
||||
state[0] = &MS_ADPCM_state.state[0];
|
||||
state[1] = &MS_ADPCM_state.state[stereo];
|
||||
while ( encoded_len >= MS_ADPCM_state.wavefmt.blockalign ) {
|
||||
/* Grab the initial information for this block */
|
||||
state[0]->hPredictor = *encoded++;
|
||||
if ( stereo ) {
|
||||
state[1]->hPredictor = *encoded++;
|
||||
}
|
||||
state[0]->iDelta = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iDelta = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
state[0]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
state[0]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor];
|
||||
coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
|
||||
|
||||
/* Store the two initial samples we start with */
|
||||
decoded[0] = state[0]->iSamp2&0xFF;
|
||||
decoded[1] = state[0]->iSamp2>>8;
|
||||
decoded += 2;
|
||||
if ( stereo ) {
|
||||
decoded[0] = state[1]->iSamp2&0xFF;
|
||||
decoded[1] = state[1]->iSamp2>>8;
|
||||
decoded += 2;
|
||||
}
|
||||
decoded[0] = state[0]->iSamp1&0xFF;
|
||||
decoded[1] = state[0]->iSamp1>>8;
|
||||
decoded += 2;
|
||||
if ( stereo ) {
|
||||
decoded[0] = state[1]->iSamp1&0xFF;
|
||||
decoded[1] = state[1]->iSamp1>>8;
|
||||
decoded += 2;
|
||||
}
|
||||
|
||||
/* Decode and store the other samples in this block */
|
||||
samplesleft = (MS_ADPCM_state.wSamplesPerBlock-2)*
|
||||
MS_ADPCM_state.wavefmt.channels;
|
||||
while ( samplesleft > 0 ) {
|
||||
nybble = (*encoded)>>4;
|
||||
new_sample = MS_ADPCM_nibble(state[0],nybble,coeff[0]);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2;
|
||||
|
||||
nybble = (*encoded)&0x0F;
|
||||
new_sample = MS_ADPCM_nibble(state[1],nybble,coeff[1]);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2;
|
||||
|
||||
++encoded;
|
||||
samplesleft -= 2;
|
||||
}
|
||||
encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
|
||||
}
|
||||
free(freeable);
|
||||
return(0);
|
||||
}
|
||||
|
||||
struct IMA_ADPCM_decodestate {
|
||||
Sint32 sample;
|
||||
Sint8 index;
|
||||
};
|
||||
static struct IMA_ADPCM_decoder {
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
/* * * */
|
||||
struct IMA_ADPCM_decodestate state[2];
|
||||
} IMA_ADPCM_state;
|
||||
|
||||
static int InitIMA_ADPCM(WaveFMT *format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
Uint16 extra_info;
|
||||
|
||||
/* Set the rogue pointer to the IMA_ADPCM specific data */
|
||||
IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||||
IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||||
IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||||
IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
|
||||
IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
|
||||
IMA_ADPCM_state.wavefmt.bitspersample =
|
||||
SDL_SwapLE16(format->bitspersample);
|
||||
rogue_feel = (Uint8 *)format+sizeof(*format);
|
||||
if ( sizeof(*format) == 16 ) {
|
||||
extra_info = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
|
||||
{
|
||||
const Sint32 max_audioval = ((1<<(16-1))-1);
|
||||
const Sint32 min_audioval = -(1<<(16-1));
|
||||
const int index_table[16] = {
|
||||
-1, -1, -1, -1,
|
||||
2, 4, 6, 8,
|
||||
-1, -1, -1, -1,
|
||||
2, 4, 6, 8
|
||||
};
|
||||
const Sint32 step_table[89] = {
|
||||
7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
|
||||
34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
|
||||
143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
|
||||
449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
|
||||
1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
|
||||
3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
|
||||
9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
|
||||
22385, 24623, 27086, 29794, 32767
|
||||
};
|
||||
Sint32 delta, step;
|
||||
|
||||
/* Compute difference and new sample value */
|
||||
step = step_table[state->index];
|
||||
delta = step >> 3;
|
||||
if ( nybble & 0x04 ) delta += step;
|
||||
if ( nybble & 0x02 ) delta += (step >> 1);
|
||||
if ( nybble & 0x01 ) delta += (step >> 2);
|
||||
if ( nybble & 0x08 ) delta = -delta;
|
||||
state->sample += delta;
|
||||
|
||||
/* Update index value */
|
||||
state->index += index_table[nybble];
|
||||
if ( state->index > 88 ) {
|
||||
state->index = 88;
|
||||
} else
|
||||
if ( state->index < 0 ) {
|
||||
state->index = 0;
|
||||
}
|
||||
|
||||
/* Clamp output sample */
|
||||
if ( state->sample > max_audioval ) {
|
||||
state->sample = max_audioval;
|
||||
} else
|
||||
if ( state->sample < min_audioval ) {
|
||||
state->sample = min_audioval;
|
||||
}
|
||||
return(state->sample);
|
||||
}
|
||||
|
||||
/* Fill the decode buffer with a channel block of data (8 samples) */
|
||||
static void Fill_IMA_ADPCM_block(Uint8 *decoded, Uint8 *encoded,
|
||||
int channel, int numchannels, struct IMA_ADPCM_decodestate *state)
|
||||
{
|
||||
int i;
|
||||
Sint8 nybble;
|
||||
Sint32 new_sample;
|
||||
|
||||
decoded += (channel * 2);
|
||||
for ( i=0; i<4; ++i ) {
|
||||
nybble = (*encoded)&0x0F;
|
||||
new_sample = IMA_ADPCM_nibble(state, nybble);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2 * numchannels;
|
||||
|
||||
nybble = (*encoded)>>4;
|
||||
new_sample = IMA_ADPCM_nibble(state, nybble);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2 * numchannels;
|
||||
|
||||
++encoded;
|
||||
}
|
||||
}
|
||||
|
||||
static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
struct IMA_ADPCM_decodestate *state;
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
int c, channels;
|
||||
|
||||
/* Check to make sure we have enough variables in the state array */
|
||||
channels = IMA_ADPCM_state.wavefmt.channels;
|
||||
if ( channels > NELEMS(IMA_ADPCM_state.state) ) {
|
||||
SDL_SetError("IMA ADPCM decoder can only handle %d channels",
|
||||
NELEMS(IMA_ADPCM_state.state));
|
||||
return(-1);
|
||||
}
|
||||
state = IMA_ADPCM_state.state;
|
||||
|
||||
/* Allocate the proper sized output buffer */
|
||||
encoded_len = *audio_len;
|
||||
encoded = *audio_buf;
|
||||
freeable = *audio_buf;
|
||||
*audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) *
|
||||
IMA_ADPCM_state.wSamplesPerBlock*
|
||||
IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *)malloc(*audio_len);
|
||||
if ( *audio_buf == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
/* Get ready... Go! */
|
||||
while ( encoded_len >= IMA_ADPCM_state.wavefmt.blockalign ) {
|
||||
/* Grab the initial information for this block */
|
||||
for ( c=0; c<channels; ++c ) {
|
||||
/* Fill the state information for this block */
|
||||
state[c].sample = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += 2;
|
||||
if ( state[c].sample & 0x8000 ) {
|
||||
state[c].sample -= 0x10000;
|
||||
}
|
||||
state[c].index = *encoded++;
|
||||
/* Reserved byte in buffer header, should be 0 */
|
||||
if ( *encoded++ != 0 ) {
|
||||
/* Uh oh, corrupt data? Buggy code? */;
|
||||
}
|
||||
|
||||
/* Store the initial sample we start with */
|
||||
decoded[0] = state[c].sample&0xFF;
|
||||
decoded[1] = state[c].sample>>8;
|
||||
decoded += 2;
|
||||
}
|
||||
|
||||
/* Decode and store the other samples in this block */
|
||||
samplesleft = (IMA_ADPCM_state.wSamplesPerBlock-1)*channels;
|
||||
while ( samplesleft > 0 ) {
|
||||
for ( c=0; c<channels; ++c ) {
|
||||
Fill_IMA_ADPCM_block(decoded, encoded,
|
||||
c, channels, &state[c]);
|
||||
encoded += 4;
|
||||
samplesleft -= 8;
|
||||
}
|
||||
decoded += (channels * 8 * 2);
|
||||
}
|
||||
encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
|
||||
}
|
||||
free(freeable);
|
||||
return(0);
|
||||
}
|
||||
|
||||
SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
||||
SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
int was_error;
|
||||
Chunk chunk;
|
||||
int lenread;
|
||||
int MS_ADPCM_encoded, IMA_ADPCM_encoded;
|
||||
int samplesize;
|
||||
|
||||
/* WAV magic header */
|
||||
Uint32 RIFFchunk;
|
||||
Uint32 wavelen;
|
||||
Uint32 WAVEmagic;
|
||||
|
||||
/* FMT chunk */
|
||||
WaveFMT *format = NULL;
|
||||
|
||||
/* Make sure we are passed a valid data source */
|
||||
was_error = 0;
|
||||
if ( src == NULL ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Check the magic header */
|
||||
RIFFchunk = SDL_ReadLE32(src);
|
||||
wavelen = SDL_ReadLE32(src);
|
||||
WAVEmagic = SDL_ReadLE32(src);
|
||||
if ( (RIFFchunk != RIFF) || (WAVEmagic != WAVE) ) {
|
||||
SDL_SetError("Unrecognized file type (not WAVE)");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Read the audio data format chunk */
|
||||
chunk.data = NULL;
|
||||
do {
|
||||
if ( chunk.data != NULL ) {
|
||||
free(chunk.data);
|
||||
}
|
||||
lenread = ReadChunk(src, &chunk);
|
||||
if ( lenread < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
} while ( (chunk.magic == FACT) || (chunk.magic == LIST) );
|
||||
|
||||
/* Decode the audio data format */
|
||||
format = (WaveFMT *)chunk.data;
|
||||
if ( chunk.magic != FMT ) {
|
||||
SDL_SetError("Complex WAVE files not supported");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
|
||||
switch (SDL_SwapLE16(format->encoding)) {
|
||||
case PCM_CODE:
|
||||
/* We can understand this */
|
||||
break;
|
||||
case MS_ADPCM_CODE:
|
||||
/* Try to understand this */
|
||||
if ( InitMS_ADPCM(format) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
MS_ADPCM_encoded = 1;
|
||||
break;
|
||||
case IMA_ADPCM_CODE:
|
||||
/* Try to understand this */
|
||||
if ( InitIMA_ADPCM(format) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
IMA_ADPCM_encoded = 1;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown WAVE data format: 0x%.4x",
|
||||
SDL_SwapLE16(format->encoding));
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
memset(spec, 0, (sizeof *spec));
|
||||
spec->freq = SDL_SwapLE32(format->frequency);
|
||||
switch (SDL_SwapLE16(format->bitspersample)) {
|
||||
case 4:
|
||||
if ( MS_ADPCM_encoded || IMA_ADPCM_encoded ) {
|
||||
spec->format = AUDIO_S16;
|
||||
} else {
|
||||
was_error = 1;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
spec->format = AUDIO_U8;
|
||||
break;
|
||||
case 16:
|
||||
spec->format = AUDIO_S16;
|
||||
break;
|
||||
default:
|
||||
was_error = 1;
|
||||
break;
|
||||
}
|
||||
if ( was_error ) {
|
||||
SDL_SetError("Unknown %d-bit PCM data format",
|
||||
SDL_SwapLE16(format->bitspersample));
|
||||
goto done;
|
||||
}
|
||||
spec->channels = (Uint8)SDL_SwapLE16(format->channels);
|
||||
spec->samples = 4096; /* Good default buffer size */
|
||||
|
||||
/* Read the audio data chunk */
|
||||
*audio_buf = NULL;
|
||||
do {
|
||||
if ( *audio_buf != NULL ) {
|
||||
free(*audio_buf);
|
||||
}
|
||||
lenread = ReadChunk(src, &chunk);
|
||||
if ( lenread < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
*audio_len = lenread;
|
||||
*audio_buf = chunk.data;
|
||||
} while ( chunk.magic != DATA );
|
||||
|
||||
if ( MS_ADPCM_encoded ) {
|
||||
if ( MS_ADPCM_decode(audio_buf, audio_len) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if ( IMA_ADPCM_encoded ) {
|
||||
if ( IMA_ADPCM_decode(audio_buf, audio_len) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't return a buffer that isn't a multiple of samplesize */
|
||||
samplesize = ((spec->format & 0xFF)/8)*spec->channels;
|
||||
*audio_len &= ~(samplesize-1);
|
||||
|
||||
done:
|
||||
if ( format != NULL ) {
|
||||
free(format);
|
||||
}
|
||||
if ( freesrc && src ) {
|
||||
SDL_RWclose(src);
|
||||
}
|
||||
if ( was_error ) {
|
||||
spec = NULL;
|
||||
}
|
||||
return(spec);
|
||||
}
|
||||
|
||||
/* Since the WAV memory is allocated in the shared library, it must also
|
||||
be freed here. (Necessary under Win32, VC++)
|
||||
*/
|
||||
void SDL_FreeWAV(Uint8 *audio_buf)
|
||||
{
|
||||
if ( audio_buf != NULL ) {
|
||||
free(audio_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static int ReadChunk(SDL_RWops *src, Chunk *chunk)
|
||||
{
|
||||
chunk->magic = SDL_ReadLE32(src);
|
||||
chunk->length = SDL_ReadLE32(src);
|
||||
chunk->data = (Uint8 *)malloc(chunk->length);
|
||||
if ( chunk->data == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
free(chunk->data);
|
||||
return(-1);
|
||||
}
|
||||
return(chunk->length);
|
||||
}
|
||||
|
||||
#endif /* ENABLE_FILE */
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_wave.h,v 1.2 2001/04/26 16:50:17 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* WAVE files are little-endian */
|
||||
|
||||
/*******************************************/
|
||||
/* Define values for Microsoft WAVE format */
|
||||
/*******************************************/
|
||||
#define RIFF 0x46464952 /* "RIFF" */
|
||||
#define WAVE 0x45564157 /* "WAVE" */
|
||||
#define FACT 0x74636166 /* "fact" */
|
||||
#define LIST 0x5453494c /* "LIST" */
|
||||
#define FMT 0x20746D66 /* "fmt " */
|
||||
#define DATA 0x61746164 /* "data" */
|
||||
#define PCM_CODE 0x0001
|
||||
#define MS_ADPCM_CODE 0x0002
|
||||
#define IMA_ADPCM_CODE 0x0011
|
||||
#define WAVE_MONO 1
|
||||
#define WAVE_STEREO 2
|
||||
|
||||
/* Normally, these three chunks come consecutively in a WAVE file */
|
||||
typedef struct WaveFMT {
|
||||
/* Not saved in the chunk we read:
|
||||
Uint32 FMTchunk;
|
||||
Uint32 fmtlen;
|
||||
*/
|
||||
Uint16 encoding;
|
||||
Uint16 channels; /* 1 = mono, 2 = stereo */
|
||||
Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
|
||||
Uint32 byterate; /* Average bytes per second */
|
||||
Uint16 blockalign; /* Bytes per sample block */
|
||||
Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
|
||||
} WaveFMT;
|
||||
|
||||
/* The general chunk found in the WAVE file */
|
||||
typedef struct Chunk {
|
||||
Uint32 magic;
|
||||
Uint32 length;
|
||||
Uint8 *data; /* Data includes magic and length */
|
||||
} Chunk;
|
||||
|
@ -1,28 +0,0 @@
|
||||
static unsigned __starttime;
|
||||
|
||||
void uSDL_StartTicks(void){
|
||||
__asm__ __volatile__ (
|
||||
"int $0x40"
|
||||
:"=a"(__starttime)
|
||||
:"a"(26),"b"(9)
|
||||
:"memory"
|
||||
);
|
||||
}
|
||||
|
||||
unsigned uSDL_GetTicks(void){
|
||||
unsigned __curtime;
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
:"=a"(__curtime)
|
||||
:"a"(26),"b"(9)
|
||||
:"memory"
|
||||
);
|
||||
return (__curtime-__starttime)*10;
|
||||
}
|
||||
|
||||
void uSDL_Delay(unsigned ms){
|
||||
unsigned start = uSDL_GetTicks();
|
||||
do{
|
||||
__asm__ __volatile__("int $0x40" :: "a"(5),"b"(1));
|
||||
}while (uSDL_GetTicks()-start < ms);
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
The following file defines all of the functions/objects used to dynamically
|
||||
link to the libFLAC library.
|
||||
~ Austen Dicken (admin@cvpcs.org)
|
||||
*/
|
||||
|
||||
#ifdef FLAC_MUSIC
|
||||
|
||||
#include <FLAC/stream_decoder.h>
|
||||
|
||||
typedef struct {
|
||||
int loaded;
|
||||
void *handle;
|
||||
FLAC__StreamDecoder *(*FLAC__stream_decoder_new)();
|
||||
void (*FLAC__stream_decoder_delete)(FLAC__StreamDecoder *decoder);
|
||||
FLAC__StreamDecoderInitStatus (*FLAC__stream_decoder_init_stream)(
|
||||
FLAC__StreamDecoder *decoder,
|
||||
FLAC__StreamDecoderReadCallback read_callback,
|
||||
FLAC__StreamDecoderSeekCallback seek_callback,
|
||||
FLAC__StreamDecoderTellCallback tell_callback,
|
||||
FLAC__StreamDecoderLengthCallback length_callback,
|
||||
FLAC__StreamDecoderEofCallback eof_callback,
|
||||
FLAC__StreamDecoderWriteCallback write_callback,
|
||||
FLAC__StreamDecoderMetadataCallback metadata_callback,
|
||||
FLAC__StreamDecoderErrorCallback error_callback,
|
||||
void *client_data);
|
||||
FLAC__bool (*FLAC__stream_decoder_finish)(FLAC__StreamDecoder *decoder);
|
||||
FLAC__bool (*FLAC__stream_decoder_flush)(FLAC__StreamDecoder *decoder);
|
||||
FLAC__bool (*FLAC__stream_decoder_process_single)(
|
||||
FLAC__StreamDecoder *decoder);
|
||||
FLAC__bool (*FLAC__stream_decoder_process_until_end_of_metadata)(
|
||||
FLAC__StreamDecoder *decoder);
|
||||
FLAC__bool (*FLAC__stream_decoder_process_until_end_of_stream)(
|
||||
FLAC__StreamDecoder *decoder);
|
||||
FLAC__bool (*FLAC__stream_decoder_seek_absolute)(
|
||||
FLAC__StreamDecoder *decoder,
|
||||
FLAC__uint64 sample);
|
||||
FLAC__StreamDecoderState (*FLAC__stream_decoder_get_state)(
|
||||
const FLAC__StreamDecoder *decoder);
|
||||
} flac_loader;
|
||||
|
||||
extern flac_loader flac;
|
||||
|
||||
#endif /* FLAC_MUSIC */
|
||||
|
||||
extern int Mix_InitFLAC();
|
||||
extern void Mix_QuitFLAC();
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
James Le Cuirot
|
||||
chewi@aura-online.co.uk
|
||||
*/
|
||||
|
||||
#ifdef USE_FLUIDSYNTH_MIDI
|
||||
|
||||
#include <fluidsynth.h>
|
||||
|
||||
typedef struct {
|
||||
int loaded;
|
||||
void *handle;
|
||||
|
||||
int (*delete_fluid_player)(fluid_player_t*);
|
||||
void (*delete_fluid_settings)(fluid_settings_t*);
|
||||
int (*delete_fluid_synth)(fluid_synth_t*);
|
||||
int (*fluid_player_add)(fluid_player_t*, const char*);
|
||||
int (*fluid_player_add_mem)(fluid_player_t*, const void*, size_t);
|
||||
int (*fluid_player_get_status)(fluid_player_t*);
|
||||
int (*fluid_player_play)(fluid_player_t*);
|
||||
int (*fluid_player_set_loop)(fluid_player_t*, int);
|
||||
int (*fluid_player_stop)(fluid_player_t*);
|
||||
int (*fluid_settings_setnum)(fluid_settings_t*, const char*, double);
|
||||
fluid_settings_t* (*fluid_synth_get_settings)(fluid_synth_t*);
|
||||
void (*fluid_synth_set_gain)(fluid_synth_t*, float);
|
||||
int (*fluid_synth_sfload)(fluid_synth_t*, const char*, int);
|
||||
int (*fluid_synth_write_s16)(fluid_synth_t*, int, void*, int, int, void*, int, int);
|
||||
fluid_player_t* (*new_fluid_player)(fluid_synth_t*);
|
||||
fluid_settings_t* (*new_fluid_settings)(void);
|
||||
fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*);
|
||||
} fluidsynth_loader;
|
||||
|
||||
extern fluidsynth_loader fluidsynth;
|
||||
|
||||
#endif /* USE_FLUIDSYNTH_MIDI */
|
||||
|
||||
extern int Mix_InitFluidSynth();
|
||||
extern void Mix_QuitFluidSynth();
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifdef MOD_MUSIC
|
||||
|
||||
#include "mikmod.h"
|
||||
|
||||
typedef struct {
|
||||
int loaded;
|
||||
void *handle;
|
||||
|
||||
void (*MikMod_Exit)(void);
|
||||
CHAR* (*MikMod_InfoDriver)(void);
|
||||
CHAR* (*MikMod_InfoLoader)(void);
|
||||
BOOL (*MikMod_Init)(CHAR*);
|
||||
void (*MikMod_RegisterAllLoaders)(void);
|
||||
void (*MikMod_RegisterDriver)(struct MDRIVER*);
|
||||
int* MikMod_errno;
|
||||
char* (*MikMod_strerror)(int);
|
||||
BOOL (*Player_Active)(void);
|
||||
void (*Player_Free)(MODULE*);
|
||||
MODULE* (*Player_LoadGeneric)(MREADER*,int,BOOL);
|
||||
void (*Player_SetPosition)(UWORD);
|
||||
void (*Player_SetVolume)(SWORD);
|
||||
void (*Player_Start)(MODULE*);
|
||||
void (*Player_Stop)(void);
|
||||
ULONG (*VC_WriteBytes)(SBYTE*,ULONG);
|
||||
struct MDRIVER* drv_nos;
|
||||
UWORD* md_device;
|
||||
UWORD* md_mixfreq;
|
||||
UWORD* md_mode;
|
||||
UBYTE* md_musicvolume;
|
||||
UBYTE* md_pansep;
|
||||
UBYTE* md_reverb;
|
||||
UBYTE* md_sndfxvolume;
|
||||
UBYTE* md_volume;
|
||||
} mikmod_loader;
|
||||
|
||||
extern mikmod_loader mikmod;
|
||||
|
||||
#endif /* MOD_MUSIC */
|
||||
|
||||
extern int Mix_InitMOD();
|
||||
extern void Mix_QuitMOD();
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifdef MP3_MUSIC
|
||||
#include "smpeg.h"
|
||||
|
||||
typedef struct {
|
||||
int loaded;
|
||||
void *handle;
|
||||
void (*SMPEG_actualSpec)( SMPEG *mpeg, SDL_AudioSpec *spec );
|
||||
void (*SMPEG_delete)( SMPEG* mpeg );
|
||||
void (*SMPEG_enableaudio)( SMPEG* mpeg, int enable );
|
||||
void (*SMPEG_enablevideo)( SMPEG* mpeg, int enable );
|
||||
SMPEG* (*SMPEG_new_rwops)(SDL_RWops *src, SMPEG_Info* info, int sdl_audio);
|
||||
void (*SMPEG_play)( SMPEG* mpeg );
|
||||
int (*SMPEG_playAudio)( SMPEG *mpeg, Uint8 *stream, int len );
|
||||
void (*SMPEG_rewind)( SMPEG* mpeg );
|
||||
void (*SMPEG_setvolume)( SMPEG* mpeg, int volume );
|
||||
void (*SMPEG_skip)( SMPEG* mpeg, float seconds );
|
||||
SMPEGstatus (*SMPEG_status)( SMPEG* mpeg );
|
||||
void (*SMPEG_stop)( SMPEG* mpeg );
|
||||
} smpeg_loader;
|
||||
|
||||
extern smpeg_loader smpeg;
|
||||
|
||||
#endif /* MUSIC_MP3 */
|
||||
|
||||
extern int Mix_InitMP3();
|
||||
extern void Mix_QuitMP3();
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifdef OGG_MUSIC
|
||||
#ifdef OGG_USE_TREMOR
|
||||
#include <tremor/ivorbisfile.h>
|
||||
#else
|
||||
#include <vorbis/vorbisfile.h>
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int loaded;
|
||||
void *handle;
|
||||
int (*ov_clear)(OggVorbis_File *vf);
|
||||
vorbis_info *(*ov_info)(OggVorbis_File *vf,int link);
|
||||
int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
|
||||
ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i);
|
||||
#ifdef OGG_USE_TREMOR
|
||||
long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream);
|
||||
#else
|
||||
long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream);
|
||||
#endif
|
||||
#ifdef OGG_USE_TREMOR
|
||||
int (*ov_time_seek)(OggVorbis_File *vf,ogg_int64_t pos);
|
||||
#else
|
||||
int (*ov_time_seek)(OggVorbis_File *vf,double pos);
|
||||
#endif
|
||||
} vorbis_loader;
|
||||
|
||||
extern vorbis_loader vorbis;
|
||||
|
||||
#endif /* OGG_MUSIC */
|
||||
|
||||
extern int Mix_InitOgg();
|
||||
extern void Mix_QuitOgg();
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
James Le Cuirot
|
||||
chewi@aura-online.co.uk
|
||||
*/
|
||||
|
||||
#ifndef _FLUIDSYNTH_H_
|
||||
#define _FLUIDSYNTH_H_
|
||||
|
||||
#ifdef USE_FLUIDSYNTH_MIDI
|
||||
|
||||
#include "dynamic_fluidsynth.h"
|
||||
#include <SDL_rwops.h>
|
||||
#include <SDL_audio.h>
|
||||
|
||||
typedef struct {
|
||||
SDL_AudioCVT convert;
|
||||
fluid_synth_t *synth;
|
||||
fluid_player_t* player;
|
||||
} FluidSynthMidiSong;
|
||||
|
||||
int fluidsynth_init(SDL_AudioSpec *mixer);
|
||||
FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *rw, int freerw);
|
||||
void fluidsynth_freesong(FluidSynthMidiSong *song);
|
||||
void fluidsynth_start(FluidSynthMidiSong *song);
|
||||
void fluidsynth_stop(FluidSynthMidiSong *song);
|
||||
int fluidsynth_active(FluidSynthMidiSong *song);
|
||||
void fluidsynth_setvolume(FluidSynthMidiSong *song, int volume);
|
||||
int fluidsynth_playsome(FluidSynthMidiSong *song, void *stream, int len);
|
||||
|
||||
#endif /* USE_FLUIDSYNTH_MIDI */
|
||||
|
||||
#endif /* _FLUIDSYNTH_H_ */
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
This is the source needed to decode a FLAC into a waveform.
|
||||
~ Austen Dicken (admin@cvpcs.org).
|
||||
*/
|
||||
|
||||
/* $Id: $ */
|
||||
|
||||
#ifdef FLAC_MUSIC
|
||||
/* Don't call this directly; use Mix_LoadWAV_RW() for now. */
|
||||
SDL_AudioSpec *Mix_LoadFLAC_RW (SDL_RWops *src, int freesrc,
|
||||
SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
|
||||
#endif
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
This is the source needed to decode an Ogg Vorbis into a waveform.
|
||||
This file by Vaclav Slavik (vaclav.slavik@matfyz.cz).
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef OGG_MUSIC
|
||||
/* Don't call this directly; use Mix_LoadWAV_RW() for now. */
|
||||
SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc,
|
||||
SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
|
||||
#endif
|
@ -32,19 +32,16 @@
|
||||
#include "SDL_mixer.h"
|
||||
#include "load_aiff.h"
|
||||
#include "load_voc.h"
|
||||
#include "load_ogg.h"
|
||||
#include "load_flac.h"
|
||||
#include "dynamic_flac.h"
|
||||
#include "dynamic_mod.h"
|
||||
#include "dynamic_mp3.h"
|
||||
#include "dynamic_ogg.h"
|
||||
//#include "load_ogg.h"
|
||||
//#include "load_flac.h"
|
||||
//#include "dynamic_flac.h"
|
||||
//#include "dynamic_mod.h"
|
||||
//#include "dynamic_mp3.h"
|
||||
//#include "dynamic_ogg.h"
|
||||
|
||||
#define __MIX_INTERNAL_EFFECT__
|
||||
#include "effects_internal.h"
|
||||
|
||||
#define uSDL_Delay SDL_Delay
|
||||
#define uSDL_GetTicks SDL_GetTicks
|
||||
|
||||
/* Magic numbers for various audio file formats */
|
||||
#define RIFF 0x46464952 /* "RIFF" */
|
||||
#define WAVE 0x45564157 /* "WAVE" */
|
||||
@ -303,7 +300,7 @@ static void mix_channels(void *udata, Uint8 *stream, int len)
|
||||
}
|
||||
|
||||
/* Mix any playing channels... */
|
||||
sdl_ticks = uSDL_GetTicks();
|
||||
sdl_ticks = SDL_GetTicks();
|
||||
for ( i=0; i<num_channels; ++i ) {
|
||||
if( ! mix_channel[i].paused ) {
|
||||
if ( mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks ) {
|
||||
@ -860,7 +857,7 @@ int Mix_PlayChannelTimed(int which, Mix_Chunk *chunk, int loops, int ticks)
|
||||
|
||||
/* Queue up the audio data for this channel */
|
||||
if ( which >= 0 && which < num_channels ) {
|
||||
Uint32 sdl_ticks = uSDL_GetTicks();
|
||||
Uint32 sdl_ticks = SDL_GetTicks();
|
||||
if (Mix_Playing(which))
|
||||
_Mix_channel_done_playing(which);
|
||||
mix_channel[which].samples = chunk->abuf;
|
||||
@ -891,7 +888,7 @@ int Mix_ExpireChannel(int which, int ticks)
|
||||
}
|
||||
} else if ( which < num_channels ) {
|
||||
SDL_LockAudio();
|
||||
mix_channel[which].expire = (ticks>0) ? ( uSDL_GetTicks() + ticks) : 0;
|
||||
mix_channel[which].expire = (ticks>0) ? ( SDL_GetTicks() + ticks) : 0;
|
||||
SDL_UnlockAudio();
|
||||
++ status;
|
||||
}
|
||||
@ -930,7 +927,7 @@ int Mix_FadeInChannelTimed(int which, Mix_Chunk *chunk, int loops, int ms, int t
|
||||
|
||||
/* Queue up the audio data for this channel */
|
||||
if ( which >= 0 && which < num_channels ) {
|
||||
Uint32 sdl_ticks = uSDL_GetTicks();
|
||||
Uint32 sdl_ticks = SDL_GetTicks();
|
||||
if (Mix_Playing(which))
|
||||
_Mix_channel_done_playing(which);
|
||||
mix_channel[which].samples = chunk->abuf;
|
||||
@ -1049,7 +1046,7 @@ int Mix_FadeOutChannel(int which, int ms)
|
||||
mix_channel[which].fade_volume = mix_channel[which].volume;
|
||||
mix_channel[which].fading = MIX_FADING_OUT;
|
||||
mix_channel[which].fade_length = ms;
|
||||
mix_channel[which].ticks_fade = uSDL_GetTicks();
|
||||
mix_channel[which].ticks_fade = SDL_GetTicks();
|
||||
|
||||
/* only change fade_volume_reset if we're not fading. */
|
||||
if (mix_channel[which].fading == MIX_NO_FADING) {
|
||||
@ -1154,7 +1151,7 @@ void Mix_CloseAudio(void)
|
||||
/* Pause a particular channel (or all) */
|
||||
void Mix_Pause(int which)
|
||||
{
|
||||
Uint32 sdl_ticks = uSDL_GetTicks();
|
||||
Uint32 sdl_ticks = SDL_GetTicks();
|
||||
if ( which == -1 ) {
|
||||
int i;
|
||||
|
||||
@ -1173,7 +1170,7 @@ void Mix_Pause(int which)
|
||||
/* Resume a paused channel */
|
||||
void Mix_Resume(int which)
|
||||
{
|
||||
Uint32 sdl_ticks = uSDL_GetTicks();
|
||||
Uint32 sdl_ticks = SDL_GetTicks();
|
||||
|
||||
SDL_LockAudio();
|
||||
if ( which == -1 ) {
|
||||
@ -1263,7 +1260,7 @@ int Mix_GroupCount(int tag)
|
||||
int Mix_GroupOldest(int tag)
|
||||
{
|
||||
int chan = -1;
|
||||
Uint32 mintime = uSDL_GetTicks();
|
||||
Uint32 mintime = SDL_GetTicks();
|
||||
int i;
|
||||
for( i=0; i < num_channels; i ++ ) {
|
||||
if ( (mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0
|
||||
|
@ -70,10 +70,7 @@
|
||||
#if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC)
|
||||
static SDL_AudioSpec used_mixer;
|
||||
#endif
|
||||
unsigned uSDL_GetTicks();
|
||||
|
||||
#define uSDL_Delay SDL_Delay
|
||||
#define uSDL_GetTicks SDL_GetTicks
|
||||
unsigned SDL_GetTicks();
|
||||
|
||||
int volatile music_active = 1;
|
||||
static int volatile music_stopped = 0;
|
||||
@ -764,7 +761,7 @@ void Mix_FreeMusic(Mix_Music *music)
|
||||
/* Wait for any fade out to finish */
|
||||
while ( music->fading == MIX_FADING_OUT ) {
|
||||
SDL_UnlockAudio();
|
||||
uSDL_Delay(100);
|
||||
SDL_Delay(100);
|
||||
SDL_LockAudio();
|
||||
}
|
||||
if ( music == music_playing ) {
|
||||
@ -1016,7 +1013,7 @@ int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
|
||||
/* If the current music is fading out, wait for the fade to complete */
|
||||
while ( music_playing && (music_playing->fading == MIX_FADING_OUT) ) {
|
||||
SDL_UnlockAudio();
|
||||
uSDL_Delay(100);
|
||||
SDL_Delay(100);
|
||||
SDL_LockAudio();
|
||||
}
|
||||
music_active = 1;
|
||||
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* This file supports an external command for playing music */
|
||||
|
||||
#ifdef CMD_MUSIC
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#if defined(__linux__) && defined(__arm__)
|
||||
# include <linux/limits.h>
|
||||
#endif
|
||||
typedef struct {
|
||||
char file[PATH_MAX];
|
||||
char cmd[PATH_MAX];
|
||||
pid_t pid;
|
||||
} MusicCMD;
|
||||
|
||||
/* Unimplemented */
|
||||
extern void MusicCMD_SetVolume(int volume);
|
||||
|
||||
/* Load a music stream from the given file */
|
||||
extern MusicCMD *MusicCMD_LoadSong(const char *cmd, const char *file);
|
||||
|
||||
/* Start playback of a given music stream */
|
||||
extern void MusicCMD_Start(MusicCMD *music);
|
||||
|
||||
/* Stop playback of a stream previously started with MusicCMD_Start() */
|
||||
extern void MusicCMD_Stop(MusicCMD *music);
|
||||
|
||||
/* Pause playback of a given music stream */
|
||||
extern void MusicCMD_Pause(MusicCMD *music);
|
||||
|
||||
/* Resume playback of a given music stream */
|
||||
extern void MusicCMD_Resume(MusicCMD *music);
|
||||
|
||||
/* Close the given music stream */
|
||||
extern void MusicCMD_FreeSong(MusicCMD *music);
|
||||
|
||||
/* Return non-zero if a stream is currently playing */
|
||||
extern int MusicCMD_Active(MusicCMD *music);
|
||||
|
||||
#endif /* CMD_MUSIC */
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Header to handle loading FLAC music files in SDL.
|
||||
~ Austen Dicken (admin@cvpcs.org)
|
||||
*/
|
||||
|
||||
/* $Id: $ */
|
||||
|
||||
#ifdef FLAC_MUSIC
|
||||
|
||||
#include <FLAC/stream_decoder.h>
|
||||
|
||||
typedef struct {
|
||||
FLAC__uint64 sample_size;
|
||||
unsigned sample_rate;
|
||||
unsigned channels;
|
||||
unsigned bits_per_sample;
|
||||
FLAC__uint64 total_samples;
|
||||
|
||||
// the following are used to handle the callback nature of the writer
|
||||
int max_to_read;
|
||||
char *data; // pointer to beginning of data array
|
||||
int data_len; // size of data array
|
||||
int data_read; // amount of data array used
|
||||
char *overflow; // pointer to beginning of overflow array
|
||||
int overflow_len; // size of overflow array
|
||||
int overflow_read; // amount of overflow array used
|
||||
} FLAC_Data;
|
||||
|
||||
typedef struct {
|
||||
int playing;
|
||||
int volume;
|
||||
int section;
|
||||
FLAC__StreamDecoder *flac_decoder;
|
||||
FLAC_Data flac_data;
|
||||
SDL_RWops *rwops;
|
||||
int freerw;
|
||||
SDL_AudioCVT cvt;
|
||||
int len_available;
|
||||
Uint8 *snd_available;
|
||||
} FLAC_music;
|
||||
|
||||
/* Initialize the FLAC player, with the given mixer settings
|
||||
This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern int FLAC_init(SDL_AudioSpec *mixer);
|
||||
|
||||
/* Set the volume for a FLAC stream */
|
||||
extern void FLAC_setvolume(FLAC_music *music, int volume);
|
||||
|
||||
/* Load an FLAC stream from an SDL_RWops object */
|
||||
extern FLAC_music *FLAC_new_RW(SDL_RWops *rw, int freerw);
|
||||
|
||||
/* Start playback of a given FLAC stream */
|
||||
extern void FLAC_play(FLAC_music *music);
|
||||
|
||||
/* Return non-zero if a stream is currently playing */
|
||||
extern int FLAC_playing(FLAC_music *music);
|
||||
|
||||
/* Play some of a stream previously started with FLAC_play() */
|
||||
extern int FLAC_playAudio(FLAC_music *music, Uint8 *stream, int len);
|
||||
|
||||
/* Stop playback of a stream previously started with FLAC_play() */
|
||||
extern void FLAC_stop(FLAC_music *music);
|
||||
|
||||
/* Close the given FLAC stream */
|
||||
extern void FLAC_delete(FLAC_music *music);
|
||||
|
||||
/* Jump (seek) to a given position (time is in seconds) */
|
||||
extern void FLAC_jump_to_time(FLAC_music *music, double time);
|
||||
|
||||
#endif /* FLAC_MUSIC */
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifdef MP3_MAD_MUSIC
|
||||
|
||||
#include "mad.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
#define MAD_INPUT_BUFFER_SIZE (5*8192)
|
||||
#define MAD_OUTPUT_BUFFER_SIZE 8192
|
||||
|
||||
enum {
|
||||
MS_input_eof = 0x0001,
|
||||
MS_input_error = 0x0001,
|
||||
MS_decode_eof = 0x0002,
|
||||
MS_decode_error = 0x0004,
|
||||
MS_error_flags = 0x000f,
|
||||
|
||||
MS_playing = 0x0100,
|
||||
MS_cvt_decoded = 0x0200,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SDL_RWops *rw;
|
||||
int freerw;
|
||||
struct mad_stream stream;
|
||||
struct mad_frame frame;
|
||||
struct mad_synth synth;
|
||||
int frames_read;
|
||||
mad_timer_t next_frame_start;
|
||||
int volume;
|
||||
int status;
|
||||
int output_begin, output_end;
|
||||
SDL_AudioSpec mixer;
|
||||
SDL_AudioCVT cvt;
|
||||
|
||||
unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD];
|
||||
unsigned char output_buffer[MAD_OUTPUT_BUFFER_SIZE];
|
||||
} mad_data;
|
||||
|
||||
mad_data *mad_openFileRW(SDL_RWops *rw, SDL_AudioSpec *mixer, int freerw);
|
||||
void mad_closeFile(mad_data *mp3_mad);
|
||||
|
||||
void mad_start(mad_data *mp3_mad);
|
||||
void mad_stop(mad_data *mp3_mad);
|
||||
int mad_isPlaying(mad_data *mp3_mad);
|
||||
|
||||
int mad_getSamples(mad_data *mp3_mad, Uint8 *stream, int len);
|
||||
void mad_seek(mad_data *mp3_mad, double position);
|
||||
void mad_setVolume(mad_data *mp3_mad, int volume);
|
||||
|
||||
#endif
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* $Id: music_mod.h 4211 2008-12-08 00:27:32Z slouken $ */
|
||||
|
||||
#ifdef MOD_MUSIC
|
||||
|
||||
/* This file supports MOD tracker music streams */
|
||||
|
||||
struct MODULE;
|
||||
|
||||
/* Initialize the Ogg Vorbis player, with the given mixer settings
|
||||
This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern int MOD_init(SDL_AudioSpec *mixer);
|
||||
|
||||
/* Uninitialize the music players */
|
||||
extern void MOD_exit(void);
|
||||
|
||||
/* Set the volume for a MOD stream */
|
||||
extern void MOD_setvolume(struct MODULE *music, int volume);
|
||||
|
||||
/* Load a MOD stream from an SDL_RWops object */
|
||||
extern struct MODULE *MOD_new_RW(SDL_RWops *rw, int freerw);
|
||||
|
||||
/* Start playback of a given MOD stream */
|
||||
extern void MOD_play(struct MODULE *music);
|
||||
|
||||
/* Return non-zero if a stream is currently playing */
|
||||
extern int MOD_playing(struct MODULE *music);
|
||||
|
||||
/* Play some of a stream previously started with MOD_play() */
|
||||
extern int MOD_playAudio(struct MODULE *music, Uint8 *stream, int len);
|
||||
|
||||
/* Stop playback of a stream previously started with MOD_play() */
|
||||
extern void MOD_stop(struct MODULE *music);
|
||||
|
||||
/* Close the given MOD stream */
|
||||
extern void MOD_delete(struct MODULE *music);
|
||||
|
||||
/* Jump (seek) to a given position (time is in seconds) */
|
||||
extern void MOD_jump_to_time(struct MODULE *music, double time);
|
||||
|
||||
#endif /* MOD_MUSIC */
|
@ -1,42 +0,0 @@
|
||||
#ifdef MODPLUG_MUSIC
|
||||
|
||||
#include "modplug.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
typedef struct {
|
||||
ModPlugFile *file;
|
||||
int playing;
|
||||
} modplug_data;
|
||||
|
||||
int modplug_init(SDL_AudioSpec *mixer);
|
||||
|
||||
/* Uninitialize the music players */
|
||||
void modplug_exit(void);
|
||||
|
||||
/* Set the volume for a modplug stream */
|
||||
void modplug_setvolume(modplug_data *music, int volume);
|
||||
|
||||
/* Load a modplug stream from an SDL_RWops object */
|
||||
modplug_data *modplug_new_RW(SDL_RWops *rw, int freerw);
|
||||
|
||||
/* Start playback of a given modplug stream */
|
||||
void modplug_play(modplug_data *music);
|
||||
|
||||
/* Return non-zero if a stream is currently playing */
|
||||
int modplug_playing(modplug_data *music);
|
||||
|
||||
/* Play some of a stream previously started with modplug_play() */
|
||||
int modplug_playAudio(modplug_data *music, Uint8 *stream, int len);
|
||||
|
||||
/* Stop playback of a stream previously started with modplug_play() */
|
||||
void modplug_stop(modplug_data *music);
|
||||
|
||||
/* Close the given modplug stream */
|
||||
void modplug_delete(modplug_data *music);
|
||||
|
||||
/* Jump (seek) to a given position (time is in seconds) */
|
||||
void modplug_jump_to_time(modplug_data *music, double time);
|
||||
|
||||
#endif
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef OGG_MUSIC
|
||||
|
||||
/* This file supports Ogg Vorbis music streams */
|
||||
|
||||
#ifdef OGG_USE_TREMOR
|
||||
#include <tremor/ivorbisfile.h>
|
||||
#else
|
||||
#include <vorbis/vorbisfile.h>
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
SDL_RWops *rw;
|
||||
int freerw;
|
||||
int playing;
|
||||
int volume;
|
||||
OggVorbis_File vf;
|
||||
int section;
|
||||
SDL_AudioCVT cvt;
|
||||
int len_available;
|
||||
Uint8 *snd_available;
|
||||
} OGG_music;
|
||||
|
||||
/* Initialize the Ogg Vorbis player, with the given mixer settings
|
||||
This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern int OGG_init(SDL_AudioSpec *mixer);
|
||||
|
||||
/* Set the volume for an OGG stream */
|
||||
extern void OGG_setvolume(OGG_music *music, int volume);
|
||||
|
||||
/* Load an OGG stream from an SDL_RWops object */
|
||||
extern OGG_music *OGG_new_RW(SDL_RWops *rw, int freerw);
|
||||
|
||||
/* Start playback of a given OGG stream */
|
||||
extern void OGG_play(OGG_music *music);
|
||||
|
||||
/* Return non-zero if a stream is currently playing */
|
||||
extern int OGG_playing(OGG_music *music);
|
||||
|
||||
/* Play some of a stream previously started with OGG_play() */
|
||||
extern int OGG_playAudio(OGG_music *music, Uint8 *stream, int len);
|
||||
|
||||
/* Stop playback of a stream previously started with OGG_play() */
|
||||
extern void OGG_stop(OGG_music *music);
|
||||
|
||||
/* Close the given OGG stream */
|
||||
extern void OGG_delete(OGG_music *music);
|
||||
|
||||
/* Jump (seek) to a given position (time is in seconds) */
|
||||
extern void OGG_jump_to_time(OGG_music *music, double time);
|
||||
|
||||
#endif /* OGG_MUSIC */
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
SDL_mixer: An audio mixer library based on the SDL library
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* This file supports streaming WAV files, without volume adjustment */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
SDL_RWops *rw;
|
||||
SDL_bool freerw;
|
||||
long start;
|
||||
long stop;
|
||||
SDL_AudioCVT cvt;
|
||||
} WAVStream;
|
||||
|
||||
/* Initialize the WAVStream player, with the given mixer settings
|
||||
This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern int WAVStream_Init(SDL_AudioSpec *mixer);
|
||||
|
||||
/* Unimplemented */
|
||||
extern void WAVStream_SetVolume(int volume);
|
||||
|
||||
/* Load a WAV stream from an SDL_RWops object */
|
||||
extern WAVStream *WAVStream_LoadSong_RW(SDL_RWops *rw, const char *magic, int freerw);
|
||||
|
||||
/* Start playback of a given WAV stream */
|
||||
extern void WAVStream_Start(WAVStream *wave);
|
||||
|
||||
/* Play some of a stream previously started with WAVStream_Start() */
|
||||
extern int WAVStream_PlaySome(Uint8 *stream, int len);
|
||||
|
||||
/* Stop playback of a stream previously started with WAVStream_Start() */
|
||||
extern void WAVStream_Stop(void);
|
||||
|
||||
/* Close the given WAV stream */
|
||||
extern void WAVStream_FreeSong(WAVStream *wave);
|
||||
|
||||
/* Return non-zero if a stream is currently playing */
|
||||
extern int WAVStream_Active(void);
|
@ -20,11 +20,10 @@ compile_gcc{
|
||||
"joystick_stub.cpp", "kolibri.cpp", "mame/fmopl.cpp",
|
||||
}
|
||||
|
||||
-- SDL and SDL_mixer --
|
||||
-- SDL_mixer stubs --
|
||||
compile_gcc{
|
||||
"SDL/SDL_wave.c", "SDL/SDL_audiocvt.c", "SDL/SDL_mixer.c", "SDL_mixer/mixer.c", "SDL_mixer/music.c",
|
||||
"SDL_mixer/load_aiff.c", "SDL_mixer/load_voc.c",
|
||||
"SDL_mixer/effects_internal.c", "SDL_mixer/effect_position.c",
|
||||
"SDL_mixer/mixer.c", "SDL_mixer/music.c", "SDL_mixer/load_aiff.c", "SDL_mixer/load_voc.c",
|
||||
"SDL_mixer/effects_internal.c", "SDL_mixer/effect_position.c",
|
||||
}
|
||||
|
||||
link_gcc("wolf3d")
|
||||
|
@ -650,7 +650,7 @@ boolean IN_UserInput(longword delay)
|
||||
IN_ProcessEvents();
|
||||
if (IN_CheckAck())
|
||||
return true;
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
} while (GetTimeCount() - lasttime < delay);
|
||||
return(false);
|
||||
}
|
||||
|
@ -935,7 +935,7 @@ SD_SetMusicMode(SMMode mode)
|
||||
|
||||
SD_FadeOutMusic();
|
||||
while (SD_MusicPlaying())
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
@ -1284,7 +1284,7 @@ void
|
||||
SD_WaitSoundDone(void)
|
||||
{
|
||||
while (SD_SoundPlaying())
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -119,17 +119,11 @@ extern SMMode MusicMode;
|
||||
extern int DigiMap[];
|
||||
extern int DigiChannel[];
|
||||
|
||||
#ifdef _KOLIBRI
|
||||
extern void uSDL_Delay(unsigned time);
|
||||
#else
|
||||
#define uSDL_Delay SDL_Delay
|
||||
#endif
|
||||
|
||||
#define GetTimeCount() (( uSDL_GetTicks()*7)/100)
|
||||
#define GetTimeCount() ((SDL_GetTicks()*7)/100)
|
||||
|
||||
inline void Delay(int wolfticks)
|
||||
{
|
||||
if(wolfticks>0) uSDL_Delay(wolfticks * 100/ 7);
|
||||
if(wolfticks>0) SDL_Delay(wolfticks * 100/ 7);
|
||||
}
|
||||
|
||||
// Function prototypes
|
||||
|
@ -741,7 +741,7 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
|
||||
|
||||
cursorvis ^= true;
|
||||
}
|
||||
else uSDL_Delay(5);
|
||||
else SDL_Delay(5);
|
||||
if (cursorvis)
|
||||
USL_XORICursor(x,y,s,cursor);
|
||||
|
||||
@ -772,7 +772,7 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
|
||||
void US_InitRndT(int randomize)
|
||||
{
|
||||
if(randomize)
|
||||
rndindex = ( uSDL_GetTicks() >> 4) & 0xff;
|
||||
rndindex = ( SDL_GetTicks() >> 4) & 0xff;
|
||||
else
|
||||
rndindex = 0;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ extern SDL_Color gamepal[256];
|
||||
// VGA hardware routines
|
||||
//
|
||||
|
||||
#define VL_WaitVBL(a) uSDL_Delay((a)*8)
|
||||
#define VL_WaitVBL(a) SDL_Delay((a)*8)
|
||||
|
||||
void VL_SetVGAPlaneMode (void);
|
||||
void VL_SetTextMode (void);
|
||||
|
@ -1,215 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ksys.h>
|
||||
#include <string.h>
|
||||
|
||||
#define asm_inline __asm__ __volatile__
|
||||
|
||||
#pragma pack(push,1)
|
||||
typedef union{
|
||||
unsigned val;
|
||||
struct{
|
||||
short x;
|
||||
short y;
|
||||
};
|
||||
}ksys_pos_t;
|
||||
|
||||
typedef union ksys_oskey_t{
|
||||
unsigned val;
|
||||
struct{
|
||||
unsigned char state;
|
||||
unsigned char code;
|
||||
unsigned char ctrl_key;
|
||||
};
|
||||
}ksys_oskey_t;
|
||||
|
||||
typedef struct{
|
||||
unsigned handle;
|
||||
unsigned io_code;
|
||||
unsigned *input;
|
||||
int inp_size;
|
||||
void *output;
|
||||
int out_size;
|
||||
}ksys_ioctl_t;
|
||||
|
||||
typedef struct{
|
||||
void *data;
|
||||
size_t size;
|
||||
}ksys_ufile_t;
|
||||
|
||||
|
||||
typedef struct{
|
||||
unsigned p00;
|
||||
union{
|
||||
uint64_t p04;
|
||||
struct {
|
||||
unsigned p04dw;
|
||||
unsigned p08dw;
|
||||
};
|
||||
};
|
||||
unsigned p12;
|
||||
union {
|
||||
unsigned p16;
|
||||
const char *new_name;
|
||||
void *bdfe;
|
||||
void *buf16;
|
||||
const void *cbuf16;
|
||||
};
|
||||
char p20;
|
||||
const char *p21;
|
||||
}ksys70_t;
|
||||
|
||||
typedef struct {
|
||||
int cpu_usage; //+0
|
||||
int window_pos_info; //+4
|
||||
short int reserved1; //+8
|
||||
char name[12]; //+10
|
||||
int memstart; //+22
|
||||
int memused; //+26
|
||||
int pid; //+30
|
||||
int winx_start; //+34
|
||||
int winy_start; //+38
|
||||
int winx_size; //+42
|
||||
int winy_size; //+46
|
||||
short int slot_info; //+50
|
||||
short int reserved2; //+52
|
||||
int clientx; //+54
|
||||
int clienty; //+58
|
||||
int clientwidth; //+62
|
||||
int clientheight; //+66
|
||||
unsigned char window_state;//+70
|
||||
char reserved3[1024-71]; //+71
|
||||
}ksys_proc_table_t;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
static inline
|
||||
int _ksys_process_info(ksys_proc_table_t* table, int pid)
|
||||
{
|
||||
int val;
|
||||
asm_inline(
|
||||
"int $0x40"
|
||||
:"=a"(val)
|
||||
:"a"(9), "b"(table), "c"(pid)
|
||||
:"memory"
|
||||
);
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline
|
||||
void _ksys_change_window(int new_x, int new_y, int new_w, int new_h)
|
||||
{
|
||||
asm_inline(
|
||||
"int $0x40"
|
||||
::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h)
|
||||
);
|
||||
}
|
||||
|
||||
static inline
|
||||
ksys_pos_t _ksys_screen_size()
|
||||
{
|
||||
ksys_pos_t size;
|
||||
ksys_pos_t size_tmp;
|
||||
asm_inline(
|
||||
"int $0x40"
|
||||
:"=a"(size_tmp)
|
||||
:"a"(14)
|
||||
:"memory"
|
||||
);
|
||||
size.x = size_tmp.y;
|
||||
size.y = size_tmp.x;
|
||||
return size;
|
||||
}
|
||||
|
||||
void *memrchr(const void *m, int c, size_t n)
|
||||
{
|
||||
const unsigned char *s = (const unsigned char*)m;
|
||||
c = (unsigned char)c;
|
||||
while (n--) if (s[n]==c) return (void *)(s+n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void kolibri_set_win_center()
|
||||
{
|
||||
ksys_proc_table_t *info = (ksys_proc_table_t*)malloc(sizeof(ksys_proc_table_t));
|
||||
_ksys_process_info(info, -1);
|
||||
|
||||
ksys_pos_t screen_size= _ksys_screen_size();
|
||||
int new_x = screen_size.x/2-info->winx_size/2;
|
||||
int new_y = screen_size.y/2-info->winy_size/2;
|
||||
_ksys_change_window(new_x, new_y, -1, -1);
|
||||
free(info);
|
||||
}
|
||||
|
||||
int mkdir(const char *path, unsigned v)
|
||||
{
|
||||
int status;
|
||||
ksys70_t dir_opt;
|
||||
dir_opt.p00 = 9;
|
||||
dir_opt.p21 = path;
|
||||
asm_inline(
|
||||
"int $0x40"
|
||||
:"=a"(status)
|
||||
:"a"(70), "b"(&dir_opt)
|
||||
:"memory"
|
||||
);
|
||||
return status;
|
||||
}
|
||||
|
||||
char *dirname (char *path)
|
||||
{
|
||||
static const char dot[] = ".";
|
||||
char *last_slash;
|
||||
/* Find last '/'. */
|
||||
last_slash = path != NULL ? strrchr (path, '/') : NULL;
|
||||
if (last_slash != NULL && last_slash != path && last_slash[1] == '\0')
|
||||
{
|
||||
/* Determine whether all remaining characters are slashes. */
|
||||
char *runp;
|
||||
for (runp = last_slash; runp != path; --runp)
|
||||
if (runp[-1] != '/')
|
||||
break;
|
||||
/* The '/' is the last character, we have to look further. */
|
||||
if (runp != path)
|
||||
last_slash = (char*)memrchr((void*)path, '/', runp - path);
|
||||
}
|
||||
if (last_slash != NULL)
|
||||
{
|
||||
/* Determine whether all remaining characters are slashes. */
|
||||
char *runp;
|
||||
for (runp = last_slash; runp != path; --runp)
|
||||
if (runp[-1] != '/')
|
||||
break;
|
||||
/* Terminate the path. */
|
||||
if (runp == path)
|
||||
{
|
||||
/* The last slash is the first character in the string. We have to
|
||||
return "/". As a special case we have to return "//" if there
|
||||
are exactly two slashes at the beginning of the string. See
|
||||
XBD 4.10 Path Name Resolution for more information. */
|
||||
if (last_slash == path + 1)
|
||||
++last_slash;
|
||||
else
|
||||
last_slash = path + 1;
|
||||
}
|
||||
else
|
||||
last_slash = runp;
|
||||
last_slash[0] = '\0';
|
||||
}
|
||||
else
|
||||
/* This assignment is ill-designed but the XPG specs require to
|
||||
return a string containing "." in any case no directory part is
|
||||
found and so a static and constant string is required. */
|
||||
path = (char *) dot;
|
||||
return path;
|
||||
}
|
||||
|
||||
void setcwd(char* path){
|
||||
asm_inline(
|
||||
"int $0x40"
|
||||
::"a"(30), "b"(1), "c"(path)
|
||||
:"memory"
|
||||
);
|
||||
}
|
||||
extern unsigned screenWidth;
|
||||
extern unsigned screenHeight;
|
||||
|
||||
|
@ -24,10 +24,6 @@
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#define uSDL_Delay SDL_Delay
|
||||
#define uSDL_GetTicks SDL_GetTicks
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
#if defined(_arch_dreamcast)
|
||||
@ -1395,7 +1391,7 @@ static inline fixed FixedMul(fixed a, fixed b)
|
||||
#endif
|
||||
#define DEMOCOND_SDL (!DEMOCOND_ORIG)
|
||||
|
||||
#define GetTicks() (( uSDL_GetTicks()*7)/100)
|
||||
#define GetTicks() (( SDL_GetTicks()*7)/100)
|
||||
|
||||
#define ISPOINTER(x) ((((uintptr_t)(x)) & ~0xffff) != 0)
|
||||
|
||||
|
@ -1074,12 +1074,12 @@ void CalcTics (void)
|
||||
if (lasttimecount > (int32_t) GetTimeCount())
|
||||
lasttimecount = GetTimeCount(); // if the game was paused a LONG time
|
||||
|
||||
uint32_t curtime = uSDL_GetTicks();
|
||||
uint32_t curtime = SDL_GetTicks();
|
||||
tics = (curtime * 7) / 100 - lasttimecount;
|
||||
if(!tics)
|
||||
{
|
||||
// wait until end of current tic
|
||||
uSDL_Delay(((lasttimecount + 1) * 100) / 7 - curtime);
|
||||
SDL_Delay(((lasttimecount + 1) * 100) / 7 - curtime);
|
||||
tics = 1;
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ BJ_Breathe (void)
|
||||
static int which = 0, max = 10;
|
||||
int pics[2] = { L_GUYPIC, L_GUY2PIC };
|
||||
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
|
||||
if ((int32_t) GetTimeCount () - lastBreathTime > max)
|
||||
{
|
||||
|
@ -11,6 +11,11 @@
|
||||
#include "wl_atmos.h"
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
#ifdef _KOLIBRI
|
||||
#include <sys/ksys.h>
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
@ -24,10 +29,6 @@
|
||||
*/
|
||||
|
||||
extern byte signon[];
|
||||
extern void kolibri_set_win_center();
|
||||
extern char* dirname(char* path);
|
||||
extern void setcwd(char* path);
|
||||
|
||||
extern boolean SD_Started;
|
||||
/*
|
||||
=============================================================================
|
||||
@ -1128,7 +1129,7 @@ void DoJukebox(void)
|
||||
|
||||
#ifndef SPEAR
|
||||
#ifndef UPLOAD
|
||||
start = (( uSDL_GetTicks()/10)%3)*6;
|
||||
start = (( SDL_GetTicks()/10)%3)*6;
|
||||
#else
|
||||
start = 0;
|
||||
#endif
|
||||
@ -1239,9 +1240,6 @@ static void InitGame()
|
||||
#endif
|
||||
|
||||
SignonScreen ();
|
||||
#ifdef _KOLIBRI
|
||||
kolibri_set_win_center();
|
||||
#endif
|
||||
|
||||
#if defined _WIN32
|
||||
if(!fullscreen)
|
||||
@ -1978,7 +1976,7 @@ extern void kolibri_set_win_max(void);
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
#ifdef _KOLIBRI
|
||||
setcwd(dirname(argv[0]));
|
||||
_ksys_setcwd(dirname(argv[0]));
|
||||
kolibri_set_win_max();
|
||||
#endif
|
||||
|
||||
|
@ -1956,7 +1956,7 @@ MouseSensitivity (int)
|
||||
DrawMouseSens ();
|
||||
do
|
||||
{
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
ReadAnyControl (&ci);
|
||||
switch (ci.dir)
|
||||
{
|
||||
@ -2228,7 +2228,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
|
||||
redraw = 0;
|
||||
}
|
||||
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
ReadAnyControl (&ci);
|
||||
|
||||
if (type == MOUSE || type == JOYSTICK)
|
||||
@ -2274,7 +2274,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
|
||||
lastFlashTime = GetTimeCount();
|
||||
VW_UpdateScreen ();
|
||||
}
|
||||
else uSDL_Delay(5);
|
||||
else SDL_Delay(5);
|
||||
|
||||
//
|
||||
// WHICH TYPE OF INPUT DO WE PROCESS?
|
||||
@ -2397,7 +2397,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
|
||||
while (!cust->allowed[which]);
|
||||
redraw = 1;
|
||||
SD_PlaySound (MOVEGUN1SND);
|
||||
while (ReadAnyControl (&ci), ci.dir != dir_None) uSDL_Delay(5);
|
||||
while (ReadAnyControl (&ci), ci.dir != dir_None) SDL_Delay(5);
|
||||
IN_ClearKeysDown ();
|
||||
break;
|
||||
|
||||
@ -2411,7 +2411,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
|
||||
while (!cust->allowed[which]);
|
||||
redraw = 1;
|
||||
SD_PlaySound (MOVEGUN1SND);
|
||||
while (ReadAnyControl (&ci), ci.dir != dir_None) uSDL_Delay(5);
|
||||
while (ReadAnyControl (&ci), ci.dir != dir_None) SDL_Delay(5);
|
||||
IN_ClearKeysDown ();
|
||||
break;
|
||||
case dir_North:
|
||||
@ -2837,7 +2837,7 @@ CP_ChangeView (int)
|
||||
do
|
||||
{
|
||||
CheckPause ();
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
ReadAnyControl (&ci);
|
||||
switch (ci.dir)
|
||||
{
|
||||
@ -3284,7 +3284,7 @@ HandleMenu (CP_iteminfo * item_i, CP_itemtype * items, void (*routine) (int w))
|
||||
routine (which);
|
||||
VW_UpdateScreen ();
|
||||
}
|
||||
else uSDL_Delay(5);
|
||||
else SDL_Delay(5);
|
||||
|
||||
CheckPause ();
|
||||
|
||||
@ -3484,7 +3484,7 @@ DrawHalfStep (int x, int y)
|
||||
VWB_DrawPic (x, y, C_CURSOR1PIC);
|
||||
VW_UpdateScreen ();
|
||||
SD_PlaySound (MOVEGUN1SND);
|
||||
uSDL_Delay(1); //Fixed too long delay in the menu
|
||||
SDL_Delay(1); //Fixed too long delay in the menu
|
||||
}
|
||||
|
||||
|
||||
@ -3526,7 +3526,7 @@ TicDelay (int count)
|
||||
int32_t startTime = GetTimeCount ();
|
||||
do
|
||||
{
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
ReadAnyControl (&ci);
|
||||
}
|
||||
while ((int32_t) GetTimeCount () - startTime < count && ci.dir != dir_None);
|
||||
@ -3732,7 +3732,7 @@ Confirm (const char *string)
|
||||
tick ^= 1;
|
||||
lastBlinkTime = GetTimeCount();
|
||||
}
|
||||
else uSDL_Delay(5);
|
||||
else SDL_Delay(5);
|
||||
|
||||
#ifdef SPANISH
|
||||
}
|
||||
|
@ -406,11 +406,11 @@ void PollControls (void)
|
||||
if (demoplayback || demorecord) // demo recording and playback needs to be constant
|
||||
{
|
||||
// wait up to DEMOTICS Wolf tics
|
||||
uint32_t curtime = uSDL_GetTicks();
|
||||
uint32_t curtime = SDL_GetTicks();
|
||||
lasttimecount += DEMOTICS;
|
||||
int32_t timediff = (lasttimecount * 100) / 7 - curtime;
|
||||
if(timediff > 0)
|
||||
uSDL_Delay(timediff);
|
||||
SDL_Delay(timediff);
|
||||
|
||||
if(timediff < -2 * DEMOTICS) // more than 2-times DEMOTICS behind?
|
||||
lasttimecount = (curtime * 7) / 100; // yes, set to current timecount
|
||||
|
@ -669,7 +669,7 @@ void ShowArticle (char *article)
|
||||
firstpage = false;
|
||||
}
|
||||
}
|
||||
uSDL_Delay(5);
|
||||
SDL_Delay(5);
|
||||
|
||||
LastScan = 0;
|
||||
ReadAnyControl(&ci);
|
||||
|
Loading…
Reference in New Issue
Block a user