mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 10:40:47 +00:00
Hopefully the last of the formatting changes + sound support for Linux. Previous commit also fixes the mouse cursor grab issue.
git-svn-id: https://svn.eduke32.com/eduke32@337 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
9f9ccf8344
commit
bbbccb7b11
47 changed files with 37320 additions and 33006 deletions
|
@ -66,9 +66,21 @@ JMACTOBJ=$(OBJ)/util_lib.$o \
|
|||
$(OBJ)/mathutil.$o \
|
||||
$(OBJ)/scriplib.$o
|
||||
|
||||
AUDIOLIB_FX_STUB=$(OBJ)/audiolib_fxstub.$o
|
||||
AUDIOLIB_MUSIC_STUB=$(OBJ)/audiolib_musicstub.$o
|
||||
AUDIOLIB_FX_SDL=$(OBJ)/mv_mix.$o \
|
||||
$(OBJ)/mv_mix16.$o \
|
||||
$(OBJ)/mvreverb.$o \
|
||||
$(OBJ)/ll_man.$o \
|
||||
$(OBJ)/fx_man.$o \
|
||||
$(OBJ)/dsl.$o \
|
||||
$(OBJ)/nodpmi.$o \
|
||||
$(OBJ)/unixpitch.$o \
|
||||
$(OBJ)/unixvoc.$o
|
||||
|
||||
AUDIOLIB_MUSIC_SDL=$(OBJ)/sdlmusic.$o \
|
||||
$(OBJ)/unixglob.$o
|
||||
|
||||
AUDIOLIB_JFAUD=$(OBJ)/jfaud_sounds.$o
|
||||
|
||||
AUDIOLIB_FX=$(OBJ)/mv_mix.$o \
|
||||
$(OBJ)/mv_mix16.$o \
|
||||
$(OBJ)/mvreverb.$o \
|
||||
|
@ -113,11 +125,12 @@ endif
|
|||
|
||||
ifeq ($(RENDERTYPE),SDL)
|
||||
OURCFLAGS+= $(subst -Dmain=SDL_main,,$(shell sdl-config --cflags))
|
||||
LIBS+= -lSDL_mixer
|
||||
|
||||
ifneq (0,$(JFAUD))
|
||||
AUDIOLIBOBJ=$(AUDIOLIB_JFAUD)
|
||||
else
|
||||
AUDIOLIBOBJ=$(AUDIOLIB_MUSIC_STUB) $(AUDIOLIB_FX_STUB) $(OBJ)/sounds.$o
|
||||
AUDIOLIBOBJ=$(AUDIOLIB_MUSIC_SDL) $(AUDIOLIB_FX_SDL) $(OBJ)/sounds.$o
|
||||
endif
|
||||
|
||||
ifeq (1,$(HAVE_GTK2))
|
||||
|
|
|
@ -45,6 +45,11 @@ $(OBJ)/mathutil.$o: $(SRC)/jmact/mathutil.c $(SRC)/jmact/types.h
|
|||
$(OBJ)/scriplib.$o: $(SRC)/jmact/scriplib.c $(SRC)/jmact/scriplib.h $(SRC)/jmact/util_lib.h $(SRC)/jmact/_scrplib.h $(SRC)/jmact/types.h $(EINC)/compat.h
|
||||
|
||||
# jAudioLib objects
|
||||
$(OBJ)/dsl.$o: $(SRC)/jaudiolib/dsl.c $(SRC)/jaudiolib/util.h
|
||||
$(OBJ)/nodpmi.$o: $(SRC)/jaudiolib/nodpmi.c $(SRC)/jaudiolib/dpmi.h
|
||||
$(OBJ)/unixpitch.$o: $(SRC)/jaudiolib/unixpitch.c $(SRC)/jaudiolib/pitch.h
|
||||
$(OBJ)/unixvoc.$o: $(SRC)/jaudiolib/unixvoc.c $(SRC)/jaudiolib/usrhooks.h $(SRC)/jaudiolib/linklist.h $(SRC)/jaudiolib/pitch.h $(SRC)/jaudiolib/multivoc.h $(SRC)/jaudiolib/_multivc.h
|
||||
|
||||
$(OBJ)/audiolib_fxstub.$o: $(SRC)/jaudiolib/audiolib_fxstub.c $(SRC)/jaudiolib/fx_man.h
|
||||
$(OBJ)/audiolib_musicstub.$o: $(SRC)/jaudiolib/audiolib_musicstub.c $(SRC)/jaudiolib/music.h
|
||||
|
||||
|
|
|
@ -4298,8 +4298,7 @@ void ExtPreSaveMap(void)
|
|||
}
|
||||
|
||||
void ExtPreLoadMap(void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
int ExtPreInit(int *argc,char ***argv)
|
||||
{
|
||||
|
|
|
@ -10,15 +10,14 @@
|
|||
|
||||
struct grpfile grpfiles[numgrpfiles] =
|
||||
{
|
||||
{ "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAMEDUKE, NULL
|
||||
}
|
||||
,
|
||||
{ "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAMEDUKE, NULL },
|
||||
{ "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAMEDUKE, NULL },
|
||||
{ "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL },
|
||||
{ "Duke Nukem 3D Shareware Version", 0x983AD923, 11035779, GAMEDUKE, NULL },
|
||||
{ "Duke Nukem 3D Mac Shareware Version", 0xC5F71561, 10444391, GAMEDUKE, NULL },
|
||||
{ "Duke Nukem 3D Mac", 0x00000000, 0, GAMEDUKE, NULL },
|
||||
{ "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL },
|
||||
{ "Napalm", 0x3DE1589A, 44365728, GAMENAM, NULL },
|
||||
};
|
||||
struct grpfile *foundgrps = NULL;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define __grpscan_h__
|
||||
|
||||
// List of internally-known GRP files
|
||||
#define numgrpfiles 7
|
||||
#define numgrpfiles 8
|
||||
struct grpfile {
|
||||
const char *name;
|
||||
int crcval;
|
||||
|
|
|
@ -67,8 +67,11 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
|
|||
#define SILENCE_8BIT 0x80808080
|
||||
//#define SILENCE_16BIT_PAS 0
|
||||
|
||||
//#define MixBufferSize 256
|
||||
#ifdef WINDOWS
|
||||
#define MixBufferSize (MV_GetBufferSize(MV_RequestedMixRate))
|
||||
#else
|
||||
#define MixBufferSize 256
|
||||
#endif
|
||||
|
||||
#define NumberOfBuffers 16
|
||||
#define TotalBufferSize ( MixBufferSize * NumberOfBuffers )
|
||||
|
@ -269,10 +272,14 @@ parm [ edi ] [ eax ] [ ecx ] modify exact [ ecx edi ];
|
|||
|
||||
#define CDEC _cdecl
|
||||
|
||||
#else
|
||||
#elif defined(WINDOWS)
|
||||
|
||||
#define CDEC __cdecl
|
||||
|
||||
#else
|
||||
|
||||
#define CDEC
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ extern long hWindow;
|
|||
#endif
|
||||
|
||||
|
||||
void (*FX_CallBackFunc)(unsigned long) = NULL;
|
||||
void(*FX_CallBackFunc)(unsigned long) = NULL;
|
||||
int FX_ErrorCode = FX_Ok;
|
||||
|
||||
#define FX_SetErrorCode( status ) \
|
||||
|
@ -68,11 +68,11 @@ char *FX_ErrorString(int ErrorNumber)
|
|||
{
|
||||
char *ErrorString;
|
||||
|
||||
switch( ErrorNumber )
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case FX_Warning :
|
||||
case FX_Error :
|
||||
ErrorString = FX_ErrorString( FX_ErrorCode );
|
||||
ErrorString = FX_ErrorString(FX_ErrorCode);
|
||||
break;
|
||||
|
||||
case FX_Ok :
|
||||
|
@ -94,7 +94,7 @@ char *FX_ErrorString(int ErrorNumber)
|
|||
break;
|
||||
}
|
||||
|
||||
return( ErrorString );
|
||||
return(ErrorString);
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,7 +106,8 @@ char *FX_ErrorString(int ErrorNumber)
|
|||
|
||||
static char *OutputType(int a)
|
||||
{
|
||||
switch (a) {
|
||||
switch (a)
|
||||
{
|
||||
case FSOUND_OUTPUT_NOSOUND: return "no-sound";
|
||||
case FSOUND_OUTPUT_WINMM: return "WinMM";
|
||||
case FSOUND_OUTPUT_DSOUND: return "DirectSound";
|
||||
|
@ -129,12 +130,14 @@ int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsig
|
|||
memset(FX_Samples, 0, sizeof(FX_Samples));
|
||||
|
||||
#ifdef WINDOWS
|
||||
if (hWindow) {
|
||||
if (hWindow)
|
||||
{
|
||||
//FSOUND_SetHWND(&hWindow);
|
||||
}
|
||||
#endif
|
||||
if (!FSOUND_Init(mixrate, numvoices, FSOUND_INIT_GLOBALFOCUS)) {
|
||||
FX_SetErrorCode( FX_FMODInit );
|
||||
if (!FSOUND_Init(mixrate, numvoices, FSOUND_INIT_GLOBALFOCUS))
|
||||
{
|
||||
FX_SetErrorCode(FX_FMODInit);
|
||||
return FX_Error;
|
||||
}
|
||||
|
||||
|
@ -167,7 +170,8 @@ int FX_Shutdown(void)
|
|||
{
|
||||
unsigned int curalloced, maxalloced;
|
||||
|
||||
if (chstates) {
|
||||
if (chstates)
|
||||
{
|
||||
FSOUND_GetMemoryStats(&curalloced, &maxalloced);
|
||||
printOSD("FX_Shutdown(): allocation stats - currently %d bytes, maximum %d bytes\n",curalloced,maxalloced);
|
||||
}
|
||||
|
@ -188,7 +192,7 @@ int FX_Shutdown(void)
|
|||
Sets the function to call when a voice is done.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_SetCallBack(void ( *function )( unsigned long ))
|
||||
int FX_SetCallBack(void(*function)(unsigned long))
|
||||
{
|
||||
FX_CallBackFunc = function;
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
|
@ -215,8 +219,7 @@ void FX_SetVolume(int volume)
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverseStereo(int setting)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -238,8 +241,7 @@ int FX_GetReverseStereo(void)
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverb(int reverb)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -249,8 +251,7 @@ void FX_SetReverb(int reverb)
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverbDelay(int delay)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -278,7 +279,7 @@ int FX_VoiceAvailable(int priority)
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayLoopedVOC
|
||||
(
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
|
@ -288,7 +289,7 @@ int FX_PlayLoopedVOC
|
|||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
)
|
||||
{
|
||||
return FX_PlayLoopedSound(pitchoffset, vol, callbackval);
|
||||
}
|
||||
|
@ -301,7 +302,7 @@ int FX_PlayLoopedVOC
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayLoopedWAV
|
||||
(
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
|
@ -311,7 +312,7 @@ int FX_PlayLoopedWAV
|
|||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
)
|
||||
{
|
||||
return FX_PlayLoopedSound(pitchoffset, vol, callbackval);
|
||||
}
|
||||
|
@ -325,14 +326,14 @@ int FX_PlayLoopedWAV
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayVOC3D
|
||||
(
|
||||
(
|
||||
char *ptr,
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
)
|
||||
{
|
||||
return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval);
|
||||
}
|
||||
|
@ -346,14 +347,14 @@ int FX_PlayVOC3D
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayWAV3D
|
||||
(
|
||||
(
|
||||
char *ptr,
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
)
|
||||
{
|
||||
return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval);
|
||||
}
|
||||
|
@ -367,11 +368,11 @@ int FX_PlayWAV3D
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_Pan3D
|
||||
(
|
||||
(
|
||||
int handle,
|
||||
int angle,
|
||||
int distance
|
||||
)
|
||||
)
|
||||
{
|
||||
return FX_Ok;
|
||||
}
|
||||
|
@ -499,21 +500,27 @@ int FX_LoadSample(char *ptr, long size, unsigned long number, int priority)
|
|||
void *ptr1,*ptr2;
|
||||
int ptr1len,ptr2len;
|
||||
|
||||
if (!memcmp(ptr, "Creative Voice File", 0x13)) {
|
||||
if (!memcmp(ptr, "Creative Voice File", 0x13))
|
||||
{
|
||||
// VOC file
|
||||
if (FX_ReadVOCInfo(ptr,size,&samplerate,&channels,&samplesize,&datalen) == 0) {
|
||||
if (FX_ReadVOCInfo(ptr,size,&samplerate,&channels,&samplesize,&datalen) == 0)
|
||||
{
|
||||
flags |= (channels==2)?FSOUND_STEREO:FSOUND_MONO;
|
||||
flags |= (samplesize==16)?FSOUND_16BITS:FSOUND_8BITS;
|
||||
flags |= FSOUND_SIGNED;
|
||||
samp = FSOUND_Sample_Alloc(number, (datalen >> (channels-1)) / (samplesize>>3), flags, samplerate, -1, -1, priority);
|
||||
if (samp) {
|
||||
if (FSOUND_Sample_Lock(samp,0,datalen,&ptr1,&ptr2,&ptr1len,&ptr2len)) {
|
||||
if (samp)
|
||||
{
|
||||
if (FSOUND_Sample_Lock(samp,0,datalen,&ptr1,&ptr2,&ptr1len,&ptr2len))
|
||||
{
|
||||
if (FX_ReadVOCData(ptr,ptr1,datalen,(samplesize==8))) ;
|
||||
FSOUND_Sample_Unlock(samp,ptr1,ptr2,ptr1len,ptr2len);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
samp = FSOUND_Sample_Load(number, ptr, FSOUND_LOADMEMORY, size);
|
||||
}
|
||||
|
||||
|
@ -552,7 +559,8 @@ int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *s
|
|||
|
||||
ptr += 4;
|
||||
|
||||
while (1) {
|
||||
while (1)
|
||||
{
|
||||
blocktype = *(ptr++);
|
||||
if ((ptr-data)>size) return -1; // truncated
|
||||
|
||||
|
@ -563,11 +571,13 @@ int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *s
|
|||
blocklen |= *(ptr++) << 8;
|
||||
blocklen |= *(ptr++) << 16;
|
||||
|
||||
switch (blocktype) {
|
||||
switch (blocktype)
|
||||
{
|
||||
case 1: /* sound data begin block */
|
||||
if (!*samplerate)
|
||||
*samplerate = REGRESSSR(ptr[0]);
|
||||
if (ptr[1] != 0) {
|
||||
if (ptr[1] != 0)
|
||||
{
|
||||
/* only 8-bit files please */
|
||||
return -1;
|
||||
}
|
||||
|
@ -619,12 +629,15 @@ int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *s
|
|||
case 8: /* sound attribute extension block */
|
||||
*samplerate = REGRESSTC(ptr[0] | (ptr[1] << 8));
|
||||
*samplesize = 8;
|
||||
if (ptr[3] == 1) {
|
||||
if (ptr[3] == 1)
|
||||
{
|
||||
*samplerate >>= 1;
|
||||
*channels = 2;
|
||||
} else
|
||||
}
|
||||
else
|
||||
*channels = 1;
|
||||
if (ptr[2] != 0) {
|
||||
if (ptr[2] != 0)
|
||||
{
|
||||
/* only 8-bit files please */
|
||||
return -1;
|
||||
}
|
||||
|
@ -637,7 +650,8 @@ int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *s
|
|||
*samplesize = ptr[4];
|
||||
*channels = ptr[5];
|
||||
if ((ptr[6] | (ptr[7] << 8)) != 0 &&
|
||||
(ptr[6] | (ptr[7] << 8)) != 4) {
|
||||
(ptr[6] | (ptr[7] << 8)) != 4)
|
||||
{
|
||||
/* only PCM please */
|
||||
return -1;
|
||||
}
|
||||
|
@ -663,7 +677,8 @@ int FX_ReadVOCData(char *data, char *buf, int bufferlen, char eightbit)
|
|||
|
||||
data += 0x14 + 2 + 4;
|
||||
|
||||
while (bufferlen>0) {
|
||||
while (bufferlen>0)
|
||||
{
|
||||
blocktype = *(data++);
|
||||
|
||||
if (blocktype == 0)
|
||||
|
@ -673,7 +688,8 @@ int FX_ReadVOCData(char *data, char *buf, int bufferlen, char eightbit)
|
|||
blocklen |= *(data++) << 8;
|
||||
blocklen |= *(data++) << 16;
|
||||
|
||||
switch (blocktype) {
|
||||
switch (blocktype)
|
||||
{
|
||||
case 1: /* sound data */
|
||||
data += 2;
|
||||
|
||||
|
@ -696,11 +712,14 @@ int FX_ReadVOCData(char *data, char *buf, int bufferlen, char eightbit)
|
|||
}
|
||||
convertdata:
|
||||
bufferlen -= br;
|
||||
if (eightbit) {
|
||||
if (eightbit)
|
||||
{
|
||||
// FMOD wants signed data
|
||||
for (; br>0; br--)
|
||||
*(buf++) = (char)((short)(*(data++)) - 0x80);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(buf,data,br);
|
||||
buf += br;
|
||||
data += br;
|
||||
|
@ -720,7 +739,8 @@ int FX_SimulateCallbacks(void)
|
|||
chstatesa = chstates + (FX_NumVoices * chtoggle);
|
||||
chstatesb = chstates + (FX_NumVoices * (chtoggle^1));
|
||||
|
||||
for (i=0;i<FX_NumVoices;i++) {
|
||||
for (i=0;i<FX_NumVoices;i++)
|
||||
{
|
||||
chstatesa[i] = FSOUND_IsPlaying(i);
|
||||
if (chstatesa[i] == chstatesb[i]) continue; // channel is still silent/playing
|
||||
if (chstatesa[i] > chstatesb[i]) continue; // channel has begun playing
|
||||
|
|
|
@ -45,18 +45,18 @@ int FX_ErrorCode = FX_Ok;
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
char *FX_ErrorString
|
||||
(
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char *ErrorString;
|
||||
|
||||
switch( ErrorNumber )
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case FX_Warning :
|
||||
case FX_Error :
|
||||
ErrorString = FX_ErrorString( FX_ErrorCode );
|
||||
ErrorString = FX_ErrorString(FX_ErrorCode);
|
||||
break;
|
||||
|
||||
case FX_Ok :
|
||||
|
@ -74,8 +74,8 @@ char *FX_ErrorString
|
|||
break;
|
||||
}
|
||||
|
||||
return( ErrorString );
|
||||
}
|
||||
return(ErrorString);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -85,17 +85,17 @@ char *FX_ErrorString
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_Init
|
||||
(
|
||||
(
|
||||
int SoundCard,
|
||||
int numvoices,
|
||||
int numchannels,
|
||||
int samplebits,
|
||||
unsigned mixrate
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( FX_Ok );
|
||||
}
|
||||
{
|
||||
return(FX_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -105,13 +105,13 @@ int FX_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_Shutdown
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( FX_Ok );
|
||||
}
|
||||
{
|
||||
return(FX_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -121,13 +121,13 @@ int FX_Shutdown
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_SetCallBack
|
||||
(
|
||||
void ( *function )( unsigned long )
|
||||
)
|
||||
(
|
||||
void(*function)(unsigned long)
|
||||
)
|
||||
|
||||
{
|
||||
return( FX_Ok );
|
||||
}
|
||||
{
|
||||
return(FX_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -137,12 +137,11 @@ int FX_SetCallBack
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetVolume
|
||||
(
|
||||
(
|
||||
int volume
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -152,12 +151,11 @@ void FX_SetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverseStereo
|
||||
(
|
||||
(
|
||||
int setting
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -167,13 +165,13 @@ void FX_SetReverseStereo
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_GetReverseStereo
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -183,12 +181,11 @@ int FX_GetReverseStereo
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverb
|
||||
(
|
||||
(
|
||||
int reverb
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -198,12 +195,11 @@ void FX_SetReverb
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverbDelay
|
||||
(
|
||||
(
|
||||
int delay
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -213,13 +209,13 @@ void FX_SetReverbDelay
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_VoiceAvailable
|
||||
(
|
||||
(
|
||||
int priority
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -229,7 +225,7 @@ int FX_VoiceAvailable
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayLoopedVOC
|
||||
(
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
|
@ -239,11 +235,11 @@ int FX_PlayLoopedVOC
|
|||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -253,7 +249,7 @@ int FX_PlayLoopedVOC
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayLoopedWAV
|
||||
(
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
|
@ -263,11 +259,11 @@ int FX_PlayLoopedWAV
|
|||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -278,18 +274,18 @@ int FX_PlayLoopedWAV
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayVOC3D
|
||||
(
|
||||
(
|
||||
char *ptr,
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -300,18 +296,18 @@ int FX_PlayVOC3D
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayWAV3D
|
||||
(
|
||||
(
|
||||
char *ptr,
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -322,15 +318,15 @@ int FX_PlayWAV3D
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_Pan3D
|
||||
(
|
||||
(
|
||||
int handle,
|
||||
int angle,
|
||||
int distance
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -340,13 +336,13 @@ int FX_Pan3D
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_StopSound
|
||||
(
|
||||
(
|
||||
int handle
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( FX_Ok );
|
||||
}
|
||||
{
|
||||
return(FX_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -356,13 +352,13 @@ int FX_StopSound
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_StopAllSounds
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( FX_Ok );
|
||||
}
|
||||
{
|
||||
return(FX_Ok);
|
||||
}
|
||||
|
||||
|
||||
void AudioUpdate(void) { }
|
||||
|
|
|
@ -41,18 +41,18 @@ int MUSIC_ErrorCode = MUSIC_Ok;
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
char *MUSIC_ErrorString
|
||||
(
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char *ErrorString;
|
||||
|
||||
switch( ErrorNumber )
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case MUSIC_Warning :
|
||||
case MUSIC_Error :
|
||||
ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode );
|
||||
ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode);
|
||||
break;
|
||||
|
||||
case MUSIC_Ok :
|
||||
|
@ -93,8 +93,8 @@ char *MUSIC_ErrorString
|
|||
break;
|
||||
}
|
||||
|
||||
return( ErrorString );
|
||||
}
|
||||
return(ErrorString);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -104,19 +104,19 @@ char *MUSIC_ErrorString
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_Init
|
||||
(
|
||||
(
|
||||
int SoundCard,
|
||||
int Address
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
|
||||
status = MUSIC_Ok;
|
||||
|
||||
return( status );
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -126,18 +126,18 @@ int MUSIC_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_Shutdown
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
int status;
|
||||
|
||||
status = MUSIC_Ok;
|
||||
|
||||
|
||||
return( status );
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -147,12 +147,11 @@ int MUSIC_Shutdown
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetMaxFMMidiChannel
|
||||
(
|
||||
(
|
||||
int channel
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -162,12 +161,11 @@ void MUSIC_SetMaxFMMidiChannel
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetVolume
|
||||
(
|
||||
(
|
||||
int volume
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -177,13 +175,12 @@ void MUSIC_SetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetMidiChannelVolume
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int volume
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -193,12 +190,11 @@ void MUSIC_SetMidiChannelVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_ResetMidiChannelVolumes
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -208,13 +204,13 @@ void MUSIC_ResetMidiChannelVolumes
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_GetVolume
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -225,12 +221,11 @@ int MUSIC_GetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetLoopFlag
|
||||
(
|
||||
(
|
||||
int loopflag
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -240,13 +235,13 @@ void MUSIC_SetLoopFlag
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_SongPlaying
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -256,12 +251,11 @@ int MUSIC_SongPlaying
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_Continue
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -271,12 +265,11 @@ void MUSIC_Continue
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_Pause
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -286,13 +279,13 @@ void MUSIC_Pause
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_StopSong
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
{
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -302,14 +295,14 @@ int MUSIC_StopSong
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_PlaySong
|
||||
(
|
||||
(
|
||||
unsigned char *song,
|
||||
int loopflag
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
{
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -319,12 +312,11 @@ int MUSIC_PlaySong
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetContext
|
||||
(
|
||||
(
|
||||
int context
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -334,12 +326,11 @@ void MUSIC_SetContext
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_GetContext
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -349,12 +340,11 @@ int MUSIC_GetContext
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongTick
|
||||
(
|
||||
(
|
||||
unsigned long PositionInTicks
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -364,12 +354,11 @@ void MUSIC_SetSongTick
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongTime
|
||||
(
|
||||
(
|
||||
unsigned long milliseconds
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -379,14 +368,13 @@ void MUSIC_SetSongTime
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongPosition
|
||||
(
|
||||
(
|
||||
int measure,
|
||||
int beat,
|
||||
int tick
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -396,12 +384,11 @@ void MUSIC_SetSongPosition
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_GetSongPosition
|
||||
(
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -411,12 +398,11 @@ void MUSIC_GetSongPosition
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_GetSongLength
|
||||
(
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
@ -431,14 +417,14 @@ void MUSIC_GetSongLength
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_FadeVolume
|
||||
(
|
||||
(
|
||||
int tovolume,
|
||||
int milliseconds
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
{
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -448,13 +434,13 @@ int MUSIC_FadeVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_FadeActive
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -464,12 +450,11 @@ int MUSIC_FadeActive
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_StopFade
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -480,13 +465,12 @@ void MUSIC_StopFade
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_RerouteMidiChannel
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int ( *function )( int event, int c1, int c2 )
|
||||
)
|
||||
int(*function)(int event, int c1, int c2)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -496,15 +480,13 @@ void MUSIC_RerouteMidiChannel
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_RegisterTimbreBank
|
||||
(
|
||||
(
|
||||
unsigned char *timbres
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void MUSIC_Update(void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
|
30
polymer/eduke32/source/jaudiolib/debugio.h
Executable file
30
polymer/eduke32/source/jaudiolib/debugio.h
Executable file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
Copyright (C) 1994-1995 Apogee Software, Ltd.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
#ifndef __DEBUGIO_H
|
||||
#define __DEBUGIO_H
|
||||
|
||||
void DB_SetXY( int x, int y );
|
||||
void DB_PutChar( char ch );
|
||||
int DB_PrintString( char *string );
|
||||
int DB_PrintNum( int number );
|
||||
int DB_PrintUnsigned( unsigned long number, int radix );
|
||||
int DB_printf( char *fmt, ... );
|
||||
|
||||
#endif
|
83
polymer/eduke32/source/jaudiolib/dma.h
Executable file
83
polymer/eduke32/source/jaudiolib/dma.h
Executable file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
Copyright (C) 1994-1995 Apogee Software, Ltd.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
/**********************************************************************
|
||||
file: DMA.H
|
||||
|
||||
author: James R. Dose
|
||||
date: February 4, 1994
|
||||
|
||||
Public header file for DMA.C
|
||||
|
||||
(c) Copyright 1994 James R. Dose. All Rights Reserved.
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __DMA_H
|
||||
#define __DMA_H
|
||||
|
||||
enum DMA_ERRORS
|
||||
{
|
||||
DMA_Error = -1,
|
||||
DMA_Ok = 0,
|
||||
DMA_ChannelOutOfRange,
|
||||
DMA_InvalidChannel
|
||||
};
|
||||
|
||||
enum DMA_Modes
|
||||
{
|
||||
DMA_SingleShotRead,
|
||||
DMA_SingleShotWrite,
|
||||
DMA_AutoInitRead,
|
||||
DMA_AutoInitWrite
|
||||
};
|
||||
|
||||
char *DMA_ErrorString
|
||||
(
|
||||
int ErrorNumber
|
||||
);
|
||||
|
||||
int DMA_VerifyChannel
|
||||
(
|
||||
int channel
|
||||
);
|
||||
|
||||
int DMA_SetupTransfer
|
||||
(
|
||||
int channel,
|
||||
char *address,
|
||||
int length,
|
||||
int mode
|
||||
);
|
||||
|
||||
int DMA_EndTransfer
|
||||
(
|
||||
int channel
|
||||
);
|
||||
|
||||
char *DMA_GetCurrentPos
|
||||
(
|
||||
int channel
|
||||
);
|
||||
|
||||
int DMA_GetTransferCount
|
||||
(
|
||||
int channel
|
||||
);
|
||||
|
||||
#endif
|
43
polymer/eduke32/source/jaudiolib/dpmi.h
Executable file
43
polymer/eduke32/source/jaudiolib/dpmi.h
Executable file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Copyright (C) 1994-1995 Apogee Software, Ltd.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
/**********************************************************************
|
||||
module: DPMI.H
|
||||
|
||||
author: James R. Dose
|
||||
date: March 31, 1994
|
||||
|
||||
Inline functions for performing DPMI calls.
|
||||
|
||||
(c) Copyright 1994 James R. Dose. All Rights Reserved.
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __DPMI_H
|
||||
#define __DPMI_H
|
||||
|
||||
enum DPMI_Errors
|
||||
{
|
||||
DPMI_Warning = -2,
|
||||
DPMI_Error = -1,
|
||||
DPMI_Ok = 0
|
||||
};
|
||||
|
||||
int DPMI_GetDOSMemory( void **ptr, int *descriptor, unsigned length );
|
||||
int DPMI_FreeDOSMemory( int descriptor );
|
||||
#endif
|
266
polymer/eduke32/source/jaudiolib/dsl.c
Executable file
266
polymer/eduke32/source/jaudiolib/dsl.c
Executable file
|
@ -0,0 +1,266 @@
|
|||
/*
|
||||
Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Originally written by Ryan C. Gordon. (icculus@clutteredmind.org)
|
||||
Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu)
|
||||
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dsl.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
extern volatile int MV_MixPage;
|
||||
|
||||
static int DSL_ErrorCode = DSL_Ok;
|
||||
|
||||
static int mixer_initialized;
|
||||
|
||||
static void(*_CallBackFunc)(void);
|
||||
static volatile char *_BufferStart;
|
||||
static int _BufferSize;
|
||||
static int _NumDivisions;
|
||||
static int _SampleRate;
|
||||
static int _remainder;
|
||||
|
||||
static Mix_Chunk *blank;
|
||||
static unsigned char *blank_buf;
|
||||
|
||||
/*
|
||||
possible todo ideas: cache sdl/sdl mixer error messages.
|
||||
*/
|
||||
|
||||
char *DSL_ErrorString(int ErrorNumber)
|
||||
{
|
||||
char *ErrorString;
|
||||
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case DSL_Warning:
|
||||
case DSL_Error:
|
||||
ErrorString = DSL_ErrorString(DSL_ErrorCode);
|
||||
break;
|
||||
|
||||
case DSL_Ok:
|
||||
ErrorString = "SDL Driver ok.";
|
||||
break;
|
||||
|
||||
case DSL_SDLInitFailure:
|
||||
ErrorString = "SDL Audio initialization failed.";
|
||||
break;
|
||||
|
||||
case DSL_MixerActive:
|
||||
ErrorString = "SDL Mixer already initialized.";
|
||||
break;
|
||||
|
||||
case DSL_MixerInitFailure:
|
||||
ErrorString = "SDL Mixer initialization failed.";
|
||||
break;
|
||||
|
||||
default:
|
||||
ErrorString = "Unknown SDL Driver error.";
|
||||
break;
|
||||
}
|
||||
|
||||
return ErrorString;
|
||||
}
|
||||
|
||||
static void DSL_SetErrorCode(int ErrorCode)
|
||||
{
|
||||
DSL_ErrorCode = ErrorCode;
|
||||
}
|
||||
|
||||
int DSL_Init(void)
|
||||
{
|
||||
DSL_SetErrorCode(DSL_Ok);
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
||||
{
|
||||
DSL_SetErrorCode(DSL_SDLInitFailure);
|
||||
|
||||
return DSL_Error;
|
||||
}
|
||||
|
||||
return DSL_Ok;
|
||||
}
|
||||
|
||||
void DSL_Shutdown(void)
|
||||
{
|
||||
DSL_StopPlayback();
|
||||
}
|
||||
|
||||
static void mixer_callback(int chan, void *stream, int len, void *udata)
|
||||
{
|
||||
Uint8 *stptr;
|
||||
Uint8 *fxptr;
|
||||
int copysize;
|
||||
|
||||
/* len should equal _BufferSize, else this is screwed up */
|
||||
|
||||
stptr = (Uint8 *)stream;
|
||||
|
||||
if (_remainder > 0)
|
||||
{
|
||||
copysize = min(len, _remainder);
|
||||
|
||||
fxptr = (Uint8 *)(&_BufferStart[MV_MixPage *
|
||||
_BufferSize]);
|
||||
|
||||
memcpy(stptr, fxptr+(_BufferSize-_remainder), copysize);
|
||||
|
||||
len -= copysize;
|
||||
_remainder -= copysize;
|
||||
|
||||
stptr += copysize;
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
/* new buffer */
|
||||
|
||||
_CallBackFunc();
|
||||
|
||||
fxptr = (Uint8 *)(&_BufferStart[MV_MixPage *
|
||||
_BufferSize]);
|
||||
|
||||
copysize = min(len, _BufferSize);
|
||||
|
||||
memcpy(stptr, fxptr, copysize);
|
||||
|
||||
len -= copysize;
|
||||
|
||||
stptr += copysize;
|
||||
}
|
||||
|
||||
_remainder = len;
|
||||
}
|
||||
|
||||
int DSL_BeginBufferedPlayback(char *BufferStart,
|
||||
int BufferSize, int NumDivisions, unsigned SampleRate,
|
||||
int MixMode, void(*CallBackFunc)(void))
|
||||
{
|
||||
Uint16 format;
|
||||
Uint8 *tmp;
|
||||
int channels;
|
||||
int chunksize;
|
||||
|
||||
if (mixer_initialized)
|
||||
{
|
||||
DSL_SetErrorCode(DSL_MixerActive);
|
||||
|
||||
return DSL_Error;
|
||||
}
|
||||
|
||||
_CallBackFunc = CallBackFunc;
|
||||
_BufferStart = BufferStart;
|
||||
_BufferSize = (BufferSize / NumDivisions);
|
||||
_NumDivisions = NumDivisions;
|
||||
_SampleRate = SampleRate;
|
||||
|
||||
_remainder = 0;
|
||||
|
||||
format = (MixMode & SIXTEEN_BIT) ? AUDIO_S16SYS : AUDIO_U8;
|
||||
channels = (MixMode & STEREO) ? 2 : 1;
|
||||
|
||||
/*
|
||||
23ms is typically ideal (11025,22050,44100)
|
||||
46ms isn't bad
|
||||
*/
|
||||
|
||||
chunksize = 512;
|
||||
|
||||
if (SampleRate >= 16000) chunksize *= 2;
|
||||
if (SampleRate >= 32000) chunksize *= 2;
|
||||
|
||||
/*
|
||||
// SDL mixer does this already
|
||||
if (MixMode & SIXTEEN_BIT) chunksize *= 2;
|
||||
if (MixMode & STEREO) chunksize *= 2;
|
||||
*/
|
||||
|
||||
if (Mix_OpenAudio(SampleRate, format, channels, chunksize) < 0)
|
||||
{
|
||||
DSL_SetErrorCode(DSL_MixerInitFailure);
|
||||
|
||||
return DSL_Error;
|
||||
}
|
||||
|
||||
/*
|
||||
Mix_SetPostMix(mixer_callback, NULL);
|
||||
*/
|
||||
/* have to use a channel because postmix will overwrite the music... */
|
||||
Mix_RegisterEffect(0, mixer_callback, NULL, NULL);
|
||||
|
||||
/* create a dummy sample just to allocate that channel */
|
||||
blank_buf = (Uint8 *)malloc(4096);
|
||||
memset(blank_buf, 0, 4096);
|
||||
|
||||
blank = Mix_QuickLoad_RAW(blank_buf, 4096);
|
||||
|
||||
Mix_PlayChannel(0, blank, -1);
|
||||
|
||||
mixer_initialized = 1;
|
||||
|
||||
return DSL_Ok;
|
||||
}
|
||||
|
||||
void DSL_StopPlayback(void)
|
||||
{
|
||||
if (mixer_initialized)
|
||||
{
|
||||
Mix_HaltChannel(0);
|
||||
}
|
||||
|
||||
if (blank != NULL)
|
||||
{
|
||||
Mix_FreeChunk(blank);
|
||||
}
|
||||
|
||||
blank = NULL;
|
||||
|
||||
if (blank_buf != NULL)
|
||||
{
|
||||
free(blank_buf);
|
||||
}
|
||||
|
||||
blank_buf = NULL;
|
||||
|
||||
if (mixer_initialized)
|
||||
{
|
||||
Mix_CloseAudio();
|
||||
}
|
||||
|
||||
mixer_initialized = 0;
|
||||
}
|
||||
|
||||
unsigned DSL_GetPlaybackRate(void)
|
||||
{
|
||||
return _SampleRate;
|
||||
}
|
||||
|
||||
unsigned long DisableInterrupts(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RestoreInterrupts(unsigned long flags)
|
||||
{}
|
50
polymer/eduke32/source/jaudiolib/dsl.h
Executable file
50
polymer/eduke32/source/jaudiolib/dsl.h
Executable file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Originally written by Ryan C. Gordon. (icculus@clutteredmind.org)
|
||||
Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu)
|
||||
|
||||
*/
|
||||
#ifndef AUDIOLIB__DSL_H
|
||||
#define AUDIOLIB__DSL_H
|
||||
|
||||
#define MONO_8BIT 0
|
||||
#define STEREO 1
|
||||
#define SIXTEEN_BIT 2
|
||||
#define STEREO_16BIT ( STEREO | SIXTEEN_BIT )
|
||||
|
||||
enum DSL_ERRORS
|
||||
{
|
||||
DSL_Warning = -2,
|
||||
DSL_Error = -1,
|
||||
DSL_Ok = 0,
|
||||
DSL_SDLInitFailure,
|
||||
DSL_MixerActive,
|
||||
DSL_MixerInitFailure
|
||||
};
|
||||
|
||||
char *DSL_ErrorString( int ErrorNumber );
|
||||
int DSL_Init( void );
|
||||
void DSL_StopPlayback( void );
|
||||
unsigned DSL_GetPlaybackRate( void );
|
||||
int DSL_BeginBufferedPlayback( char *BufferStart,
|
||||
int BufferSize, int NumDivisions, unsigned SampleRate,
|
||||
int MixMode, void ( *CallBackFunc )( void ) );
|
||||
void DSL_Shutdown( void );
|
||||
|
||||
#endif
|
|
@ -58,7 +58,7 @@ static LPDIRECTSOUNDBUFFER lpDSBSecondary = NULL;
|
|||
static LPDIRECTSOUNDNOTIFY lpDSNotify = NULL;
|
||||
static HANDLE *hPosNotify = NULL;
|
||||
|
||||
static int (*_DSOUND_CallBack)(int) = NULL;
|
||||
static int(*_DSOUND_CallBack)(int) = NULL;
|
||||
static int _DSOUND_BufferLength = 0;
|
||||
static int _DSOUND_NumBuffers = 0;
|
||||
static char *_DSOUND_MixBuffer = NULL;
|
||||
|
@ -107,7 +107,8 @@ int RestoreInterrupts(int a)
|
|||
*/
|
||||
char *DSOUND_ErrorString(int errorcode)
|
||||
{
|
||||
switch (errorcode) {
|
||||
switch (errorcode)
|
||||
{
|
||||
case DSOUND_Warning:
|
||||
case DSOUND_Error:
|
||||
return DSOUND_ErrorString(DSOUND_ErrorCode);
|
||||
|
@ -169,19 +170,21 @@ char *DSOUND_ErrorString(int errorcode)
|
|||
*/
|
||||
int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int buffersize)
|
||||
{
|
||||
HRESULT (WINAPI *aDirectSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN);
|
||||
HRESULT(WINAPI *aDirectSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN);
|
||||
HRESULT hr;
|
||||
DSBUFFERDESC dsbuf;
|
||||
WAVEFORMATEX wfex;
|
||||
DSBPOSITIONNOTIFY posn;
|
||||
|
||||
if (DSOUND_Installed) {
|
||||
if (DSOUND_Installed)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
}
|
||||
|
||||
printOSD("Initializing DirectSound...\n");
|
||||
|
||||
if (!_DSOUND_CriticalSectionAlloced) {
|
||||
if (!_DSOUND_CriticalSectionAlloced)
|
||||
{
|
||||
// initialize the critical section object we'll use to
|
||||
// simulate (dis|en)abling interrupts
|
||||
InitializeCriticalSection(&mutex);
|
||||
|
@ -190,14 +193,16 @@ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int
|
|||
|
||||
printOSD(" - Loading DSOUND.DLL\n");
|
||||
hDSoundDLL = LoadLibrary("DSOUND.DLL");
|
||||
if (!hDSoundDLL) {
|
||||
if (!hDSoundDLL)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_NoDLL);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
aDirectSoundCreate = (void *)GetProcAddress(hDSoundDLL, "DirectSoundCreate");
|
||||
if (!aDirectSoundCreate) {
|
||||
if (!aDirectSoundCreate)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_NoDirectSoundCreate);
|
||||
return DSOUND_Error;
|
||||
|
@ -205,14 +210,16 @@ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int
|
|||
|
||||
printOSD(" - Creating DirectSound object\n");
|
||||
hr = aDirectSoundCreate(NULL, &lpDS, NULL);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedDSC);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hr = IDirectSound_SetCooperativeLevel(lpDS, (HWND)win_gethwnd(), DSSCL_EXCLUSIVE);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetCoopLevel);
|
||||
return DSOUND_Error;
|
||||
|
@ -223,7 +230,8 @@ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int
|
|||
dsbuf.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||
hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBPrimary, NULL);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreatePrimary);
|
||||
return DSOUND_Error;
|
||||
|
@ -242,7 +250,8 @@ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int
|
|||
wfex.nBlockAlign = (wfex.wBitsPerSample / 8) * wfex.nChannels;
|
||||
wfex.nAvgBytesPerSec = wfex.nBlockAlign * wfex.nSamplesPerSec;
|
||||
hr = IDirectSoundBuffer_SetFormat(lpDSBPrimary, &wfex);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetFormat);
|
||||
return DSOUND_Error;
|
||||
|
@ -255,28 +264,32 @@ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int
|
|||
dsbuf.dwBufferBytes = buffersize;
|
||||
dsbuf.lpwfxFormat = &wfex;
|
||||
hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBSecondary, NULL);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateSecondary);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hr = IDirectSoundBuffer_QueryInterface(lpDSBSecondary, &IID_IDirectSoundNotify, &lpDSNotify);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedQueryNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hPosNotify = (HANDLE *)malloc(sizeof(HANDLE));
|
||||
if (!hPosNotify) {
|
||||
if (!hPosNotify)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hPosNotify[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!hPosNotify) {
|
||||
if (!hPosNotify)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateNotifyEvent);
|
||||
return DSOUND_Error;
|
||||
|
@ -288,7 +301,8 @@ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int
|
|||
posn.hEventNotify = hPosNotify[0];
|
||||
|
||||
hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, 1, &posn);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
|
@ -315,39 +329,46 @@ int DSOUND_Shutdown(void)
|
|||
|
||||
DSOUND_StopPlayback();
|
||||
|
||||
if (lpDSNotify) {
|
||||
if (lpDSNotify)
|
||||
{
|
||||
IDirectSoundNotify_Release(lpDSNotify);
|
||||
lpDSNotify = NULL;
|
||||
}
|
||||
|
||||
if (hPosNotify) {
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++) {
|
||||
if (hPosNotify)
|
||||
{
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++)
|
||||
{
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
hPosNotify = NULL;
|
||||
}
|
||||
|
||||
if (lpDSBSecondary) {
|
||||
if (lpDSBSecondary)
|
||||
{
|
||||
printOSD(" - Releasing secondary buffer\n");
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
IDirectSoundBuffer_Release(lpDSBSecondary);
|
||||
lpDSBSecondary = NULL;
|
||||
}
|
||||
|
||||
if (lpDSBPrimary) {
|
||||
if (lpDSBPrimary)
|
||||
{
|
||||
printOSD(" - Releasing primary buffer\n");
|
||||
IDirectSoundBuffer_Release(lpDSBPrimary);
|
||||
lpDSBPrimary = NULL;
|
||||
}
|
||||
|
||||
if (lpDS) {
|
||||
if (lpDS)
|
||||
{
|
||||
printOSD(" - Releasing DirectSound object\n");
|
||||
IDirectSound_Release(lpDS);
|
||||
lpDS = NULL;
|
||||
}
|
||||
|
||||
if (hDSoundDLL) {
|
||||
if (hDSoundDLL)
|
||||
{
|
||||
printOSD(" - Unloading DSOUND.DLL\n");
|
||||
FreeLibrary(hDSoundDLL);
|
||||
hDSoundDLL = NULL;
|
||||
|
@ -396,18 +417,21 @@ static DWORD WINAPI isr(LPVOID parm)
|
|||
h = creat("audio.raw",S_IREAD|S_IWRITE);
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
while (1)
|
||||
{
|
||||
rv = WaitForMultipleObjects(1+_DSOUND_NumBuffers, handles, FALSE, INFINITE);
|
||||
|
||||
if (!(rv >= WAIT_OBJECT_0 && rv <= WAIT_OBJECT_0+1+_DSOUND_NumBuffers)) return -1;
|
||||
|
||||
if (rv == WAIT_OBJECT_0) {
|
||||
if (rv == WAIT_OBJECT_0)
|
||||
{
|
||||
// we've been asked to finish up
|
||||
break;
|
||||
}
|
||||
|
||||
// otherwise we just service the interrupt
|
||||
if (_DSOUND_CallBack) {
|
||||
if (_DSOUND_CallBack)
|
||||
{
|
||||
DisableInterrupts();
|
||||
|
||||
p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1);
|
||||
|
@ -417,17 +441,19 @@ static DWORD WINAPI isr(LPVOID parm)
|
|||
|
||||
hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength,
|
||||
&lockptr, &lockbytes, &lockptr2, &lockbytes2, 0);
|
||||
if (hr == DSERR_BUFFERLOST) {
|
||||
if (hr == DSERR_BUFFERLOST)
|
||||
{
|
||||
hr = IDirectSoundBuffer_Restore(lpDSBSecondary);
|
||||
}
|
||||
if (hr == DS_OK) {
|
||||
if (hr == DS_OK)
|
||||
{
|
||||
/*
|
||||
#define copybuf(S,D,c) \
|
||||
#define copybuf(S,D,c) \
|
||||
({ void *__S=(S), *__D=(D); long __c=(c); \
|
||||
__asm__ __volatile__ ("rep; movsl" \
|
||||
: "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \
|
||||
0; })
|
||||
*/
|
||||
*/
|
||||
//copybuf(_DSOUND_MixBuffer + p * _DSOUND_BufferLength, lockptr, _DSOUND_BufferLength >> 2);
|
||||
memcpy(lockptr, _DSOUND_MixBuffer + p * _DSOUND_BufferLength, _DSOUND_BufferLength);
|
||||
IDirectSoundBuffer_Unlock(lpDSBSecondary, lockptr, lockbytes, lockptr2, lockbytes2);
|
||||
|
@ -449,7 +475,7 @@ static DWORD WINAPI isr(LPVOID parm)
|
|||
* DSOUND_BeginBufferedPlayback
|
||||
* Spins off a thread that behaves somewhat like the SoundBlaster DMA ISR did.
|
||||
*/
|
||||
int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), int buffersize, int numdivisions)
|
||||
int DSOUND_BeginBufferedPlayback(char *BufferStart, int(*CallBackFunc)(int), int buffersize, int numdivisions)
|
||||
{
|
||||
DWORD threadid;
|
||||
HRESULT hr;
|
||||
|
@ -461,33 +487,39 @@ int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), in
|
|||
|
||||
if (!lpDSBSecondary) return DSOUND_Error;
|
||||
|
||||
if (isrthread) {
|
||||
if (isrthread)
|
||||
{
|
||||
DSOUND_StopPlayback();
|
||||
}
|
||||
|
||||
isrfinish = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (!isrfinish) {
|
||||
if (!isrfinish)
|
||||
{
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateFinishEvent);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
isrthread = CreateThread(NULL, 0, isr, NULL, CREATE_SUSPENDED, &threadid);
|
||||
if (!isrthread) {
|
||||
if (!isrthread)
|
||||
{
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateThread);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hPosNotify = (HANDLE *)malloc(sizeof(HANDLE)*numdivisions);
|
||||
if (!hPosNotify) {
|
||||
if (!hPosNotify)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
memset(hPosNotify, 0, sizeof(HANDLE)*numdivisions);
|
||||
for (i=0; i<numdivisions; i++) {
|
||||
for (i=0; i<numdivisions; i++)
|
||||
{
|
||||
hPosNotify[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!hPosNotify[i]) {
|
||||
if (!hPosNotify[i])
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
|
@ -495,7 +527,8 @@ int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), in
|
|||
}
|
||||
|
||||
posns = (LPDSBPOSITIONNOTIFY)malloc(sizeof(DSBPOSITIONNOTIFY)*numdivisions);
|
||||
if (!posns) {
|
||||
if (!posns)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
|
@ -503,13 +536,15 @@ int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), in
|
|||
|
||||
_DSOUND_BufferLength = buffersize/numdivisions;
|
||||
_DSOUND_NumBuffers = numdivisions;
|
||||
for (i=0; i<numdivisions; i++) {
|
||||
for (i=0; i<numdivisions; i++)
|
||||
{
|
||||
posns[i].dwOffset = i*_DSOUND_BufferLength;
|
||||
posns[i].hEventNotify = hPosNotify[i];
|
||||
}
|
||||
|
||||
hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, numdivisions, posns);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
free(posns);
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
|
@ -522,7 +557,8 @@ int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), in
|
|||
ResumeThread(isrthread);
|
||||
|
||||
hr = IDirectSoundBuffer_Play(lpDSBSecondary, 0, 0, DSBPLAY_LOOPING);
|
||||
if (hr != DS_OK) {
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_SetErrorCode(DSOUND_FailedPlaySecondary);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
@ -541,7 +577,8 @@ int DSOUND_StopPlayback(void)
|
|||
BOOL t;
|
||||
int i;
|
||||
|
||||
if (isrthread) {
|
||||
if (isrthread)
|
||||
{
|
||||
SetEvent(isrfinish);
|
||||
|
||||
printOSD("DirectSound: Waiting for sound thread to exit\n");
|
||||
|
@ -562,17 +599,21 @@ int DSOUND_StopPlayback(void)
|
|||
isrthread = NULL;
|
||||
}
|
||||
|
||||
if (isrfinish) {
|
||||
if (isrfinish)
|
||||
{
|
||||
CloseHandle(isrfinish);
|
||||
isrfinish = NULL;
|
||||
}
|
||||
|
||||
if (lpDSBSecondary) {
|
||||
if (lpDSBSecondary)
|
||||
{
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
}
|
||||
|
||||
if (hPosNotify) {
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++) {
|
||||
if (hPosNotify)
|
||||
{
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++)
|
||||
{
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
|
|
File diff suppressed because it is too large
Load diff
50
polymer/eduke32/source/jaudiolib/interrup.h
Executable file
50
polymer/eduke32/source/jaudiolib/interrup.h
Executable file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Copyright (C) 1994-1995 Apogee Software, Ltd.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
/**********************************************************************
|
||||
module: INTERRUP.H
|
||||
|
||||
author: James R. Dose
|
||||
date: March 31, 1994
|
||||
|
||||
Inline functions for disabling and restoring the interrupt flag.
|
||||
|
||||
(c) Copyright 1994 James R. Dose. All Rights Reserved.
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __INTERRUPT_H
|
||||
#define __INTERRUPT_H
|
||||
|
||||
unsigned long DisableInterrupts( void );
|
||||
void RestoreInterrupts( unsigned long flags );
|
||||
|
||||
#ifdef PLAT_DOS
|
||||
#pragma aux DisableInterrupts = \
|
||||
"pushfd", \
|
||||
"pop eax", \
|
||||
"cli" \
|
||||
modify [ eax ];
|
||||
|
||||
#pragma aux RestoreInterrupts = \
|
||||
"push eax", \
|
||||
"popfd" \
|
||||
parm [ eax ];
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -44,21 +44,21 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
|
|||
|
||||
|
||||
void LL_AddNode
|
||||
(
|
||||
(
|
||||
char *item,
|
||||
char **head,
|
||||
char **tail,
|
||||
int next,
|
||||
int prev
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
OFFSET( item, prev ) = NULL;
|
||||
OFFSET( item, next ) = *head;
|
||||
{
|
||||
OFFSET(item, prev) = NULL;
|
||||
OFFSET(item, next) = *head;
|
||||
|
||||
if ( *head )
|
||||
if (*head)
|
||||
{
|
||||
OFFSET( *head, prev ) = item;
|
||||
OFFSET(*head, prev) = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -66,38 +66,38 @@ void LL_AddNode
|
|||
}
|
||||
|
||||
*head = item;
|
||||
}
|
||||
}
|
||||
|
||||
void LL_RemoveNode
|
||||
(
|
||||
(
|
||||
char *item,
|
||||
char **head,
|
||||
char **tail,
|
||||
int next,
|
||||
int prev
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
if (OFFSET(item, prev) == NULL)
|
||||
{
|
||||
if ( OFFSET( item, prev ) == NULL )
|
||||
{
|
||||
*head = OFFSET( item, next );
|
||||
*head = OFFSET(item, next);
|
||||
}
|
||||
else
|
||||
{
|
||||
OFFSET( OFFSET( item, prev ), next ) = OFFSET( item, next );
|
||||
OFFSET(OFFSET(item, prev), next) = OFFSET(item, next);
|
||||
}
|
||||
|
||||
if ( OFFSET( item, next ) == NULL )
|
||||
if (OFFSET(item, next) == NULL)
|
||||
{
|
||||
*tail = OFFSET( item, prev );
|
||||
*tail = OFFSET(item, prev);
|
||||
}
|
||||
else
|
||||
{
|
||||
OFFSET( OFFSET( item, next ), prev ) = OFFSET( item, prev );
|
||||
OFFSET(OFFSET(item, next), prev) = OFFSET(item, prev);
|
||||
}
|
||||
|
||||
OFFSET( item, next ) = NULL;
|
||||
OFFSET( item, prev ) = NULL;
|
||||
}
|
||||
OFFSET(item, next) = NULL;
|
||||
OFFSET(item, prev) = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -40,11 +40,13 @@ static HMIDISTRM hmido = (HMIDISTRM)-1;
|
|||
static MIDIOUTCAPS midicaps;
|
||||
static DWORD mididevice = -1;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
long time;
|
||||
long stream;
|
||||
long event;
|
||||
} MIDIEVENTHEAD;
|
||||
}
|
||||
MIDIEVENTHEAD;
|
||||
#define PAD(x) ((((x)+3)&(~3)))
|
||||
|
||||
#define BUFFERLEN (32*4*4)
|
||||
|
@ -52,8 +54,8 @@ typedef struct {
|
|||
static char eventbuf[NUMBUFFERS][BUFFERLEN];
|
||||
static int eventcnt[NUMBUFFERS];
|
||||
static MIDIHDR bufferheaders[NUMBUFFERS];
|
||||
int _MPU_CurrentBuffer = 0;
|
||||
int _MPU_BuffersWaiting = 0;
|
||||
int _MPU_CurrentBuffer = 0;
|
||||
int _MPU_BuffersWaiting = 0;
|
||||
|
||||
extern unsigned long _MIDI_GlobalPositionInTicks;
|
||||
unsigned long _MPU_LastEvent=0;
|
||||
|
@ -79,7 +81,7 @@ unsigned long _MPU_LastEvent=0;
|
|||
**********************************************************************/
|
||||
|
||||
|
||||
void MPU_FinishBuffer( int buffer )
|
||||
void MPU_FinishBuffer(int buffer)
|
||||
{
|
||||
if (!eventcnt[buffer]) return;
|
||||
ZeroMemory(&bufferheaders[buffer], sizeof(MIDIHDR));
|
||||
|
@ -92,7 +94,7 @@ void MPU_FinishBuffer( int buffer )
|
|||
_MPU_BuffersWaiting++;
|
||||
}
|
||||
|
||||
void MPU_BeginPlayback( void )
|
||||
void MPU_BeginPlayback(void)
|
||||
{
|
||||
_MPU_LastEvent = _MIDI_GlobalPositionInTicks;
|
||||
if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido);
|
||||
|
@ -112,11 +114,14 @@ void MPU_Unpause(void)
|
|||
void CALLBACK MPU_MIDICallback(HMIDIOUT handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
|
||||
{
|
||||
int i;
|
||||
switch (uMsg) {
|
||||
switch (uMsg)
|
||||
{
|
||||
case MOM_DONE:
|
||||
midiOutUnprepareHeader((HMIDIOUT)handle, (MIDIHDR*)dwParam1, sizeof(MIDIHDR));
|
||||
for (i=0;i<NUMBUFFERS;i++) {
|
||||
if (dwParam1 == (long)&bufferheaders[i]) {
|
||||
for (i=0;i<NUMBUFFERS;i++)
|
||||
{
|
||||
if (dwParam1 == (long)&bufferheaders[i])
|
||||
{
|
||||
eventcnt[i] = 0; // marks the buffer as free
|
||||
// printf("Finished buffer %d\n",i);
|
||||
_MPU_BuffersWaiting--;
|
||||
|
@ -139,24 +144,28 @@ void CALLBACK MPU_MIDICallback(HMIDIOUT handle, UINT uMsg, DWORD dwInstance, DWO
|
|||
int MPU_GetNextBuffer(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<NUMBUFFERS; i++) {
|
||||
for (i=0; i<NUMBUFFERS; i++)
|
||||
{
|
||||
if (eventcnt[i] == 0) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void MPU_SendMidi( char *data, int count )
|
||||
void MPU_SendMidi(char *data, int count)
|
||||
{
|
||||
char *p;
|
||||
int padded, nextbuffer;
|
||||
static int masks[3] = { 0x000000ffl, 0x0000ffffl, 0x00ffffffl };
|
||||
|
||||
if (count <= 0) return;
|
||||
if (count <= 3) {
|
||||
if (eventcnt[_MPU_CurrentBuffer] + 12 > BUFFERLEN) {
|
||||
if (count <= 3)
|
||||
{
|
||||
if (eventcnt[_MPU_CurrentBuffer] + 12 > BUFFERLEN)
|
||||
{
|
||||
// buffer over-full
|
||||
nextbuffer = MPU_GetNextBuffer();
|
||||
if (nextbuffer < 0) {
|
||||
if (nextbuffer < 0)
|
||||
{
|
||||
// printf("All buffers full!\n");
|
||||
return;
|
||||
}
|
||||
|
@ -169,12 +178,16 @@ void MPU_SendMidi( char *data, int count )
|
|||
((long*)p)[1] = 0;
|
||||
((long*)p)[2] = (MEVT_SHORTMSG << 24) | ((*((long*)data)) & masks[count-1]);
|
||||
eventcnt[_MPU_CurrentBuffer] += 12;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
padded = PAD(count);
|
||||
if (eventcnt[_MPU_CurrentBuffer] + 12 + padded > BUFFERLEN) {
|
||||
if (eventcnt[_MPU_CurrentBuffer] + 12 + padded > BUFFERLEN)
|
||||
{
|
||||
// buffer over-full
|
||||
nextbuffer = MPU_GetNextBuffer();
|
||||
if (nextbuffer < 0) {
|
||||
if (nextbuffer < 0)
|
||||
{
|
||||
// printf("All buffers full!\n");
|
||||
return;
|
||||
}
|
||||
|
@ -201,14 +214,15 @@ void MPU_SendMidi( char *data, int count )
|
|||
|
||||
Sends a MIDI message immediately to the the music device.
|
||||
---------------------------------------------------------------------*/
|
||||
void MPU_SendMidiImmediate( char *data, int count )
|
||||
void MPU_SendMidiImmediate(char *data, int count)
|
||||
{
|
||||
MIDIHDR mhdr;
|
||||
static int masks[3] = { 0x00ffffffl, 0x0000ffffl, 0x000000ffl };
|
||||
|
||||
if (!count) return;
|
||||
if (count<=3) midiOutShortMsg((HMIDIOUT)hmido, (*((long*)data)) & masks[count-1]);
|
||||
else {
|
||||
else
|
||||
{
|
||||
ZeroMemory(&mhdr, sizeof(mhdr));
|
||||
mhdr.lpData = data;
|
||||
mhdr.dwBufferLength = count;
|
||||
|
@ -227,16 +241,16 @@ void MPU_SendMidiImmediate( char *data, int count )
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MPU_Reset
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
midiStreamStop(hmido);
|
||||
midiStreamClose(hmido);
|
||||
|
||||
return( MPU_Ok );
|
||||
}
|
||||
return(MPU_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -246,11 +260,11 @@ int MPU_Reset
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MPU_Init
|
||||
(
|
||||
(
|
||||
int addr
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<NUMBUFFERS;i++) eventcnt[i]=0;
|
||||
|
@ -261,8 +275,8 @@ int MPU_Init
|
|||
|
||||
if (midiStreamOpen(&hmido,&mididevice,1,(DWORD)MPU_MIDICallback,0L,CALLBACK_FUNCTION) != MMSYSERR_NOERROR) return(MPU_Error);
|
||||
|
||||
return( MPU_Ok );
|
||||
}
|
||||
return(MPU_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -272,19 +286,19 @@ int MPU_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_NoteOff
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int key,
|
||||
int velocity
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char msg[3];
|
||||
msg[0] = ( MIDI_NOTE_OFF | channel );
|
||||
msg[1] = ( key );
|
||||
msg[2] = ( velocity );
|
||||
MPU_SendMidi( msg, 3 );
|
||||
}
|
||||
msg[0] = (MIDI_NOTE_OFF | channel);
|
||||
msg[1] = (key);
|
||||
msg[2] = (velocity);
|
||||
MPU_SendMidi(msg, 3);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -294,19 +308,19 @@ void MPU_NoteOff
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_NoteOn
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int key,
|
||||
int velocity
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char msg[3];
|
||||
msg[0] = ( MIDI_NOTE_ON | channel );
|
||||
msg[1] = ( key );
|
||||
msg[2] = ( velocity );
|
||||
MPU_SendMidi( msg, 3 );
|
||||
}
|
||||
msg[0] = (MIDI_NOTE_ON | channel);
|
||||
msg[1] = (key);
|
||||
msg[2] = (velocity);
|
||||
MPU_SendMidi(msg, 3);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -316,19 +330,19 @@ void MPU_NoteOn
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_PolyAftertouch
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int key,
|
||||
int pressure
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char msg[3];
|
||||
msg[0] = ( MIDI_POLY_AFTER_TCH | channel );
|
||||
msg[1] = ( key );
|
||||
msg[2] = ( pressure );
|
||||
MPU_SendMidi( msg, 3 );
|
||||
}
|
||||
msg[0] = (MIDI_POLY_AFTER_TCH | channel);
|
||||
msg[1] = (key);
|
||||
msg[2] = (pressure);
|
||||
MPU_SendMidi(msg, 3);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -338,19 +352,19 @@ void MPU_PolyAftertouch
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_ControlChange
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int number,
|
||||
int value
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char msg[3];
|
||||
msg[0] = ( MIDI_CONTROL_CHANGE | channel );
|
||||
msg[1] = ( number );
|
||||
msg[2] = ( value );
|
||||
MPU_SendMidi( msg, 3 );
|
||||
}
|
||||
msg[0] = (MIDI_CONTROL_CHANGE | channel);
|
||||
msg[1] = (number);
|
||||
msg[2] = (value);
|
||||
MPU_SendMidi(msg, 3);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -360,17 +374,17 @@ void MPU_ControlChange
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_ProgramChange
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int program
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char msg[2];
|
||||
msg[0] = ( MIDI_PROGRAM_CHANGE | channel );
|
||||
msg[1] = ( program );
|
||||
MPU_SendMidi( msg, 2 );
|
||||
}
|
||||
msg[0] = (MIDI_PROGRAM_CHANGE | channel);
|
||||
msg[1] = (program);
|
||||
MPU_SendMidi(msg, 2);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -380,17 +394,17 @@ void MPU_ProgramChange
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_ChannelAftertouch
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int pressure
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char msg[2];
|
||||
msg[0] = ( MIDI_AFTER_TOUCH | channel );
|
||||
msg[1] = ( pressure );
|
||||
MPU_SendMidi( msg, 2 );
|
||||
}
|
||||
msg[0] = (MIDI_AFTER_TOUCH | channel);
|
||||
msg[1] = (pressure);
|
||||
MPU_SendMidi(msg, 2);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -400,23 +414,23 @@ void MPU_ChannelAftertouch
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_PitchBend
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int lsb,
|
||||
int msb
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char msg[3];
|
||||
msg[0] = ( MIDI_PITCH_BEND | channel );
|
||||
msg[1] = ( lsb );
|
||||
msg[2] = ( msb );
|
||||
MPU_SendMidi( msg, 3 );
|
||||
}
|
||||
msg[0] = (MIDI_PITCH_BEND | channel);
|
||||
msg[1] = (lsb);
|
||||
msg[2] = (msb);
|
||||
MPU_SendMidi(msg, 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MPU_SetTempo( int tempo )
|
||||
void MPU_SetTempo(int tempo)
|
||||
{
|
||||
MIDIPROPTEMPO prop;
|
||||
prop.cbStruct = sizeof(MIDIPROPTEMPO);
|
||||
|
@ -424,7 +438,7 @@ void MPU_SetTempo( int tempo )
|
|||
midiStreamProperty(hmido, (LPBYTE)&prop, MIDIPROP_SET|MIDIPROP_TEMPO);
|
||||
}
|
||||
|
||||
void MPU_SetDivision( int division )
|
||||
void MPU_SetDivision(int division)
|
||||
{
|
||||
MIDIPROPTIMEDIV prop;
|
||||
prop.cbStruct = sizeof(MIDIPROPTIMEDIV);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -54,7 +54,7 @@ static unsigned MUSIC_CurrentFadeVolume;
|
|||
static unsigned MUSIC_LastFadeVolume;
|
||||
static int MUSIC_EndingFadeVolume;
|
||||
|
||||
int MUSIC_InitMidi( int card, midifuncs *Funcs, int Address );
|
||||
int MUSIC_InitMidi(int card, midifuncs *Funcs, int Address);
|
||||
|
||||
#define MUSIC_SetErrorCode( status ) \
|
||||
MUSIC_ErrorCode = ( status );
|
||||
|
@ -67,18 +67,18 @@ int MUSIC_InitMidi( int card, midifuncs *Funcs, int Address );
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
char *MUSIC_ErrorString
|
||||
(
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
char *ErrorString;
|
||||
|
||||
switch( ErrorNumber )
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case MUSIC_Warning :
|
||||
case MUSIC_Error :
|
||||
ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode );
|
||||
ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode);
|
||||
break;
|
||||
|
||||
case MUSIC_Ok :
|
||||
|
@ -117,8 +117,8 @@ char *MUSIC_ErrorString
|
|||
break;
|
||||
}
|
||||
|
||||
return( ErrorString );
|
||||
}
|
||||
return(ErrorString);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -128,26 +128,26 @@ char *MUSIC_ErrorString
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_Init
|
||||
(
|
||||
(
|
||||
int SoundCard,
|
||||
int Address
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
|
||||
for( i = 0; i < 128; i++ )
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
MIDI_PatchMap[ i ] = i;
|
||||
}
|
||||
|
||||
MUSIC_SoundDevice = SoundCard;
|
||||
|
||||
status = MUSIC_InitMidi( SoundCard, &MUSIC_MidiFunctions, Address );
|
||||
status = MUSIC_InitMidi(SoundCard, &MUSIC_MidiFunctions, Address);
|
||||
|
||||
return( status );
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -157,11 +157,11 @@ int MUSIC_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_Shutdown
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
int status;
|
||||
|
||||
status = MUSIC_Ok;
|
||||
|
@ -170,8 +170,8 @@ int MUSIC_Shutdown
|
|||
|
||||
//MPU_Reset();
|
||||
|
||||
return( status );
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -181,19 +181,19 @@ int MUSIC_Shutdown
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetVolume
|
||||
(
|
||||
(
|
||||
int volume
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
volume = max( 0, volume );
|
||||
volume = min( volume, 255 );
|
||||
{
|
||||
volume = max(0, volume);
|
||||
volume = min(volume, 255);
|
||||
|
||||
if ( MUSIC_SoundDevice != -1 )
|
||||
if (MUSIC_SoundDevice != -1)
|
||||
{
|
||||
MIDI_SetVolume( volume );
|
||||
}
|
||||
MIDI_SetVolume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -203,14 +203,14 @@ void MUSIC_SetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetMidiChannelVolume
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int volume
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetUserChannelVolume( channel, volume );
|
||||
}
|
||||
{
|
||||
MIDI_SetUserChannelVolume(channel, volume);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -220,13 +220,13 @@ void MUSIC_SetMidiChannelVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_ResetMidiChannelVolumes
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
MIDI_ResetUserChannelVolume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -236,17 +236,17 @@ void MUSIC_ResetMidiChannelVolumes
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_GetVolume
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
if (MUSIC_SoundDevice == -1)
|
||||
{
|
||||
if ( MUSIC_SoundDevice == -1 )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
return( MIDI_GetVolume() );
|
||||
return(0);
|
||||
}
|
||||
return(MIDI_GetVolume());
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -257,13 +257,13 @@ int MUSIC_GetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetLoopFlag
|
||||
(
|
||||
(
|
||||
int loopflag
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetLoopFlag( loopflag );
|
||||
}
|
||||
{
|
||||
MIDI_SetLoopFlag(loopflag);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -273,13 +273,13 @@ void MUSIC_SetLoopFlag
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_SongPlaying
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( MIDI_SongPlaying() );
|
||||
}
|
||||
{
|
||||
return(MIDI_SongPlaying());
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -289,13 +289,13 @@ int MUSIC_SongPlaying
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_Continue
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
MIDI_ContinueSong();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -305,13 +305,13 @@ void MUSIC_Continue
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_Pause
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
MIDI_PauseSong();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -321,16 +321,16 @@ void MUSIC_Pause
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_StopSong
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
MUSIC_StopFade();
|
||||
MIDI_StopSong();
|
||||
MUSIC_SetErrorCode( MUSIC_Ok );
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
MUSIC_SetErrorCode(MUSIC_Ok);
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -340,25 +340,25 @@ int MUSIC_StopSong
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_PlaySong
|
||||
(
|
||||
(
|
||||
unsigned char *song,
|
||||
int loopflag
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
int status;
|
||||
|
||||
MUSIC_StopSong();
|
||||
|
||||
status = MIDI_PlaySong( song, loopflag );
|
||||
if ( status != MIDI_Ok )
|
||||
status = MIDI_PlaySong(song, loopflag);
|
||||
if (status != MIDI_Ok)
|
||||
{
|
||||
MUSIC_SetErrorCode( MUSIC_MidiError );
|
||||
return( MUSIC_Warning );
|
||||
MUSIC_SetErrorCode(MUSIC_MidiError);
|
||||
return(MUSIC_Warning);
|
||||
}
|
||||
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -368,13 +368,13 @@ int MUSIC_PlaySong
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetContext
|
||||
(
|
||||
(
|
||||
int context
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetContext( context );
|
||||
}
|
||||
{
|
||||
MIDI_SetContext(context);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -384,13 +384,13 @@ void MUSIC_SetContext
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_GetContext
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
return MIDI_GetContext();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -400,13 +400,13 @@ int MUSIC_GetContext
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongTick
|
||||
(
|
||||
(
|
||||
unsigned long PositionInTicks
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetSongTick( PositionInTicks );
|
||||
}
|
||||
{
|
||||
MIDI_SetSongTick(PositionInTicks);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -416,13 +416,13 @@ void MUSIC_SetSongTick
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongTime
|
||||
(
|
||||
(
|
||||
unsigned long milliseconds
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetSongTime( milliseconds );
|
||||
}
|
||||
{
|
||||
MIDI_SetSongTime(milliseconds);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -432,15 +432,15 @@ void MUSIC_SetSongTime
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongPosition
|
||||
(
|
||||
(
|
||||
int measure,
|
||||
int beat,
|
||||
int tick
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetSongPosition( measure, beat, tick );
|
||||
}
|
||||
{
|
||||
MIDI_SetSongPosition(measure, beat, tick);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -450,13 +450,13 @@ void MUSIC_SetSongPosition
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_GetSongPosition
|
||||
(
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_GetSongPosition( pos );
|
||||
}
|
||||
{
|
||||
MIDI_GetSongPosition(pos);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -466,23 +466,23 @@ void MUSIC_GetSongPosition
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_GetSongLength
|
||||
(
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_GetSongLength( pos );
|
||||
}
|
||||
{
|
||||
MIDI_GetSongLength(pos);
|
||||
}
|
||||
|
||||
|
||||
int MUSIC_InitMidi
|
||||
(
|
||||
(
|
||||
int card,
|
||||
midifuncs *Funcs,
|
||||
int Address
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
int status;
|
||||
|
||||
Funcs->NoteOff = MPU_NoteOff;
|
||||
|
@ -497,10 +497,10 @@ int MUSIC_InitMidi
|
|||
Funcs->SetVolume = NULL /*MPU_SetVolume*/;
|
||||
Funcs->GetVolume = NULL /*MPU_GetVolume*/;
|
||||
|
||||
MIDI_SetMidiFuncs( Funcs );
|
||||
MIDI_SetMidiFuncs(Funcs);
|
||||
|
||||
return( MIDI_Ok );
|
||||
}
|
||||
return(MIDI_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -511,16 +511,16 @@ int MUSIC_InitMidi
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_FadeVolume
|
||||
(
|
||||
(
|
||||
int tovolume,
|
||||
int milliseconds
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
int fromvolume;
|
||||
|
||||
MIDI_SetVolume( tovolume );
|
||||
return( MUSIC_Ok );
|
||||
MIDI_SetVolume(tovolume);
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
|
@ -531,13 +531,13 @@ int MUSIC_FadeVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_FadeActive
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -547,12 +547,11 @@ int MUSIC_FadeActive
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_StopFade
|
||||
(
|
||||
(
|
||||
void
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -563,14 +562,14 @@ void MUSIC_StopFade
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_RerouteMidiChannel
|
||||
(
|
||||
(
|
||||
int channel,
|
||||
int ( *function )( int event, int c1, int c2 )
|
||||
)
|
||||
int(*function)(int event, int c1, int c2)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_RerouteMidiChannel( channel, function );
|
||||
}
|
||||
{
|
||||
MIDI_RerouteMidiChannel(channel, function);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -580,12 +579,11 @@ void MUSIC_RerouteMidiChannel
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_RegisterTimbreBank
|
||||
(
|
||||
(
|
||||
unsigned char *timbres
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void MUSIC_Update(void)
|
||||
|
|
50
polymer/eduke32/source/jaudiolib/nodpmi.c
Executable file
50
polymer/eduke32/source/jaudiolib/nodpmi.c
Executable file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Copyright (C) 1994-1995 Apogee Software, Ltd.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
/**********************************************************************
|
||||
module: NODPMI.C
|
||||
|
||||
Functions for faking DPMI calls.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "dpmi.h"
|
||||
|
||||
#define TRUE ( 1 == 1 )
|
||||
#define FALSE ( !TRUE )
|
||||
|
||||
int DPMI_GetDOSMemory(void **ptr, int *descriptor, unsigned length)
|
||||
{
|
||||
/* Lovely... */
|
||||
|
||||
*ptr = (void *)malloc(length);
|
||||
|
||||
*descriptor = (int) *ptr;
|
||||
|
||||
return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
|
||||
}
|
||||
|
||||
int DPMI_FreeDOSMemory(int descriptor)
|
||||
{
|
||||
free((void *)descriptor);
|
||||
|
||||
return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
|
||||
}
|
|
@ -38,10 +38,12 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
|
|||
|
||||
static unsigned long PitchTable[ 12 ][ MAXDETUNE ] =
|
||||
{
|
||||
{ 0x10000, 0x10097, 0x1012f, 0x101c7, 0x10260, 0x102f9, 0x10392, 0x1042c,
|
||||
{
|
||||
0x10000, 0x10097, 0x1012f, 0x101c7, 0x10260, 0x102f9, 0x10392, 0x1042c,
|
||||
0x104c6, 0x10561, 0x105fb, 0x10696, 0x10732, 0x107ce, 0x1086a, 0x10907,
|
||||
0x109a4, 0x10a41, 0x10adf, 0x10b7d, 0x10c1b, 0x10cba, 0x10d59, 0x10df8,
|
||||
0x10e98 },
|
||||
0x10e98
|
||||
},
|
||||
{ 0x10f38, 0x10fd9, 0x1107a, 0x1111b, 0x111bd, 0x1125f, 0x11302, 0x113a5,
|
||||
0x11448, 0x114eb, 0x1158f, 0x11634, 0x116d8, 0x1177e, 0x11823, 0x118c9,
|
||||
0x1196f, 0x11a16, 0x11abd, 0x11b64, 0x11c0c, 0x11cb4, 0x11d5d, 0x11e06,
|
||||
|
@ -137,11 +139,11 @@ void PITCH_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
unsigned long PITCH_GetScale
|
||||
(
|
||||
(
|
||||
int pitchoffset
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
{
|
||||
unsigned long scale;
|
||||
int octaveshift;
|
||||
int noteshift;
|
||||
|
@ -153,26 +155,26 @@ unsigned long PITCH_GetScale
|
|||
// PITCH_Init();
|
||||
// }
|
||||
|
||||
if ( pitchoffset == 0 )
|
||||
if (pitchoffset == 0)
|
||||
{
|
||||
return( PitchTable[ 0 ][ 0 ] );
|
||||
return(PitchTable[ 0 ][ 0 ]);
|
||||
}
|
||||
|
||||
noteshift = pitchoffset % 1200;
|
||||
if ( noteshift < 0 )
|
||||
if (noteshift < 0)
|
||||
{
|
||||
noteshift += 1200;
|
||||
}
|
||||
|
||||
note = noteshift / 100;
|
||||
detune = ( noteshift % 100 ) / ( 100 / MAXDETUNE );
|
||||
octaveshift = ( pitchoffset - noteshift ) / 1200;
|
||||
detune = (noteshift % 100) / (100 / MAXDETUNE);
|
||||
octaveshift = (pitchoffset - noteshift) / 1200;
|
||||
|
||||
if ( detune < 0 )
|
||||
if (detune < 0)
|
||||
{
|
||||
detune += ( 100 / MAXDETUNE );
|
||||
detune += (100 / MAXDETUNE);
|
||||
note--;
|
||||
if ( note < 0 )
|
||||
if (note < 0)
|
||||
{
|
||||
note += 12;
|
||||
octaveshift--;
|
||||
|
@ -181,7 +183,7 @@ unsigned long PITCH_GetScale
|
|||
|
||||
scale = PitchTable[ note ][ detune ];
|
||||
|
||||
if ( octaveshift < 0 )
|
||||
if (octaveshift < 0)
|
||||
{
|
||||
scale >>= -octaveshift;
|
||||
}
|
||||
|
@ -190,8 +192,8 @@ unsigned long PITCH_GetScale
|
|||
scale <<= octaveshift;
|
||||
}
|
||||
|
||||
return( scale );
|
||||
}
|
||||
return(scale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
61
polymer/eduke32/source/jaudiolib/platform.h
Executable file
61
polymer/eduke32/source/jaudiolib/platform.h
Executable file
|
@ -0,0 +1,61 @@
|
|||
#ifndef _INCLUDE_PLATFORM_H_
|
||||
#define _INCLUDE_PLATFORM_H_
|
||||
|
||||
#if (!defined __EXPORT__)
|
||||
#define __EXPORT__
|
||||
#endif
|
||||
|
||||
#if (defined __WATCOMC__)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static __inline unsigned short _swap16(unsigned short D)
|
||||
{
|
||||
#if PLATFORM_MACOSX
|
||||
register unsigned short returnValue;
|
||||
__asm__ volatile("lhbrx %0,0,%1"
|
||||
: "=r" (returnValue)
|
||||
: "r" (&D)
|
||||
);
|
||||
return returnValue;
|
||||
#else
|
||||
return((D<<8)|(D>>8));
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline unsigned int _swap32(unsigned int D)
|
||||
{
|
||||
#if PLATFORM_MACOSX
|
||||
register unsigned int returnValue;
|
||||
__asm__ volatile("lwbrx %0,0,%1"
|
||||
: "=r" (returnValue)
|
||||
: "r" (&D)
|
||||
);
|
||||
return returnValue;
|
||||
#else
|
||||
return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PLATFORM_MACOSX
|
||||
#define PLATFORM_BIGENDIAN 1
|
||||
#define BUILDSWAP_INTEL16(x) _swap16(x)
|
||||
#define BUILDSWAP_INTEL32(x) _swap32(x)
|
||||
#else
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define PLATFORM_LITTLEENDIAN 1
|
||||
#define BUILDSWAP_INTEL16(x) (x)
|
||||
#define BUILDSWAP_INTEL32(x) (x)
|
||||
#else
|
||||
#define PLATFORM_BIGENDIAN 1
|
||||
#define BUILDSWAP_INTEL16(x) _swap16(x)
|
||||
#define BUILDSWAP_INTEL32(x) _swap32(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int has_altivec; /* PowerPC-specific. */
|
||||
|
||||
#endif /* !defined _INCLUDE_PLATFORM_H_ */
|
||||
|
||||
/* end of platform.h ... */
|
||||
|
477
polymer/eduke32/source/jaudiolib/sdlmusic.c
Executable file
477
polymer/eduke32/source/jaudiolib/sdlmusic.c
Executable file
|
@ -0,0 +1,477 @@
|
|||
/*
|
||||
Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Originally written by Ryan C. Gordon. (icculus@clutteredmind.org)
|
||||
Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu)
|
||||
|
||||
*/
|
||||
/*
|
||||
* A reimplementation of Jim Dose's FX_MAN routines, using SDL_mixer 1.2.
|
||||
* Whee. FX_MAN is also known as the "Apogee Sound System", or "ASS" for
|
||||
* short. How strangely appropriate that seems.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "duke3d.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
|
||||
#if (defined __WATCOMC__)
|
||||
// This is probably out of date. --ryan.
|
||||
#include "dukesnd_watcom.h"
|
||||
#endif
|
||||
|
||||
#if (!defined __WATCOMC__)
|
||||
#define cdecl
|
||||
#endif
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_mixer.h>
|
||||
#include "music.h"
|
||||
|
||||
#define __FX_TRUE (1 == 1)
|
||||
#define __FX_FALSE (!__FX_TRUE)
|
||||
|
||||
#define DUKESND_DEBUG "DUKESND_DEBUG"
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef max
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
void GetUnixPathFromEnvironment(char *fullname, int32 length, const char *filename);
|
||||
|
||||
int MUSIC_ErrorCode = MUSIC_Ok;
|
||||
|
||||
static char warningMessage[80];
|
||||
static char errorMessage[80];
|
||||
static int fx_initialized = 0;
|
||||
static int numChannels = MIX_CHANNELS;
|
||||
static void(*callback)(unsigned long);
|
||||
static int reverseStereo = 0;
|
||||
static int reverbDelay = 256;
|
||||
static int reverbLevel = 0;
|
||||
static int fastReverb = 0;
|
||||
static FILE *debug_file = NULL;
|
||||
static int initialized_debugging = 0;
|
||||
static int mixerIsStereo = 1;
|
||||
|
||||
// This gets called all over the place for information and debugging messages.
|
||||
// If the user set the DUKESND_DEBUG environment variable, the messages
|
||||
// go to the file that is specified in that variable. Otherwise, they
|
||||
// are ignored for the expense of the function call. If DUKESND_DEBUG is
|
||||
// set to "-" (without the quotes), then the output goes to stdout.
|
||||
static void musdebug(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (debug_file)
|
||||
{
|
||||
fprintf(debug_file, "DUKEMUS: ");
|
||||
va_start(ap, fmt);
|
||||
vfprintf(debug_file, fmt, ap);
|
||||
va_end(ap);
|
||||
fprintf(debug_file, "\n");
|
||||
fflush(debug_file);
|
||||
} // if
|
||||
} // musdebug
|
||||
|
||||
static void init_debugging(void)
|
||||
{
|
||||
const char *envr;
|
||||
|
||||
if (initialized_debugging)
|
||||
return;
|
||||
|
||||
envr = getenv(DUKESND_DEBUG);
|
||||
if (envr != NULL)
|
||||
{
|
||||
if (strcmp(envr, "-") == 0)
|
||||
debug_file = stdout;
|
||||
else
|
||||
debug_file = fopen(envr, "w");
|
||||
|
||||
if (debug_file == NULL)
|
||||
fprintf(stderr, "DUKESND: -WARNING- Could not open debug file!\n");
|
||||
else
|
||||
setbuf(debug_file, NULL);
|
||||
} // if
|
||||
|
||||
initialized_debugging = 1;
|
||||
} // init_debugging
|
||||
|
||||
static void setWarningMessage(const char *msg)
|
||||
{
|
||||
strncpy(warningMessage, msg, sizeof(warningMessage));
|
||||
// strncpy() doesn't add the null char if there isn't room...
|
||||
warningMessage[sizeof(warningMessage) - 1] = '\0';
|
||||
musdebug("Warning message set to [%s].", warningMessage);
|
||||
} // setErrorMessage
|
||||
|
||||
|
||||
static void setErrorMessage(const char *msg)
|
||||
{
|
||||
strncpy(errorMessage, msg, sizeof(errorMessage));
|
||||
// strncpy() doesn't add the null char if there isn't room...
|
||||
errorMessage[sizeof(errorMessage) - 1] = '\0';
|
||||
musdebug("Error message set to [%s].", errorMessage);
|
||||
} // setErrorMessage
|
||||
|
||||
// The music functions...
|
||||
|
||||
char *MUSIC_ErrorString(int ErrorNumber)
|
||||
{
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case MUSIC_Warning:
|
||||
return(warningMessage);
|
||||
|
||||
case MUSIC_Error:
|
||||
return(errorMessage);
|
||||
|
||||
case MUSIC_Ok:
|
||||
return("OK; no error.");
|
||||
|
||||
case MUSIC_ASSVersion:
|
||||
return("Incorrect sound library version.");
|
||||
|
||||
case MUSIC_SoundCardError:
|
||||
return("General sound card error.");
|
||||
|
||||
case MUSIC_InvalidCard:
|
||||
return("Invalid sound card.");
|
||||
|
||||
case MUSIC_MidiError:
|
||||
return("MIDI error.");
|
||||
|
||||
case MUSIC_MPU401Error:
|
||||
return("MPU401 error.");
|
||||
|
||||
case MUSIC_TaskManError:
|
||||
return("Task Manager error.");
|
||||
|
||||
//case MUSIC_FMNotDetected:
|
||||
// return("FM not detected error.");
|
||||
|
||||
case MUSIC_DPMI_Error:
|
||||
return("DPMI error.");
|
||||
|
||||
default:
|
||||
return("Unknown error.");
|
||||
} // switch
|
||||
|
||||
assert(0); // shouldn't hit this point.
|
||||
return(NULL);
|
||||
} // MUSIC_ErrorString
|
||||
|
||||
|
||||
static int music_initialized = 0;
|
||||
static int music_context = 0;
|
||||
static int music_loopflag = MUSIC_PlayOnce;
|
||||
static char *music_songdata = NULL;
|
||||
static Mix_Music *music_musicchunk = NULL;
|
||||
|
||||
int MUSIC_Init(int SoundCard, int Address)
|
||||
{
|
||||
init_debugging();
|
||||
|
||||
musdebug("INIT! card=>%d, address=>%d...", SoundCard, Address);
|
||||
|
||||
if (music_initialized)
|
||||
{
|
||||
setErrorMessage("Music system is already initialized.");
|
||||
return(MUSIC_Error);
|
||||
} // if
|
||||
|
||||
SoundCard = 1;
|
||||
|
||||
music_initialized = 1;
|
||||
return(MUSIC_Ok);
|
||||
} // MUSIC_Init
|
||||
|
||||
|
||||
int MUSIC_Shutdown(void)
|
||||
{
|
||||
musdebug("shutting down sound subsystem.");
|
||||
|
||||
MUSIC_StopSong();
|
||||
music_context = 0;
|
||||
music_initialized = 0;
|
||||
music_loopflag = MUSIC_PlayOnce;
|
||||
return(MUSIC_Ok);
|
||||
} // MUSIC_Shutdown
|
||||
|
||||
|
||||
void MUSIC_SetMaxFMMidiChannel(int channel)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_SetMaxFMMidiChannel(%d).\n", channel);
|
||||
} // MUSIC_SetMaxFMMidiChannel
|
||||
|
||||
|
||||
void MUSIC_SetVolume(int volume)
|
||||
{
|
||||
volume = max(0, volume);
|
||||
volume = min(volume, 255);
|
||||
|
||||
Mix_VolumeMusic(volume >> 1); // convert 0-255 to 0-128.
|
||||
} // MUSIC_SetVolume
|
||||
|
||||
|
||||
void MUSIC_SetMidiChannelVolume(int channel, int volume)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_SetMidiChannelVolume(%d, %d).\n", channel, volume);
|
||||
} // MUSIC_SetMidiChannelVolume
|
||||
|
||||
|
||||
void MUSIC_ResetMidiChannelVolumes(void)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_ResetMidiChannelVolumes().\n");
|
||||
} // MUSIC_ResetMidiChannelVolumes
|
||||
|
||||
|
||||
int MUSIC_GetVolume(void)
|
||||
{
|
||||
return(Mix_VolumeMusic(-1) << 1); // convert 0-128 to 0-255.
|
||||
} // MUSIC_GetVolume
|
||||
|
||||
|
||||
void MUSIC_SetLoopFlag(int loopflag)
|
||||
{
|
||||
music_loopflag = loopflag;
|
||||
} // MUSIC_SetLoopFlag
|
||||
|
||||
|
||||
int MUSIC_SongPlaying(void)
|
||||
{
|
||||
return((Mix_PlayingMusic()) ? __FX_TRUE : __FX_FALSE);
|
||||
} // MUSIC_SongPlaying
|
||||
|
||||
|
||||
void MUSIC_Continue(void)
|
||||
{
|
||||
if (Mix_PausedMusic())
|
||||
Mix_ResumeMusic();
|
||||
else if (music_songdata)
|
||||
MUSIC_PlaySong(music_songdata, MUSIC_PlayOnce);
|
||||
} // MUSIC_Continue
|
||||
|
||||
|
||||
void MUSIC_Pause(void)
|
||||
{
|
||||
Mix_PauseMusic();
|
||||
} // MUSIC_Pause
|
||||
|
||||
|
||||
int MUSIC_StopSong(void)
|
||||
{
|
||||
//if (!fx_initialized)
|
||||
if (!Mix_QuerySpec(NULL, NULL, NULL))
|
||||
{
|
||||
setErrorMessage("Need FX system initialized, too. Sorry.");
|
||||
return(MUSIC_Error);
|
||||
} // if
|
||||
|
||||
if ((Mix_PlayingMusic()) || (Mix_PausedMusic()))
|
||||
Mix_HaltMusic();
|
||||
|
||||
if (music_musicchunk)
|
||||
Mix_FreeMusic(music_musicchunk);
|
||||
|
||||
music_songdata = NULL;
|
||||
music_musicchunk = NULL;
|
||||
return(MUSIC_Ok);
|
||||
} // MUSIC_StopSong
|
||||
|
||||
|
||||
int MUSIC_PlaySong(unsigned char *song, int loopflag)
|
||||
{
|
||||
//SDL_RWops *rw;
|
||||
|
||||
MUSIC_StopSong();
|
||||
|
||||
music_songdata = song;
|
||||
|
||||
// !!! FIXME: This could be a problem...SDL/SDL_mixer wants a RWops, which
|
||||
// !!! FIXME: is an i/o abstraction. Since we already have the MIDI data
|
||||
// !!! FIXME: in memory, we fake it with a memory-based RWops. None of
|
||||
// !!! FIXME: this is a problem, except the RWops wants to know how big
|
||||
// !!! FIXME: its memory block is (so it can do things like seek on an
|
||||
// !!! FIXME: offset from the end of the block), and since we don't have
|
||||
// !!! FIXME: this information, we have to give it SOMETHING.
|
||||
|
||||
/* !!! ARGH! There's no LoadMUS_RW ?!
|
||||
rw = SDL_RWFromMem((void *) song, (10 * 1024) * 1024); // yikes.
|
||||
music_musicchunk = Mix_LoadMUS_RW(rw);
|
||||
Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_PlayOnce) ? 0 : -1);
|
||||
*/
|
||||
|
||||
return(MUSIC_Ok);
|
||||
} // MUSIC_PlaySong
|
||||
|
||||
|
||||
extern char ApogeePath[256] = "/tmp/";
|
||||
|
||||
// Duke3D-specific. --ryan.
|
||||
void PlayMusic(char *_filename)
|
||||
{
|
||||
//char filename[MAX_PATH];
|
||||
//strcpy(filename, _filename);
|
||||
//FixFilePath(filename);
|
||||
|
||||
char filename[MAX_PATH];
|
||||
long handle;
|
||||
long size;
|
||||
void *song;
|
||||
long rc;
|
||||
|
||||
MUSIC_StopSong();
|
||||
|
||||
// Read from a groupfile, write it to disk so SDL_mixer can read it.
|
||||
// Lame. --ryan.
|
||||
handle = kopen4load(_filename, 0);
|
||||
if (handle == -1)
|
||||
return;
|
||||
|
||||
size = kfilelength(handle);
|
||||
if (size == -1)
|
||||
{
|
||||
kclose(handle);
|
||||
return;
|
||||
} // if
|
||||
|
||||
song = malloc(size);
|
||||
if (song == NULL)
|
||||
{
|
||||
kclose(handle);
|
||||
return;
|
||||
} // if
|
||||
|
||||
rc = kread(handle, song, size);
|
||||
kclose(handle);
|
||||
if (rc != size)
|
||||
{
|
||||
free(song);
|
||||
return;
|
||||
} // if
|
||||
|
||||
// save the file somewhere, so SDL_mixer can load it
|
||||
GetUnixPathFromEnvironment(filename, MAX_PATH, "tmpsong.mid");
|
||||
handle = SafeOpenWrite(filename, filetype_binary);
|
||||
|
||||
SafeWrite(handle, song, size);
|
||||
close(handle);
|
||||
free(song);
|
||||
|
||||
//music_songdata = song;
|
||||
|
||||
music_musicchunk = Mix_LoadMUS(filename);
|
||||
if (music_musicchunk != NULL)
|
||||
{
|
||||
// !!! FIXME: I set the music to loop. Hope that's okay. --ryan.
|
||||
Mix_PlayMusic(music_musicchunk, -1);
|
||||
} // if
|
||||
}
|
||||
|
||||
|
||||
void MUSIC_SetContext(int context)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_SetContext().\n");
|
||||
music_context = context;
|
||||
} // MUSIC_SetContext
|
||||
|
||||
|
||||
int MUSIC_GetContext(void)
|
||||
{
|
||||
return(music_context);
|
||||
} // MUSIC_GetContext
|
||||
|
||||
|
||||
void MUSIC_SetSongTick(unsigned long PositionInTicks)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_SetSongTick().\n");
|
||||
} // MUSIC_SetSongTick
|
||||
|
||||
|
||||
void MUSIC_SetSongTime(unsigned long milliseconds)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_SetSongTime().\n");
|
||||
}// MUSIC_SetSongTime
|
||||
|
||||
|
||||
void MUSIC_SetSongPosition(int measure, int beat, int tick)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_SetSongPosition().\n");
|
||||
} // MUSIC_SetSongPosition
|
||||
|
||||
|
||||
void MUSIC_GetSongPosition(songposition *pos)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_GetSongPosition().\n");
|
||||
} // MUSIC_GetSongPosition
|
||||
|
||||
|
||||
void MUSIC_GetSongLength(songposition *pos)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_GetSongLength().\n");
|
||||
} // MUSIC_GetSongLength
|
||||
|
||||
|
||||
int MUSIC_FadeVolume(int tovolume, int milliseconds)
|
||||
{
|
||||
Mix_FadeOutMusic(milliseconds);
|
||||
return(MUSIC_Ok);
|
||||
} // MUSIC_FadeVolume
|
||||
|
||||
|
||||
int MUSIC_FadeActive(void)
|
||||
{
|
||||
return((Mix_FadingMusic() == MIX_FADING_OUT) ? __FX_TRUE : __FX_FALSE);
|
||||
} // MUSIC_FadeActive
|
||||
|
||||
|
||||
void MUSIC_StopFade(void)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_StopFade().\n");
|
||||
} // MUSIC_StopFade
|
||||
|
||||
|
||||
void MUSIC_RerouteMidiChannel(int channel, int cdecl(*function)(int event, int c1, int c2))
|
||||
{
|
||||
musdebug("STUB ... MUSIC_RerouteMidiChannel().\n");
|
||||
} // MUSIC_RerouteMidiChannel
|
||||
|
||||
|
||||
void MUSIC_RegisterTimbreBank(unsigned char *timbres)
|
||||
{
|
||||
musdebug("STUB ... MUSIC_RegisterTimbreBank().\n");
|
||||
} // MUSIC_RegisterTimbreBank
|
||||
|
||||
|
||||
void MUSIC_Update(void)
|
||||
{}
|
|
@ -42,7 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#error The SDL output module for AudioLib only works with the SDL interface.
|
||||
#endif
|
||||
|
||||
static int (*_SDLSOUND_CallBack)(int) = NULL;
|
||||
static int(*_SDLSOUND_CallBack)(int) = NULL;
|
||||
static int _SDLSOUND_BufferLength = 0;
|
||||
static int _SDLSOUND_NumBuffers = 0;
|
||||
static char *_SDLSOUND_MixBuffer = NULL;
|
||||
|
@ -87,7 +87,8 @@ int RestoreInterrupts(int a)
|
|||
*/
|
||||
char *SDLSOUND_ErrorString(int errorcode)
|
||||
{
|
||||
switch (errorcode) {
|
||||
switch (errorcode)
|
||||
{
|
||||
case SDLSOUND_Warning:
|
||||
case SDLSOUND_Error:
|
||||
return SDLSOUND_ErrorString(SDLSOUND_ErrorCode);
|
||||
|
@ -109,7 +110,8 @@ int SDLSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, i
|
|||
{
|
||||
SDL_AudioSpec spec,got;
|
||||
|
||||
if (SDLSOUND_Installed) {
|
||||
if (SDLSOUND_Installed)
|
||||
{
|
||||
SDLSOUND_Shutdown();
|
||||
}
|
||||
|
||||
|
@ -169,30 +171,33 @@ int SDLSOUND_SetMixMode(int mode)
|
|||
static void isr(void *userdata, unsigned char *stream, int len)
|
||||
{
|
||||
// otherwise we just service the interrupt
|
||||
if (_DSOUND_CallBack) {
|
||||
if (_DSOUND_CallBack)
|
||||
{
|
||||
|
||||
p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1);
|
||||
|
||||
hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength,
|
||||
&lockptr, &lockbytes, &lockptr2, &lockbytes2, 0);
|
||||
if (hr == DSERR_BUFFERLOST) {
|
||||
if (hr == DSERR_BUFFERLOST)
|
||||
{
|
||||
hr = IDirectSoundBuffer_Restore(lpDSBSecondary);
|
||||
}
|
||||
if (hr == DS_OK) {
|
||||
if (hr == DS_OK)
|
||||
{
|
||||
/*
|
||||
#define copybuf(S,D,c) \
|
||||
#define copybuf(S,D,c) \
|
||||
({ void *__S=(S), *__D=(D); long __c=(c); \
|
||||
__asm__ __volatile__ ("rep; movsl" \
|
||||
: "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \
|
||||
0; })
|
||||
*/
|
||||
*/
|
||||
//copybuf(_DSOUND_MixBuffer + p * _DSOUND_BufferLength, lockptr, _DSOUND_BufferLength >> 2);
|
||||
memcpy(lockptr, _DSOUND_MixBuffer + p * _DSOUND_BufferLength, _DSOUND_BufferLength);
|
||||
IDirectSoundBuffer_Unlock(lpDSBSecondary, lockptr, lockbytes, lockptr2, lockbytes2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,7 +205,7 @@ static void isr(void *userdata, unsigned char *stream, int len)
|
|||
* SDLSOUND_BeginBufferedPlayback
|
||||
* Unpause SDL sound playback.
|
||||
*/
|
||||
int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), int buffersize, int numdivisions)
|
||||
int DSOUND_BeginBufferedPlayback(char *BufferStart, int(*CallBackFunc)(int), int buffersize, int numdivisions)
|
||||
{
|
||||
_SDLSOUND_CallBack = CallBackFunc;
|
||||
_SDLSOUND_MixBuffer = BufferStart;
|
||||
|
@ -222,7 +227,8 @@ int DSOUND_StopPlayback(void)
|
|||
BOOL t;
|
||||
int i;
|
||||
|
||||
if (isrthread) {
|
||||
if (isrthread)
|
||||
{
|
||||
SetEvent(isrfinish);
|
||||
|
||||
printOSD("DirectSound: Waiting for sound thread to exit\n");
|
||||
|
@ -243,17 +249,21 @@ int DSOUND_StopPlayback(void)
|
|||
isrthread = NULL;
|
||||
}
|
||||
|
||||
if (isrfinish) {
|
||||
if (isrfinish)
|
||||
{
|
||||
CloseHandle(isrfinish);
|
||||
isrfinish = NULL;
|
||||
}
|
||||
|
||||
if (lpDSBSecondary) {
|
||||
if (lpDSBSecondary)
|
||||
{
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
}
|
||||
|
||||
if (hPosNotify) {
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++) {
|
||||
if (hPosNotify)
|
||||
{
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++)
|
||||
{
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
|
|
151
polymer/eduke32/source/jaudiolib/unixglob.c
Executable file
151
polymer/eduke32/source/jaudiolib/unixglob.c
Executable file
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Originally written by Ryan C. Gordon. (icculus@clutteredmind.org)
|
||||
Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu)
|
||||
|
||||
*/
|
||||
|
||||
static char ApogeePath[256] = "/tmp/";
|
||||
|
||||
#define PATH_SEP_CHAR '/'
|
||||
#define PATH_SEP_STR "/"
|
||||
#define ROOTDIR "/"
|
||||
#define CURDIR "./"
|
||||
|
||||
#include "duke3d.h"
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
|
||||
void FixFilePath(char *filename)
|
||||
{
|
||||
char *ptr;
|
||||
char *lastsep = filename;
|
||||
|
||||
if ((!filename) || (*filename == '\0'))
|
||||
return;
|
||||
|
||||
if (access(filename, F_OK) == 0) /* File exists; we're good to go. */
|
||||
return;
|
||||
|
||||
for (ptr = filename; 1; ptr++)
|
||||
{
|
||||
if (*ptr == '\\')
|
||||
*ptr = PATH_SEP_CHAR;
|
||||
|
||||
if ((*ptr == PATH_SEP_CHAR) || (*ptr == '\0'))
|
||||
{
|
||||
char pch = *ptr;
|
||||
struct dirent *dent = NULL;
|
||||
DIR *dir;
|
||||
|
||||
if ((pch == PATH_SEP_CHAR) && (*(ptr + 1) == '\0'))
|
||||
return; /* eos is pathsep; we're done. */
|
||||
|
||||
if (lastsep == ptr)
|
||||
continue; /* absolute path; skip to next one. */
|
||||
|
||||
*ptr = '\0';
|
||||
if (lastsep == filename)
|
||||
{
|
||||
dir = opendir((*lastsep == PATH_SEP_CHAR) ? ROOTDIR : CURDIR);
|
||||
|
||||
if (*lastsep == PATH_SEP_CHAR)
|
||||
{
|
||||
lastsep++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*lastsep = '\0';
|
||||
dir = opendir(filename);
|
||||
*lastsep = PATH_SEP_CHAR;
|
||||
lastsep++;
|
||||
}
|
||||
|
||||
if (dir == NULL)
|
||||
{
|
||||
*ptr = PATH_SEP_CHAR;
|
||||
return; /* maybe dir doesn't exist? give up. */
|
||||
}
|
||||
|
||||
while ((dent = readdir(dir)) != NULL)
|
||||
{
|
||||
if (strcasecmp(dent->d_name, lastsep) == 0)
|
||||
{
|
||||
/* found match; replace it. */
|
||||
strcpy(lastsep, dent->d_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
*ptr = pch;
|
||||
lastsep = ptr;
|
||||
|
||||
if (dent == NULL)
|
||||
return; /* no match. oh well. */
|
||||
|
||||
if (pch == '\0') /* eos? */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32 SafeOpenWrite(const char *_filename, int32 filetype)
|
||||
{
|
||||
int handle;
|
||||
char filename[MAX_PATH];
|
||||
strncpy(filename, _filename, sizeof(filename));
|
||||
filename[sizeof(filename) - 1] = '\0';
|
||||
FixFilePath(filename);
|
||||
|
||||
handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC
|
||||
, S_IREAD | S_IWRITE);
|
||||
|
||||
if (handle == -1)
|
||||
Error("Error opening %s: %s",filename,strerror(errno));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
void SafeWrite(int32 handle, void *buffer, int32 count)
|
||||
{
|
||||
unsigned iocount;
|
||||
|
||||
while (count)
|
||||
{
|
||||
iocount = count > 0x8000 ? 0x8000 : count;
|
||||
if (write(handle,buffer,iocount) != (int)iocount)
|
||||
Error("File write failure writing %ld bytes",count);
|
||||
buffer = (void *)((byte *)buffer + iocount);
|
||||
count -= iocount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GetUnixPathFromEnvironment(char *fullname, int32 length, const char *filename)
|
||||
{
|
||||
snprintf(fullname, length-1, "%s%s", ApogeePath, filename);
|
||||
}
|
213
polymer/eduke32/source/jaudiolib/unixpitch.c
Executable file
213
polymer/eduke32/source/jaudiolib/unixpitch.c
Executable file
|
@ -0,0 +1,213 @@
|
|||
/*
|
||||
Copyright (C) 1994-1995 Apogee Software, Ltd.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
/**********************************************************************
|
||||
module: PITCH.C
|
||||
|
||||
author: James R. Dose
|
||||
date: June 14, 1993
|
||||
|
||||
Routines for pitch scaling.
|
||||
|
||||
(c) Copyright 1993 James R. Dose. All Rights Reserved.
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
//#include <math.h>
|
||||
#include "dpmi.h"
|
||||
#include "standard.h"
|
||||
#include "pitch.h"
|
||||
|
||||
#define MAXDETUNE 25
|
||||
|
||||
static unsigned long PitchTable[ 12 ][ MAXDETUNE ] =
|
||||
{
|
||||
{
|
||||
0x10000, 0x10097, 0x1012f, 0x101c7, 0x10260, 0x102f9, 0x10392, 0x1042c,
|
||||
0x104c6, 0x10561, 0x105fb, 0x10696, 0x10732, 0x107ce, 0x1086a, 0x10907,
|
||||
0x109a4, 0x10a41, 0x10adf, 0x10b7d, 0x10c1b, 0x10cba, 0x10d59, 0x10df8,
|
||||
0x10e98
|
||||
},
|
||||
{ 0x10f38, 0x10fd9, 0x1107a, 0x1111b, 0x111bd, 0x1125f, 0x11302, 0x113a5,
|
||||
0x11448, 0x114eb, 0x1158f, 0x11634, 0x116d8, 0x1177e, 0x11823, 0x118c9,
|
||||
0x1196f, 0x11a16, 0x11abd, 0x11b64, 0x11c0c, 0x11cb4, 0x11d5d, 0x11e06,
|
||||
0x11eaf },
|
||||
{ 0x11f59, 0x12003, 0x120ae, 0x12159, 0x12204, 0x122b0, 0x1235c, 0x12409,
|
||||
0x124b6, 0x12563, 0x12611, 0x126bf, 0x1276d, 0x1281c, 0x128cc, 0x1297b,
|
||||
0x12a2b, 0x12adc, 0x12b8d, 0x12c3e, 0x12cf0, 0x12da2, 0x12e55, 0x12f08,
|
||||
0x12fbc },
|
||||
{ 0x1306f, 0x13124, 0x131d8, 0x1328d, 0x13343, 0x133f9, 0x134af, 0x13566,
|
||||
0x1361d, 0x136d5, 0x1378d, 0x13846, 0x138fe, 0x139b8, 0x13a72, 0x13b2c,
|
||||
0x13be6, 0x13ca1, 0x13d5d, 0x13e19, 0x13ed5, 0x13f92, 0x1404f, 0x1410d,
|
||||
0x141cb },
|
||||
{ 0x1428a, 0x14349, 0x14408, 0x144c8, 0x14588, 0x14649, 0x1470a, 0x147cc,
|
||||
0x1488e, 0x14951, 0x14a14, 0x14ad7, 0x14b9b, 0x14c5f, 0x14d24, 0x14dea,
|
||||
0x14eaf, 0x14f75, 0x1503c, 0x15103, 0x151cb, 0x15293, 0x1535b, 0x15424,
|
||||
0x154ee },
|
||||
{ 0x155b8, 0x15682, 0x1574d, 0x15818, 0x158e4, 0x159b0, 0x15a7d, 0x15b4a,
|
||||
0x15c18, 0x15ce6, 0x15db4, 0x15e83, 0x15f53, 0x16023, 0x160f4, 0x161c5,
|
||||
0x16296, 0x16368, 0x1643a, 0x1650d, 0x165e1, 0x166b5, 0x16789, 0x1685e,
|
||||
0x16934 },
|
||||
{ 0x16a09, 0x16ae0, 0x16bb7, 0x16c8e, 0x16d66, 0x16e3e, 0x16f17, 0x16ff1,
|
||||
0x170ca, 0x171a5, 0x17280, 0x1735b, 0x17437, 0x17513, 0x175f0, 0x176ce,
|
||||
0x177ac, 0x1788a, 0x17969, 0x17a49, 0x17b29, 0x17c09, 0x17cea, 0x17dcc,
|
||||
0x17eae },
|
||||
{ 0x17f91, 0x18074, 0x18157, 0x1823c, 0x18320, 0x18406, 0x184eb, 0x185d2,
|
||||
0x186b8, 0x187a0, 0x18888, 0x18970, 0x18a59, 0x18b43, 0x18c2d, 0x18d17,
|
||||
0x18e02, 0x18eee, 0x18fda, 0x190c7, 0x191b5, 0x192a2, 0x19391, 0x19480,
|
||||
0x1956f },
|
||||
{ 0x1965f, 0x19750, 0x19841, 0x19933, 0x19a25, 0x19b18, 0x19c0c, 0x19d00,
|
||||
0x19df4, 0x19ee9, 0x19fdf, 0x1a0d5, 0x1a1cc, 0x1a2c4, 0x1a3bc, 0x1a4b4,
|
||||
0x1a5ad, 0x1a6a7, 0x1a7a1, 0x1a89c, 0x1a998, 0x1aa94, 0x1ab90, 0x1ac8d,
|
||||
0x1ad8b },
|
||||
{ 0x1ae89, 0x1af88, 0x1b088, 0x1b188, 0x1b289, 0x1b38a, 0x1b48c, 0x1b58f,
|
||||
0x1b692, 0x1b795, 0x1b89a, 0x1b99f, 0x1baa4, 0x1bbaa, 0x1bcb1, 0x1bdb8,
|
||||
0x1bec0, 0x1bfc9, 0x1c0d2, 0x1c1dc, 0x1c2e6, 0x1c3f1, 0x1c4fd, 0x1c609,
|
||||
0x1c716 },
|
||||
{ 0x1c823, 0x1c931, 0x1ca40, 0x1cb50, 0x1cc60, 0x1cd70, 0x1ce81, 0x1cf93,
|
||||
0x1d0a6, 0x1d1b9, 0x1d2cd, 0x1d3e1, 0x1d4f6, 0x1d60c, 0x1d722, 0x1d839,
|
||||
0x1d951, 0x1da69, 0x1db82, 0x1dc9c, 0x1ddb6, 0x1ded1, 0x1dfec, 0x1e109,
|
||||
0x1e225 },
|
||||
{ 0x1e343, 0x1e461, 0x1e580, 0x1e6a0, 0x1e7c0, 0x1e8e0, 0x1ea02, 0x1eb24,
|
||||
0x1ec47, 0x1ed6b, 0x1ee8f, 0x1efb4, 0x1f0d9, 0x1f1ff, 0x1f326, 0x1f44e,
|
||||
0x1f576, 0x1f69f, 0x1f7c9, 0x1f8f3, 0x1fa1e, 0x1fb4a, 0x1fc76, 0x1fda3,
|
||||
0x1fed1 }
|
||||
};
|
||||
|
||||
|
||||
//static int PITCH_Installed = FALSE;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: PITCH_Init
|
||||
|
||||
Initializes pitch table.
|
||||
---------------------------------------------------------------------*/
|
||||
/*
|
||||
void PITCH_Init
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
int note;
|
||||
int detune;
|
||||
|
||||
if ( !PITCH_Installed )
|
||||
{
|
||||
for( note = 0; note < 12; note++ )
|
||||
{
|
||||
for( detune = 0; detune < MAXDETUNE; detune++ )
|
||||
{
|
||||
PitchTable[ note ][ detune ] = 0x10000 *
|
||||
pow( 2, ( note * MAXDETUNE + detune ) / ( 12.0 * MAXDETUNE ) );
|
||||
}
|
||||
}
|
||||
|
||||
PITCH_Installed = TRUE;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
Memory locked functions:
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#define PITCH_LockStart PITCH_GetScale
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: PITCH_GetScale
|
||||
|
||||
Returns a fixed-point value to scale number the specified amount.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
unsigned long PITCH_GetScale
|
||||
(
|
||||
int pitchoffset
|
||||
)
|
||||
|
||||
{
|
||||
unsigned long scale;
|
||||
int octaveshift;
|
||||
int noteshift;
|
||||
int note;
|
||||
int detune;
|
||||
|
||||
// if ( !PITCH_Installed )
|
||||
// {
|
||||
// PITCH_Init();
|
||||
// }
|
||||
|
||||
if (pitchoffset == 0)
|
||||
{
|
||||
return(PitchTable[ 0 ][ 0 ]);
|
||||
}
|
||||
|
||||
noteshift = pitchoffset % 1200;
|
||||
if (noteshift < 0)
|
||||
{
|
||||
noteshift += 1200;
|
||||
}
|
||||
|
||||
note = noteshift / 100;
|
||||
detune = (noteshift % 100) / (100 / MAXDETUNE);
|
||||
octaveshift = (pitchoffset - noteshift) / 1200;
|
||||
|
||||
if (detune < 0)
|
||||
{
|
||||
detune += (100 / MAXDETUNE);
|
||||
note--;
|
||||
if (note < 0)
|
||||
{
|
||||
note += 12;
|
||||
octaveshift--;
|
||||
}
|
||||
}
|
||||
|
||||
scale = PitchTable[ note ][ detune ];
|
||||
|
||||
if (octaveshift < 0)
|
||||
{
|
||||
scale >>= -octaveshift;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale <<= octaveshift;
|
||||
}
|
||||
|
||||
return(scale);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: PITCH_LockEnd
|
||||
|
||||
Used for determining the length of the functions to lock in memory.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
static void PITCH_LockEnd
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{}
|
2710
polymer/eduke32/source/jaudiolib/unixvoc.c
Executable file
2710
polymer/eduke32/source/jaudiolib/unixvoc.c
Executable file
File diff suppressed because it is too large
Load diff
12
polymer/eduke32/source/jaudiolib/util.h
Executable file
12
polymer/eduke32/source/jaudiolib/util.h
Executable file
|
@ -0,0 +1,12 @@
|
|||
#ifndef AUDIOLIB__UTIL_H
|
||||
#define AUDIOLIB__UTIL_H
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef max
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -41,15 +41,10 @@ static int currentlist=0;
|
|||
|
||||
static int function, whichkey;
|
||||
static int changesmade, newvidmode, curvidmode, newfullscreen;
|
||||
static int vidsets[16] =
|
||||
{
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
}
|
||||
, curvidset, newvidset = 0;
|
||||
static int vidsets[16] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
|
||||
static int curvidset, newvidset = 0;
|
||||
|
||||
static char *mousebuttonnames[] =
|
||||
{ "Left", "Right", "Middle", "Thumb", "Wheel Down", "Wheel Up"
|
||||
};
|
||||
static char *mousebuttonnames[] = { "Left", "Right", "Middle", "Thumb", "Wheel Down", "Wheel Up" };
|
||||
|
||||
extern int gotvote[MAXPLAYERS], votes[MAXPLAYERS], voting;
|
||||
|
||||
|
|
|
@ -204,6 +204,7 @@ void intomenusounds(void)
|
|||
|
||||
void playmusic(char *fn)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
short fp;
|
||||
long l;
|
||||
|
||||
|
@ -224,6 +225,15 @@ void playmusic(char *fn)
|
|||
kread(fp, MusicPtr, l);
|
||||
kclose(fp);
|
||||
MUSIC_PlaySong(MusicPtr, MUSIC_LoopSong);
|
||||
#else
|
||||
void PlayMusic(char *_filename);
|
||||
if(MusicToggle == 0) return;
|
||||
if(MusicDevice < 0) return;
|
||||
|
||||
// FIXME: I need this to get the music volume initialized (not sure why) -- Jim Bentler
|
||||
MUSIC_SetVolume( MusicVolume );
|
||||
PlayMusic(fn);
|
||||
#endif
|
||||
}
|
||||
|
||||
char loadsound(unsigned short num)
|
||||
|
|
Loading…
Reference in a new issue