mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
git-svn-id: https://svn.eduke32.com/eduke32@640 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
68675e28aa
commit
dd4a7b5450
14 changed files with 236 additions and 161 deletions
|
@ -23,11 +23,11 @@ flags_link=/RELEASE
|
|||
!endif
|
||||
|
||||
|
||||
DXROOT=c:\sdks\dx6
|
||||
DXROOT=c:\sdks\dx6
|
||||
MSSDKROOT="C:\Program Files\Microsoft Visual Studio 8\VC
|
||||
PLATFORMSDK="C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK
|
||||
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,9 +38,10 @@ 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
|
||||
EXESUFFIX=.exe
|
||||
|
@ -61,15 +62,15 @@ 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
|
||||
AUDIOLIB_MUSIC=$(OBJ)\midi.$o \
|
||||
$(OBJ)\mpu401.$o \
|
||||
$(OBJ)\music.$o
|
||||
|
||||
AUDIOLIBOBJ=$(AUDIOLIB_MUSIC) $(AUDIOLIB_FX) $(OBJ)\sounds.$o
|
||||
$(OBJ)\music.$o
|
||||
|
||||
AUDIOLIBOBJ=$(AUDIOLIB_MUSIC) $(AUDIOLIB_FX) $(OBJ)\sounds.$o
|
||||
|
||||
GAMEOBJS=$(OBJ)\game.$o \
|
||||
$(OBJ)\actors.$o \
|
||||
|
@ -145,9 +146,9 @@ eduke32$(EXESUFFIX): $(GAMEOBJS) $(EOBJ)\$(ENGINELIB)
|
|||
mapster32$(EXESUFFIX): $(EDITOROBJS) $(EOBJ)\$(ENGINELIB) $(EOBJ)\$(EDITORLIB)
|
||||
$(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) msvcrt.lib
|
||||
$(MT) -manifest $@.manifest $(RSRC)\manifest.build.xml -hashupdate -outputresource:$@ -out:$@.manifest
|
||||
|
||||
duke3d_w32$(EXESUFFIX): $(OBJ)/wrapper.$o
|
||||
$(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) msvcrt.lib
|
||||
|
||||
duke3d_w32$(EXESUFFIX): $(OBJ)/wrapper.$o
|
||||
$(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) msvcrt.lib
|
||||
$(MT) -manifest $@.manifest -outputresource:$@
|
||||
|
||||
!include Makefile.deps
|
||||
|
@ -166,7 +167,7 @@ $(EOBJ)\$(ENGINELIB): enginelib ;
|
|||
|
||||
# PHONIES
|
||||
clean:
|
||||
-del /Q $(OBJ)\* eduke32$(EXESUFFIX) mapster32$(EXESUFFIX) duke3d_w32$(EXESUFFIX) \
|
||||
-del /Q $(OBJ)\* eduke32$(EXESUFFIX) mapster32$(EXESUFFIX) duke3d_w32$(EXESUFFIX) \
|
||||
*.pdb *.map *.manifest
|
||||
|
||||
veryclean: clean
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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]);
|
||||
Bstrcat(fta_quotes[26],". USE SHIFT-F5 TO CHANGE.");
|
||||
}
|
||||
else fta_quotes[26][0] = '\0';
|
||||
Bstrcat(fta_quotes[26],". USE SHIFT-F5 TO CHANGE.");
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 *
|
||||
|
@ -267,7 +267,7 @@ int DisableInterrupts(void)
|
|||
SDL_LockAudio();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int RestoreInterrupts(int flags)
|
||||
{
|
||||
SDL_UnlockAudio();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -912,13 +912,14 @@ void downsample(char *ptr,int size,int factor)
|
|||
{
|
||||
short *pti=(short *)ptr;int i,j,sum;
|
||||
|
||||
for(i=0;i<size>>factor;i++)
|
||||
for (i=0;i<size>>factor;i++)
|
||||
{
|
||||
sum=0;
|
||||
for(j=0;j<1<<factor;j++)sum+=pti[(i<<factor)+j];
|
||||
for (j=0;j<1<<factor;j++)sum+=pti[(i<<factor)+j];
|
||||
pti[i]=sum>>factor;
|
||||
}
|
||||
}
|
||||
|
||||
playbackstatus MV_GetNextOGGBlock(VoiceNode *voice)
|
||||
{
|
||||
int sz;
|
||||
|
@ -948,24 +949,25 @@ playbackstatus MV_GetNextOGGBlock(VoiceNode *voice)
|
|||
voice->length <<= 16;
|
||||
|
||||
sz<<=voice->downsample+1;
|
||||
while(size<sz)
|
||||
while (size<sz)
|
||||
{
|
||||
result=ov_read(&voice->OGGstream.oggStream,voice->bufsnd+(size>>voice->downsample),sz-size,0,2,1,§ion);
|
||||
if(result> 0)
|
||||
{
|
||||
downsample(voice->bufsnd+(size>>voice->downsample),result,voice->downsample);
|
||||
size+=result;
|
||||
}else
|
||||
if(result==0)
|
||||
{
|
||||
result=ov_read(&voice->OGGstream.oggStream,voice->bufsnd+(size>>voice->downsample),sz-size,0,2,1,§ion);
|
||||
if (result> 0)
|
||||
{
|
||||
downsample(voice->bufsnd+(size>>voice->downsample),result,voice->downsample);
|
||||
size+=result;
|
||||
}
|
||||
else if (result==0)
|
||||
{
|
||||
// initprintf("!repeat %d\n",voice->callbackval);
|
||||
voice->BlockLength=0;
|
||||
voice->length=size<<16;break;
|
||||
}else
|
||||
{
|
||||
initprintf("#%d\n",result);
|
||||
break;
|
||||
}
|
||||
voice->BlockLength=0;
|
||||
voice->length=size<<16;break;
|
||||
}
|
||||
else
|
||||
{
|
||||
initprintf("#%d\n",result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
voice->sound=voice->bufsnd;
|
||||
|
||||
|
@ -1758,39 +1760,39 @@ int MV_SetMixMode(int numchannels, int samplebits)
|
|||
ov_callbacks cb;
|
||||
size_t ReadOgg(void *ptr, size_t size1, size_t nmemb, void *datasource)
|
||||
{
|
||||
sounddef *d=(sounddef *)datasource;
|
||||
size1*=nmemb;
|
||||
if(d->pos>=d->size)return 0;
|
||||
if(d->pos+size1>=d->size)size1=d->size-d->pos;
|
||||
Bmemcpy(ptr,(d->ptrsnd+d->pos),size1);
|
||||
d->pos+=size1;
|
||||
return size1;
|
||||
sounddef *d=(sounddef *)datasource;
|
||||
size1*=nmemb;
|
||||
if (d->pos>=d->size)return 0;
|
||||
if (d->pos+size1>=d->size)size1=d->size-d->pos;
|
||||
Bmemcpy(ptr,(d->ptrsnd+d->pos),size1);
|
||||
d->pos+=size1;
|
||||
return size1;
|
||||
}
|
||||
|
||||
int SeekOgg(void *datasource,ogg_int64_t offset,int whence)
|
||||
{
|
||||
sounddef *d=(sounddef *)datasource;
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET: whence=offset;break;
|
||||
case SEEK_CUR: whence=d->pos+offset;break;
|
||||
case SEEK_END: whence=d->size-offset-1;break;
|
||||
default: return -1;
|
||||
}
|
||||
if(whence>=(int)d->size||whence<0)return -1;
|
||||
d->pos=whence;
|
||||
return 0;
|
||||
sounddef *d=(sounddef *)datasource;
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET: whence=offset;break;
|
||||
case SEEK_CUR: whence=d->pos+offset;break;
|
||||
case SEEK_END: whence=d->size-offset-1;break;
|
||||
default: return -1;
|
||||
}
|
||||
if (whence>=(int)d->size||whence<0)return -1;
|
||||
d->pos=whence;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long TellOgg(void *datasource)
|
||||
{
|
||||
sounddef *d=(sounddef *)datasource;
|
||||
return d->pos;
|
||||
sounddef *d=(sounddef *)datasource;
|
||||
return d->pos;
|
||||
}
|
||||
|
||||
int CloseOgg(void *datasource)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -2394,7 +2396,7 @@ int MV_PlayLoopedVOC(char *ptr, int loopstart, int loopend, int pitchoffset, int
|
|||
Begin playback of sound data with the given sound levels and
|
||||
priority.
|
||||
---------------------------------------------------------------------*/
|
||||
VoiceNode *voice;
|
||||
VoiceNode *voice;
|
||||
|
||||
int MV_PlayLoopedOGG(char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval)
|
||||
{
|
||||
|
@ -2419,23 +2421,23 @@ int MV_PlayLoopedOGG(char *ptr, int loopstart, int loopend, int pitchoffset, int
|
|||
voice->OGGstream.ptrsnd=ptr;
|
||||
voice->OGGstream.size=g_sounds[callbackval].soundsiz;
|
||||
voice->downsample=0;
|
||||
if(ov_open_callbacks(&voice->OGGstream,&voice->OGGstream.oggStream,0,0,cb)<0)
|
||||
if (ov_open_callbacks(&voice->OGGstream,&voice->OGGstream.oggStream,0,0,cb)<0)
|
||||
{
|
||||
MV_SetErrorCode(MV_InvalidOGGFile);
|
||||
return(MV_Error);
|
||||
}
|
||||
|
||||
vorbisInfo=ov_info(&voice->OGGstream.oggStream,-1);
|
||||
if(!vorbisInfo)
|
||||
if (!vorbisInfo)
|
||||
{
|
||||
MV_SetErrorCode(MV_InvalidOGGFile);
|
||||
return(MV_Error);
|
||||
}
|
||||
|
||||
while((uint64)(vorbisInfo->rate)/(1<<voice->downsample)*PITCH_GetScale(pitchoffset)/0x1000000/0x100)
|
||||
voice->downsample++;
|
||||
while ((uint64)(vorbisInfo->rate)/(1<<voice->downsample)*PITCH_GetScale(pitchoffset)/0x1000000/0x100)
|
||||
voice->downsample++;
|
||||
length=ov_pcm_total(&voice->OGGstream.oggStream,0);
|
||||
if(!length)length=0xffffff;
|
||||
if (!length)length=0xffffff;
|
||||
loopend=length=length>>voice->downsample;
|
||||
|
||||
voice->wavetype = OGG;
|
||||
|
@ -2466,7 +2468,7 @@ int MV_PlayLoopedOGG(char *ptr, int loopstart, int loopend, int pitchoffset, int
|
|||
}
|
||||
|
||||
MV_SetVoicePitch(voice, vorbisInfo->rate>>voice->downsample, pitchoffset);
|
||||
if(vorbisInfo->channels==2)voice->downsample++;
|
||||
if (vorbisInfo->channels==2)voice->downsample++;
|
||||
MV_SetVoiceVolume(voice, vol, left, right);
|
||||
MV_PlayVoice(voice);
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
||||
free(aldriver);
|
||||
if (aldriver)
|
||||
free(aldriver);
|
||||
aldriver = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(hALDLL);
|
||||
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,39 +283,39 @@ 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));
|
||||
if (!s) initprintf(balGetString(AL_EXTENSIONS));
|
||||
else
|
||||
{
|
||||
i = 0; t = u = s;
|
||||
while (*t)
|
||||
{
|
||||
if (*t == ' ')
|
||||
/* s = Bstrdup(balGetString(AL_EXTENSIONS));
|
||||
if (!s) initprintf(balGetString(AL_EXTENSIONS));
|
||||
else
|
||||
{
|
||||
if (i&1)
|
||||
i = 0; t = u = s;
|
||||
while (*t)
|
||||
{
|
||||
*t = 0;
|
||||
initprintf(" %s\n",u);
|
||||
u = t+1;
|
||||
if (*t == ' ')
|
||||
{
|
||||
if (i&1)
|
||||
{
|
||||
*t = 0;
|
||||
initprintf(" %s\n",u);
|
||||
u = t+1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
t++;
|
||||
}
|
||||
i++;
|
||||
if (i&1) initprintf(" %s\n",u);
|
||||
Bfree(s);
|
||||
}
|
||||
t++;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -429,9 +429,9 @@ void MUSIC_Continue(void)
|
|||
Mix_ResumeMusic();
|
||||
else if (music_songdata
|
||||
#ifdef USE_OPENAL
|
||||
&& (openal_disabled || AL_isntALmusic())
|
||||
&& (openal_disabled || AL_isntALmusic())
|
||||
#endif
|
||||
)
|
||||
)
|
||||
MUSIC_PlaySong((unsigned char *)music_songdata, MUSIC_PlayOnce);
|
||||
} // MUSIC_Continue
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -279,7 +279,7 @@ static int getsound(unsigned int num)
|
|||
if (ud.config.FXDevice < 0) return 0;
|
||||
|
||||
if (!g_sounds[num].filename) return 0;
|
||||
if(g_sounds[num].filename1)fp = kopen4load(g_sounds[num].filename1,loadfromgrouponly);
|
||||
if (g_sounds[num].filename1)fp = kopen4load(g_sounds[num].filename1,loadfromgrouponly);
|
||||
if (fp == -1)fp = kopen4load(g_sounds[num].filename,loadfromgrouponly);
|
||||
if (fp == -1) return 0;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue