git-svn-id: https://svn.eduke32.com/eduke32@640 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-03-09 08:14:12 +00:00
parent 68675e28aa
commit dd4a7b5450
14 changed files with 236 additions and 161 deletions

View file

@ -27,7 +27,7 @@ DXROOT=c:\sdks\dx6
MSSDKROOT="C:\Program Files\Microsoft Visual Studio 8\VC
PLATFORMSDK="C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK
ENGINEOPTS=/DSUPERBUILD /DPOLYMOST /DUSE_OPENGL
ENGINEOPTS=/DSUPERBUILD /DPOLYMOST /DUSE_OPENGL /DUSE_OPENAL
CC=cl
AS=ml
@ -38,8 +38,9 @@ CFLAGS= /MD /J /nologo $(flags_cl) \
/DNOCOPYPROTECT /D "_CRT_SECURE_NO_DEPRECATE" -W0 $(ENGINEOPTS) \
/I$(DXROOT)\include /DRENDERTYPEWIN=1
LIBS=user32.lib gdi32.lib shell32.lib dxguid.lib winmm.lib wsock32.lib comctl32.lib \
/NODEFAULTLIB:libFLAC.lib glu32.lib
/NODEFAULTLIB:libFLAC.lib /NODEFAULTLIB:glu32.lib /NODEFAULTLIB:LIBCMT.lib /NODEFAULTLIB:LIBCMTD.lib
LIBS=vorbisfile_static.lib vorbis_static.lib ogg_static.lib $(LIBS)
ASFLAGS=/nologo /coff
ASFLAGS=/nologo /coff
@ -61,7 +62,7 @@ AUDIOLIB_FX=$(OBJ)\mv_mix.$o \
$(OBJ)\mvreverb.$o \
$(OBJ)\pitch.$o \
$(OBJ)\multivoc.$o \
# $(OBJ)\openal.$o \
$(OBJ)\openal.$o \
$(OBJ)\ll_man.$o \
$(OBJ)\fx_man.$o \
$(OBJ)\dsoundout.$o

View file

@ -328,7 +328,8 @@ extern short numanimwalls;
extern int probey;
extern char typebuflen,typebuf[141];
extern char *MusicPtr;extern int Musicsize;
extern char *MusicPtr;
extern int Musicsize;
extern int msx[2048],msy[2048];
extern short cyclers[MAXCYCLERS][6],numcyclers;
extern char myname[32];

View file

@ -31,7 +31,7 @@ extern void SoundShutdown(void);
extern void MusicStartup(void);
extern void MusicShutdown(void);
extern void intomenusounds(void);
extern void playmusicMAP(const char *fn,const int sel);
extern int playmusicMAP(const char *fn, const int sel);
extern int loadsound(unsigned num);
extern int xyzsound(int num,int i,int x,int y,int z);
extern void sound(int num);

View file

@ -43,6 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "scriptfile.h"
#include "grpscan.h"
#include "gamedef.h"
#include "kplib.h"
//#include "crc32.h"
@ -7991,9 +7992,11 @@ static void nonsharedkeys(void)
music_select = 0;
if (map[(unsigned char)music_select].musicfn != NULL)
{
Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn[0]);
if (playmusicMAP(&map[(unsigned char)music_select].musicfn[0],music_select))
Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn1[0]);
else
Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn1[0]);
FTA(26,g_player[myconnectindex].ps);
playmusicMAP(&map[(unsigned char)music_select].musicfn[0],music_select);
}
return;
}
@ -8211,10 +8214,14 @@ FAKE_F3:
if (KB_KeyPressed(sc_F5) && ud.config.MusicDevice >= 0)
{
KB_ClearKeyDown(sc_F5);
if (map[(unsigned char)music_select].musicfn != NULL)
if (map[(unsigned char)music_select].musicfn1 != NULL)
Bstrcpy(fta_quotes[26],&map[(unsigned char)music_select].musicfn1[0]);
else if (map[(unsigned char)music_select].musicfn != NULL)
{
Bstrcpy(fta_quotes[26],&map[(unsigned char)music_select].musicfn[0]);
else fta_quotes[26][0] = '\0';
Bstrcat(fta_quotes[26],". USE SHIFT-F5 TO CHANGE.");
}
else fta_quotes[26][0] = '\0';
FTA(26,g_player[myconnectindex].ps);
}
@ -8647,7 +8654,7 @@ int AL_DefineSound(int ID,char *name)
if (ID>=MAXSOUNDS)
return 1;
g_sounds[ID].filename1=makename(g_sounds[ID].filename1,name,g_sounds[ID].filename);
// initprintf("(%s)(%s)(%s)\n",g_sounds[ID].filename1,name,g_sounds[ID].filename);
initprintf("(%s)(%s)(%s)\n",g_sounds[ID].filename1,name,g_sounds[ID].filename);
// loadsound(ID);
return 0;
}
@ -8695,7 +8702,7 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
int tokn;
char *cmdtokptr;
tokenlist grptokens[] =
tokenlist tokens[] =
{
{ "include", T_INCLUDE },
{ "#include", T_INCLUDE },
@ -8714,7 +8721,7 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
while (1)
{
tokn = getatoken(script,grptokens,sizeof(grptokens)/sizeof(tokenlist));
tokn = getatoken(script,tokens,sizeof(tokens)/sizeof(tokenlist));
cmdtokptr = script->ltextptr;
switch (tokn)
{
@ -8753,9 +8760,8 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
char *fn;
if (!scriptfile_getstring(script,&fn))
{
scriptfile *included;
scriptfile *included = scriptfile_fromfile(fn);
included = scriptfile_fromfile(fn);
if (!included)
{
initprintf("Warning: Failed including %s on line %s:%d\n",
@ -8776,7 +8782,7 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
case T_MUSIC:
{
char *tinttokptr = script->ltextptr;
char *ID=NULL,*ext="";
char *ID=NULL,*fn="",*tfn = NULL;
char *musicend;
if (scriptfile_getbraces(script,&musicend)) break;
@ -8788,19 +8794,38 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
scriptfile_getstring(script,&ID);
break;
case T_FILE:
scriptfile_getstring(script,&ext);
scriptfile_getstring(script,&fn);
break;
}
}
if (!preload)
{
int i;
if (ID==NULL)
{
initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
break;
}
#ifdef USE_OPENAL
if (AL_DefineMusic(ID,ext))
i = pathsearchmode;
pathsearchmode = 1;
if (findfrompath(fn,&tfn) < 0)
{
char buf[BMAX_PATH];
Bstrcpy(buf,fn);
kzfindfilestart(buf);
if (!kzfindfile(buf))
{
initprintf("Error: file '%s' does not exist\n",fn);
pathsearchmode = i;
break;
}
}
else Bfree(tfn);
pathsearchmode = i;
if (AL_DefineMusic(ID,fn))
initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
#endif
}
@ -8810,7 +8835,8 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
case T_SOUND:
{
char *tinttokptr = script->ltextptr;
char *name="";int num=-1;
char *fn="", *tfn = NULL;
int num=-1;
char *musicend;
if (scriptfile_getbraces(script,&musicend)) break;
@ -8822,18 +8848,40 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
scriptfile_getsymbol(script,&num);
break;
case T_FILE:
scriptfile_getstring(script,&name);
scriptfile_getstring(script,&fn);
break;
}
}
if (!preload)
{
int i;
if (num==-1)
{
initprintf("Error: missing ID for sound definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
break;
}
if (AL_DefineSound(num,name))initprintf("Error: invalid sound ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
i = pathsearchmode;
pathsearchmode = 1;
if (findfrompath(fn,&tfn) < 0)
{
char buf[BMAX_PATH];
Bstrcpy(buf,fn);
kzfindfilestart(buf);
if (!kzfindfile(buf))
{
initprintf("Error: file '%s' does not exist\n",fn);
pathsearchmode = i;
break;
}
}
else Bfree(tfn);
pathsearchmode = i;
if (AL_DefineSound(num,fn))
initprintf("Error: invalid sound ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
}
}
break;

View file

@ -23,7 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//-------------------------------------------------------------------------
#include "duke3d.h"
char *MusicPtr=0;int Musicsize;
char *MusicPtr = NULL;
int Musicsize;
short global_random;
short neartagsector, neartagwall, neartagsprite;

View file

@ -134,7 +134,8 @@ typedef struct VoiceNode
void ( *DemandFeed )( char **ptr, unsigned int *length );
struct sounddef OGGstream;
char *bufsnd;
// char *bufsnd;
char bufsnd[0x8000*4];
int downsample;
short *LeftVolume;

View file

@ -118,6 +118,10 @@ static void mixer_callback(int chan, void *stream, int len, void *udata)
/* len should equal _BufferSize, else this is screwed up */
#ifdef USE_OPENAL
AL_Update();
#endif
stptr = (Uint8 *)stream;
if (_remainder > 0)
@ -139,10 +143,6 @@ static void mixer_callback(int chan, void *stream, int len, void *udata)
{
/* new buffer */
#ifdef USE_OPENAL
AL_Update();
#endif
_CallBackFunc();
fxptr = (Uint8 *)(&_BufferStart[MV_MixPage *

View file

@ -1162,11 +1162,15 @@ void AudioUpdate(void) { MUSIC_Update(); }
void playmusic(const char *fn);
void playmusicMAP(const char *fn,const int sel)
int playmusicMAP(const char *fn,const int sel)
{
Musicsize=0;
if(map[sel].musicfn1)
if(map[sel].musicfn1 != NULL)
playmusic(map[sel].musicfn1);
if(!Musicsize)
{
playmusic(fn);
return 0;
}
return 1;
}

View file

@ -375,8 +375,8 @@ void MV_PlayVoice(VoiceNode *voice)
flags = DisableInterrupts();
LL_SortedInsertion(&VoiceList, voice, prev, next, VoiceNode, priority);
if(!voice->bufsnd)voice->bufsnd=(char *)Bcalloc(0x8000*4,sizeof(char));
if(!voice->bufsnd)initprintf("Attention. It gonna crash! Thank you."); // FIXME: change the msg
// if(!voice->bufsnd)voice->bufsnd=(char *)Bcalloc(0x8000*4,sizeof(char));
// if(!voice->bufsnd)initprintf("Attention. It gonna crash! Thank you."); // FIXME: change the msg
RestoreInterrupts(flags);
}
@ -392,7 +392,7 @@ void MV_StopVoice(VoiceNode *voice)
unsigned int flags;
flags = DisableInterrupts();
if(!voice->bufsnd)Bfree(voice->bufsnd);
// if(!voice->bufsnd)Bfree(voice->bufsnd);
// move the voice from the play list to the free list
LL_Remove(voice, next, prev);
LL_Add(&VoicePool, voice, next, prev);
@ -919,6 +919,7 @@ void downsample(char *ptr,int size,int factor)
pti[i]=sum>>factor;
}
}
playbackstatus MV_GetNextOGGBlock(VoiceNode *voice)
{
int sz;
@ -955,13 +956,14 @@ playbackstatus MV_GetNextOGGBlock(VoiceNode *voice)
{
downsample(voice->bufsnd+(size>>voice->downsample),result,voice->downsample);
size+=result;
}else
if(result==0)
}
else if (result==0)
{
// initprintf("!repeat %d\n",voice->callbackval);
voice->BlockLength=0;
voice->length=size<<16;break;
}else
}
else
{
initprintf("#%d\n",result);
break;
@ -2873,6 +2875,7 @@ int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, int sampleb
{
if (map[i].musicfn1 != NULL)
Bfree(map[i].musicfn1);
map[i].musicfn1 = NULL;
}
}
#endif

View file

@ -367,7 +367,7 @@ int MUSIC_PlaySong
#ifdef USE_OPENAL
if (!openal_disabled)
AL_PlaySong((char *)song,loopflag);
AL_PlaySong((unsigned char *)song,loopflag);
if(openal_disabled || AL_isntALmusic())
#endif
{

View file

@ -12,7 +12,7 @@
ALCdevice * device=NULL;
ALCcontext * context=NULL;
char *ALdoing="";
char *ALdoing = NULL;
int AL_Error;
int bufsize;
int openal_disabled = 0;
@ -33,37 +33,36 @@ sounddef1 sounds1[2];
#ifdef _WIN32
// Windows
static HANDLE hALDLL;
static HANDLE hALDLL = NULL;
#else
#include <dlfcn.h>
static void *alhandle = NULL;
#endif
char *aldriver = NULL;
static char *aldriver = NULL;
void (AL_APIENTRY * balGetSourcei)(ALuint sid, ALenum param, ALint* value);
void (AL_APIENTRY * balSourcef)(ALuint sid, ALenum param, ALfloat value);
void (AL_APIENTRY * balSourcePlay)(ALuint sid);
void (AL_APIENTRY * balSourcePause)(ALuint sid);
ALCenum(ALC_APIENTRY * balcGetError)(ALCdevice *device);
ALenum(AL_APIENTRY * balGetError)(void);
void (AL_APIENTRY * balBufferData)(ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq);
void (AL_APIENTRY * balGenBuffers)(ALsizei n, ALuint* buffers);
void (AL_APIENTRY * balGenSources)(ALsizei n, ALuint* sources);
void (AL_APIENTRY * balSourcei)(ALuint sid, ALenum param, ALint value);
void (AL_APIENTRY * balSourceQueueBuffers)(ALuint sid, ALsizei numEntries, const ALuint *bids);
void (AL_APIENTRY * balSourceStop)(ALuint sid);
void (AL_APIENTRY * balSourceUnqueueBuffers)(ALuint sid, ALsizei numEntries, ALuint *bids);
void (AL_APIENTRY * bbalDeleteSources)(ALsizei n, const ALuint* sources);
ALCboolean(ALC_APIENTRY * balcMakeContextCurrent)(ALCcontext *context);
void (AL_APIENTRY * balDeleteSources)(ALsizei n, const ALuint* sources);
void (AL_APIENTRY * balDeleteBuffers)(ALsizei n, const ALuint* buffers);
void (ALC_APIENTRY * balcDestroyContext)(ALCcontext *context);
ALCboolean(ALC_APIENTRY * balcCloseDevice)(ALCdevice *device);
ALCdevice *(ALC_APIENTRY * balcOpenDevice)(const ALCchar *devicename);
ALCcontext *(ALC_APIENTRY * balcCreateContext)(ALCdevice *device, const ALCint* attrlist);
const ALchar*(AL_APIENTRY * balGetString)(ALenum param);
static void (AL_APIENTRY * balGetSourcei)(ALuint sid, ALenum param, ALint* value);
static void (AL_APIENTRY * balSourcef)(ALuint sid, ALenum param, ALfloat value);
static void (AL_APIENTRY * balSourcePlay)(ALuint sid);
static void (AL_APIENTRY * balSourcePause)(ALuint sid);
static ALCenum(ALC_APIENTRY * balcGetError)(ALCdevice *device);
static ALenum(AL_APIENTRY * balGetError)(void);
static void (AL_APIENTRY * balBufferData)(ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq);
static void (AL_APIENTRY * balGenBuffers)(ALsizei n, ALuint* buffers);
static void (AL_APIENTRY * balGenSources)(ALsizei n, ALuint* sources);
static void (AL_APIENTRY * balSourcei)(ALuint sid, ALenum param, ALint value);
static void (AL_APIENTRY * balSourceQueueBuffers)(ALuint sid, ALsizei numEntries, const ALuint *bids);
static void (AL_APIENTRY * balSourceStop)(ALuint sid);
static void (AL_APIENTRY * balSourceUnqueueBuffers)(ALuint sid, ALsizei numEntries, ALuint *bids);
static void (AL_APIENTRY * bbalDeleteSources)(ALsizei n, const ALuint* sources);
static ALCboolean(ALC_APIENTRY * balcMakeContextCurrent)(ALCcontext *context);
static void (AL_APIENTRY * balDeleteSources)(ALsizei n, const ALuint* sources);
static void (AL_APIENTRY * balDeleteBuffers)(ALsizei n, const ALuint* buffers);
static void (ALC_APIENTRY * balcDestroyContext)(ALCcontext *context);
static ALCboolean(ALC_APIENTRY * balcCloseDevice)(ALCdevice *device);
static ALCdevice *(ALC_APIENTRY * balcOpenDevice)(const ALCchar *devicename);
static ALCcontext *(ALC_APIENTRY * balcCreateContext)(ALCdevice *device, const ALCint* attrlist);
static const ALchar*(AL_APIENTRY * balGetString)(ALenum param);
static void * algetproc_(const char *s, int *err, int fatal)
{
@ -83,20 +82,23 @@ static void * algetproc_(const char *s, int *err, int fatal)
#define ALGETPROC(s) algetproc_(s,&err,1)
#define ALGETPROCSOFT(s) algetproc_(s,&err,0)
int unloadaldriver(void)
static int unloadaldriver(void)
{
#ifdef _WIN32
if (!hALDLL) return 0;
#endif
if (aldriver)
free(aldriver);
aldriver = NULL;
#ifdef _WIN32
if (hALDLL)
FreeLibrary(hALDLL);
hALDLL = NULL;
#else
if (alhandle) dlclose(alhandle);
if (alhandle)
dlclose(alhandle);
alhandle = NULL;
#endif
@ -126,14 +128,15 @@ int unloadaldriver(void)
return 0;
}
int loadaldriver(void)
static int loadaldriver(void)
{
void *t;
int err=0;
char *driver;
#ifdef _WIN32
if (hALDLL) return 0;
if (hALDLL)
return 0;
#endif
// if (!driver)
@ -149,7 +152,7 @@ int loadaldriver(void)
initprintf("Loading %s\n",driver);
#if defined _WIN32
#ifdef _WIN32
hALDLL = LoadLibrary(driver);
if (!hALDLL) return -1;
#else
@ -280,17 +283,17 @@ int AL_Init()
if (context)
{
char *s,*t,*u,i;
// char *s,*t,*u,i;
balcMakeContextCurrent(context);check(1);
initprintf("OpenAL Information:\n"
" Version: %s\n"
" Vendor: %s\n"
" Renderer: %s\n"
" Extensions:\n"
// " Extensions:\n"
,balGetString(AL_VERSION),balGetString(AL_VENDOR),balGetString(AL_RENDERER));
s = Bstrdup(balGetString(AL_EXTENSIONS));
/* s = Bstrdup(balGetString(AL_EXTENSIONS));
if (!s) initprintf(balGetString(AL_EXTENSIONS));
else
{
@ -312,7 +315,7 @@ int AL_Init()
if (i&1) initprintf(" %s\n",u);
Bfree(s);
}
*/
}
else initprintf("OpenAL initialization failed.\n");
@ -425,9 +428,10 @@ void AL_Stop()
Bmemset(&music,0,sizeof(sounddef1));
}
static char pcm[BUFFER_SIZE];
int stream(ALuint buffer)
{
char pcm[BUFFER_SIZE];
ALsizei size=0;
int section,result;
@ -437,7 +441,8 @@ int stream(ALuint buffer)
if (result==0&&music.loop)ov_pcm_seek(&music.def.oggStream,0);else
if (result> 0)size+=result;else break;
}
if (!size)return 0;
if (!size)
return 0;
ALdoing="stream";
balBufferData(buffer,music.format,pcm,size,music.rate);
check(1);
@ -448,14 +453,21 @@ void AL_PlaySong(char *ptr,int loop)
{
vorbis_info* vorbisInfo;
int bf=2,i;
ALenum format;ALsizei size;ALsizei freq;ALvoid* data;
ALenum format;
ALsizei size;
ALsizei freq;
ALvoid* data;
if (!context)return;
if (!context)
return;
Bmemset(&music,0,sizeof(sounddef1));
switch (*ptr)
{
case 'O':music.type=1;break;
default: return;
case 'O':
music.type=1;
break;
default:
return;
}
music.def.size=Musicsize;
music.loop=loop;
@ -478,7 +490,8 @@ void AL_PlaySong(char *ptr,int loop)
return;
}
music.rate=vorbisInfo->rate;
music.format=(vorbisInfo->channels==1)?AL_FORMAT_MONO16:AL_FORMAT_STEREO16;break;
music.format=(vorbisInfo->channels==1)?AL_FORMAT_MONO16:AL_FORMAT_STEREO16;
break;
}
ALdoing="Open";
@ -488,8 +501,10 @@ void AL_PlaySong(char *ptr,int loop)
switch (music.type)
{
case 1: stream(music.buffers[0]);
if (!stream(music.buffers[1]))bf=1;
case 1:
stream(music.buffers[0]);
if (!stream(music.buffers[1]))
bf=1;
balSourceQueueBuffers(music.source,bf,music.buffers);
break;
}

View file

@ -512,7 +512,7 @@ void PlayMusic(char *_filename, int loopflag)
#ifdef USE_OPENAL
if (!openal_disabled)
{
short fp;
int fp;
int l;
fp = kopen4load(_filename,0);

View file

@ -194,7 +194,7 @@ void intomenusounds(void)
void playmusic(const char *fn)
{
#if defined(_WIN32)
short fp;
int fp;
int l;
if (fn == NULL) return;
@ -209,11 +209,12 @@ void playmusic(const char *fn)
l = kfilelength(fp);
MUSIC_StopSong();
Musicsize=0;
if(!MusicPtr)MusicPtr=Bcalloc(1,l);
else MusicPtr=Brealloc(MusicPtr,l);
if(!MusicPtr)
MusicPtr=Bcalloc(1,l * sizeof(char));
else MusicPtr=Brealloc(MusicPtr,l * sizeof(char));
Musicsize=l;
kread(fp, MusicPtr, l);
kread(fp, (unsigned char *)MusicPtr, l);
kclose(fp);
MUSIC_PlaySong((unsigned char *)MusicPtr, MUSIC_LoopSong);
#else