mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +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 \
|
||||
|
@ -99,7 +111,7 @@ GAMEOBJS=$(OBJ)/game.$o \
|
|||
$(OBJ)/testcd.$o \
|
||||
$(OBJ)/osdfuncs.$o \
|
||||
$(OBJ)/osdcmds.$o \
|
||||
$(OBJ)/grpscan.$o \
|
||||
$(OBJ)/grpscan.$o \
|
||||
$(JMACTOBJ)
|
||||
|
||||
EDITOROBJS=$(OBJ)/astub.$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
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -27,64 +27,64 @@ void endanimsounds(long fr)
|
|||
{
|
||||
switch (ud.volume_number)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
switch (fr)
|
||||
{
|
||||
case 1:
|
||||
switch (fr)
|
||||
{
|
||||
case 1:
|
||||
sound(WIND_AMBIENCE);
|
||||
break;
|
||||
case 26:
|
||||
sound(ENDSEQVOL2SND1);
|
||||
break;
|
||||
case 36:
|
||||
sound(ENDSEQVOL2SND2);
|
||||
break;
|
||||
case 54:
|
||||
sound(THUD);
|
||||
break;
|
||||
case 62:
|
||||
sound(ENDSEQVOL2SND3);
|
||||
break;
|
||||
case 75:
|
||||
sound(ENDSEQVOL2SND4);
|
||||
break;
|
||||
case 81:
|
||||
sound(ENDSEQVOL2SND5);
|
||||
break;
|
||||
case 115:
|
||||
sound(ENDSEQVOL2SND6);
|
||||
break;
|
||||
case 124:
|
||||
sound(ENDSEQVOL2SND7);
|
||||
break;
|
||||
}
|
||||
sound(WIND_AMBIENCE);
|
||||
break;
|
||||
case 2:
|
||||
switch (fr)
|
||||
{
|
||||
case 1:
|
||||
sound(WIND_REPEAT);
|
||||
break;
|
||||
case 98:
|
||||
sound(DUKE_GRUNT);
|
||||
break;
|
||||
case 82+20:
|
||||
sound(THUD);
|
||||
sound(SQUISHED);
|
||||
break;
|
||||
case 104+20:
|
||||
sound(ENDSEQVOL3SND3);
|
||||
break;
|
||||
case 114+20:
|
||||
sound(ENDSEQVOL3SND2);
|
||||
break;
|
||||
case 158:
|
||||
sound(PIPEBOMB_EXPLODE);
|
||||
break;
|
||||
}
|
||||
case 26:
|
||||
sound(ENDSEQVOL2SND1);
|
||||
break;
|
||||
case 36:
|
||||
sound(ENDSEQVOL2SND2);
|
||||
break;
|
||||
case 54:
|
||||
sound(THUD);
|
||||
break;
|
||||
case 62:
|
||||
sound(ENDSEQVOL2SND3);
|
||||
break;
|
||||
case 75:
|
||||
sound(ENDSEQVOL2SND4);
|
||||
break;
|
||||
case 81:
|
||||
sound(ENDSEQVOL2SND5);
|
||||
break;
|
||||
case 115:
|
||||
sound(ENDSEQVOL2SND6);
|
||||
break;
|
||||
case 124:
|
||||
sound(ENDSEQVOL2SND7);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (fr)
|
||||
{
|
||||
case 1:
|
||||
sound(WIND_REPEAT);
|
||||
break;
|
||||
case 98:
|
||||
sound(DUKE_GRUNT);
|
||||
break;
|
||||
case 82+20:
|
||||
sound(THUD);
|
||||
sound(SQUISHED);
|
||||
break;
|
||||
case 104+20:
|
||||
sound(ENDSEQVOL3SND3);
|
||||
break;
|
||||
case 114+20:
|
||||
sound(ENDSEQVOL3SND2);
|
||||
break;
|
||||
case 158:
|
||||
sound(PIPEBOMB_EXPLODE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,12 +92,12 @@ void logoanimsounds(long fr)
|
|||
{
|
||||
switch (fr)
|
||||
{
|
||||
case 1:
|
||||
sound(FLY_BY);
|
||||
break;
|
||||
case 19:
|
||||
sound(PIPEBOMB_EXPLODE);
|
||||
break;
|
||||
case 1:
|
||||
sound(FLY_BY);
|
||||
break;
|
||||
case 19:
|
||||
sound(PIPEBOMB_EXPLODE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,16 +105,16 @@ void intro4animsounds(long fr)
|
|||
{
|
||||
switch (fr)
|
||||
{
|
||||
case 1:
|
||||
sound(INTRO4_B);
|
||||
break;
|
||||
case 12:
|
||||
case 34:
|
||||
sound(SHORT_CIRCUIT);
|
||||
break;
|
||||
case 18:
|
||||
sound(INTRO4_5);
|
||||
break;
|
||||
case 1:
|
||||
sound(INTRO4_B);
|
||||
break;
|
||||
case 12:
|
||||
case 34:
|
||||
sound(SHORT_CIRCUIT);
|
||||
break;
|
||||
case 18:
|
||||
sound(INTRO4_5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,18 +122,18 @@ void first4animsounds(long fr)
|
|||
{
|
||||
switch (fr)
|
||||
{
|
||||
case 1:
|
||||
sound(INTRO4_1);
|
||||
break;
|
||||
case 12:
|
||||
sound(INTRO4_2);
|
||||
break;
|
||||
case 7:
|
||||
sound(INTRO4_3);
|
||||
break;
|
||||
case 26:
|
||||
sound(INTRO4_4);
|
||||
break;
|
||||
case 1:
|
||||
sound(INTRO4_1);
|
||||
break;
|
||||
case 12:
|
||||
sound(INTRO4_2);
|
||||
break;
|
||||
case 7:
|
||||
sound(INTRO4_3);
|
||||
break;
|
||||
case 26:
|
||||
sound(INTRO4_4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,9 +141,9 @@ void intro42animsounds(long fr)
|
|||
{
|
||||
switch (fr)
|
||||
{
|
||||
case 10:
|
||||
sound(INTRO4_6);
|
||||
break;
|
||||
case 10:
|
||||
sound(INTRO4_6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,12 +151,12 @@ void endanimvol41(long fr)
|
|||
{
|
||||
switch (fr)
|
||||
{
|
||||
case 3:
|
||||
sound(DUKE_UNDERWATER);
|
||||
break;
|
||||
case 35:
|
||||
sound(VOL4ENDSND1);
|
||||
break;
|
||||
case 3:
|
||||
sound(DUKE_UNDERWATER);
|
||||
break;
|
||||
case 35:
|
||||
sound(VOL4ENDSND1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,18 +164,18 @@ void endanimvol42(long fr)
|
|||
{
|
||||
switch (fr)
|
||||
{
|
||||
case 11:
|
||||
sound(DUKE_UNDERWATER);
|
||||
break;
|
||||
case 20:
|
||||
sound(VOL4ENDSND1);
|
||||
break;
|
||||
case 39:
|
||||
sound(VOL4ENDSND2);
|
||||
break;
|
||||
case 50:
|
||||
FX_StopAllSounds();
|
||||
break;
|
||||
case 11:
|
||||
sound(DUKE_UNDERWATER);
|
||||
break;
|
||||
case 20:
|
||||
sound(VOL4ENDSND1);
|
||||
break;
|
||||
case 39:
|
||||
sound(VOL4ENDSND2);
|
||||
break;
|
||||
case 50:
|
||||
FX_StopAllSounds();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,16 +183,16 @@ void endanimvol43(long fr)
|
|||
{
|
||||
switch (fr)
|
||||
{
|
||||
case 1:
|
||||
sound(BOSS4_DEADSPEECH);
|
||||
break;
|
||||
case 40:
|
||||
sound(VOL4ENDSND1);
|
||||
sound(DUKE_UNDERWATER);
|
||||
break;
|
||||
case 50:
|
||||
sound(BIGBANG);
|
||||
break;
|
||||
case 1:
|
||||
sound(BOSS4_DEADSPEECH);
|
||||
break;
|
||||
case 40:
|
||||
sound(VOL4ENDSND1);
|
||||
sound(DUKE_UNDERWATER);
|
||||
break;
|
||||
case 50:
|
||||
sound(BIGBANG);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -190,14 +190,14 @@ char * CONFIG_AnalogNumToName(int32 func)
|
|||
{
|
||||
switch (func)
|
||||
{
|
||||
case analog_turning:
|
||||
return "analog_turning";
|
||||
case analog_strafing:
|
||||
return "analog_strafing";
|
||||
case analog_moving:
|
||||
return "analog_moving";
|
||||
case analog_lookingupanddown:
|
||||
return "analog_lookingupanddown";
|
||||
case analog_turning:
|
||||
return "analog_turning";
|
||||
case analog_strafing:
|
||||
return "analog_strafing";
|
||||
case analog_moving:
|
||||
return "analog_moving";
|
||||
case analog_lookingupanddown:
|
||||
return "analog_lookingupanddown";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -10,15 +10,14 @@
|
|||
|
||||
struct grpfile grpfiles[numgrpfiles] =
|
||||
{
|
||||
{ "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", 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 },
|
||||
{ "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,9 +272,13 @@ parm [ edi ] [ eax ] [ ecx ] modify exact [ ecx edi ];
|
|||
|
||||
#define CDEC _cdecl
|
||||
|
||||
#else
|
||||
#elif defined(WINDOWS)
|
||||
|
||||
#define CDEC __cdecl
|
||||
#define CDEC __cdecl
|
||||
|
||||
#else
|
||||
|
||||
#define CDEC
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define TRUE (1==1)
|
||||
#define FALSE (1==0)
|
||||
|
||||
#define dprintOSD(...)
|
||||
#define dprintOSD(...)
|
||||
|
||||
#ifdef WINDOWS
|
||||
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 ) \
|
||||
|
@ -66,35 +66,35 @@ int FX_SimulateCallbacks(void);
|
|||
|
||||
char *FX_ErrorString(int ErrorNumber)
|
||||
{
|
||||
char *ErrorString;
|
||||
char *ErrorString;
|
||||
|
||||
switch( ErrorNumber )
|
||||
{
|
||||
case FX_Warning :
|
||||
case FX_Error :
|
||||
ErrorString = FX_ErrorString( FX_ErrorCode );
|
||||
break;
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case FX_Warning :
|
||||
case FX_Error :
|
||||
ErrorString = FX_ErrorString(FX_ErrorCode);
|
||||
break;
|
||||
|
||||
case FX_Ok :
|
||||
ErrorString = "Fx ok.";
|
||||
break;
|
||||
case FX_Ok :
|
||||
ErrorString = "Fx ok.";
|
||||
break;
|
||||
|
||||
case FX_ASSVersion :
|
||||
ErrorString = "Apogee Sound System Version WinMM "
|
||||
"Programmed by Jim Dose, Ported by Jonathon Fowler\n"
|
||||
"(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
|
||||
break;
|
||||
case FX_ASSVersion :
|
||||
ErrorString = "Apogee Sound System Version WinMM "
|
||||
"Programmed by Jim Dose, Ported by Jonathon Fowler\n"
|
||||
"(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
|
||||
break;
|
||||
|
||||
case FX_FMODInit :
|
||||
ErrorString = "Failed initializing FMOD.";
|
||||
break;
|
||||
case FX_FMODInit :
|
||||
ErrorString = "Failed initializing FMOD.";
|
||||
break;
|
||||
|
||||
default :
|
||||
ErrorString = "Unknown Fx error code.";
|
||||
break;
|
||||
}
|
||||
default :
|
||||
ErrorString = "Unknown Fx error code.";
|
||||
break;
|
||||
}
|
||||
|
||||
return( ErrorString );
|
||||
return(ErrorString);
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,54 +106,57 @@ char *FX_ErrorString(int ErrorNumber)
|
|||
|
||||
static char *OutputType(int a)
|
||||
{
|
||||
switch (a) {
|
||||
case FSOUND_OUTPUT_NOSOUND: return "no-sound";
|
||||
case FSOUND_OUTPUT_WINMM: return "WinMM";
|
||||
case FSOUND_OUTPUT_DSOUND: return "DirectSound";
|
||||
case FSOUND_OUTPUT_A3D: return "Aureal3D";
|
||||
case FSOUND_OUTPUT_OSS: return "OSS";
|
||||
case FSOUND_OUTPUT_ESD: return "ESD";
|
||||
case FSOUND_OUTPUT_ALSA: return "ALSA";
|
||||
case FSOUND_OUTPUT_ASIO: return "ASIO";
|
||||
case FSOUND_OUTPUT_XBOX: return "Xbox";
|
||||
case FSOUND_OUTPUT_PS2: return "Playstation2";
|
||||
case FSOUND_OUTPUT_MAC: return "Macintosh Sound Manager";
|
||||
default: return "unknown";
|
||||
}
|
||||
switch (a)
|
||||
{
|
||||
case FSOUND_OUTPUT_NOSOUND: return "no-sound";
|
||||
case FSOUND_OUTPUT_WINMM: return "WinMM";
|
||||
case FSOUND_OUTPUT_DSOUND: return "DirectSound";
|
||||
case FSOUND_OUTPUT_A3D: return "Aureal3D";
|
||||
case FSOUND_OUTPUT_OSS: return "OSS";
|
||||
case FSOUND_OUTPUT_ESD: return "ESD";
|
||||
case FSOUND_OUTPUT_ALSA: return "ALSA";
|
||||
case FSOUND_OUTPUT_ASIO: return "ASIO";
|
||||
case FSOUND_OUTPUT_XBOX: return "Xbox";
|
||||
case FSOUND_OUTPUT_PS2: return "Playstation2";
|
||||
case FSOUND_OUTPUT_MAC: return "Macintosh Sound Manager";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate)
|
||||
{
|
||||
FSOUND_Close();
|
||||
FSOUND_Close();
|
||||
|
||||
memset(FX_Samples, 0, sizeof(FX_Samples));
|
||||
memset(FX_Samples, 0, sizeof(FX_Samples));
|
||||
|
||||
#ifdef WINDOWS
|
||||
if (hWindow) {
|
||||
//FSOUND_SetHWND(&hWindow);
|
||||
}
|
||||
if (hWindow)
|
||||
{
|
||||
//FSOUND_SetHWND(&hWindow);
|
||||
}
|
||||
#endif
|
||||
if (!FSOUND_Init(mixrate, numvoices, FSOUND_INIT_GLOBALFOCUS)) {
|
||||
FX_SetErrorCode( FX_FMODInit );
|
||||
return FX_Error;
|
||||
}
|
||||
if (!FSOUND_Init(mixrate, numvoices, FSOUND_INIT_GLOBALFOCUS))
|
||||
{
|
||||
FX_SetErrorCode(FX_FMODInit);
|
||||
return FX_Error;
|
||||
}
|
||||
|
||||
printOSD("FX_Init(): %d voices, %d channels, %dHz samplerate\n", numvoices,numchannels,FSOUND_GetOutputRate());
|
||||
printOSD("FX_Init(): FMOD is using the %s output driver\n", OutputType(FSOUND_GetOutput()));
|
||||
printOSD("FX_Init(): %d voices, %d channels, %dHz samplerate\n", numvoices,numchannels,FSOUND_GetOutputRate());
|
||||
printOSD("FX_Init(): FMOD is using the %s output driver\n", OutputType(FSOUND_GetOutput()));
|
||||
|
||||
chtoggle=0;
|
||||
if (chstates) free(chstates);
|
||||
chstates = (char*)malloc(numvoices*2 + sizeof(long)*numvoices);
|
||||
memset(chstates,0,numvoices*2 + sizeof(long)*numvoices);
|
||||
|
||||
chcallvals = (long*)(chstates + numvoices*2);
|
||||
chstatesa = chstates;
|
||||
chstatesb = chstates + numvoices;
|
||||
chtoggle=0;
|
||||
if (chstates) free(chstates);
|
||||
chstates = (char*)malloc(numvoices*2 + sizeof(long)*numvoices);
|
||||
memset(chstates,0,numvoices*2 + sizeof(long)*numvoices);
|
||||
|
||||
FX_NumVoices = numvoices;
|
||||
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
chcallvals = (long*)(chstates + numvoices*2);
|
||||
chstatesa = chstates;
|
||||
chstatesb = chstates + numvoices;
|
||||
|
||||
FX_NumVoices = numvoices;
|
||||
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -165,20 +168,21 @@ int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsig
|
|||
|
||||
int FX_Shutdown(void)
|
||||
{
|
||||
unsigned int curalloced, maxalloced;
|
||||
|
||||
if (chstates) {
|
||||
FSOUND_GetMemoryStats(&curalloced, &maxalloced);
|
||||
printOSD("FX_Shutdown(): allocation stats - currently %d bytes, maximum %d bytes\n",curalloced,maxalloced);
|
||||
}
|
||||
|
||||
FSOUND_Close();
|
||||
unsigned int curalloced, maxalloced;
|
||||
|
||||
if (chstates) free(chstates);
|
||||
chstates=chstatesa=chstatesb=0;
|
||||
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
if (chstates)
|
||||
{
|
||||
FSOUND_GetMemoryStats(&curalloced, &maxalloced);
|
||||
printOSD("FX_Shutdown(): allocation stats - currently %d bytes, maximum %d bytes\n",curalloced,maxalloced);
|
||||
}
|
||||
|
||||
FSOUND_Close();
|
||||
|
||||
if (chstates) free(chstates);
|
||||
chstates=chstatesa=chstatesb=0;
|
||||
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -188,11 +192,11 @@ 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);
|
||||
return FX_Ok;
|
||||
FX_CallBackFunc = function;
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -204,7 +208,7 @@ int FX_SetCallBack(void ( *function )( unsigned long ))
|
|||
|
||||
void FX_SetVolume(int volume)
|
||||
{
|
||||
FSOUND_SetSFXMasterVolume(volume);
|
||||
FSOUND_SetSFXMasterVolume(volume);
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,8 +219,7 @@ void FX_SetVolume(int volume)
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverseStereo(int setting)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -227,7 +230,7 @@ void FX_SetReverseStereo(int setting)
|
|||
|
||||
int FX_GetReverseStereo(void)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -261,8 +262,8 @@ void FX_SetReverbDelay(int delay)
|
|||
|
||||
int FX_VoiceAvailable(int priority)
|
||||
{
|
||||
FX_SimulateCallbacks();
|
||||
return 1;
|
||||
FX_SimulateCallbacks();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -278,19 +279,19 @@ int FX_VoiceAvailable(int priority)
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayLoopedVOC
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
{
|
||||
return FX_PlayLoopedSound(pitchoffset, vol, callbackval);
|
||||
return FX_PlayLoopedSound(pitchoffset, vol, callbackval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -301,19 +302,19 @@ int FX_PlayLoopedVOC
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayLoopedWAV
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
{
|
||||
return FX_PlayLoopedSound(pitchoffset, vol, callbackval);
|
||||
return FX_PlayLoopedSound(pitchoffset, vol, callbackval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,16 +326,16 @@ int FX_PlayLoopedWAV
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayVOC3D
|
||||
(
|
||||
char *ptr,
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
(
|
||||
char *ptr,
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
{
|
||||
return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval);
|
||||
return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -346,16 +347,16 @@ int FX_PlayVOC3D
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayWAV3D
|
||||
(
|
||||
char *ptr,
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
(
|
||||
char *ptr,
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
{
|
||||
return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval);
|
||||
return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -367,13 +368,13 @@ int FX_PlayWAV3D
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_Pan3D
|
||||
(
|
||||
int handle,
|
||||
int angle,
|
||||
int distance
|
||||
)
|
||||
(
|
||||
int handle,
|
||||
int angle,
|
||||
int distance
|
||||
)
|
||||
{
|
||||
return FX_Ok;
|
||||
return FX_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -385,14 +386,14 @@ int FX_Pan3D
|
|||
|
||||
int FX_StopSound(int handle)
|
||||
{
|
||||
FX_SimulateCallbacks();
|
||||
FSOUND_StopSound(handle);
|
||||
FX_SimulateCallbacks();
|
||||
FSOUND_StopSound(handle);
|
||||
|
||||
if (handle>=0 && handle<FX_NumVoices)
|
||||
chstatesa[handle] = chstatesb[handle] = 0; // no callback for you!
|
||||
if (handle>=0 && handle<FX_NumVoices)
|
||||
chstatesa[handle] = chstatesb[handle] = 0; // no callback for you!
|
||||
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -404,13 +405,13 @@ int FX_StopSound(int handle)
|
|||
|
||||
int FX_StopAllSounds(void)
|
||||
{
|
||||
FX_SimulateCallbacks();
|
||||
FSOUND_StopSound(FSOUND_ALL);
|
||||
FX_SimulateCallbacks();
|
||||
FSOUND_StopSound(FSOUND_ALL);
|
||||
|
||||
memset(chstates, 0, FX_NumVoices*2); // no callbacks for any of you!
|
||||
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
memset(chstates, 0, FX_NumVoices*2); // no callbacks for any of you!
|
||||
|
||||
FX_SetErrorCode(FX_Ok);
|
||||
return FX_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -421,113 +422,119 @@ int FX_StopAllSounds(void)
|
|||
the channel number it played on.
|
||||
---------------------------------------------------------------------*/
|
||||
int FX_PlayLoopedSound(
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
unsigned long num
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
unsigned long num
|
||||
)
|
||||
{
|
||||
int chan;
|
||||
int chan;
|
||||
|
||||
FX_SimulateCallbacks();
|
||||
FX_SimulateCallbacks();
|
||||
|
||||
if (!FX_Samples[num]) return -1;
|
||||
if (!FX_Samples[num]) return -1;
|
||||
|
||||
chan = FSOUND_PlaySoundEx(FSOUND_FREE, FX_Samples[num], NULL, TRUE) & 4095;
|
||||
if (chan < 0) return -1;
|
||||
chan = FSOUND_PlaySoundEx(FSOUND_FREE, FX_Samples[num], NULL, TRUE) & 4095;
|
||||
if (chan < 0) return -1;
|
||||
|
||||
// channel was already playing
|
||||
if (chstatesa[chan] && FX_CallBackFunc) FX_CallBackFunc(chcallvals[chan]);
|
||||
// channel was already playing
|
||||
if (chstatesa[chan] && FX_CallBackFunc) FX_CallBackFunc(chcallvals[chan]);
|
||||
|
||||
// set pitch
|
||||
FSOUND_SetVolume(chan, vol);
|
||||
if (FSOUND_Sample_GetMode(FX_Samples[num]) & FSOUND_STEREO)
|
||||
FSOUND_SetPan(chan, FSOUND_STEREOPAN);
|
||||
else
|
||||
FSOUND_SetPan(chan, 128);
|
||||
FSOUND_SetLoopMode(chan, FSOUND_LOOP_NORMAL);
|
||||
// set pitch
|
||||
FSOUND_SetVolume(chan, vol);
|
||||
if (FSOUND_Sample_GetMode(FX_Samples[num]) & FSOUND_STEREO)
|
||||
FSOUND_SetPan(chan, FSOUND_STEREOPAN);
|
||||
else
|
||||
FSOUND_SetPan(chan, 128);
|
||||
FSOUND_SetLoopMode(chan, FSOUND_LOOP_NORMAL);
|
||||
|
||||
chcallvals[chan] = num;
|
||||
FSOUND_SetPaused(chan, FALSE);
|
||||
chcallvals[chan] = num;
|
||||
FSOUND_SetPaused(chan, FALSE);
|
||||
|
||||
dprintOSD("FX_PlayLoopedSound(): Play sound %d in channel %d\n",num,chan);
|
||||
dprintOSD("FX_PlayLoopedSound(): Play sound %d in channel %d\n",num,chan);
|
||||
|
||||
return chan;
|
||||
return chan;
|
||||
}
|
||||
|
||||
|
||||
int FX_PlayPositionedSound(
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
unsigned long num
|
||||
int pitchoffset,
|
||||
int angle,
|
||||
int distance,
|
||||
unsigned long num
|
||||
)
|
||||
{
|
||||
int chan;
|
||||
int chan;
|
||||
|
||||
FX_SimulateCallbacks();
|
||||
FX_SimulateCallbacks();
|
||||
|
||||
if (!FX_Samples[num]) return -1;
|
||||
if (!FX_Samples[num]) return -1;
|
||||
|
||||
chan = FSOUND_PlaySoundEx(FSOUND_FREE, FX_Samples[num], NULL, TRUE) & 4095;
|
||||
if (chan < 0) return -1;
|
||||
chan = FSOUND_PlaySoundEx(FSOUND_FREE, FX_Samples[num], NULL, TRUE) & 4095;
|
||||
if (chan < 0) return -1;
|
||||
|
||||
// channel was already playing
|
||||
if (chstatesa[chan] && FX_CallBackFunc) FX_CallBackFunc(chcallvals[chan]);
|
||||
// channel was already playing
|
||||
if (chstatesa[chan] && FX_CallBackFunc) FX_CallBackFunc(chcallvals[chan]);
|
||||
|
||||
if (angle<0) angle = 255-angle; // behind us
|
||||
|
||||
// set pitch
|
||||
FSOUND_SetVolume(chan,255);
|
||||
FSOUND_SetPan(chan,128);
|
||||
FSOUND_SetLoopMode(chan, FSOUND_LOOP_OFF);
|
||||
|
||||
chcallvals[chan] = num;
|
||||
FSOUND_SetPaused(chan, FALSE);
|
||||
if (angle<0) angle = 255-angle; // behind us
|
||||
|
||||
dprintOSD("FX_PlayPositionedSound(): Play sound %d in channel %d\n",num,chan);
|
||||
// set pitch
|
||||
FSOUND_SetVolume(chan,255);
|
||||
FSOUND_SetPan(chan,128);
|
||||
FSOUND_SetLoopMode(chan, FSOUND_LOOP_OFF);
|
||||
|
||||
return chan;
|
||||
chcallvals[chan] = num;
|
||||
FSOUND_SetPaused(chan, FALSE);
|
||||
|
||||
dprintOSD("FX_PlayPositionedSound(): Play sound %d in channel %d\n",num,chan);
|
||||
|
||||
return chan;
|
||||
}
|
||||
|
||||
|
||||
int FX_LoadSample(char *ptr, long size, unsigned long number, int priority)
|
||||
{
|
||||
FSOUND_SAMPLE *samp = NULL;
|
||||
int samplerate=0, channels=0, samplesize=0;
|
||||
int flags=0;
|
||||
long datalen=0;
|
||||
void *ptr1,*ptr2;
|
||||
int ptr1len,ptr2len;
|
||||
FSOUND_SAMPLE *samp = NULL;
|
||||
int samplerate=0, channels=0, samplesize=0;
|
||||
int flags=0;
|
||||
long datalen=0;
|
||||
void *ptr1,*ptr2;
|
||||
int ptr1len,ptr2len;
|
||||
|
||||
if (!memcmp(ptr, "Creative Voice File", 0x13)) {
|
||||
// VOC file
|
||||
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 (FX_ReadVOCData(ptr,ptr1,datalen,(samplesize==8))) ;
|
||||
FSOUND_Sample_Unlock(samp,ptr1,ptr2,ptr1len,ptr2len);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
samp = FSOUND_Sample_Load(number, ptr, FSOUND_LOADMEMORY, size);
|
||||
}
|
||||
if (!memcmp(ptr, "Creative Voice File", 0x13))
|
||||
{
|
||||
// VOC file
|
||||
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 (FX_ReadVOCData(ptr,ptr1,datalen,(samplesize==8))) ;
|
||||
FSOUND_Sample_Unlock(samp,ptr1,ptr2,ptr1len,ptr2len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
samp = FSOUND_Sample_Load(number, ptr, FSOUND_LOADMEMORY, size);
|
||||
}
|
||||
|
||||
dprintOSD("FX_LoadSample(): loaded sound %d\n",number);
|
||||
if (samp) FSOUND_Sample_SetDefaults(samp, -1, -1, -1, priority);
|
||||
FX_Samples[number] = samp;
|
||||
dprintOSD("FX_LoadSample(): loaded sound %d\n",number);
|
||||
if (samp) FSOUND_Sample_SetDefaults(samp, -1, -1, -1, priority);
|
||||
FX_Samples[number] = samp;
|
||||
|
||||
return (samp != NULL);
|
||||
return (samp != NULL);
|
||||
}
|
||||
|
||||
|
||||
int FX_SampleLoaded(unsigned long number)
|
||||
{
|
||||
return (FX_Samples[number] != NULL);
|
||||
return (FX_Samples[number] != NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -536,202 +543,215 @@ int FX_SampleLoaded(unsigned long number)
|
|||
|
||||
int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *samplesize, long *datalen)
|
||||
{
|
||||
short version,version2;
|
||||
char blocktype=0;
|
||||
int blocklen=0;
|
||||
char *ptr=data;
|
||||
short version,version2;
|
||||
char blocktype=0;
|
||||
int blocklen=0;
|
||||
char *ptr=data;
|
||||
|
||||
if (memcmp(ptr, "Creative Voice File\x1A", 0x14)) return -1;
|
||||
ptr += 0x14;
|
||||
|
||||
ptr += 2;
|
||||
version = ((short*)ptr)[0];
|
||||
version2 = ((short*)ptr)[1];
|
||||
if (memcmp(ptr, "Creative Voice File\x1A", 0x14)) return -1;
|
||||
ptr += 0x14;
|
||||
|
||||
if (~version + 0x1234 != version2) return -1;
|
||||
ptr += 2;
|
||||
version = ((short*)ptr)[0];
|
||||
version2 = ((short*)ptr)[1];
|
||||
|
||||
ptr += 4;
|
||||
if (~version + 0x1234 != version2) return -1;
|
||||
|
||||
while (1) {
|
||||
blocktype = *(ptr++);
|
||||
if ((ptr-data)>size) return -1; // truncated
|
||||
|
||||
if (blocktype == 0)
|
||||
break;
|
||||
ptr += 4;
|
||||
|
||||
blocklen = *(ptr++);
|
||||
blocklen |= *(ptr++) << 8;
|
||||
blocklen |= *(ptr++) << 16;
|
||||
while (1)
|
||||
{
|
||||
blocktype = *(ptr++);
|
||||
if ((ptr-data)>size) return -1; // truncated
|
||||
|
||||
switch (blocktype) {
|
||||
case 1: /* sound data begin block */
|
||||
if (!*samplerate)
|
||||
*samplerate = REGRESSSR(ptr[0]);
|
||||
if (ptr[1] != 0) {
|
||||
/* only 8-bit files please */
|
||||
return -1;
|
||||
}
|
||||
if (!*channels) *channels = 1;
|
||||
*samplesize = 8;
|
||||
*datalen += blocklen-2;
|
||||
ptr += blocklen;
|
||||
break;
|
||||
if (blocktype == 0)
|
||||
break;
|
||||
|
||||
case 2: /* sound continue */
|
||||
*datalen += blocklen;
|
||||
ptr += blocklen;
|
||||
break;
|
||||
blocklen = *(ptr++);
|
||||
blocklen |= *(ptr++) << 8;
|
||||
blocklen |= *(ptr++) << 16;
|
||||
|
||||
switch (blocktype)
|
||||
{
|
||||
case 1: /* sound data begin block */
|
||||
if (!*samplerate)
|
||||
*samplerate = REGRESSSR(ptr[0]);
|
||||
if (ptr[1] != 0)
|
||||
{
|
||||
/* only 8-bit files please */
|
||||
return -1;
|
||||
}
|
||||
if (!*channels) *channels = 1;
|
||||
*samplesize = 8;
|
||||
*datalen += blocklen-2;
|
||||
ptr += blocklen;
|
||||
break;
|
||||
|
||||
case 2: /* sound continue */
|
||||
*datalen += blocklen;
|
||||
ptr += blocklen;
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case 3: /* silence */
|
||||
kread(fh, blockprop, 3);
|
||||
/*
|
||||
length = blockprop[0] | (blockprop[1] << 8)
|
||||
sample rate = REGRESSSR(blockprop[2]))
|
||||
*/
|
||||
break;
|
||||
case 3: /* silence */
|
||||
kread(fh, blockprop, 3);
|
||||
/*
|
||||
length = blockprop[0] | (blockprop[1] << 8)
|
||||
sample rate = REGRESSSR(blockprop[2]))
|
||||
*/
|
||||
break;
|
||||
|
||||
case 4: /* marker */
|
||||
kread(fh, &blockprop, 2);
|
||||
/*
|
||||
id = blockprop[0] | (blockprop[1] << 8))
|
||||
*/
|
||||
break;
|
||||
case 4: /* marker */
|
||||
kread(fh, &blockprop, 2);
|
||||
/*
|
||||
id = blockprop[0] | (blockprop[1] << 8))
|
||||
*/
|
||||
break;
|
||||
|
||||
case 5: /* ASCII data */
|
||||
klseek(fh, blocklen, SEEK_CUR);
|
||||
/*
|
||||
asciiz string
|
||||
*/
|
||||
break;
|
||||
case 5: /* ASCII data */
|
||||
klseek(fh, blocklen, SEEK_CUR);
|
||||
/*
|
||||
asciiz string
|
||||
*/
|
||||
break;
|
||||
|
||||
case 6: /* repeat */
|
||||
kread(fh, blockprop, 2);
|
||||
/*
|
||||
num repetitions = (blockprop[0] | (blockprop[1] << 8)) - 1
|
||||
*/
|
||||
break;
|
||||
case 6: /* repeat */
|
||||
kread(fh, blockprop, 2);
|
||||
/*
|
||||
num repetitions = (blockprop[0] | (blockprop[1] << 8)) - 1
|
||||
*/
|
||||
break;
|
||||
|
||||
case 7: /* end repeat */
|
||||
break;
|
||||
case 7: /* end repeat */
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 8: /* sound attribute extension block */
|
||||
*samplerate = REGRESSTC(ptr[0] | (ptr[1] << 8));
|
||||
*samplesize = 8;
|
||||
if (ptr[3] == 1) {
|
||||
*samplerate >>= 1;
|
||||
*channels = 2;
|
||||
} else
|
||||
*channels = 1;
|
||||
if (ptr[2] != 0) {
|
||||
/* only 8-bit files please */
|
||||
return -1;
|
||||
}
|
||||
ptr += 4;
|
||||
/* a block 1 follows */
|
||||
break;
|
||||
case 8: /* sound attribute extension block */
|
||||
*samplerate = REGRESSTC(ptr[0] | (ptr[1] << 8));
|
||||
*samplesize = 8;
|
||||
if (ptr[3] == 1)
|
||||
{
|
||||
*samplerate >>= 1;
|
||||
*channels = 2;
|
||||
}
|
||||
else
|
||||
*channels = 1;
|
||||
if (ptr[2] != 0)
|
||||
{
|
||||
/* only 8-bit files please */
|
||||
return -1;
|
||||
}
|
||||
ptr += 4;
|
||||
/* a block 1 follows */
|
||||
break;
|
||||
|
||||
case 9: /* sound data format 3 */
|
||||
*samplerate = *((long*)(ptr));
|
||||
*samplesize = ptr[4];
|
||||
*channels = ptr[5];
|
||||
if ((ptr[6] | (ptr[7] << 8)) != 0 &&
|
||||
(ptr[6] | (ptr[7] << 8)) != 4) {
|
||||
/* only PCM please */
|
||||
return -1;
|
||||
}
|
||||
*datalen += blocklen-12;
|
||||
ptr += blocklen;
|
||||
break;
|
||||
case 9: /* sound data format 3 */
|
||||
*samplerate = *((long*)(ptr));
|
||||
*samplesize = ptr[4];
|
||||
*channels = ptr[5];
|
||||
if ((ptr[6] | (ptr[7] << 8)) != 0 &&
|
||||
(ptr[6] | (ptr[7] << 8)) != 4)
|
||||
{
|
||||
/* only PCM please */
|
||||
return -1;
|
||||
}
|
||||
*datalen += blocklen-12;
|
||||
ptr += blocklen;
|
||||
break;
|
||||
|
||||
default:
|
||||
ptr += blocklen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
ptr += blocklen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int FX_ReadVOCData(char *data, char *buf, int bufferlen, char eightbit)
|
||||
{
|
||||
short offset;
|
||||
char blocktype=0;
|
||||
int blocklen=0, br;
|
||||
short offset;
|
||||
char blocktype=0;
|
||||
int blocklen=0, br;
|
||||
|
||||
data += 0x14 + 2 + 4;
|
||||
data += 0x14 + 2 + 4;
|
||||
|
||||
while (bufferlen>0) {
|
||||
blocktype = *(data++);
|
||||
|
||||
if (blocktype == 0)
|
||||
break;
|
||||
while (bufferlen>0)
|
||||
{
|
||||
blocktype = *(data++);
|
||||
|
||||
blocklen = *(data++);
|
||||
blocklen |= *(data++) << 8;
|
||||
blocklen |= *(data++) << 16;
|
||||
if (blocktype == 0)
|
||||
break;
|
||||
|
||||
switch (blocktype) {
|
||||
case 1: /* sound data */
|
||||
data += 2;
|
||||
blocklen = *(data++);
|
||||
blocklen |= *(data++) << 8;
|
||||
blocklen |= *(data++) << 16;
|
||||
|
||||
br = min(blocklen-2, bufferlen);
|
||||
goto convertdata;
|
||||
switch (blocktype)
|
||||
{
|
||||
case 1: /* sound data */
|
||||
data += 2;
|
||||
|
||||
case 2: /* sound continue */
|
||||
br = min(blocklen, bufferlen);
|
||||
goto convertdata;
|
||||
br = min(blocklen-2, bufferlen);
|
||||
goto convertdata;
|
||||
|
||||
case 9: /* sound data format 3 */
|
||||
data += 12;
|
||||
case 2: /* sound continue */
|
||||
br = min(blocklen, bufferlen);
|
||||
goto convertdata;
|
||||
|
||||
br = min(blocklen-12, bufferlen);
|
||||
goto convertdata;
|
||||
case 9: /* sound data format 3 */
|
||||
data += 12;
|
||||
|
||||
default:
|
||||
data += blocklen;
|
||||
continue;
|
||||
}
|
||||
br = min(blocklen-12, bufferlen);
|
||||
goto convertdata;
|
||||
|
||||
default:
|
||||
data += blocklen;
|
||||
continue;
|
||||
}
|
||||
convertdata:
|
||||
bufferlen -= br;
|
||||
if (eightbit) {
|
||||
// FMOD wants signed data
|
||||
for (; br>0; br--)
|
||||
*(buf++) = (char)((short)(*(data++)) - 0x80);
|
||||
} else {
|
||||
memcpy(buf,data,br);
|
||||
buf += br;
|
||||
data += br;
|
||||
}
|
||||
}
|
||||
bufferlen -= br;
|
||||
if (eightbit)
|
||||
{
|
||||
// FMOD wants signed data
|
||||
for (; br>0; br--)
|
||||
*(buf++) = (char)((short)(*(data++)) - 0x80);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(buf,data,br);
|
||||
buf += br;
|
||||
data += br;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int FX_SimulateCallbacks(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!FX_CallBackFunc || !chstates) return 0;
|
||||
int i;
|
||||
|
||||
chstatesa = chstates + (FX_NumVoices * chtoggle);
|
||||
chstatesb = chstates + (FX_NumVoices * (chtoggle^1));
|
||||
if (!FX_CallBackFunc || !chstates) return 0;
|
||||
|
||||
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
|
||||
chstatesa = chstates + (FX_NumVoices * chtoggle);
|
||||
chstatesb = chstates + (FX_NumVoices * (chtoggle^1));
|
||||
|
||||
// channel has ended playing
|
||||
FX_CallBackFunc(chcallvals[i]);
|
||||
dprintOSD("FX_SimulateCallbacks(): channel %d ended sound %d\n",i,chcallvals[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
|
||||
|
||||
chtoggle ^= 1;
|
||||
// channel has ended playing
|
||||
FX_CallBackFunc(chcallvals[i]);
|
||||
dprintOSD("FX_SimulateCallbacks(): channel %d ended sound %d\n",i,chcallvals[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
chtoggle ^= 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,37 +45,37 @@ int FX_ErrorCode = FX_Ok;
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
char *FX_ErrorString
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
|
||||
{
|
||||
char *ErrorString;
|
||||
{
|
||||
char *ErrorString;
|
||||
|
||||
switch( ErrorNumber )
|
||||
{
|
||||
case FX_Warning :
|
||||
case FX_Error :
|
||||
ErrorString = FX_ErrorString( FX_ErrorCode );
|
||||
break;
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case FX_Warning :
|
||||
case FX_Error :
|
||||
ErrorString = FX_ErrorString(FX_ErrorCode);
|
||||
break;
|
||||
|
||||
case FX_Ok :
|
||||
ErrorString = "Fx ok.";
|
||||
break;
|
||||
case FX_Ok :
|
||||
ErrorString = "Fx ok.";
|
||||
break;
|
||||
|
||||
case FX_ASSVersion :
|
||||
ErrorString = "Apogee Sound System Version 0 "
|
||||
"Programmed by Jim Dose\n"
|
||||
"(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
|
||||
break;
|
||||
case FX_ASSVersion :
|
||||
ErrorString = "Apogee Sound System Version 0 "
|
||||
"Programmed by Jim Dose\n"
|
||||
"(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
|
||||
break;
|
||||
|
||||
default :
|
||||
ErrorString = "Unknown Fx error code.";
|
||||
break;
|
||||
}
|
||||
default :
|
||||
ErrorString = "Unknown Fx error code.";
|
||||
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
|
||||
)
|
||||
(
|
||||
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
|
||||
)
|
||||
(
|
||||
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
|
||||
)
|
||||
(
|
||||
int volume
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -152,12 +151,11 @@ void FX_SetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverseStereo
|
||||
(
|
||||
int setting
|
||||
)
|
||||
(
|
||||
int setting
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -167,13 +165,13 @@ void FX_SetReverseStereo
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_GetReverseStereo
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -183,12 +181,11 @@ int FX_GetReverseStereo
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverb
|
||||
(
|
||||
int reverb
|
||||
)
|
||||
(
|
||||
int reverb
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -198,12 +195,11 @@ void FX_SetReverb
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void FX_SetReverbDelay
|
||||
(
|
||||
int delay
|
||||
)
|
||||
(
|
||||
int delay
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -213,13 +209,13 @@ void FX_SetReverbDelay
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_VoiceAvailable
|
||||
(
|
||||
int priority
|
||||
)
|
||||
(
|
||||
int priority
|
||||
)
|
||||
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -229,21 +225,21 @@ int FX_VoiceAvailable
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayLoopedVOC
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -253,21 +249,21 @@ int FX_PlayLoopedVOC
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_PlayLoopedWAV
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
int right,
|
||||
int priority,
|
||||
unsigned long callbackval
|
||||
)
|
||||
(
|
||||
char *ptr,
|
||||
long loopstart,
|
||||
long loopend,
|
||||
int pitchoffset,
|
||||
int vol,
|
||||
int left,
|
||||
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
|
||||
)
|
||||
(
|
||||
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
|
||||
)
|
||||
(
|
||||
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
|
||||
)
|
||||
(
|
||||
int handle,
|
||||
int angle,
|
||||
int distance
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -340,13 +336,13 @@ int FX_Pan3D
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_StopSound
|
||||
(
|
||||
int handle
|
||||
)
|
||||
(
|
||||
int handle
|
||||
)
|
||||
|
||||
{
|
||||
return( FX_Ok );
|
||||
}
|
||||
{
|
||||
return(FX_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -356,13 +352,13 @@ int FX_StopSound
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int FX_StopAllSounds
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return( FX_Ok );
|
||||
}
|
||||
{
|
||||
return(FX_Ok);
|
||||
}
|
||||
|
||||
|
||||
void AudioUpdate(void) { }
|
||||
|
|
|
@ -41,60 +41,60 @@ int MUSIC_ErrorCode = MUSIC_Ok;
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
char *MUSIC_ErrorString
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
|
||||
{
|
||||
char *ErrorString;
|
||||
{
|
||||
char *ErrorString;
|
||||
|
||||
switch( ErrorNumber )
|
||||
{
|
||||
case MUSIC_Warning :
|
||||
case MUSIC_Error :
|
||||
ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode );
|
||||
break;
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case MUSIC_Warning :
|
||||
case MUSIC_Error :
|
||||
ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode);
|
||||
break;
|
||||
|
||||
case MUSIC_Ok :
|
||||
ErrorString = "Music ok.";
|
||||
break;
|
||||
case MUSIC_Ok :
|
||||
ErrorString = "Music ok.";
|
||||
break;
|
||||
|
||||
case MUSIC_ASSVersion :
|
||||
ErrorString = "Apogee Sound System Version "
|
||||
"Programmed by Jim Dose\n"
|
||||
"(c) Copyright 1996 James R. Dose. All Rights Reserved.\n";
|
||||
break;
|
||||
case MUSIC_ASSVersion :
|
||||
ErrorString = "Apogee Sound System Version "
|
||||
"Programmed by Jim Dose\n"
|
||||
"(c) Copyright 1996 James R. Dose. All Rights Reserved.\n";
|
||||
break;
|
||||
|
||||
case MUSIC_SoundCardError :
|
||||
break;
|
||||
case MUSIC_SoundCardError :
|
||||
break;
|
||||
|
||||
case MUSIC_MPU401Error :
|
||||
ErrorString = "Could not detect MPU-401.";
|
||||
break;
|
||||
case MUSIC_MPU401Error :
|
||||
ErrorString = "Could not detect MPU-401.";
|
||||
break;
|
||||
|
||||
case MUSIC_InvalidCard :
|
||||
ErrorString = "Invalid Music device.";
|
||||
break;
|
||||
case MUSIC_InvalidCard :
|
||||
ErrorString = "Invalid Music device.";
|
||||
break;
|
||||
|
||||
case MUSIC_MidiError :
|
||||
ErrorString = "Error playing MIDI file.";
|
||||
break;
|
||||
case MUSIC_MidiError :
|
||||
ErrorString = "Error playing MIDI file.";
|
||||
break;
|
||||
|
||||
case MUSIC_TaskManError :
|
||||
ErrorString = "TaskMan error.";
|
||||
break;
|
||||
case MUSIC_TaskManError :
|
||||
ErrorString = "TaskMan error.";
|
||||
break;
|
||||
|
||||
case MUSIC_DPMI_Error :
|
||||
ErrorString = "DPMI Error in MUSIC.";
|
||||
break;
|
||||
case MUSIC_DPMI_Error :
|
||||
ErrorString = "DPMI Error in MUSIC.";
|
||||
break;
|
||||
|
||||
default :
|
||||
ErrorString = "Unknown Music error code.";
|
||||
break;
|
||||
}
|
||||
default :
|
||||
ErrorString = "Unknown Music error code.";
|
||||
break;
|
||||
}
|
||||
|
||||
return( ErrorString );
|
||||
}
|
||||
return(ErrorString);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -104,19 +104,19 @@ char *MUSIC_ErrorString
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_Init
|
||||
(
|
||||
int SoundCard,
|
||||
int Address
|
||||
)
|
||||
(
|
||||
int SoundCard,
|
||||
int Address
|
||||
)
|
||||
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
|
||||
status = MUSIC_Ok;
|
||||
status = MUSIC_Ok;
|
||||
|
||||
return( status );
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -126,18 +126,18 @@ int MUSIC_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_Shutdown
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
int status;
|
||||
{
|
||||
int status;
|
||||
|
||||
status = MUSIC_Ok;
|
||||
status = MUSIC_Ok;
|
||||
|
||||
|
||||
return( status );
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -147,12 +147,11 @@ int MUSIC_Shutdown
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetMaxFMMidiChannel
|
||||
(
|
||||
int channel
|
||||
)
|
||||
(
|
||||
int channel
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -162,12 +161,11 @@ void MUSIC_SetMaxFMMidiChannel
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetVolume
|
||||
(
|
||||
int volume
|
||||
)
|
||||
(
|
||||
int volume
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -177,13 +175,12 @@ void MUSIC_SetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetMidiChannelVolume
|
||||
(
|
||||
int channel,
|
||||
int volume
|
||||
)
|
||||
(
|
||||
int channel,
|
||||
int volume
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -193,12 +190,11 @@ void MUSIC_SetMidiChannelVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_ResetMidiChannelVolumes
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -208,13 +204,13 @@ void MUSIC_ResetMidiChannelVolumes
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_GetVolume
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -225,12 +221,11 @@ int MUSIC_GetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetLoopFlag
|
||||
(
|
||||
int loopflag
|
||||
)
|
||||
(
|
||||
int loopflag
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -240,13 +235,13 @@ void MUSIC_SetLoopFlag
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_SongPlaying
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -256,12 +251,11 @@ int MUSIC_SongPlaying
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_Continue
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -271,12 +265,11 @@ void MUSIC_Continue
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_Pause
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -286,13 +279,13 @@ void MUSIC_Pause
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_StopSong
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
{
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -302,14 +295,14 @@ int MUSIC_StopSong
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_PlaySong
|
||||
(
|
||||
unsigned char *song,
|
||||
int loopflag
|
||||
)
|
||||
(
|
||||
unsigned char *song,
|
||||
int loopflag
|
||||
)
|
||||
|
||||
{
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
{
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -319,12 +312,11 @@ int MUSIC_PlaySong
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetContext
|
||||
(
|
||||
int context
|
||||
)
|
||||
(
|
||||
int context
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -334,12 +326,11 @@ void MUSIC_SetContext
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_GetContext
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -349,12 +340,11 @@ int MUSIC_GetContext
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongTick
|
||||
(
|
||||
unsigned long PositionInTicks
|
||||
)
|
||||
(
|
||||
unsigned long PositionInTicks
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -364,12 +354,11 @@ void MUSIC_SetSongTick
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongTime
|
||||
(
|
||||
unsigned long milliseconds
|
||||
)
|
||||
(
|
||||
unsigned long milliseconds
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -379,14 +368,13 @@ void MUSIC_SetSongTime
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongPosition
|
||||
(
|
||||
int measure,
|
||||
int beat,
|
||||
int tick
|
||||
)
|
||||
(
|
||||
int measure,
|
||||
int beat,
|
||||
int tick
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -396,12 +384,11 @@ void MUSIC_SetSongPosition
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_GetSongPosition
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -411,12 +398,11 @@ void MUSIC_GetSongPosition
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_GetSongLength
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
@ -431,14 +417,14 @@ void MUSIC_GetSongLength
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_FadeVolume
|
||||
(
|
||||
int tovolume,
|
||||
int milliseconds
|
||||
)
|
||||
(
|
||||
int tovolume,
|
||||
int milliseconds
|
||||
)
|
||||
|
||||
{
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
{
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -448,13 +434,13 @@ int MUSIC_FadeVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_FadeActive
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -464,12 +450,11 @@ int MUSIC_FadeActive
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_StopFade
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -480,13 +465,12 @@ void MUSIC_StopFade
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_RerouteMidiChannel
|
||||
(
|
||||
int channel,
|
||||
int ( *function )( int event, int c1, int c2 )
|
||||
)
|
||||
(
|
||||
int channel,
|
||||
int(*function)(int event, int c1, int c2)
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -496,15 +480,13 @@ void MUSIC_RerouteMidiChannel
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_RegisterTimbreBank
|
||||
(
|
||||
unsigned char *timbres
|
||||
)
|
||||
(
|
||||
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;
|
||||
|
@ -78,11 +78,11 @@ int DSOUND_ErrorCode = DSOUND_Ok;
|
|||
*/
|
||||
int DisableInterrupts(void)
|
||||
{
|
||||
if (!_DSOUND_CriticalSectionAlloced) return -1;
|
||||
if (!_DSOUND_CriticalSectionAlloced) return -1;
|
||||
|
||||
EnterCriticalSection(&mutex);
|
||||
EnterCriticalSection(&mutex);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,12 +92,12 @@ int DisableInterrupts(void)
|
|||
*/
|
||||
int RestoreInterrupts(int a)
|
||||
{
|
||||
if (!_DSOUND_CriticalSectionAlloced) return -1;
|
||||
if (!_DSOUND_CriticalSectionAlloced) return -1;
|
||||
|
||||
LeaveCriticalSection(&mutex);
|
||||
LeaveCriticalSection(&mutex);
|
||||
|
||||
return 0;
|
||||
a=a;
|
||||
return 0;
|
||||
a=a;
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,59 +107,60 @@ int RestoreInterrupts(int a)
|
|||
*/
|
||||
char *DSOUND_ErrorString(int errorcode)
|
||||
{
|
||||
switch (errorcode) {
|
||||
case DSOUND_Warning:
|
||||
case DSOUND_Error:
|
||||
return DSOUND_ErrorString(DSOUND_ErrorCode);
|
||||
switch (errorcode)
|
||||
{
|
||||
case DSOUND_Warning:
|
||||
case DSOUND_Error:
|
||||
return DSOUND_ErrorString(DSOUND_ErrorCode);
|
||||
|
||||
case DSOUND_Ok:
|
||||
return "DirectSound ok.";
|
||||
case DSOUND_Ok:
|
||||
return "DirectSound ok.";
|
||||
|
||||
case DSOUND_NoDLL:
|
||||
return "Failed loading DSOUND.DLL.";
|
||||
case DSOUND_NoDLL:
|
||||
return "Failed loading DSOUND.DLL.";
|
||||
|
||||
case DSOUND_NoDirectSoundCreate:
|
||||
return "Failed getting DirectSoundCreate entry point.";
|
||||
case DSOUND_NoDirectSoundCreate:
|
||||
return "Failed getting DirectSoundCreate entry point.";
|
||||
|
||||
case DSOUND_FailedDSC:
|
||||
return "DirectSoundCreate failed.";
|
||||
case DSOUND_FailedDSC:
|
||||
return "DirectSoundCreate failed.";
|
||||
|
||||
case DSOUND_FailedSetCoopLevel:
|
||||
return "Failed setting cooperative level.";
|
||||
case DSOUND_FailedSetCoopLevel:
|
||||
return "Failed setting cooperative level.";
|
||||
|
||||
case DSOUND_FailedCreatePrimary:
|
||||
return "Failed creating primary buffer.";
|
||||
case DSOUND_FailedCreatePrimary:
|
||||
return "Failed creating primary buffer.";
|
||||
|
||||
case DSOUND_FailedSetFormat:
|
||||
return "Failed setting primary buffer format.";
|
||||
case DSOUND_FailedSetFormat:
|
||||
return "Failed setting primary buffer format.";
|
||||
|
||||
case DSOUND_FailedCreateSecondary:
|
||||
return "Failed creating secondary buffer.";
|
||||
case DSOUND_FailedCreateSecondary:
|
||||
return "Failed creating secondary buffer.";
|
||||
|
||||
case DSOUND_FailedCreateNotifyEvent:
|
||||
return "Failed creating notification event object.";
|
||||
case DSOUND_FailedCreateNotifyEvent:
|
||||
return "Failed creating notification event object.";
|
||||
|
||||
case DSOUND_FailedQueryNotify:
|
||||
return "Failed querying notification interface.";
|
||||
case DSOUND_FailedQueryNotify:
|
||||
return "Failed querying notification interface.";
|
||||
|
||||
case DSOUND_FailedSetNotify:
|
||||
return "Failed setting notification positions.";
|
||||
case DSOUND_FailedSetNotify:
|
||||
return "Failed setting notification positions.";
|
||||
|
||||
case DSOUND_FailedCreateFinishEvent:
|
||||
return "Failed creating finish event object.";
|
||||
case DSOUND_FailedCreateFinishEvent:
|
||||
return "Failed creating finish event object.";
|
||||
|
||||
case DSOUND_FailedCreateThread:
|
||||
return "Failed creating playback thread.";
|
||||
case DSOUND_FailedCreateThread:
|
||||
return "Failed creating playback thread.";
|
||||
|
||||
case DSOUND_FailedPlaySecondary:
|
||||
return "Failed playing secondary buffer.";
|
||||
case DSOUND_FailedPlaySecondary:
|
||||
return "Failed playing secondary buffer.";
|
||||
|
||||
case DSOUND_FailedGetExitCode:
|
||||
return "GetExitCodeThread failed.";
|
||||
case DSOUND_FailedGetExitCode:
|
||||
return "GetExitCodeThread failed.";
|
||||
|
||||
default:
|
||||
return "Unknown DirectSound error code.";
|
||||
}
|
||||
default:
|
||||
return "Unknown DirectSound error code.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,135 +170,148 @@ 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 hr;
|
||||
DSBUFFERDESC dsbuf;
|
||||
WAVEFORMATEX wfex;
|
||||
DSBPOSITIONNOTIFY posn;
|
||||
|
||||
if (DSOUND_Installed) {
|
||||
DSOUND_Shutdown();
|
||||
}
|
||||
HRESULT(WINAPI *aDirectSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN);
|
||||
HRESULT hr;
|
||||
DSBUFFERDESC dsbuf;
|
||||
WAVEFORMATEX wfex;
|
||||
DSBPOSITIONNOTIFY posn;
|
||||
|
||||
printOSD("Initializing DirectSound...\n");
|
||||
|
||||
if (!_DSOUND_CriticalSectionAlloced) {
|
||||
// initialize the critical section object we'll use to
|
||||
// simulate (dis|en)abling interrupts
|
||||
InitializeCriticalSection(&mutex);
|
||||
_DSOUND_CriticalSectionAlloced = TRUE;
|
||||
}
|
||||
if (DSOUND_Installed)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
}
|
||||
|
||||
printOSD(" - Loading DSOUND.DLL\n");
|
||||
hDSoundDLL = LoadLibrary("DSOUND.DLL");
|
||||
if (!hDSoundDLL) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_NoDLL);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
printOSD("Initializing DirectSound...\n");
|
||||
|
||||
aDirectSoundCreate = (void *)GetProcAddress(hDSoundDLL, "DirectSoundCreate");
|
||||
if (!aDirectSoundCreate) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_NoDirectSoundCreate);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
if (!_DSOUND_CriticalSectionAlloced)
|
||||
{
|
||||
// initialize the critical section object we'll use to
|
||||
// simulate (dis|en)abling interrupts
|
||||
InitializeCriticalSection(&mutex);
|
||||
_DSOUND_CriticalSectionAlloced = TRUE;
|
||||
}
|
||||
|
||||
printOSD(" - Creating DirectSound object\n");
|
||||
hr = aDirectSoundCreate(NULL, &lpDS, NULL);
|
||||
if (hr != DS_OK) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedDSC);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
printOSD(" - Loading DSOUND.DLL\n");
|
||||
hDSoundDLL = LoadLibrary("DSOUND.DLL");
|
||||
if (!hDSoundDLL)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_NoDLL);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hr = IDirectSound_SetCooperativeLevel(lpDS, (HWND)win_gethwnd(), DSSCL_EXCLUSIVE);
|
||||
if (hr != DS_OK) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetCoopLevel);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
aDirectSoundCreate = (void *)GetProcAddress(hDSoundDLL, "DirectSoundCreate");
|
||||
if (!aDirectSoundCreate)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_NoDirectSoundCreate);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
printOSD(" - Creating primary buffer\n");
|
||||
ZeroMemory(&dsbuf, sizeof(dsbuf));
|
||||
dsbuf.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||
hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBPrimary, NULL);
|
||||
if (hr != DS_OK) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreatePrimary);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
printOSD(" - Creating DirectSound object\n");
|
||||
hr = aDirectSoundCreate(NULL, &lpDS, NULL);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedDSC);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
printOSD(" - Setting primary buffer format\n"
|
||||
" Channels: %d\n"
|
||||
" Sample rate: %dHz\n"
|
||||
" Sample size: %d bits\n",
|
||||
numchannels, mixrate, samplebits);
|
||||
ZeroMemory(&wfex, sizeof(wfex));
|
||||
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfex.nChannels = numchannels;
|
||||
wfex.nSamplesPerSec = mixrate;
|
||||
wfex.wBitsPerSample = samplebits;
|
||||
wfex.nBlockAlign = (wfex.wBitsPerSample / 8) * wfex.nChannels;
|
||||
wfex.nAvgBytesPerSec = wfex.nBlockAlign * wfex.nSamplesPerSec;
|
||||
hr = IDirectSoundBuffer_SetFormat(lpDSBPrimary, &wfex);
|
||||
if (hr != DS_OK) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetFormat);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
hr = IDirectSound_SetCooperativeLevel(lpDS, (HWND)win_gethwnd(), DSSCL_EXCLUSIVE);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetCoopLevel);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
printOSD(" - Creating secondary buffer\n");
|
||||
ZeroMemory(&dsbuf, sizeof(dsbuf));
|
||||
dsbuf.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbuf.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_LOCSOFTWARE;
|
||||
dsbuf.dwBufferBytes = buffersize;
|
||||
dsbuf.lpwfxFormat = &wfex;
|
||||
hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBSecondary, NULL);
|
||||
if (hr != DS_OK) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateSecondary);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
printOSD(" - Creating primary buffer\n");
|
||||
ZeroMemory(&dsbuf, sizeof(dsbuf));
|
||||
dsbuf.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||
hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBPrimary, NULL);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreatePrimary);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hr = IDirectSoundBuffer_QueryInterface(lpDSBSecondary, &IID_IDirectSoundNotify, &lpDSNotify);
|
||||
if (hr != DS_OK) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedQueryNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
printOSD(" - Setting primary buffer format\n"
|
||||
" Channels: %d\n"
|
||||
" Sample rate: %dHz\n"
|
||||
" Sample size: %d bits\n",
|
||||
numchannels, mixrate, samplebits);
|
||||
ZeroMemory(&wfex, sizeof(wfex));
|
||||
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfex.nChannels = numchannels;
|
||||
wfex.nSamplesPerSec = mixrate;
|
||||
wfex.wBitsPerSample = samplebits;
|
||||
wfex.nBlockAlign = (wfex.wBitsPerSample / 8) * wfex.nChannels;
|
||||
wfex.nAvgBytesPerSec = wfex.nBlockAlign * wfex.nSamplesPerSec;
|
||||
hr = IDirectSoundBuffer_SetFormat(lpDSBPrimary, &wfex);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetFormat);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hPosNotify = (HANDLE *)malloc(sizeof(HANDLE));
|
||||
if (!hPosNotify) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hPosNotify[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!hPosNotify) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateNotifyEvent);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
printOSD(" - Creating secondary buffer\n");
|
||||
ZeroMemory(&dsbuf, sizeof(dsbuf));
|
||||
dsbuf.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbuf.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_LOCSOFTWARE;
|
||||
dsbuf.dwBufferBytes = buffersize;
|
||||
dsbuf.lpwfxFormat = &wfex;
|
||||
hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBSecondary, NULL);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateSecondary);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
_DSOUND_BufferLength = 0;
|
||||
_DSOUND_NumBuffers = 1;
|
||||
posn.dwOffset = 0;
|
||||
posn.hEventNotify = hPosNotify[0];
|
||||
hr = IDirectSoundBuffer_QueryInterface(lpDSBSecondary, &IID_IDirectSoundNotify, &lpDSNotify);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedQueryNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, 1, &posn);
|
||||
if (hr != DS_OK) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
hPosNotify = (HANDLE *)malloc(sizeof(HANDLE));
|
||||
if (!hPosNotify)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
DSOUND_Installed = TRUE;
|
||||
|
||||
DSOUND_SetErrorCode(DSOUND_Ok);
|
||||
return DSOUND_Ok;
|
||||
hPosNotify[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!hPosNotify)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateNotifyEvent);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
_DSOUND_BufferLength = 0;
|
||||
_DSOUND_NumBuffers = 1;
|
||||
posn.dwOffset = 0;
|
||||
posn.hEventNotify = hPosNotify[0];
|
||||
|
||||
hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, 1, &posn);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
DSOUND_Installed = TRUE;
|
||||
|
||||
DSOUND_SetErrorCode(DSOUND_Ok);
|
||||
return DSOUND_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -307,54 +321,61 @@ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int
|
|||
*/
|
||||
int DSOUND_Shutdown(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (DSOUND_Installed) printOSD("Uninitializing DirectSound...\n");
|
||||
if (DSOUND_Installed) printOSD("Uninitializing DirectSound...\n");
|
||||
|
||||
DSOUND_Installed = FALSE;
|
||||
DSOUND_Installed = FALSE;
|
||||
|
||||
DSOUND_StopPlayback();
|
||||
DSOUND_StopPlayback();
|
||||
|
||||
if (lpDSNotify) {
|
||||
IDirectSoundNotify_Release(lpDSNotify);
|
||||
lpDSNotify = NULL;
|
||||
}
|
||||
if (lpDSNotify)
|
||||
{
|
||||
IDirectSoundNotify_Release(lpDSNotify);
|
||||
lpDSNotify = NULL;
|
||||
}
|
||||
|
||||
if (hPosNotify) {
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++) {
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
hPosNotify = NULL;
|
||||
}
|
||||
if (hPosNotify)
|
||||
{
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++)
|
||||
{
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
hPosNotify = NULL;
|
||||
}
|
||||
|
||||
if (lpDSBSecondary) {
|
||||
printOSD(" - Releasing secondary buffer\n");
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
IDirectSoundBuffer_Release(lpDSBSecondary);
|
||||
lpDSBSecondary = NULL;
|
||||
}
|
||||
if (lpDSBSecondary)
|
||||
{
|
||||
printOSD(" - Releasing secondary buffer\n");
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
IDirectSoundBuffer_Release(lpDSBSecondary);
|
||||
lpDSBSecondary = NULL;
|
||||
}
|
||||
|
||||
if (lpDSBPrimary) {
|
||||
printOSD(" - Releasing primary buffer\n");
|
||||
IDirectSoundBuffer_Release(lpDSBPrimary);
|
||||
lpDSBPrimary = NULL;
|
||||
}
|
||||
if (lpDSBPrimary)
|
||||
{
|
||||
printOSD(" - Releasing primary buffer\n");
|
||||
IDirectSoundBuffer_Release(lpDSBPrimary);
|
||||
lpDSBPrimary = NULL;
|
||||
}
|
||||
|
||||
if (lpDS) {
|
||||
printOSD(" - Releasing DirectSound object\n");
|
||||
IDirectSound_Release(lpDS);
|
||||
lpDS = NULL;
|
||||
}
|
||||
if (lpDS)
|
||||
{
|
||||
printOSD(" - Releasing DirectSound object\n");
|
||||
IDirectSound_Release(lpDS);
|
||||
lpDS = NULL;
|
||||
}
|
||||
|
||||
if (hDSoundDLL) {
|
||||
printOSD(" - Unloading DSOUND.DLL\n");
|
||||
FreeLibrary(hDSoundDLL);
|
||||
hDSoundDLL = NULL;
|
||||
}
|
||||
|
||||
DSOUND_SetErrorCode(DSOUND_Ok);
|
||||
return DSOUND_Ok;
|
||||
if (hDSoundDLL)
|
||||
{
|
||||
printOSD(" - Unloading DSOUND.DLL\n");
|
||||
FreeLibrary(hDSoundDLL);
|
||||
hDSoundDLL = NULL;
|
||||
}
|
||||
|
||||
DSOUND_SetErrorCode(DSOUND_Ok);
|
||||
return DSOUND_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -364,7 +385,7 @@ int DSOUND_Shutdown(void)
|
|||
*/
|
||||
int DSOUND_SetMixMode(int mode)
|
||||
{
|
||||
return mode;
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
|
@ -375,73 +396,78 @@ int DSOUND_SetMixMode(int mode)
|
|||
#endif
|
||||
static DWORD WINAPI isr(LPVOID parm)
|
||||
{
|
||||
HANDLE *handles;
|
||||
HRESULT hr;
|
||||
DWORD rv;
|
||||
HANDLE *handles;
|
||||
HRESULT hr;
|
||||
DWORD rv;
|
||||
#ifdef DEBUGAUDIO
|
||||
int h;
|
||||
int h;
|
||||
#endif
|
||||
int p;
|
||||
LPVOID lockptr; DWORD lockbytes;
|
||||
LPVOID lockptr2; DWORD lockbytes2;
|
||||
int p;
|
||||
LPVOID lockptr; DWORD lockbytes;
|
||||
LPVOID lockptr2; DWORD lockbytes2;
|
||||
|
||||
handles = (HANDLE *)malloc(sizeof(HANDLE)*(1+_DSOUND_NumBuffers));
|
||||
if (!handles) return 1;
|
||||
|
||||
handles[0] = isrfinish;
|
||||
for (p=0; p<_DSOUND_NumBuffers; p++)
|
||||
handles[p+1] = hPosNotify[p];
|
||||
handles = (HANDLE *)malloc(sizeof(HANDLE)*(1+_DSOUND_NumBuffers));
|
||||
if (!handles) return 1;
|
||||
|
||||
handles[0] = isrfinish;
|
||||
for (p=0; p<_DSOUND_NumBuffers; p++)
|
||||
handles[p+1] = hPosNotify[p];
|
||||
|
||||
#ifdef DEBUGAUDIO
|
||||
h = creat("audio.raw",S_IREAD|S_IWRITE);
|
||||
h = creat("audio.raw",S_IREAD|S_IWRITE);
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
rv = WaitForMultipleObjects(1+_DSOUND_NumBuffers, handles, FALSE, INFINITE);
|
||||
|
||||
if (!(rv >= WAIT_OBJECT_0 && rv <= WAIT_OBJECT_0+1+_DSOUND_NumBuffers)) return -1;
|
||||
while (1)
|
||||
{
|
||||
rv = WaitForMultipleObjects(1+_DSOUND_NumBuffers, handles, FALSE, INFINITE);
|
||||
|
||||
if (rv == WAIT_OBJECT_0) {
|
||||
// we've been asked to finish up
|
||||
break;
|
||||
}
|
||||
if (!(rv >= WAIT_OBJECT_0 && rv <= WAIT_OBJECT_0+1+_DSOUND_NumBuffers)) return -1;
|
||||
|
||||
// otherwise we just service the interrupt
|
||||
if (_DSOUND_CallBack) {
|
||||
DisableInterrupts();
|
||||
if (rv == WAIT_OBJECT_0)
|
||||
{
|
||||
// we've been asked to finish up
|
||||
break;
|
||||
}
|
||||
|
||||
p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1);
|
||||
// otherwise we just service the interrupt
|
||||
if (_DSOUND_CallBack)
|
||||
{
|
||||
DisableInterrupts();
|
||||
|
||||
p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1);
|
||||
#ifdef DEBUGAUDIO
|
||||
write(h, _DSOUND_MixBuffer + p*_DSOUND_BufferLength, _DSOUND_BufferLength);
|
||||
write(h, _DSOUND_MixBuffer + p*_DSOUND_BufferLength, _DSOUND_BufferLength);
|
||||
#endif
|
||||
|
||||
hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength,
|
||||
&lockptr, &lockbytes, &lockptr2, &lockbytes2, 0);
|
||||
if (hr == DSERR_BUFFERLOST) {
|
||||
hr = IDirectSoundBuffer_Restore(lpDSBSecondary);
|
||||
}
|
||||
if (hr == DS_OK) {
|
||||
/*
|
||||
#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);
|
||||
}
|
||||
hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength,
|
||||
&lockptr, &lockbytes, &lockptr2, &lockbytes2, 0);
|
||||
if (hr == DSERR_BUFFERLOST)
|
||||
{
|
||||
hr = IDirectSoundBuffer_Restore(lpDSBSecondary);
|
||||
}
|
||||
if (hr == DS_OK)
|
||||
{
|
||||
/*
|
||||
#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);
|
||||
}
|
||||
|
||||
RestoreInterrupts(0);
|
||||
}
|
||||
}
|
||||
RestoreInterrupts(0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUGAUDIO
|
||||
close(h);
|
||||
close(h);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -449,85 +475,95 @@ 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;
|
||||
DSBPOSITIONNOTIFY *posns;
|
||||
int i;
|
||||
|
||||
_DSOUND_CallBack = CallBackFunc;
|
||||
_DSOUND_MixBuffer = BufferStart;
|
||||
DWORD threadid;
|
||||
HRESULT hr;
|
||||
DSBPOSITIONNOTIFY *posns;
|
||||
int i;
|
||||
|
||||
if (!lpDSBSecondary) return DSOUND_Error;
|
||||
_DSOUND_CallBack = CallBackFunc;
|
||||
_DSOUND_MixBuffer = BufferStart;
|
||||
|
||||
if (isrthread) {
|
||||
DSOUND_StopPlayback();
|
||||
}
|
||||
|
||||
isrfinish = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (!isrfinish) {
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateFinishEvent);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
isrthread = CreateThread(NULL, 0, isr, NULL, CREATE_SUSPENDED, &threadid);
|
||||
if (!isrthread) {
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateThread);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
if (!lpDSBSecondary) return DSOUND_Error;
|
||||
|
||||
hPosNotify = (HANDLE *)malloc(sizeof(HANDLE)*numdivisions);
|
||||
if (!hPosNotify) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
memset(hPosNotify, 0, sizeof(HANDLE)*numdivisions);
|
||||
for (i=0; i<numdivisions; i++) {
|
||||
hPosNotify[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!hPosNotify[i]) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
}
|
||||
if (isrthread)
|
||||
{
|
||||
DSOUND_StopPlayback();
|
||||
}
|
||||
|
||||
posns = (LPDSBPOSITIONNOTIFY)malloc(sizeof(DSBPOSITIONNOTIFY)*numdivisions);
|
||||
if (!posns) {
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
isrfinish = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (!isrfinish)
|
||||
{
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateFinishEvent);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
_DSOUND_BufferLength = buffersize/numdivisions;
|
||||
_DSOUND_NumBuffers = numdivisions;
|
||||
for (i=0; i<numdivisions; i++) {
|
||||
posns[i].dwOffset = i*_DSOUND_BufferLength;
|
||||
posns[i].hEventNotify = hPosNotify[i];
|
||||
}
|
||||
isrthread = CreateThread(NULL, 0, isr, NULL, CREATE_SUSPENDED, &threadid);
|
||||
if (!isrthread)
|
||||
{
|
||||
DSOUND_SetErrorCode(DSOUND_FailedCreateThread);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, numdivisions, posns);
|
||||
if (hr != DS_OK) {
|
||||
free(posns);
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
hPosNotify = (HANDLE *)malloc(sizeof(HANDLE)*numdivisions);
|
||||
if (!hPosNotify)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
free(posns);
|
||||
memset(hPosNotify, 0, sizeof(HANDLE)*numdivisions);
|
||||
for (i=0; i<numdivisions; i++)
|
||||
{
|
||||
hPosNotify[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!hPosNotify[i])
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
}
|
||||
|
||||
SetThreadPriority(isrthread, THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
ResumeThread(isrthread);
|
||||
posns = (LPDSBPOSITIONNOTIFY)malloc(sizeof(DSBPOSITIONNOTIFY)*numdivisions);
|
||||
if (!posns)
|
||||
{
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
hr = IDirectSoundBuffer_Play(lpDSBSecondary, 0, 0, DSBPLAY_LOOPING);
|
||||
if (hr != DS_OK) {
|
||||
DSOUND_SetErrorCode(DSOUND_FailedPlaySecondary);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
_DSOUND_BufferLength = buffersize/numdivisions;
|
||||
_DSOUND_NumBuffers = numdivisions;
|
||||
for (i=0; i<numdivisions; i++)
|
||||
{
|
||||
posns[i].dwOffset = i*_DSOUND_BufferLength;
|
||||
posns[i].hEventNotify = hPosNotify[i];
|
||||
}
|
||||
|
||||
return DSOUND_Ok;
|
||||
hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, numdivisions, posns);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
free(posns);
|
||||
DSOUND_Shutdown();
|
||||
DSOUND_SetErrorCode(DSOUND_FailedSetNotify);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
free(posns);
|
||||
|
||||
SetThreadPriority(isrthread, THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
ResumeThread(isrthread);
|
||||
|
||||
hr = IDirectSoundBuffer_Play(lpDSBSecondary, 0, 0, DSBPLAY_LOOPING);
|
||||
if (hr != DS_OK)
|
||||
{
|
||||
DSOUND_SetErrorCode(DSOUND_FailedPlaySecondary);
|
||||
return DSOUND_Error;
|
||||
}
|
||||
|
||||
return DSOUND_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -538,48 +574,53 @@ int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), in
|
|||
int DSOUND_StopPlayback(void)
|
||||
{
|
||||
// DWORD exitcode;
|
||||
BOOL t;
|
||||
int i;
|
||||
|
||||
if (isrthread) {
|
||||
SetEvent(isrfinish);
|
||||
BOOL t;
|
||||
int i;
|
||||
|
||||
printOSD("DirectSound: Waiting for sound thread to exit\n");
|
||||
if (WaitForSingleObject(isrthread, 300) == WAIT_OBJECT_0)
|
||||
printOSD("DirectSound: Sound thread has exited\n");
|
||||
else
|
||||
printOSD("DirectSound: Sound thread failed to exit!\n");
|
||||
/*
|
||||
while (1) {
|
||||
if (!GetExitCodeThread(isrthread, &exitcode)) {
|
||||
DSOUND_SetErrorCode(DSOUND_FailedGetExitCode);
|
||||
return DSOUND_Warning;
|
||||
}
|
||||
if (exitcode != STILL_ACTIVE) break;
|
||||
}*/
|
||||
if (isrthread)
|
||||
{
|
||||
SetEvent(isrfinish);
|
||||
|
||||
CloseHandle(isrthread);
|
||||
isrthread = NULL;
|
||||
}
|
||||
printOSD("DirectSound: Waiting for sound thread to exit\n");
|
||||
if (WaitForSingleObject(isrthread, 300) == WAIT_OBJECT_0)
|
||||
printOSD("DirectSound: Sound thread has exited\n");
|
||||
else
|
||||
printOSD("DirectSound: Sound thread failed to exit!\n");
|
||||
/*
|
||||
while (1) {
|
||||
if (!GetExitCodeThread(isrthread, &exitcode)) {
|
||||
DSOUND_SetErrorCode(DSOUND_FailedGetExitCode);
|
||||
return DSOUND_Warning;
|
||||
}
|
||||
if (exitcode != STILL_ACTIVE) break;
|
||||
}*/
|
||||
|
||||
if (isrfinish) {
|
||||
CloseHandle(isrfinish);
|
||||
isrfinish = NULL;
|
||||
}
|
||||
CloseHandle(isrthread);
|
||||
isrthread = NULL;
|
||||
}
|
||||
|
||||
if (lpDSBSecondary) {
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
}
|
||||
|
||||
if (hPosNotify) {
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++) {
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
hPosNotify = NULL;
|
||||
}
|
||||
if (isrfinish)
|
||||
{
|
||||
CloseHandle(isrfinish);
|
||||
isrfinish = NULL;
|
||||
}
|
||||
|
||||
return DSOUND_Ok;
|
||||
if (lpDSBSecondary)
|
||||
{
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
}
|
||||
|
||||
if (hPosNotify)
|
||||
{
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++)
|
||||
{
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
hPosNotify = NULL;
|
||||
}
|
||||
|
||||
return DSOUND_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
|
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,60 +44,60 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
|
|||
|
||||
|
||||
void LL_AddNode
|
||||
(
|
||||
char *item,
|
||||
char **head,
|
||||
char **tail,
|
||||
int next,
|
||||
int prev
|
||||
)
|
||||
(
|
||||
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 )
|
||||
{
|
||||
OFFSET( *head, prev ) = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
*tail = item;
|
||||
}
|
||||
if (*head)
|
||||
{
|
||||
OFFSET(*head, prev) = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
*tail = item;
|
||||
}
|
||||
|
||||
*head = item;
|
||||
}
|
||||
*head = item;
|
||||
}
|
||||
|
||||
void LL_RemoveNode
|
||||
(
|
||||
char *item,
|
||||
char **head,
|
||||
char **tail,
|
||||
int next,
|
||||
int prev
|
||||
)
|
||||
(
|
||||
char *item,
|
||||
char **head,
|
||||
char **tail,
|
||||
int next,
|
||||
int prev
|
||||
)
|
||||
|
||||
{
|
||||
if ( OFFSET( item, prev ) == NULL )
|
||||
{
|
||||
*head = OFFSET( item, next );
|
||||
}
|
||||
else
|
||||
{
|
||||
OFFSET( OFFSET( item, prev ), next ) = OFFSET( item, next );
|
||||
}
|
||||
{
|
||||
if (OFFSET(item, prev) == NULL)
|
||||
{
|
||||
*head = OFFSET(item, next);
|
||||
}
|
||||
else
|
||||
{
|
||||
OFFSET(OFFSET(item, prev), next) = OFFSET(item, next);
|
||||
}
|
||||
|
||||
if ( OFFSET( item, next ) == NULL )
|
||||
{
|
||||
*tail = OFFSET( item, prev );
|
||||
}
|
||||
else
|
||||
{
|
||||
OFFSET( OFFSET( item, next ), prev ) = OFFSET( item, prev );
|
||||
}
|
||||
if (OFFSET(item, next) == NULL)
|
||||
{
|
||||
*tail = OFFSET(item, prev);
|
||||
}
|
||||
else
|
||||
{
|
||||
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 {
|
||||
long time;
|
||||
long stream;
|
||||
long event;
|
||||
} MIDIEVENTHEAD;
|
||||
typedef struct
|
||||
{
|
||||
long time;
|
||||
long stream;
|
||||
long event;
|
||||
}
|
||||
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,54 +81,57 @@ unsigned long _MPU_LastEvent=0;
|
|||
**********************************************************************/
|
||||
|
||||
|
||||
void MPU_FinishBuffer( int buffer )
|
||||
void MPU_FinishBuffer(int buffer)
|
||||
{
|
||||
if (!eventcnt[buffer]) return;
|
||||
ZeroMemory(&bufferheaders[buffer], sizeof(MIDIHDR));
|
||||
bufferheaders[buffer].lpData = eventbuf[buffer];
|
||||
bufferheaders[buffer].dwBufferLength =
|
||||
bufferheaders[buffer].dwBytesRecorded = eventcnt[buffer];
|
||||
midiOutPrepareHeader((HMIDIOUT)hmido, &bufferheaders[buffer], sizeof(MIDIHDR));
|
||||
midiStreamOut(hmido, &bufferheaders[buffer], sizeof(MIDIHDR));
|
||||
if (!eventcnt[buffer]) return;
|
||||
ZeroMemory(&bufferheaders[buffer], sizeof(MIDIHDR));
|
||||
bufferheaders[buffer].lpData = eventbuf[buffer];
|
||||
bufferheaders[buffer].dwBufferLength =
|
||||
bufferheaders[buffer].dwBytesRecorded = eventcnt[buffer];
|
||||
midiOutPrepareHeader((HMIDIOUT)hmido, &bufferheaders[buffer], sizeof(MIDIHDR));
|
||||
midiStreamOut(hmido, &bufferheaders[buffer], sizeof(MIDIHDR));
|
||||
// printf("Sending %d bytes (buffer %d)\n",eventcnt[buffer],buffer);
|
||||
_MPU_BuffersWaiting++;
|
||||
_MPU_BuffersWaiting++;
|
||||
}
|
||||
|
||||
void MPU_BeginPlayback( void )
|
||||
void MPU_BeginPlayback(void)
|
||||
{
|
||||
_MPU_LastEvent = _MIDI_GlobalPositionInTicks;
|
||||
if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido);
|
||||
_MPU_LastEvent = _MIDI_GlobalPositionInTicks;
|
||||
if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido);
|
||||
}
|
||||
|
||||
void MPU_Pause(void)
|
||||
{
|
||||
if (hmido != (HMIDISTRM)-1) midiStreamPause(hmido);
|
||||
if (hmido != (HMIDISTRM)-1) midiStreamPause(hmido);
|
||||
}
|
||||
|
||||
void MPU_Unpause(void)
|
||||
{
|
||||
if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido);
|
||||
if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido);
|
||||
}
|
||||
|
||||
|
||||
void CALLBACK MPU_MIDICallback(HMIDIOUT handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
|
||||
{
|
||||
int i;
|
||||
switch (uMsg) {
|
||||
case MOM_DONE:
|
||||
midiOutUnprepareHeader((HMIDIOUT)handle, (MIDIHDR*)dwParam1, sizeof(MIDIHDR));
|
||||
for (i=0;i<NUMBUFFERS;i++) {
|
||||
if (dwParam1 == (long)&bufferheaders[i]) {
|
||||
eventcnt[i] = 0; // marks the buffer as free
|
||||
int i;
|
||||
switch (uMsg)
|
||||
{
|
||||
case MOM_DONE:
|
||||
midiOutUnprepareHeader((HMIDIOUT)handle, (MIDIHDR*)dwParam1, sizeof(MIDIHDR));
|
||||
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--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
default: return;
|
||||
}
|
||||
_MPU_BuffersWaiting--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,61 +143,69 @@ void CALLBACK MPU_MIDICallback(HMIDIOUT handle, UINT uMsg, DWORD dwInstance, DWO
|
|||
|
||||
int MPU_GetNextBuffer(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<NUMBUFFERS; i++) {
|
||||
if (eventcnt[i] == 0) return i;
|
||||
}
|
||||
return -1;
|
||||
int 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 };
|
||||
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) {
|
||||
// buffer over-full
|
||||
nextbuffer = MPU_GetNextBuffer();
|
||||
if (nextbuffer < 0) {
|
||||
if (count <= 0) return;
|
||||
if (count <= 3)
|
||||
{
|
||||
if (eventcnt[_MPU_CurrentBuffer] + 12 > BUFFERLEN)
|
||||
{
|
||||
// buffer over-full
|
||||
nextbuffer = MPU_GetNextBuffer();
|
||||
if (nextbuffer < 0)
|
||||
{
|
||||
// printf("All buffers full!\n");
|
||||
return;
|
||||
}
|
||||
MPU_FinishBuffer(_MPU_CurrentBuffer);
|
||||
_MPU_CurrentBuffer = nextbuffer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
MPU_FinishBuffer(_MPU_CurrentBuffer);
|
||||
_MPU_CurrentBuffer = nextbuffer;
|
||||
}
|
||||
|
||||
p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer];
|
||||
((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent;
|
||||
((long*)p)[1] = 0;
|
||||
((long*)p)[2] = (MEVT_SHORTMSG << 24) | ((*((long*)data)) & masks[count-1]);
|
||||
eventcnt[_MPU_CurrentBuffer] += 12;
|
||||
} else {
|
||||
padded = PAD(count);
|
||||
if (eventcnt[_MPU_CurrentBuffer] + 12 + padded > BUFFERLEN) {
|
||||
// buffer over-full
|
||||
nextbuffer = MPU_GetNextBuffer();
|
||||
if (nextbuffer < 0) {
|
||||
p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer];
|
||||
((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent;
|
||||
((long*)p)[1] = 0;
|
||||
((long*)p)[2] = (MEVT_SHORTMSG << 24) | ((*((long*)data)) & masks[count-1]);
|
||||
eventcnt[_MPU_CurrentBuffer] += 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
padded = PAD(count);
|
||||
if (eventcnt[_MPU_CurrentBuffer] + 12 + padded > BUFFERLEN)
|
||||
{
|
||||
// buffer over-full
|
||||
nextbuffer = MPU_GetNextBuffer();
|
||||
if (nextbuffer < 0)
|
||||
{
|
||||
// printf("All buffers full!\n");
|
||||
return;
|
||||
}
|
||||
MPU_FinishBuffer(_MPU_CurrentBuffer);
|
||||
_MPU_CurrentBuffer = nextbuffer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
MPU_FinishBuffer(_MPU_CurrentBuffer);
|
||||
_MPU_CurrentBuffer = nextbuffer;
|
||||
}
|
||||
|
||||
p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer];
|
||||
((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent;
|
||||
((long*)p)[1] = 0;
|
||||
((long*)p)[2] = (MEVT_LONGMSG<<24) | (count & 0xffffffl);
|
||||
p+=12; eventcnt[_MPU_CurrentBuffer] += 12;
|
||||
for (; count>0; count--, padded--, eventcnt[_MPU_CurrentBuffer]++)
|
||||
*(p++) = *(data++);
|
||||
for (; padded>0; padded--, eventcnt[_MPU_CurrentBuffer]++)
|
||||
*(p++) = 0;
|
||||
}
|
||||
_MPU_LastEvent = _MIDI_GlobalPositionInTicks;
|
||||
p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer];
|
||||
((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent;
|
||||
((long*)p)[1] = 0;
|
||||
((long*)p)[2] = (MEVT_LONGMSG<<24) | (count & 0xffffffl);
|
||||
p+=12; eventcnt[_MPU_CurrentBuffer] += 12;
|
||||
for (; count>0; count--, padded--, eventcnt[_MPU_CurrentBuffer]++)
|
||||
*(p++) = *(data++);
|
||||
for (; padded>0; padded--, eventcnt[_MPU_CurrentBuffer]++)
|
||||
*(p++) = 0;
|
||||
}
|
||||
_MPU_LastEvent = _MIDI_GlobalPositionInTicks;
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,22 +214,23 @@ 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 };
|
||||
MIDIHDR mhdr;
|
||||
static int masks[3] = { 0x00ffffffl, 0x0000ffffl, 0x000000ffl };
|
||||
|
||||
if (!count) return;
|
||||
if (count<=3) midiOutShortMsg((HMIDIOUT)hmido, (*((long*)data)) & masks[count-1]);
|
||||
else {
|
||||
ZeroMemory(&mhdr, sizeof(mhdr));
|
||||
mhdr.lpData = data;
|
||||
mhdr.dwBufferLength = count;
|
||||
midiOutPrepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR));
|
||||
midiOutLongMsg((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR));
|
||||
while (!(mhdr.dwFlags & MHDR_DONE)) ;
|
||||
midiOutUnprepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR));
|
||||
}
|
||||
if (!count) return;
|
||||
if (count<=3) midiOutShortMsg((HMIDIOUT)hmido, (*((long*)data)) & masks[count-1]);
|
||||
else
|
||||
{
|
||||
ZeroMemory(&mhdr, sizeof(mhdr));
|
||||
mhdr.lpData = data;
|
||||
mhdr.dwBufferLength = count;
|
||||
midiOutPrepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR));
|
||||
midiOutLongMsg((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR));
|
||||
while (!(mhdr.dwFlags & MHDR_DONE)) ;
|
||||
midiOutUnprepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -227,16 +241,16 @@ void MPU_SendMidiImmediate( char *data, int count )
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MPU_Reset
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
midiStreamStop(hmido);
|
||||
midiStreamClose(hmido);
|
||||
{
|
||||
midiStreamStop(hmido);
|
||||
midiStreamClose(hmido);
|
||||
|
||||
return( MPU_Ok );
|
||||
}
|
||||
return(MPU_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -246,23 +260,23 @@ int MPU_Reset
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MPU_Init
|
||||
(
|
||||
int addr
|
||||
)
|
||||
(
|
||||
int addr
|
||||
)
|
||||
|
||||
{
|
||||
int i;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<NUMBUFFERS;i++) eventcnt[i]=0;
|
||||
|
||||
mididevice = addr;
|
||||
for (i=0;i<NUMBUFFERS;i++) eventcnt[i]=0;
|
||||
|
||||
if (midiOutGetDevCaps(mididevice, &midicaps, sizeof(MIDIOUTCAPS)) != MMSYSERR_NOERROR) return MPU_Error;
|
||||
mididevice = addr;
|
||||
|
||||
if (midiStreamOpen(&hmido,&mididevice,1,(DWORD)MPU_MIDICallback,0L,CALLBACK_FUNCTION) != MMSYSERR_NOERROR) return(MPU_Error);
|
||||
if (midiOutGetDevCaps(mididevice, &midicaps, sizeof(MIDIOUTCAPS)) != MMSYSERR_NOERROR) return MPU_Error;
|
||||
|
||||
return( MPU_Ok );
|
||||
}
|
||||
if (midiStreamOpen(&hmido,&mididevice,1,(DWORD)MPU_MIDICallback,0L,CALLBACK_FUNCTION) != MMSYSERR_NOERROR) return(MPU_Error);
|
||||
|
||||
return(MPU_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -272,19 +286,19 @@ int MPU_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_NoteOff
|
||||
(
|
||||
int channel,
|
||||
int key,
|
||||
int velocity
|
||||
)
|
||||
(
|
||||
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 );
|
||||
}
|
||||
{
|
||||
char 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
|
||||
)
|
||||
(
|
||||
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 );
|
||||
}
|
||||
{
|
||||
char 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
|
||||
)
|
||||
(
|
||||
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 );
|
||||
}
|
||||
{
|
||||
char 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
|
||||
)
|
||||
(
|
||||
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 );
|
||||
}
|
||||
{
|
||||
char 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
|
||||
)
|
||||
(
|
||||
int channel,
|
||||
int program
|
||||
)
|
||||
|
||||
{
|
||||
char msg[2];
|
||||
msg[0] = ( MIDI_PROGRAM_CHANGE | channel );
|
||||
msg[1] = ( program );
|
||||
MPU_SendMidi( msg, 2 );
|
||||
}
|
||||
{
|
||||
char 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
|
||||
)
|
||||
(
|
||||
int channel,
|
||||
int pressure
|
||||
)
|
||||
|
||||
{
|
||||
char msg[2];
|
||||
msg[0] = ( MIDI_AFTER_TOUCH | channel );
|
||||
msg[1] = ( pressure );
|
||||
MPU_SendMidi( msg, 2 );
|
||||
}
|
||||
{
|
||||
char msg[2];
|
||||
msg[0] = (MIDI_AFTER_TOUCH | channel);
|
||||
msg[1] = (pressure);
|
||||
MPU_SendMidi(msg, 2);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -400,76 +414,76 @@ void MPU_ChannelAftertouch
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MPU_PitchBend
|
||||
(
|
||||
int channel,
|
||||
int lsb,
|
||||
int msb
|
||||
)
|
||||
(
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MPU_SetTempo( int tempo )
|
||||
{
|
||||
MIDIPROPTEMPO prop;
|
||||
prop.cbStruct = sizeof(MIDIPROPTEMPO);
|
||||
prop.dwTempo = 60000000l/tempo;
|
||||
midiStreamProperty(hmido, (LPBYTE)&prop, MIDIPROP_SET|MIDIPROP_TEMPO);
|
||||
char msg[3];
|
||||
msg[0] = (MIDI_PITCH_BEND | channel);
|
||||
msg[1] = (lsb);
|
||||
msg[2] = (msb);
|
||||
MPU_SendMidi(msg, 3);
|
||||
}
|
||||
|
||||
void MPU_SetDivision( int division )
|
||||
|
||||
|
||||
void MPU_SetTempo(int tempo)
|
||||
{
|
||||
MIDIPROPTIMEDIV prop;
|
||||
prop.cbStruct = sizeof(MIDIPROPTIMEDIV);
|
||||
prop.dwTimeDiv = division;
|
||||
midiStreamProperty(hmido, (LPBYTE)&prop, MIDIPROP_SET|MIDIPROP_TIMEDIV);
|
||||
MIDIPROPTEMPO prop;
|
||||
prop.cbStruct = sizeof(MIDIPROPTEMPO);
|
||||
prop.dwTempo = 60000000l/tempo;
|
||||
midiStreamProperty(hmido, (LPBYTE)&prop, MIDIPROP_SET|MIDIPROP_TEMPO);
|
||||
}
|
||||
|
||||
void MPU_SetDivision(int division)
|
||||
{
|
||||
MIDIPROPTIMEDIV prop;
|
||||
prop.cbStruct = sizeof(MIDIPROPTIMEDIV);
|
||||
prop.dwTimeDiv = division;
|
||||
midiStreamProperty(hmido, (LPBYTE)&prop, MIDIPROP_SET|MIDIPROP_TIMEDIV);
|
||||
}
|
||||
|
||||
void MPU_SetVolume(int volume)
|
||||
{
|
||||
/*
|
||||
HMIXER hmixer;
|
||||
long mixerid;
|
||||
MIXERCONTROLDETAILS mxcd;
|
||||
MIXERCONTROLDETAILS_UNSIGNED mxcdu;
|
||||
MMRESULT mme;
|
||||
|
||||
if (mididevice < 0) return;
|
||||
/*
|
||||
HMIXER hmixer;
|
||||
long mixerid;
|
||||
MIXERCONTROLDETAILS mxcd;
|
||||
MIXERCONTROLDETAILS_UNSIGNED mxcdu;
|
||||
MMRESULT mme;
|
||||
|
||||
mme = mixerOpen(&hmixer, mididevice, 0,0, MIXER_OBJECTF_MIDIOUT);
|
||||
if (mme) {
|
||||
puts("Failed opening mixer");
|
||||
return;
|
||||
}
|
||||
if (mididevice < 0) return;
|
||||
|
||||
mixerGetID(hmixer, &mixerid, MIXER_OBJECTF_HMIXER);
|
||||
printf("mixerid=%d\n",mixerid);
|
||||
mme = mixerOpen(&hmixer, mididevice, 0,0, MIXER_OBJECTF_MIDIOUT);
|
||||
if (mme) {
|
||||
puts("Failed opening mixer");
|
||||
return;
|
||||
}
|
||||
|
||||
ZeroMemory(&mxcd,sizeof(mxcd));
|
||||
mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
|
||||
mxcd.dwControlID = MIXERCONTROL_CONTROLTYPE_VOLUME;
|
||||
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
||||
mxcd.paDetails = (LPVOID)&mxcdu;
|
||||
mxcdu.dwValue = (volume << 8) & 0xffff;
|
||||
mixerGetID(hmixer, &mixerid, MIXER_OBJECTF_HMIXER);
|
||||
printf("mixerid=%d\n",mixerid);
|
||||
|
||||
printf("set %d\n",mixerSetControlDetails((HMIXEROBJ)mididevice, &mxcd,
|
||||
MIXER_OBJECTF_MIDIOUT|MIXER_SETCONTROLDETAILSF_VALUE));
|
||||
ZeroMemory(&mxcd,sizeof(mxcd));
|
||||
mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
|
||||
mxcd.dwControlID = MIXERCONTROL_CONTROLTYPE_VOLUME;
|
||||
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
||||
mxcd.paDetails = (LPVOID)&mxcdu;
|
||||
mxcdu.dwValue = (volume << 8) & 0xffff;
|
||||
|
||||
mixerClose(hmixer);
|
||||
*/
|
||||
printf("set %d\n",mixerSetControlDetails((HMIXEROBJ)mididevice, &mxcd,
|
||||
MIXER_OBJECTF_MIDIOUT|MIXER_SETCONTROLDETAILSF_VALUE));
|
||||
|
||||
mixerClose(hmixer);
|
||||
*/
|
||||
}
|
||||
|
||||
int MPU_GetVolume(void)
|
||||
{
|
||||
if (mididevice < 0) return 0;
|
||||
if (mididevice < 0) return 0;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
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,58 +67,58 @@ int MUSIC_InitMidi( int card, midifuncs *Funcs, int Address );
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
char *MUSIC_ErrorString
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
(
|
||||
int ErrorNumber
|
||||
)
|
||||
|
||||
{
|
||||
char *ErrorString;
|
||||
{
|
||||
char *ErrorString;
|
||||
|
||||
switch( ErrorNumber )
|
||||
{
|
||||
case MUSIC_Warning :
|
||||
case MUSIC_Error :
|
||||
ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode );
|
||||
break;
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case MUSIC_Warning :
|
||||
case MUSIC_Error :
|
||||
ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode);
|
||||
break;
|
||||
|
||||
case MUSIC_Ok :
|
||||
ErrorString = "Music ok.";
|
||||
break;
|
||||
case MUSIC_Ok :
|
||||
ErrorString = "Music ok.";
|
||||
break;
|
||||
|
||||
case MUSIC_ASSVersion :
|
||||
ErrorString = "Apogee Sound System Version WinMM "
|
||||
"Programmed by Jim Dose, Ported by Jonathon Fowler\n"
|
||||
"(c) Copyright 1996 James R. Dose. All Rights Reserved.\n";
|
||||
break;
|
||||
case MUSIC_ASSVersion :
|
||||
ErrorString = "Apogee Sound System Version WinMM "
|
||||
"Programmed by Jim Dose, Ported by Jonathon Fowler\n"
|
||||
"(c) Copyright 1996 James R. Dose. All Rights Reserved.\n";
|
||||
break;
|
||||
|
||||
case MUSIC_SoundCardError :
|
||||
case MUSIC_MPU401Error :
|
||||
ErrorString = "Could not detect MPU-401.";
|
||||
break;
|
||||
case MUSIC_SoundCardError :
|
||||
case MUSIC_MPU401Error :
|
||||
ErrorString = "Could not detect MPU-401.";
|
||||
break;
|
||||
|
||||
case MUSIC_InvalidCard :
|
||||
ErrorString = "Invalid Music device.";
|
||||
break;
|
||||
case MUSIC_InvalidCard :
|
||||
ErrorString = "Invalid Music device.";
|
||||
break;
|
||||
|
||||
case MUSIC_MidiError :
|
||||
ErrorString = "Error playing MIDI file.";
|
||||
break;
|
||||
case MUSIC_MidiError :
|
||||
ErrorString = "Error playing MIDI file.";
|
||||
break;
|
||||
|
||||
case MUSIC_TaskManError :
|
||||
ErrorString = "TaskMan error.";
|
||||
break;
|
||||
case MUSIC_TaskManError :
|
||||
ErrorString = "TaskMan error.";
|
||||
break;
|
||||
|
||||
case MUSIC_DPMI_Error :
|
||||
ErrorString = "DPMI Error in MUSIC.";
|
||||
break;
|
||||
case MUSIC_DPMI_Error :
|
||||
ErrorString = "DPMI Error in MUSIC.";
|
||||
break;
|
||||
|
||||
default :
|
||||
ErrorString = "Unknown Music error code.";
|
||||
break;
|
||||
}
|
||||
default :
|
||||
ErrorString = "Unknown Music error code.";
|
||||
break;
|
||||
}
|
||||
|
||||
return( ErrorString );
|
||||
}
|
||||
return(ErrorString);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -128,26 +128,26 @@ char *MUSIC_ErrorString
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_Init
|
||||
(
|
||||
int SoundCard,
|
||||
int Address
|
||||
)
|
||||
(
|
||||
int SoundCard,
|
||||
int Address
|
||||
)
|
||||
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
|
||||
for( i = 0; i < 128; i++ )
|
||||
{
|
||||
MIDI_PatchMap[ i ] = i;
|
||||
}
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
MIDI_PatchMap[ i ] = i;
|
||||
}
|
||||
|
||||
MUSIC_SoundDevice = SoundCard;
|
||||
MUSIC_SoundDevice = SoundCard;
|
||||
|
||||
status = MUSIC_InitMidi( SoundCard, &MUSIC_MidiFunctions, Address );
|
||||
status = MUSIC_InitMidi(SoundCard, &MUSIC_MidiFunctions, Address);
|
||||
|
||||
return( status );
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -157,21 +157,21 @@ int MUSIC_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_Shutdown
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
int status;
|
||||
{
|
||||
int status;
|
||||
|
||||
status = MUSIC_Ok;
|
||||
status = MUSIC_Ok;
|
||||
|
||||
MIDI_StopSong();
|
||||
MIDI_StopSong();
|
||||
|
||||
//MPU_Reset();
|
||||
//MPU_Reset();
|
||||
|
||||
return( status );
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -181,19 +181,19 @@ int MUSIC_Shutdown
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetVolume
|
||||
(
|
||||
int volume
|
||||
)
|
||||
(
|
||||
int volume
|
||||
)
|
||||
|
||||
{
|
||||
volume = max( 0, volume );
|
||||
volume = min( volume, 255 );
|
||||
{
|
||||
volume = max(0, volume);
|
||||
volume = min(volume, 255);
|
||||
|
||||
if ( MUSIC_SoundDevice != -1 )
|
||||
{
|
||||
MIDI_SetVolume( volume );
|
||||
}
|
||||
}
|
||||
if (MUSIC_SoundDevice != -1)
|
||||
{
|
||||
MIDI_SetVolume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -203,14 +203,14 @@ void MUSIC_SetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetMidiChannelVolume
|
||||
(
|
||||
int channel,
|
||||
int volume
|
||||
)
|
||||
(
|
||||
int channel,
|
||||
int volume
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetUserChannelVolume( channel, volume );
|
||||
}
|
||||
{
|
||||
MIDI_SetUserChannelVolume(channel, volume);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -220,13 +220,13 @@ void MUSIC_SetMidiChannelVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_ResetMidiChannelVolumes
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_ResetUserChannelVolume();
|
||||
}
|
||||
{
|
||||
MIDI_ResetUserChannelVolume();
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -236,17 +236,17 @@ void MUSIC_ResetMidiChannelVolumes
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_GetVolume
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
if ( MUSIC_SoundDevice == -1 )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
return( MIDI_GetVolume() );
|
||||
}
|
||||
{
|
||||
if (MUSIC_SoundDevice == -1)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return(MIDI_GetVolume());
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -257,13 +257,13 @@ int MUSIC_GetVolume
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetLoopFlag
|
||||
(
|
||||
int loopflag
|
||||
)
|
||||
(
|
||||
int loopflag
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetLoopFlag( loopflag );
|
||||
}
|
||||
{
|
||||
MIDI_SetLoopFlag(loopflag);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -273,13 +273,13 @@ void MUSIC_SetLoopFlag
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_SongPlaying
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return( MIDI_SongPlaying() );
|
||||
}
|
||||
{
|
||||
return(MIDI_SongPlaying());
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -289,13 +289,13 @@ int MUSIC_SongPlaying
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_Continue
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_ContinueSong();
|
||||
}
|
||||
{
|
||||
MIDI_ContinueSong();
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -305,13 +305,13 @@ void MUSIC_Continue
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_Pause
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_PauseSong();
|
||||
}
|
||||
{
|
||||
MIDI_PauseSong();
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -321,16 +321,16 @@ void MUSIC_Pause
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_StopSong
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
MUSIC_StopFade();
|
||||
MIDI_StopSong();
|
||||
MUSIC_SetErrorCode( MUSIC_Ok );
|
||||
return( MUSIC_Ok );
|
||||
}
|
||||
{
|
||||
MUSIC_StopFade();
|
||||
MIDI_StopSong();
|
||||
MUSIC_SetErrorCode(MUSIC_Ok);
|
||||
return(MUSIC_Ok);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -340,25 +340,25 @@ int MUSIC_StopSong
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_PlaySong
|
||||
(
|
||||
unsigned char *song,
|
||||
int loopflag
|
||||
)
|
||||
(
|
||||
unsigned char *song,
|
||||
int loopflag
|
||||
)
|
||||
|
||||
{
|
||||
int status;
|
||||
{
|
||||
int status;
|
||||
|
||||
MUSIC_StopSong();
|
||||
MUSIC_StopSong();
|
||||
|
||||
status = MIDI_PlaySong( song, loopflag );
|
||||
if ( status != MIDI_Ok )
|
||||
{
|
||||
MUSIC_SetErrorCode( MUSIC_MidiError );
|
||||
return( MUSIC_Warning );
|
||||
}
|
||||
status = MIDI_PlaySong(song, loopflag);
|
||||
if (status != MIDI_Ok)
|
||||
{
|
||||
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
|
||||
)
|
||||
(
|
||||
int context
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetContext( context );
|
||||
}
|
||||
{
|
||||
MIDI_SetContext(context);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -384,13 +384,13 @@ void MUSIC_SetContext
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
int MUSIC_GetContext
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return MIDI_GetContext();
|
||||
}
|
||||
{
|
||||
return MIDI_GetContext();
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -400,13 +400,13 @@ int MUSIC_GetContext
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongTick
|
||||
(
|
||||
unsigned long PositionInTicks
|
||||
)
|
||||
(
|
||||
unsigned long PositionInTicks
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_SetSongTick( PositionInTicks );
|
||||
}
|
||||
{
|
||||
MIDI_SetSongTick(PositionInTicks);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -416,13 +416,13 @@ void MUSIC_SetSongTick
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_SetSongTime
|
||||
(
|
||||
unsigned long milliseconds
|
||||
)
|
||||
(
|
||||
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
|
||||
)
|
||||
(
|
||||
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
|
||||
)
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_GetSongPosition( pos );
|
||||
}
|
||||
{
|
||||
MIDI_GetSongPosition(pos);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -466,41 +466,41 @@ void MUSIC_GetSongPosition
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_GetSongLength
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
(
|
||||
songposition *pos
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_GetSongLength( pos );
|
||||
}
|
||||
{
|
||||
MIDI_GetSongLength(pos);
|
||||
}
|
||||
|
||||
|
||||
int MUSIC_InitMidi
|
||||
(
|
||||
int card,
|
||||
midifuncs *Funcs,
|
||||
int Address
|
||||
)
|
||||
(
|
||||
int card,
|
||||
midifuncs *Funcs,
|
||||
int Address
|
||||
)
|
||||
|
||||
{
|
||||
int status;
|
||||
{
|
||||
int status;
|
||||
|
||||
Funcs->NoteOff = MPU_NoteOff;
|
||||
Funcs->NoteOn = MPU_NoteOn;
|
||||
Funcs->PolyAftertouch = MPU_PolyAftertouch;
|
||||
Funcs->ControlChange = MPU_ControlChange;
|
||||
Funcs->ProgramChange = MPU_ProgramChange;
|
||||
Funcs->ChannelAftertouch = MPU_ChannelAftertouch;
|
||||
Funcs->PitchBend = MPU_PitchBend;
|
||||
Funcs->ReleasePatches = NULL;
|
||||
Funcs->LoadPatch = NULL;
|
||||
Funcs->SetVolume = NULL /*MPU_SetVolume*/;
|
||||
Funcs->GetVolume = NULL /*MPU_GetVolume*/;
|
||||
Funcs->NoteOff = MPU_NoteOff;
|
||||
Funcs->NoteOn = MPU_NoteOn;
|
||||
Funcs->PolyAftertouch = MPU_PolyAftertouch;
|
||||
Funcs->ControlChange = MPU_ControlChange;
|
||||
Funcs->ProgramChange = MPU_ProgramChange;
|
||||
Funcs->ChannelAftertouch = MPU_ChannelAftertouch;
|
||||
Funcs->PitchBend = MPU_PitchBend;
|
||||
Funcs->ReleasePatches = NULL;
|
||||
Funcs->LoadPatch = NULL;
|
||||
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 tovolume,
|
||||
int milliseconds
|
||||
)
|
||||
|
||||
{
|
||||
int fromvolume;
|
||||
{
|
||||
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
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -547,12 +547,11 @@ int MUSIC_FadeActive
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_StopFade
|
||||
(
|
||||
void
|
||||
)
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -563,14 +562,14 @@ void MUSIC_StopFade
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_RerouteMidiChannel
|
||||
(
|
||||
int channel,
|
||||
int ( *function )( int event, int c1, int c2 )
|
||||
)
|
||||
(
|
||||
int channel,
|
||||
int(*function)(int event, int c1, int c2)
|
||||
)
|
||||
|
||||
{
|
||||
MIDI_RerouteMidiChannel( channel, function );
|
||||
}
|
||||
{
|
||||
MIDI_RerouteMidiChannel(channel, function);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
|
@ -580,16 +579,15 @@ void MUSIC_RerouteMidiChannel
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
void MUSIC_RegisterTimbreBank
|
||||
(
|
||||
unsigned char *timbres
|
||||
)
|
||||
(
|
||||
unsigned char *timbres
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void MUSIC_Update(void)
|
||||
{
|
||||
MIDI_UpdateMusic();
|
||||
MIDI_UpdateMusic();
|
||||
}
|
||||
|
||||
|
|
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;
|
||||
}
|
|
@ -37,56 +37,58 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
|
|||
#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 }
|
||||
};
|
||||
{
|
||||
{
|
||||
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;
|
||||
|
@ -137,61 +139,61 @@ void PITCH_Init
|
|||
---------------------------------------------------------------------*/
|
||||
|
||||
unsigned long PITCH_GetScale
|
||||
(
|
||||
int pitchoffset
|
||||
)
|
||||
(
|
||||
int pitchoffset
|
||||
)
|
||||
|
||||
{
|
||||
unsigned long scale;
|
||||
int octaveshift;
|
||||
int noteshift;
|
||||
int note;
|
||||
int detune;
|
||||
{
|
||||
unsigned long scale;
|
||||
int octaveshift;
|
||||
int noteshift;
|
||||
int note;
|
||||
int detune;
|
||||
|
||||
// if ( !PITCH_Installed )
|
||||
// {
|
||||
// PITCH_Init();
|
||||
// }
|
||||
|
||||
if ( pitchoffset == 0 )
|
||||
{
|
||||
return( PitchTable[ 0 ][ 0 ] );
|
||||
}
|
||||
if (pitchoffset == 0)
|
||||
{
|
||||
return(PitchTable[ 0 ][ 0 ]);
|
||||
}
|
||||
|
||||
noteshift = pitchoffset % 1200;
|
||||
if ( noteshift < 0 )
|
||||
{
|
||||
noteshift += 1200;
|
||||
}
|
||||
noteshift = pitchoffset % 1200;
|
||||
if (noteshift < 0)
|
||||
{
|
||||
noteshift += 1200;
|
||||
}
|
||||
|
||||
note = noteshift / 100;
|
||||
detune = ( noteshift % 100 ) / ( 100 / MAXDETUNE );
|
||||
octaveshift = ( pitchoffset - 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--;
|
||||
}
|
||||
}
|
||||
if (detune < 0)
|
||||
{
|
||||
detune += (100 / MAXDETUNE);
|
||||
note--;
|
||||
if (note < 0)
|
||||
{
|
||||
note += 12;
|
||||
octaveshift--;
|
||||
}
|
||||
}
|
||||
|
||||
scale = PitchTable[ note ][ detune ];
|
||||
scale = PitchTable[ note ][ detune ];
|
||||
|
||||
if ( octaveshift < 0 )
|
||||
{
|
||||
scale >>= -octaveshift;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale <<= octaveshift;
|
||||
}
|
||||
if (octaveshift < 0)
|
||||
{
|
||||
scale >>= -octaveshift;
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
|
@ -62,9 +62,9 @@ static void isr(void *userdata, unsigned char *stream, int len);
|
|||
*/
|
||||
int DisableInterrupts(void)
|
||||
{
|
||||
SDL_LockAudio();
|
||||
SDL_LockAudio();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,10 +74,10 @@ int DisableInterrupts(void)
|
|||
*/
|
||||
int RestoreInterrupts(int a)
|
||||
{
|
||||
SDL_UnlockAudio();
|
||||
SDL_UnlockAudio();
|
||||
|
||||
return 0;
|
||||
a=a;
|
||||
return 0;
|
||||
a=a;
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,17 +87,18 @@ int RestoreInterrupts(int a)
|
|||
*/
|
||||
char *SDLSOUND_ErrorString(int errorcode)
|
||||
{
|
||||
switch (errorcode) {
|
||||
case SDLSOUND_Warning:
|
||||
case SDLSOUND_Error:
|
||||
return SDLSOUND_ErrorString(SDLSOUND_ErrorCode);
|
||||
switch (errorcode)
|
||||
{
|
||||
case SDLSOUND_Warning:
|
||||
case SDLSOUND_Error:
|
||||
return SDLSOUND_ErrorString(SDLSOUND_ErrorCode);
|
||||
|
||||
case SDLSOUND_Ok:
|
||||
return "SDL Sound ok.";
|
||||
case SDLSOUND_Ok:
|
||||
return "SDL Sound ok.";
|
||||
|
||||
default:
|
||||
return "Unknown SDL sound error code.";
|
||||
}
|
||||
default:
|
||||
return "Unknown SDL sound error code.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,32 +108,33 @@ char *SDLSOUND_ErrorString(int errorcode)
|
|||
*/
|
||||
int SDLSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int buffersize)
|
||||
{
|
||||
SDL_AudioSpec spec,got;
|
||||
|
||||
if (SDLSOUND_Installed) {
|
||||
SDLSOUND_Shutdown();
|
||||
}
|
||||
SDL_AudioSpec spec,got;
|
||||
|
||||
printOSD("Initializing SDL sound...\n");
|
||||
if (SDLSOUND_Installed)
|
||||
{
|
||||
SDLSOUND_Shutdown();
|
||||
}
|
||||
|
||||
printOSD(" - Requested sound format\n"
|
||||
" Channels: %d\n"
|
||||
" Sample rate: %dHz\n"
|
||||
" Sample size: %d bits\n",
|
||||
numchannels, mixrate, samplebits);
|
||||
printOSD("Initializing SDL sound...\n");
|
||||
|
||||
spec.freq = mixrate;
|
||||
spec.format = (samplebits == 8 ? AUDIO_U8 : AUDIO_S16LSB);
|
||||
spec.channels = (numchannels == 1 ? 1:2);
|
||||
spec.samples = (buffersize >> (spec.channels-1)) >> (samplebits==16);
|
||||
spec.callback = isr;
|
||||
spec.userdata = NULL;
|
||||
printOSD(" - Requested sound format\n"
|
||||
" Channels: %d\n"
|
||||
" Sample rate: %dHz\n"
|
||||
" Sample size: %d bits\n",
|
||||
numchannels, mixrate, samplebits);
|
||||
|
||||
spec.freq = mixrate;
|
||||
spec.format = (samplebits == 8 ? AUDIO_U8 : AUDIO_S16LSB);
|
||||
spec.channels = (numchannels == 1 ? 1:2);
|
||||
spec.samples = (buffersize >> (spec.channels-1)) >> (samplebits==16);
|
||||
spec.callback = isr;
|
||||
spec.userdata = NULL;
|
||||
|
||||
|
||||
SDLSOUND_Installed = TRUE;
|
||||
|
||||
SDLSOUND_SetErrorCode(SDLSOUND_Ok);
|
||||
return SDLSOUND_Ok;
|
||||
SDLSOUND_Installed = TRUE;
|
||||
|
||||
SDLSOUND_SetErrorCode(SDLSOUND_Ok);
|
||||
return SDLSOUND_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,17 +144,17 @@ int SDLSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, i
|
|||
*/
|
||||
int SDLSOUND_Shutdown(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (SDLSOUND_Installed) printOSD("Uninitializing SDL sound...\n");
|
||||
if (SDLSOUND_Installed) printOSD("Uninitializing SDL sound...\n");
|
||||
|
||||
SDLSOUND_Installed = FALSE;
|
||||
SDLSOUND_Installed = FALSE;
|
||||
|
||||
SDLSOUND_StopPlayback();
|
||||
SDLSOUND_StopPlayback();
|
||||
|
||||
|
||||
SDLSOUND_SetErrorCode(SDLSOUND_Ok);
|
||||
return SDLSOUND_Ok;
|
||||
|
||||
SDLSOUND_SetErrorCode(SDLSOUND_Ok);
|
||||
return SDLSOUND_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,37 +164,40 @@ int SDLSOUND_Shutdown(void)
|
|||
*/
|
||||
int SDLSOUND_SetMixMode(int mode)
|
||||
{
|
||||
return mode;
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
static void isr(void *userdata, unsigned char *stream, int len)
|
||||
{
|
||||
// otherwise we just service the interrupt
|
||||
if (_DSOUND_CallBack) {
|
||||
// otherwise we just service the interrupt
|
||||
if (_DSOUND_CallBack)
|
||||
{
|
||||
|
||||
p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1);
|
||||
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) {
|
||||
hr = IDirectSoundBuffer_Restore(lpDSBSecondary);
|
||||
}
|
||||
if (hr == DS_OK) {
|
||||
/*
|
||||
#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);
|
||||
}
|
||||
hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength,
|
||||
&lockptr, &lockbytes, &lockptr2, &lockbytes2, 0);
|
||||
if (hr == DSERR_BUFFERLOST)
|
||||
{
|
||||
hr = IDirectSoundBuffer_Restore(lpDSBSecondary);
|
||||
}
|
||||
if (hr == DS_OK)
|
||||
{
|
||||
/*
|
||||
#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,15 +205,15 @@ 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;
|
||||
_SDLSOUND_CallBack = CallBackFunc;
|
||||
_SDLSOUND_MixBuffer = BufferStart;
|
||||
|
||||
_SDLSOUND_BufferLength = buffersize/numdivisions;
|
||||
_SDLSOUND_NumBuffers = numdivisions;
|
||||
_SDLSOUND_BufferLength = buffersize/numdivisions;
|
||||
_SDLSOUND_NumBuffers = numdivisions;
|
||||
|
||||
return SDLSOUND_Ok;
|
||||
return SDLSOUND_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -219,48 +224,53 @@ int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), in
|
|||
int DSOUND_StopPlayback(void)
|
||||
{
|
||||
// DWORD exitcode;
|
||||
BOOL t;
|
||||
int i;
|
||||
|
||||
if (isrthread) {
|
||||
SetEvent(isrfinish);
|
||||
BOOL t;
|
||||
int i;
|
||||
|
||||
printOSD("DirectSound: Waiting for sound thread to exit\n");
|
||||
if (WaitForSingleObject(isrthread, 300) == WAIT_OBJECT_0)
|
||||
printOSD("DirectSound: Sound thread has exited\n");
|
||||
else
|
||||
printOSD("DirectSound: Sound thread failed to exit!\n");
|
||||
/*
|
||||
while (1) {
|
||||
if (!GetExitCodeThread(isrthread, &exitcode)) {
|
||||
DSOUND_SetErrorCode(DSOUND_FailedGetExitCode);
|
||||
return DSOUND_Warning;
|
||||
}
|
||||
if (exitcode != STILL_ACTIVE) break;
|
||||
}*/
|
||||
if (isrthread)
|
||||
{
|
||||
SetEvent(isrfinish);
|
||||
|
||||
CloseHandle(isrthread);
|
||||
isrthread = NULL;
|
||||
}
|
||||
printOSD("DirectSound: Waiting for sound thread to exit\n");
|
||||
if (WaitForSingleObject(isrthread, 300) == WAIT_OBJECT_0)
|
||||
printOSD("DirectSound: Sound thread has exited\n");
|
||||
else
|
||||
printOSD("DirectSound: Sound thread failed to exit!\n");
|
||||
/*
|
||||
while (1) {
|
||||
if (!GetExitCodeThread(isrthread, &exitcode)) {
|
||||
DSOUND_SetErrorCode(DSOUND_FailedGetExitCode);
|
||||
return DSOUND_Warning;
|
||||
}
|
||||
if (exitcode != STILL_ACTIVE) break;
|
||||
}*/
|
||||
|
||||
if (isrfinish) {
|
||||
CloseHandle(isrfinish);
|
||||
isrfinish = NULL;
|
||||
}
|
||||
CloseHandle(isrthread);
|
||||
isrthread = NULL;
|
||||
}
|
||||
|
||||
if (lpDSBSecondary) {
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
}
|
||||
|
||||
if (hPosNotify) {
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++) {
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
hPosNotify = NULL;
|
||||
}
|
||||
if (isrfinish)
|
||||
{
|
||||
CloseHandle(isrfinish);
|
||||
isrfinish = NULL;
|
||||
}
|
||||
|
||||
return DSOUND_Ok;
|
||||
if (lpDSBSecondary)
|
||||
{
|
||||
IDirectSoundBuffer_Stop(lpDSBSecondary);
|
||||
}
|
||||
|
||||
if (hPosNotify)
|
||||
{
|
||||
for (i=0; i<_DSOUND_NumBuffers; i++)
|
||||
{
|
||||
if (hPosNotify[i]) CloseHandle(hPosNotify[i]);
|
||||
}
|
||||
free(hPosNotify);
|
||||
hPosNotify = NULL;
|
||||
}
|
||||
|
||||
return DSOUND_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
|
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
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -257,21 +257,21 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm)
|
|||
|
||||
switch (parm->numparms)
|
||||
{
|
||||
case 1: // bpp switch
|
||||
newbpp = Batol(parm->parms[0]);
|
||||
break;
|
||||
case 2: // res switch
|
||||
newwidth = Batol(parm->parms[0]);
|
||||
newheight = Batol(parm->parms[1]);
|
||||
break;
|
||||
case 3: // res & bpp switch
|
||||
case 4:
|
||||
newwidth = Batol(parm->parms[0]);
|
||||
newheight = Batol(parm->parms[1]);
|
||||
newbpp = Batol(parm->parms[2]);
|
||||
if (parm->numparms == 4)
|
||||
newfs = (Batol(parm->parms[3]) != 0);
|
||||
break;
|
||||
case 1: // bpp switch
|
||||
newbpp = Batol(parm->parms[0]);
|
||||
break;
|
||||
case 2: // res switch
|
||||
newwidth = Batol(parm->parms[0]);
|
||||
newheight = Batol(parm->parms[1]);
|
||||
break;
|
||||
case 3: // res & bpp switch
|
||||
case 4:
|
||||
newwidth = Batol(parm->parms[0]);
|
||||
newheight = Batol(parm->parms[1]);
|
||||
newbpp = Batol(parm->parms[2]);
|
||||
if (parm->numparms == 4)
|
||||
newfs = (Batol(parm->parms[3]) != 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (setgamemode(newfs,newwidth,newheight,newbpp))
|
||||
|
@ -334,58 +334,58 @@ static int osdcmd_spawn(const osdfuncparm_t *parm)
|
|||
|
||||
switch (parm->numparms)
|
||||
{
|
||||
case 7: // x,y,z
|
||||
x = Batol(parm->parms[4]);
|
||||
y = Batol(parm->parms[5]);
|
||||
z = Batol(parm->parms[6]);
|
||||
set |= 8;
|
||||
case 4: // ang
|
||||
ang = Batol(parm->parms[3]) & 2047;
|
||||
set |= 4;
|
||||
case 3: // cstat
|
||||
cstat = (unsigned short)Batol(parm->parms[2]);
|
||||
set |= 2;
|
||||
case 2: // pal
|
||||
pal = (unsigned char)Batol(parm->parms[1]);
|
||||
set |= 1;
|
||||
case 1: // tile number
|
||||
if (isdigit(parm->parms[0][0]))
|
||||
case 7: // x,y,z
|
||||
x = Batol(parm->parms[4]);
|
||||
y = Batol(parm->parms[5]);
|
||||
z = Batol(parm->parms[6]);
|
||||
set |= 8;
|
||||
case 4: // ang
|
||||
ang = Batol(parm->parms[3]) & 2047;
|
||||
set |= 4;
|
||||
case 3: // cstat
|
||||
cstat = (unsigned short)Batol(parm->parms[2]);
|
||||
set |= 2;
|
||||
case 2: // pal
|
||||
pal = (unsigned char)Batol(parm->parms[1]);
|
||||
set |= 1;
|
||||
case 1: // tile number
|
||||
if (isdigit(parm->parms[0][0]))
|
||||
{
|
||||
picnum = (unsigned short)Batol(parm->parms[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i,j;
|
||||
for (j=0; j<2; j++)
|
||||
{
|
||||
picnum = (unsigned short)Batol(parm->parms[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i,j;
|
||||
for (j=0; j<2; j++)
|
||||
for (i=0; i<labelcnt; i++)
|
||||
{
|
||||
for (i=0; i<labelcnt; i++)
|
||||
if (
|
||||
(j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) ||
|
||||
(j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
|
||||
)
|
||||
{
|
||||
if (
|
||||
(j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) ||
|
||||
(j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
|
||||
)
|
||||
{
|
||||
picnum = (unsigned short)labelcode[i];
|
||||
break;
|
||||
}
|
||||
picnum = (unsigned short)labelcode[i];
|
||||
break;
|
||||
}
|
||||
if (i<labelcnt) break;
|
||||
}
|
||||
if (i==labelcnt)
|
||||
{
|
||||
OSD_Printf("spawn: Invalid tile label given\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
if (i<labelcnt) break;
|
||||
}
|
||||
|
||||
if (picnum >= MAXTILES)
|
||||
if (i==labelcnt)
|
||||
{
|
||||
OSD_Printf("spawn: Invalid tile number\n");
|
||||
OSD_Printf("spawn: Invalid tile label given\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
if (picnum >= MAXTILES)
|
||||
{
|
||||
OSD_Printf("spawn: Invalid tile number\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
idx = spawn(ps[myconnectindex].i, (short)picnum);
|
||||
|
@ -552,46 +552,46 @@ int osdcmd_cvar_set(const osdfuncparm_t *parm)
|
|||
else
|
||||
switch (cvar[i].type&0x7f)
|
||||
{
|
||||
case CVAR_INT:
|
||||
case CVAR_UNSIGNEDINT:
|
||||
case CVAR_BOOL:
|
||||
case CVAR_INT:
|
||||
case CVAR_UNSIGNEDINT:
|
||||
case CVAR_BOOL:
|
||||
{
|
||||
int val;
|
||||
if (showval)
|
||||
{
|
||||
int val;
|
||||
if (showval)
|
||||
{
|
||||
OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
val = atoi(parm->parms[0]);
|
||||
if (cvar[i].type == CVAR_BOOL) val = val != 0;
|
||||
|
||||
if (val < cvar[i].min || val > cvar[i].max)
|
||||
{
|
||||
OSD_Printf("%s value out of range\n",cvar[i].name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
*(int*)cvar[i].var = val;
|
||||
OSD_Printf("%s %d",cvar[i].name,val);
|
||||
OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
break;
|
||||
case CVAR_STRING:
|
||||
|
||||
val = atoi(parm->parms[0]);
|
||||
if (cvar[i].type == CVAR_BOOL) val = val != 0;
|
||||
|
||||
if (val < cvar[i].min || val > cvar[i].max)
|
||||
{
|
||||
if (showval)
|
||||
{
|
||||
OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1);
|
||||
((char*)cvar[i].var)[cvar[i].extra-1] = 0;
|
||||
OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var);
|
||||
}
|
||||
OSD_Printf("%s value out of range\n",cvar[i].name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
*(int*)cvar[i].var = val;
|
||||
OSD_Printf("%s %d",cvar[i].name,val);
|
||||
}
|
||||
break;
|
||||
case CVAR_STRING:
|
||||
{
|
||||
if (showval)
|
||||
{
|
||||
OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1);
|
||||
((char*)cvar[i].var)[cvar[i].extra-1] = 0;
|
||||
OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (cvar[i].type&256)
|
||||
updatenames();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -79,124 +79,124 @@ void cachespritenum(short i)
|
|||
|
||||
switch (dynamictostatic[PN])
|
||||
{
|
||||
case HYDRENT__STATIC:
|
||||
tloadtile(BROKEFIREHYDRENT,1);
|
||||
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
||||
break;
|
||||
case TOILET__STATIC:
|
||||
tloadtile(TOILETBROKE,1);
|
||||
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
||||
break;
|
||||
case STALL__STATIC:
|
||||
tloadtile(STALLBROKE,1);
|
||||
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
||||
break;
|
||||
case RUBBERCAN__STATIC:
|
||||
maxc = 2;
|
||||
break;
|
||||
case TOILETWATER__STATIC:
|
||||
maxc = 4;
|
||||
break;
|
||||
case FEMPIC1__STATIC:
|
||||
maxc = 44;
|
||||
break;
|
||||
case LIZTROOP__STATIC:
|
||||
case LIZTROOPRUNNING__STATIC:
|
||||
case LIZTROOPSHOOT__STATIC:
|
||||
case LIZTROOPJETPACK__STATIC:
|
||||
case LIZTROOPONTOILET__STATIC:
|
||||
case LIZTROOPDUCKING__STATIC:
|
||||
for (j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1);
|
||||
for (j=HEADJIB1;j<LEGJIB1+3;j++) tloadtile(j,1);
|
||||
maxc = 0;
|
||||
break;
|
||||
case WOODENHORSE__STATIC:
|
||||
case HYDRENT__STATIC:
|
||||
tloadtile(BROKEFIREHYDRENT,1);
|
||||
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
||||
break;
|
||||
case TOILET__STATIC:
|
||||
tloadtile(TOILETBROKE,1);
|
||||
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
||||
break;
|
||||
case STALL__STATIC:
|
||||
tloadtile(STALLBROKE,1);
|
||||
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
||||
break;
|
||||
case RUBBERCAN__STATIC:
|
||||
maxc = 2;
|
||||
break;
|
||||
case TOILETWATER__STATIC:
|
||||
maxc = 4;
|
||||
break;
|
||||
case FEMPIC1__STATIC:
|
||||
maxc = 44;
|
||||
break;
|
||||
case LIZTROOP__STATIC:
|
||||
case LIZTROOPRUNNING__STATIC:
|
||||
case LIZTROOPSHOOT__STATIC:
|
||||
case LIZTROOPJETPACK__STATIC:
|
||||
case LIZTROOPONTOILET__STATIC:
|
||||
case LIZTROOPDUCKING__STATIC:
|
||||
for (j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1);
|
||||
for (j=HEADJIB1;j<LEGJIB1+3;j++) tloadtile(j,1);
|
||||
maxc = 0;
|
||||
break;
|
||||
case WOODENHORSE__STATIC:
|
||||
maxc = 5;
|
||||
for (j = HORSEONSIDE; j < (HORSEONSIDE+4); j++) tloadtile(j,1);
|
||||
break;
|
||||
case NEWBEAST__STATIC:
|
||||
case NEWBEASTSTAYPUT__STATIC:
|
||||
maxc = 90;
|
||||
break;
|
||||
case BOSS1__STATIC:
|
||||
case BOSS2__STATIC:
|
||||
case BOSS3__STATIC:
|
||||
maxc = 30;
|
||||
break;
|
||||
case OCTABRAIN__STATIC:
|
||||
case OCTABRAINSTAYPUT__STATIC:
|
||||
case COMMANDER__STATIC:
|
||||
case COMMANDERSTAYPUT__STATIC:
|
||||
maxc = 38;
|
||||
break;
|
||||
case RECON__STATIC:
|
||||
maxc = 13;
|
||||
break;
|
||||
case PIGCOP__STATIC:
|
||||
case PIGCOPDIVE__STATIC:
|
||||
maxc = 61;
|
||||
break;
|
||||
case SHARK__STATIC:
|
||||
maxc = 30;
|
||||
break;
|
||||
case LIZMAN__STATIC:
|
||||
case LIZMANSPITTING__STATIC:
|
||||
case LIZMANFEEDING__STATIC:
|
||||
case LIZMANJUMP__STATIC:
|
||||
for (j=LIZMANHEAD1;j<LIZMANLEG1+3;j++) tloadtile(j,1);
|
||||
maxc = 80;
|
||||
break;
|
||||
case APLAYER__STATIC:
|
||||
maxc = 0;
|
||||
if (ud.multimode > 1)
|
||||
{
|
||||
maxc = 5;
|
||||
for (j = HORSEONSIDE; j < (HORSEONSIDE+4); j++) tloadtile(j,1);
|
||||
break;
|
||||
case NEWBEAST__STATIC:
|
||||
case NEWBEASTSTAYPUT__STATIC:
|
||||
maxc = 90;
|
||||
break;
|
||||
case BOSS1__STATIC:
|
||||
case BOSS2__STATIC:
|
||||
case BOSS3__STATIC:
|
||||
maxc = 30;
|
||||
break;
|
||||
case OCTABRAIN__STATIC:
|
||||
case OCTABRAINSTAYPUT__STATIC:
|
||||
case COMMANDER__STATIC:
|
||||
case COMMANDERSTAYPUT__STATIC:
|
||||
maxc = 38;
|
||||
break;
|
||||
case RECON__STATIC:
|
||||
maxc = 13;
|
||||
break;
|
||||
case PIGCOP__STATIC:
|
||||
case PIGCOPDIVE__STATIC:
|
||||
maxc = 61;
|
||||
break;
|
||||
case SHARK__STATIC:
|
||||
maxc = 30;
|
||||
break;
|
||||
case LIZMAN__STATIC:
|
||||
case LIZMANSPITTING__STATIC:
|
||||
case LIZMANFEEDING__STATIC:
|
||||
case LIZMANJUMP__STATIC:
|
||||
for (j=LIZMANHEAD1;j<LIZMANLEG1+3;j++) tloadtile(j,1);
|
||||
maxc = 80;
|
||||
break;
|
||||
case APLAYER__STATIC:
|
||||
maxc = 0;
|
||||
if (ud.multimode > 1)
|
||||
{
|
||||
maxc = 5;
|
||||
for (j = 1420;j < 1420+106; j++) tloadtile(j,1);
|
||||
}
|
||||
break;
|
||||
case ATOMICHEALTH__STATIC:
|
||||
maxc = 14;
|
||||
break;
|
||||
case DRONE__STATIC:
|
||||
maxc = 10;
|
||||
break;
|
||||
case EXPLODINGBARREL__STATIC:
|
||||
case SEENINE__STATIC:
|
||||
case OOZFILTER__STATIC:
|
||||
maxc = 3;
|
||||
break;
|
||||
case NUKEBARREL__STATIC:
|
||||
case CAMERA1__STATIC:
|
||||
maxc = 5;
|
||||
break;
|
||||
// caching of HUD sprites for weapons that may be in the level
|
||||
case CHAINGUNSPRITE__STATIC:
|
||||
for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1);
|
||||
break;
|
||||
case RPGSPRITE__STATIC:
|
||||
for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1);
|
||||
break;
|
||||
case FREEZESPRITE__STATIC:
|
||||
for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1);
|
||||
break;
|
||||
case GROWSPRITEICON__STATIC:
|
||||
case SHRINKERSPRITE__STATIC:
|
||||
for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1);
|
||||
break;
|
||||
case HBOMBAMMO__STATIC:
|
||||
case HEAVYHBOMB__STATIC:
|
||||
for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1);
|
||||
break;
|
||||
case TRIPBOMBSPRITE__STATIC:
|
||||
for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1);
|
||||
break;
|
||||
case SHOTGUNSPRITE__STATIC:
|
||||
tloadtile(SHOTGUNSHELL,1);
|
||||
for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1);
|
||||
break;
|
||||
case DEVISTATORSPRITE__STATIC:
|
||||
for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1);
|
||||
break;
|
||||
for (j = 1420;j < 1420+106; j++) tloadtile(j,1);
|
||||
}
|
||||
break;
|
||||
case ATOMICHEALTH__STATIC:
|
||||
maxc = 14;
|
||||
break;
|
||||
case DRONE__STATIC:
|
||||
maxc = 10;
|
||||
break;
|
||||
case EXPLODINGBARREL__STATIC:
|
||||
case SEENINE__STATIC:
|
||||
case OOZFILTER__STATIC:
|
||||
maxc = 3;
|
||||
break;
|
||||
case NUKEBARREL__STATIC:
|
||||
case CAMERA1__STATIC:
|
||||
maxc = 5;
|
||||
break;
|
||||
// caching of HUD sprites for weapons that may be in the level
|
||||
case CHAINGUNSPRITE__STATIC:
|
||||
for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1);
|
||||
break;
|
||||
case RPGSPRITE__STATIC:
|
||||
for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1);
|
||||
break;
|
||||
case FREEZESPRITE__STATIC:
|
||||
for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1);
|
||||
break;
|
||||
case GROWSPRITEICON__STATIC:
|
||||
case SHRINKERSPRITE__STATIC:
|
||||
for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1);
|
||||
break;
|
||||
case HBOMBAMMO__STATIC:
|
||||
case HEAVYHBOMB__STATIC:
|
||||
for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1);
|
||||
break;
|
||||
case TRIPBOMBSPRITE__STATIC:
|
||||
for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1);
|
||||
break;
|
||||
case SHOTGUNSPRITE__STATIC:
|
||||
tloadtile(SHOTGUNSHELL,1);
|
||||
for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1);
|
||||
break;
|
||||
case DEVISTATORSPRITE__STATIC:
|
||||
for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
@ -719,32 +719,32 @@ void setupbackdrop(short sky)
|
|||
|
||||
switch (dynamictostatic[sky])
|
||||
{
|
||||
case CLOUDYOCEAN__STATIC:
|
||||
parallaxyscale = 65536L;
|
||||
break;
|
||||
case MOONSKY1__STATIC :
|
||||
pskyoff[6]=1;
|
||||
pskyoff[1]=2;
|
||||
pskyoff[4]=2;
|
||||
pskyoff[2]=3;
|
||||
break;
|
||||
case BIGORBIT1__STATIC: // orbit
|
||||
pskyoff[5]=1;
|
||||
pskyoff[6]=2;
|
||||
pskyoff[7]=3;
|
||||
pskyoff[2]=4;
|
||||
break;
|
||||
case LA__STATIC:
|
||||
parallaxyscale = 16384+1024;
|
||||
pskyoff[0]=1;
|
||||
pskyoff[1]=2;
|
||||
pskyoff[2]=1;
|
||||
pskyoff[3]=3;
|
||||
pskyoff[4]=4;
|
||||
pskyoff[5]=0;
|
||||
pskyoff[6]=2;
|
||||
pskyoff[7]=3;
|
||||
break;
|
||||
case CLOUDYOCEAN__STATIC:
|
||||
parallaxyscale = 65536L;
|
||||
break;
|
||||
case MOONSKY1__STATIC :
|
||||
pskyoff[6]=1;
|
||||
pskyoff[1]=2;
|
||||
pskyoff[4]=2;
|
||||
pskyoff[2]=3;
|
||||
break;
|
||||
case BIGORBIT1__STATIC: // orbit
|
||||
pskyoff[5]=1;
|
||||
pskyoff[6]=2;
|
||||
pskyoff[7]=3;
|
||||
pskyoff[2]=4;
|
||||
break;
|
||||
case LA__STATIC:
|
||||
parallaxyscale = 16384+1024;
|
||||
pskyoff[0]=1;
|
||||
pskyoff[1]=2;
|
||||
pskyoff[2]=1;
|
||||
pskyoff[3]=3;
|
||||
pskyoff[4]=4;
|
||||
pskyoff[5]=0;
|
||||
pskyoff[6]=2;
|
||||
pskyoff[7]=3;
|
||||
break;
|
||||
}
|
||||
|
||||
pskybits=3;
|
||||
|
@ -770,11 +770,11 @@ void prelevel(char g)
|
|||
|
||||
switch (sector[i].lotag)
|
||||
{
|
||||
case 20:
|
||||
case 22:
|
||||
if (sector[i].floorz > sector[i].ceilingz)
|
||||
sector[i].lotag |= 32768;
|
||||
continue;
|
||||
case 20:
|
||||
case 22:
|
||||
if (sector[i].floorz > sector[i].ceilingz)
|
||||
sector[i].lotag |= 32768;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sector[i].ceilingstat&1)
|
||||
|
@ -821,37 +821,37 @@ void prelevel(char g)
|
|||
}
|
||||
else switch (dynamictostatic[PN])
|
||||
{
|
||||
case GPSPEED__STATIC:
|
||||
sector[SECT].extra = SLT;
|
||||
deletesprite(i);
|
||||
break;
|
||||
case GPSPEED__STATIC:
|
||||
sector[SECT].extra = SLT;
|
||||
deletesprite(i);
|
||||
break;
|
||||
|
||||
case CYCLER__STATIC:
|
||||
if (numcyclers >= MAXCYCLERS)
|
||||
{
|
||||
Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS);
|
||||
gameexit(tempbuf);
|
||||
}
|
||||
cyclers[numcyclers][0] = SECT;
|
||||
cyclers[numcyclers][1] = SLT;
|
||||
cyclers[numcyclers][2] = SS;
|
||||
cyclers[numcyclers][3] = sector[SECT].floorshade;
|
||||
cyclers[numcyclers][4] = SHT;
|
||||
cyclers[numcyclers][5] = (SA == 1536);
|
||||
numcyclers++;
|
||||
deletesprite(i);
|
||||
break;
|
||||
case CYCLER__STATIC:
|
||||
if (numcyclers >= MAXCYCLERS)
|
||||
{
|
||||
Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS);
|
||||
gameexit(tempbuf);
|
||||
}
|
||||
cyclers[numcyclers][0] = SECT;
|
||||
cyclers[numcyclers][1] = SLT;
|
||||
cyclers[numcyclers][2] = SS;
|
||||
cyclers[numcyclers][3] = sector[SECT].floorshade;
|
||||
cyclers[numcyclers][4] = SHT;
|
||||
cyclers[numcyclers][5] = (SA == 1536);
|
||||
numcyclers++;
|
||||
deletesprite(i);
|
||||
break;
|
||||
|
||||
case SECTOREFFECTOR__STATIC:
|
||||
case ACTIVATOR__STATIC:
|
||||
case TOUCHPLATE__STATIC:
|
||||
case ACTIVATORLOCKED__STATIC:
|
||||
case MUSICANDSFX__STATIC:
|
||||
case LOCATORS__STATIC:
|
||||
case MASTERSWITCH__STATIC:
|
||||
case RESPAWN__STATIC:
|
||||
sprite[i].cstat = 0;
|
||||
break;
|
||||
case SECTOREFFECTOR__STATIC:
|
||||
case ACTIVATOR__STATIC:
|
||||
case TOUCHPLATE__STATIC:
|
||||
case ACTIVATORLOCKED__STATIC:
|
||||
case MUSICANDSFX__STATIC:
|
||||
case LOCATORS__STATIC:
|
||||
case MASTERSWITCH__STATIC:
|
||||
case RESPAWN__STATIC:
|
||||
sprite[i].cstat = 0;
|
||||
break;
|
||||
}
|
||||
i = nexti;
|
||||
}
|
||||
|
@ -880,39 +880,39 @@ void prelevel(char g)
|
|||
{
|
||||
switch (dynamictostatic[PN-1])
|
||||
{
|
||||
case DIPSWITCH__STATIC:
|
||||
case DIPSWITCH2__STATIC:
|
||||
case PULLSWITCH__STATIC:
|
||||
case HANDSWITCH__STATIC:
|
||||
case SLOTDOOR__STATIC:
|
||||
case LIGHTSWITCH__STATIC:
|
||||
case SPACELIGHTSWITCH__STATIC:
|
||||
case SPACEDOORSWITCH__STATIC:
|
||||
case FRANKENSTINESWITCH__STATIC:
|
||||
case LIGHTSWITCH2__STATIC:
|
||||
case POWERSWITCH1__STATIC:
|
||||
case LOCKSWITCH1__STATIC:
|
||||
case POWERSWITCH2__STATIC:
|
||||
for (j=0;j<lotaglist;j++)
|
||||
if (SLT == lotags[j])
|
||||
break;
|
||||
case DIPSWITCH__STATIC:
|
||||
case DIPSWITCH2__STATIC:
|
||||
case PULLSWITCH__STATIC:
|
||||
case HANDSWITCH__STATIC:
|
||||
case SLOTDOOR__STATIC:
|
||||
case LIGHTSWITCH__STATIC:
|
||||
case SPACELIGHTSWITCH__STATIC:
|
||||
case SPACEDOORSWITCH__STATIC:
|
||||
case FRANKENSTINESWITCH__STATIC:
|
||||
case LIGHTSWITCH2__STATIC:
|
||||
case POWERSWITCH1__STATIC:
|
||||
case LOCKSWITCH1__STATIC:
|
||||
case POWERSWITCH2__STATIC:
|
||||
for (j=0;j<lotaglist;j++)
|
||||
if (SLT == lotags[j])
|
||||
break;
|
||||
|
||||
if (j == lotaglist)
|
||||
if (j == lotaglist)
|
||||
{
|
||||
lotags[lotaglist] = SLT;
|
||||
lotaglist++;
|
||||
if (lotaglist > 64)
|
||||
gameexit("\nToo many switches (64 max).");
|
||||
|
||||
j = headspritestat[3];
|
||||
while (j >= 0)
|
||||
{
|
||||
lotags[lotaglist] = SLT;
|
||||
lotaglist++;
|
||||
if (lotaglist > 64)
|
||||
gameexit("\nToo many switches (64 max).");
|
||||
|
||||
j = headspritestat[3];
|
||||
while (j >= 0)
|
||||
{
|
||||
if (sprite[j].lotag == 12 && sprite[j].hitag == SLT)
|
||||
hittype[j].temp_data[0] = 1;
|
||||
j = nextspritestat[j];
|
||||
}
|
||||
if (sprite[j].lotag == 12 && sprite[j].hitag == SLT)
|
||||
hittype[j].temp_data[0] = 1;
|
||||
j = nextspritestat[j];
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
i = nextspritestat[i];
|
||||
}
|
||||
|
@ -956,105 +956,105 @@ void prelevel(char g)
|
|||
}
|
||||
switch (dynamictostatic[switchpicnum])
|
||||
{
|
||||
case FANSHADOW__STATIC:
|
||||
case FANSPRITE__STATIC:
|
||||
wall->cstat |= 65;
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
numanimwalls++;
|
||||
break;
|
||||
case FANSHADOW__STATIC:
|
||||
case FANSPRITE__STATIC:
|
||||
wall->cstat |= 65;
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
numanimwalls++;
|
||||
break;
|
||||
|
||||
case W_FORCEFIELD__STATIC:
|
||||
if (wal->overpicnum==W_FORCEFIELD__STATIC)
|
||||
for (j=0;j<3;j++)
|
||||
tloadtile(W_FORCEFIELD+j, 0);
|
||||
if (wal->shade > 31)
|
||||
wal->cstat = 0;
|
||||
else wal->cstat |= 85+256;
|
||||
case W_FORCEFIELD__STATIC:
|
||||
if (wal->overpicnum==W_FORCEFIELD__STATIC)
|
||||
for (j=0;j<3;j++)
|
||||
tloadtile(W_FORCEFIELD+j, 0);
|
||||
if (wal->shade > 31)
|
||||
wal->cstat = 0;
|
||||
else wal->cstat |= 85+256;
|
||||
|
||||
|
||||
if (wal->lotag && wal->nextwall >= 0)
|
||||
wall[wal->nextwall].lotag =
|
||||
wal->lotag;
|
||||
if (wal->lotag && wal->nextwall >= 0)
|
||||
wall[wal->nextwall].lotag =
|
||||
wal->lotag;
|
||||
|
||||
case BIGFORCE__STATIC:
|
||||
case BIGFORCE__STATIC:
|
||||
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
numanimwalls++;
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
numanimwalls++;
|
||||
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
wal->extra = -1;
|
||||
|
||||
switch (dynamictostatic[wal->picnum])
|
||||
{
|
||||
case WATERTILE2__STATIC:
|
||||
for (j=0;j<3;j++)
|
||||
tloadtile(wal->picnum+j, 0);
|
||||
break;
|
||||
case WATERTILE2__STATIC:
|
||||
for (j=0;j<3;j++)
|
||||
tloadtile(wal->picnum+j, 0);
|
||||
break;
|
||||
|
||||
case TECHLIGHT2__STATIC:
|
||||
case TECHLIGHT4__STATIC:
|
||||
tloadtile(wal->picnum, 0);
|
||||
break;
|
||||
case W_TECHWALL1__STATIC:
|
||||
case W_TECHWALL2__STATIC:
|
||||
case W_TECHWALL3__STATIC:
|
||||
case W_TECHWALL4__STATIC:
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
// animwall[numanimwalls].tag = -1;
|
||||
numanimwalls++;
|
||||
break;
|
||||
case SCREENBREAK6__STATIC:
|
||||
case SCREENBREAK7__STATIC:
|
||||
case SCREENBREAK8__STATIC:
|
||||
for (j=SCREENBREAK6;j<SCREENBREAK9;j++)
|
||||
tloadtile(j, 0);
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
animwall[numanimwalls].tag = -1;
|
||||
numanimwalls++;
|
||||
break;
|
||||
case TECHLIGHT2__STATIC:
|
||||
case TECHLIGHT4__STATIC:
|
||||
tloadtile(wal->picnum, 0);
|
||||
break;
|
||||
case W_TECHWALL1__STATIC:
|
||||
case W_TECHWALL2__STATIC:
|
||||
case W_TECHWALL3__STATIC:
|
||||
case W_TECHWALL4__STATIC:
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
// animwall[numanimwalls].tag = -1;
|
||||
numanimwalls++;
|
||||
break;
|
||||
case SCREENBREAK6__STATIC:
|
||||
case SCREENBREAK7__STATIC:
|
||||
case SCREENBREAK8__STATIC:
|
||||
for (j=SCREENBREAK6;j<SCREENBREAK9;j++)
|
||||
tloadtile(j, 0);
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
animwall[numanimwalls].tag = -1;
|
||||
numanimwalls++;
|
||||
break;
|
||||
|
||||
case FEMPIC1__STATIC:
|
||||
case FEMPIC2__STATIC:
|
||||
case FEMPIC3__STATIC:
|
||||
case FEMPIC1__STATIC:
|
||||
case FEMPIC2__STATIC:
|
||||
case FEMPIC3__STATIC:
|
||||
|
||||
wal->extra = wal->picnum;
|
||||
animwall[numanimwalls].tag = -1;
|
||||
if (ud.lockout)
|
||||
{
|
||||
if (wal->picnum == FEMPIC1)
|
||||
wal->picnum = BLANKSCREEN;
|
||||
else wal->picnum = SCREENBREAK6;
|
||||
}
|
||||
wal->extra = wal->picnum;
|
||||
animwall[numanimwalls].tag = -1;
|
||||
if (ud.lockout)
|
||||
{
|
||||
if (wal->picnum == FEMPIC1)
|
||||
wal->picnum = BLANKSCREEN;
|
||||
else wal->picnum = SCREENBREAK6;
|
||||
}
|
||||
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
animwall[numanimwalls].tag = wal->picnum;
|
||||
numanimwalls++;
|
||||
break;
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
animwall[numanimwalls].tag = wal->picnum;
|
||||
numanimwalls++;
|
||||
break;
|
||||
|
||||
case SCREENBREAK1__STATIC:
|
||||
case SCREENBREAK2__STATIC:
|
||||
case SCREENBREAK3__STATIC:
|
||||
case SCREENBREAK4__STATIC:
|
||||
case SCREENBREAK5__STATIC:
|
||||
case SCREENBREAK1__STATIC:
|
||||
case SCREENBREAK2__STATIC:
|
||||
case SCREENBREAK3__STATIC:
|
||||
case SCREENBREAK4__STATIC:
|
||||
case SCREENBREAK5__STATIC:
|
||||
|
||||
case SCREENBREAK9__STATIC:
|
||||
case SCREENBREAK10__STATIC:
|
||||
case SCREENBREAK11__STATIC:
|
||||
case SCREENBREAK12__STATIC:
|
||||
case SCREENBREAK13__STATIC:
|
||||
case SCREENBREAK14__STATIC:
|
||||
case SCREENBREAK15__STATIC:
|
||||
case SCREENBREAK16__STATIC:
|
||||
case SCREENBREAK17__STATIC:
|
||||
case SCREENBREAK18__STATIC:
|
||||
case SCREENBREAK19__STATIC:
|
||||
case SCREENBREAK9__STATIC:
|
||||
case SCREENBREAK10__STATIC:
|
||||
case SCREENBREAK11__STATIC:
|
||||
case SCREENBREAK12__STATIC:
|
||||
case SCREENBREAK13__STATIC:
|
||||
case SCREENBREAK14__STATIC:
|
||||
case SCREENBREAK15__STATIC:
|
||||
case SCREENBREAK16__STATIC:
|
||||
case SCREENBREAK17__STATIC:
|
||||
case SCREENBREAK18__STATIC:
|
||||
case SCREENBREAK19__STATIC:
|
||||
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
animwall[numanimwalls].tag = wal->picnum;
|
||||
numanimwalls++;
|
||||
break;
|
||||
animwall[numanimwalls].wallnum = i;
|
||||
animwall[numanimwalls].tag = wal->picnum;
|
||||
numanimwalls++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1320,12 +1320,12 @@ void resetpspritevars(char g)
|
|||
{
|
||||
switch (ud.pteam[j])
|
||||
{
|
||||
case 0:
|
||||
k = 3;
|
||||
break;
|
||||
case 1:
|
||||
k = 21;
|
||||
break;
|
||||
case 0:
|
||||
k = 3;
|
||||
break;
|
||||
case 1:
|
||||
k = 21;
|
||||
break;
|
||||
}
|
||||
ps[j].team = ud.pteam[j];
|
||||
}
|
||||
|
@ -1738,16 +1738,16 @@ int enterlevel(char g)
|
|||
for (i=connecthead;i>=0;i=connectpoint2[i])
|
||||
switch (dynamictostatic[sector[sprite[ps[i].i].sectnum].floorpicnum])
|
||||
{
|
||||
case HURTRAIL__STATIC:
|
||||
case FLOORSLIME__STATIC:
|
||||
case FLOORPLASMA__STATIC:
|
||||
resetweapons(i);
|
||||
resetinventory(i);
|
||||
ps[i].gotweapon[PISTOL_WEAPON] = 0;
|
||||
ps[i].ammo_amount[PISTOL_WEAPON] = 0;
|
||||
ps[i].curr_weapon = KNEE_WEAPON;
|
||||
ps[i].kickback_pic = 0;
|
||||
break;
|
||||
case HURTRAIL__STATIC:
|
||||
case FLOORSLIME__STATIC:
|
||||
case FLOORPLASMA__STATIC:
|
||||
resetweapons(i);
|
||||
resetinventory(i);
|
||||
ps[i].gotweapon[PISTOL_WEAPON] = 0;
|
||||
ps[i].ammo_amount[PISTOL_WEAPON] = 0;
|
||||
ps[i].curr_weapon = KNEE_WEAPON;
|
||||
ps[i].kickback_pic = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
//PREMAP.C - replace near the my's at the end of the file
|
||||
|
|
|
@ -379,13 +379,13 @@ int loadplayer(signed char spot)
|
|||
for (x=0;x<numanimwalls;x++)
|
||||
switch (dynamictostatic[wall[animwall[x].wallnum].picnum])
|
||||
{
|
||||
case FEMPIC1__STATIC:
|
||||
wall[animwall[x].wallnum].picnum = BLANKSCREEN;
|
||||
break;
|
||||
case FEMPIC2__STATIC:
|
||||
case FEMPIC3__STATIC:
|
||||
wall[animwall[x].wallnum].picnum = SCREENBREAK6;
|
||||
break;
|
||||
case FEMPIC1__STATIC:
|
||||
wall[animwall[x].wallnum].picnum = BLANKSCREEN;
|
||||
break;
|
||||
case FEMPIC2__STATIC:
|
||||
case FEMPIC3__STATIC:
|
||||
wall[animwall[x].wallnum].picnum = SCREENBREAK6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,31 +397,31 @@ int loadplayer(signed char spot)
|
|||
{
|
||||
switch (sprite[k].lotag)
|
||||
{
|
||||
case 31:
|
||||
setinterpolation(§or[sprite[k].sectnum].floorz);
|
||||
break;
|
||||
case 32:
|
||||
setinterpolation(§or[sprite[k].sectnum].ceilingz);
|
||||
break;
|
||||
case 25:
|
||||
setinterpolation(§or[sprite[k].sectnum].floorz);
|
||||
setinterpolation(§or[sprite[k].sectnum].ceilingz);
|
||||
break;
|
||||
case 17:
|
||||
setinterpolation(§or[sprite[k].sectnum].floorz);
|
||||
setinterpolation(§or[sprite[k].sectnum].ceilingz);
|
||||
break;
|
||||
case 0:
|
||||
case 5:
|
||||
case 6:
|
||||
case 11:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case 26:
|
||||
case 30:
|
||||
setsectinterpolate(k);
|
||||
break;
|
||||
case 31:
|
||||
setinterpolation(§or[sprite[k].sectnum].floorz);
|
||||
break;
|
||||
case 32:
|
||||
setinterpolation(§or[sprite[k].sectnum].ceilingz);
|
||||
break;
|
||||
case 25:
|
||||
setinterpolation(§or[sprite[k].sectnum].floorz);
|
||||
setinterpolation(§or[sprite[k].sectnum].ceilingz);
|
||||
break;
|
||||
case 17:
|
||||
setinterpolation(§or[sprite[k].sectnum].floorz);
|
||||
setinterpolation(§or[sprite[k].sectnum].ceilingz);
|
||||
break;
|
||||
case 0:
|
||||
case 5:
|
||||
case 6:
|
||||
case 11:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case 26:
|
||||
case 30:
|
||||
setsectinterpolate(k);
|
||||
break;
|
||||
}
|
||||
|
||||
k = nextspritestat[k];
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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)
|
||||
|
@ -318,20 +328,20 @@ int xyzsound(short num,short i,long x,long y,long z)
|
|||
|
||||
switch (num)
|
||||
{
|
||||
case PIPEBOMB_EXPLODE:
|
||||
case LASERTRIP_EXPLODE:
|
||||
case RPG_EXPLODE:
|
||||
if (sndist > (6144))
|
||||
sndist = 6144;
|
||||
if (sector[ps[screenpeek].cursectnum].lotag == 2)
|
||||
pitch -= 1024;
|
||||
break;
|
||||
default:
|
||||
if (sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0)
|
||||
pitch = -768;
|
||||
if (sndist > 31444 && PN != MUSICANDSFX)
|
||||
return -1;
|
||||
break;
|
||||
case PIPEBOMB_EXPLODE:
|
||||
case LASERTRIP_EXPLODE:
|
||||
case RPG_EXPLODE:
|
||||
if (sndist > (6144))
|
||||
sndist = 6144;
|
||||
if (sector[ps[screenpeek].cursectnum].lotag == 2)
|
||||
pitch -= 1024;
|
||||
break;
|
||||
default:
|
||||
if (sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0)
|
||||
pitch = -768;
|
||||
if (sndist > 31444 && PN != MUSICANDSFX)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ps[screenpeek].sound_pitch) pitch += ps[screenpeek].sound_pitch;
|
||||
|
@ -558,17 +568,17 @@ void pan3dsound(void)
|
|||
|
||||
switch (j)
|
||||
{
|
||||
case PIPEBOMB_EXPLODE:
|
||||
case LASERTRIP_EXPLODE:
|
||||
case RPG_EXPLODE:
|
||||
if (sndist > (6144)) sndist = (6144);
|
||||
break;
|
||||
default:
|
||||
if (sndist > 31444 && PN != MUSICANDSFX)
|
||||
{
|
||||
stopsound(j);
|
||||
continue;
|
||||
}
|
||||
case PIPEBOMB_EXPLODE:
|
||||
case LASERTRIP_EXPLODE:
|
||||
case RPG_EXPLODE:
|
||||
if (sndist > (6144)) sndist = (6144);
|
||||
break;
|
||||
default:
|
||||
if (sndist > 31444 && PN != MUSICANDSFX)
|
||||
{
|
||||
stopsound(j);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (Sound[j].ptr == 0 && loadsound(j) == 0) continue;
|
||||
|
|
|
@ -558,31 +558,31 @@ int startwin_puts(const char *str)
|
|||
{
|
||||
switch (*bptr)
|
||||
{
|
||||
case '\b':
|
||||
if (bptr > aptr)
|
||||
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
|
||||
case '\b':
|
||||
if (bptr > aptr)
|
||||
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
|
||||
#if GTK_CHECK_VERSION(2,6,0)
|
||||
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
|
||||
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
|
||||
#else
|
||||
{
|
||||
GtkTextIter iter2 = enditer;
|
||||
gtk_text_iter_backward_cursor_position(&iter2);
|
||||
//FIXME: this seems be deleting one too many chars somewhere!
|
||||
if (!gtk_text_iter_equal(&iter2, &enditer))
|
||||
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
|
||||
}
|
||||
{
|
||||
GtkTextIter iter2 = enditer;
|
||||
gtk_text_iter_backward_cursor_position(&iter2);
|
||||
//FIXME: this seems be deleting one too many chars somewhere!
|
||||
if (!gtk_text_iter_equal(&iter2, &enditer))
|
||||
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
|
||||
}
|
||||
#endif
|
||||
aptr = ++bptr;
|
||||
break;
|
||||
case 0:
|
||||
if (bptr > aptr)
|
||||
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
|
||||
aptr = bptr;
|
||||
break;
|
||||
case '\r': // FIXME
|
||||
default:
|
||||
bptr++;
|
||||
break;
|
||||
aptr = ++bptr;
|
||||
break;
|
||||
case 0:
|
||||
if (bptr > aptr)
|
||||
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
|
||||
aptr = bptr;
|
||||
break;
|
||||
case '\r': // FIXME
|
||||
default:
|
||||
bptr++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,42 +153,42 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
|
|||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDCFULLSCREEN:
|
||||
settings.fullscreen = !settings.fullscreen;
|
||||
PopulateForm(POPULATE_VIDEO);
|
||||
return TRUE;
|
||||
case IDCVMODE:
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||
{
|
||||
case IDCFULLSCREEN:
|
||||
settings.fullscreen = !settings.fullscreen;
|
||||
PopulateForm(POPULATE_VIDEO);
|
||||
return TRUE;
|
||||
case IDCVMODE:
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||
{
|
||||
int i;
|
||||
i = ComboBox_GetCurSel((HWND)lParam);
|
||||
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
|
||||
if (i != CB_ERR)
|
||||
{
|
||||
settings.xdim = validmode[i].xdim;
|
||||
settings.ydim = validmode[i].ydim;
|
||||
settings.bpp = validmode[i].bpp;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
case IDCALWAYSSHOW:
|
||||
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
|
||||
return TRUE;
|
||||
case IDCINPUTMOUSE:
|
||||
settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED;
|
||||
return TRUE;
|
||||
case IDCINPUTJOY:
|
||||
settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
int i;
|
||||
i = ComboBox_GetCurSel((HWND)lParam);
|
||||
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
|
||||
if (i != CB_ERR)
|
||||
{
|
||||
settings.xdim = validmode[i].xdim;
|
||||
settings.ydim = validmode[i].ydim;
|
||||
settings.bpp = validmode[i].bpp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
return TRUE;
|
||||
case IDCALWAYSSHOW:
|
||||
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
|
||||
return TRUE;
|
||||
case IDCINPUTMOUSE:
|
||||
settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED;
|
||||
return TRUE;
|
||||
case IDCINPUTJOY:
|
||||
settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -197,28 +197,28 @@ static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
|
|||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDGDATA:
|
||||
{
|
||||
int i;
|
||||
if (HIWORD(wParam) != LBN_SELCHANGE) break;
|
||||
i = ListBox_GetCurSel((HWND)lParam);
|
||||
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
|
||||
if (i != CB_ERR)
|
||||
{
|
||||
case IDGDATA:
|
||||
{
|
||||
int i;
|
||||
if (HIWORD(wParam) != LBN_SELCHANGE) break;
|
||||
i = ListBox_GetCurSel((HWND)lParam);
|
||||
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
|
||||
if (i != CB_ERR)
|
||||
{
|
||||
strcpy(settings.selectedgrp, ((struct grpfile*)i)->name);
|
||||
settings.game = ((struct grpfile*)i)->game;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
strcpy(settings.selectedgrp, ((struct grpfile*)i)->name);
|
||||
settings.game = ((struct grpfile*)i)->game;
|
||||
}
|
||||
break;
|
||||
return TRUE;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -258,204 +258,204 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
|
|||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
HWND hwnd;
|
||||
RECT r, rdlg, chrome, rtab, rcancel, rstart;
|
||||
int xoffset = 0, yoffset = 0;
|
||||
|
||||
// Fetch the positions (in screen coordinates) of all the windows we need to tweak
|
||||
ZeroMemory(&chrome, sizeof(chrome));
|
||||
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
|
||||
GetWindowRect(hwndDlg, &rdlg);
|
||||
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
|
||||
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
|
||||
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
|
||||
|
||||
// Knock off the non-client area of the main dialogue to give just the client area
|
||||
rdlg.left -= chrome.left;
|
||||
rdlg.top -= chrome.top;
|
||||
rdlg.right -= chrome.right;
|
||||
rdlg.bottom -= chrome.bottom;
|
||||
|
||||
// Translate them to client-relative coordinates wrt the main dialogue window
|
||||
rtab.right -= rtab.left - 1;
|
||||
rtab.bottom -= rtab.top - 1;
|
||||
rtab.left -= rdlg.left;
|
||||
rtab.top -= rdlg.top;
|
||||
|
||||
rcancel.right -= rcancel.left - 1;
|
||||
rcancel.bottom -= rcancel.top - 1;
|
||||
rcancel.left -= rdlg.left;
|
||||
rcancel.top -= rdlg.top;
|
||||
|
||||
rstart.right -= rstart.left - 1;
|
||||
rstart.bottom -= rstart.top - 1;
|
||||
rstart.left -= rdlg.left;
|
||||
rstart.top -= rdlg.top;
|
||||
|
||||
// And then convert the main dialogue coordinates to just width/length
|
||||
rdlg.right -= rdlg.left - 1;
|
||||
rdlg.bottom -= rdlg.top - 1;
|
||||
rdlg.left = 0;
|
||||
rdlg.top = 0;
|
||||
|
||||
// Load the bitmap into the bitmap control and fetch its dimensions
|
||||
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
|
||||
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
|
||||
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
|
||||
GetClientRect(hwnd, &r);
|
||||
xoffset = r.right;
|
||||
yoffset = r.bottom - rdlg.bottom;
|
||||
|
||||
// Shift and resize the controls that require it
|
||||
rtab.left += xoffset;
|
||||
rtab.bottom += yoffset;
|
||||
rcancel.left += xoffset;
|
||||
rcancel.top += yoffset;
|
||||
rstart.left += xoffset;
|
||||
rstart.top += yoffset;
|
||||
rdlg.right += xoffset;
|
||||
rdlg.bottom += yoffset;
|
||||
|
||||
// Move the controls to their new positions
|
||||
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
|
||||
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
|
||||
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
|
||||
|
||||
// Move the main dialogue to the centre of the screen
|
||||
hdc = GetDC(NULL);
|
||||
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
|
||||
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
|
||||
ReleaseDC(NULL, hdc);
|
||||
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
|
||||
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
|
||||
|
||||
// Add tabs to the tab control
|
||||
{
|
||||
HWND hwnd;
|
||||
RECT r, rdlg, chrome, rtab, rcancel, rstart;
|
||||
int xoffset = 0, yoffset = 0;
|
||||
TCITEM tab;
|
||||
|
||||
// Fetch the positions (in screen coordinates) of all the windows we need to tweak
|
||||
ZeroMemory(&chrome, sizeof(chrome));
|
||||
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
|
||||
GetWindowRect(hwndDlg, &rdlg);
|
||||
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
|
||||
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
|
||||
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
|
||||
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
|
||||
|
||||
// Knock off the non-client area of the main dialogue to give just the client area
|
||||
rdlg.left -= chrome.left;
|
||||
rdlg.top -= chrome.top;
|
||||
rdlg.right -= chrome.right;
|
||||
rdlg.bottom -= chrome.bottom;
|
||||
ZeroMemory(&tab, sizeof(tab));
|
||||
tab.mask = TCIF_TEXT;
|
||||
tab.pszText = TEXT("Configuration");
|
||||
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
|
||||
tab.mask = TCIF_TEXT;
|
||||
tab.pszText = TEXT("Game");
|
||||
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab);
|
||||
tab.mask = TCIF_TEXT;
|
||||
tab.pszText = TEXT("Messages");
|
||||
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
|
||||
|
||||
// Translate them to client-relative coordinates wrt the main dialogue window
|
||||
rtab.right -= rtab.left - 1;
|
||||
rtab.bottom -= rtab.top - 1;
|
||||
rtab.left -= rdlg.left;
|
||||
rtab.top -= rdlg.top;
|
||||
|
||||
rcancel.right -= rcancel.left - 1;
|
||||
rcancel.bottom -= rcancel.top - 1;
|
||||
rcancel.left -= rdlg.left;
|
||||
rcancel.top -= rdlg.top;
|
||||
|
||||
rstart.right -= rstart.left - 1;
|
||||
rstart.bottom -= rstart.top - 1;
|
||||
rstart.left -= rdlg.left;
|
||||
rstart.top -= rdlg.top;
|
||||
|
||||
// And then convert the main dialogue coordinates to just width/length
|
||||
rdlg.right -= rdlg.left - 1;
|
||||
rdlg.bottom -= rdlg.top - 1;
|
||||
rdlg.left = 0;
|
||||
rdlg.top = 0;
|
||||
|
||||
// Load the bitmap into the bitmap control and fetch its dimensions
|
||||
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
|
||||
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
|
||||
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
|
||||
// Work out the position and size of the area inside the tab control for the pages
|
||||
ZeroMemory(&r, sizeof(r));
|
||||
GetClientRect(hwnd, &r);
|
||||
xoffset = r.right;
|
||||
yoffset = r.bottom - rdlg.bottom;
|
||||
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
|
||||
r.right -= r.left-1;
|
||||
r.bottom -= r.top-1;
|
||||
r.top += rtab.top;
|
||||
r.left += rtab.left;
|
||||
|
||||
// Shift and resize the controls that require it
|
||||
rtab.left += xoffset;
|
||||
rtab.bottom += yoffset;
|
||||
rcancel.left += xoffset;
|
||||
rcancel.top += yoffset;
|
||||
rstart.left += xoffset;
|
||||
rstart.top += yoffset;
|
||||
rdlg.right += xoffset;
|
||||
rdlg.bottom += yoffset;
|
||||
// Create the pages and position them in the tab control, but hide them
|
||||
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
|
||||
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
|
||||
pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(),
|
||||
MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc);
|
||||
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
|
||||
SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
|
||||
SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
|
||||
SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
|
||||
|
||||
// Move the controls to their new positions
|
||||
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
|
||||
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
|
||||
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
|
||||
// Tell the editfield acting as the console to exclude the width of the scrollbar
|
||||
GetClientRect(pages[TAB_MESSAGES],&r);
|
||||
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
|
||||
r.left = r.top = 0;
|
||||
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
|
||||
|
||||
// Move the main dialogue to the centre of the screen
|
||||
hdc = GetDC(NULL);
|
||||
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
|
||||
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
|
||||
ReleaseDC(NULL, hdc);
|
||||
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
|
||||
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
|
||||
|
||||
// Add tabs to the tab control
|
||||
// Set a tab stop in the game data listbox
|
||||
{
|
||||
TCITEM tab;
|
||||
|
||||
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
|
||||
|
||||
ZeroMemory(&tab, sizeof(tab));
|
||||
tab.mask = TCIF_TEXT;
|
||||
tab.pszText = TEXT("Configuration");
|
||||
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
|
||||
tab.mask = TCIF_TEXT;
|
||||
tab.pszText = TEXT("Game");
|
||||
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab);
|
||||
tab.mask = TCIF_TEXT;
|
||||
tab.pszText = TEXT("Messages");
|
||||
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
|
||||
|
||||
// Work out the position and size of the area inside the tab control for the pages
|
||||
ZeroMemory(&r, sizeof(r));
|
||||
GetClientRect(hwnd, &r);
|
||||
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
|
||||
r.right -= r.left-1;
|
||||
r.bottom -= r.top-1;
|
||||
r.top += rtab.top;
|
||||
r.left += rtab.left;
|
||||
|
||||
// Create the pages and position them in the tab control, but hide them
|
||||
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
|
||||
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
|
||||
pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(),
|
||||
MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc);
|
||||
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
|
||||
SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
|
||||
SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
|
||||
SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
|
||||
|
||||
// Tell the editfield acting as the console to exclude the width of the scrollbar
|
||||
GetClientRect(pages[TAB_MESSAGES],&r);
|
||||
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
|
||||
r.left = r.top = 0;
|
||||
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
|
||||
|
||||
// Set a tab stop in the game data listbox
|
||||
{
|
||||
DWORD tabs[1] = { 150 };
|
||||
ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs);
|
||||
}
|
||||
|
||||
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
|
||||
SetWindowText(hwndDlg, apptitle);
|
||||
DWORD tabs[1] = { 150 };
|
||||
ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
case WM_NOTIFY:
|
||||
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
|
||||
SetWindowText(hwndDlg, apptitle);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR nmhdr = (LPNMHDR)lParam;
|
||||
int cur;
|
||||
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
|
||||
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
|
||||
switch (nmhdr->code)
|
||||
{
|
||||
LPNMHDR nmhdr = (LPNMHDR)lParam;
|
||||
int cur;
|
||||
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
|
||||
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
|
||||
switch (nmhdr->code)
|
||||
{
|
||||
case TCN_SELCHANGING:
|
||||
{
|
||||
if (cur < 0 || !pages[cur]) break;
|
||||
ShowWindow(pages[cur],SW_HIDE);
|
||||
return TRUE;
|
||||
}
|
||||
case TCN_SELCHANGE:
|
||||
{
|
||||
if (cur < 0 || !pages[cur]) break;
|
||||
ShowWindow(pages[cur],SW_SHOW);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TCN_SELCHANGING:
|
||||
{
|
||||
if (cur < 0 || !pages[cur]) break;
|
||||
ShowWindow(pages[cur],SW_HIDE);
|
||||
return TRUE;
|
||||
}
|
||||
case TCN_SELCHANGE:
|
||||
{
|
||||
if (cur < 0 || !pages[cur]) break;
|
||||
ShowWindow(pages[cur],SW_SHOW);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_CLOSE:
|
||||
if (mode == TAB_CONFIG) done = 0;
|
||||
else quitevent++;
|
||||
return TRUE;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (hbmp)
|
||||
{
|
||||
DeleteObject(hbmp);
|
||||
hbmp = NULL;
|
||||
}
|
||||
|
||||
case WM_CLOSE:
|
||||
if (pages[TAB_GAME])
|
||||
{
|
||||
DestroyWindow(pages[TAB_GAME]);
|
||||
pages[TAB_GAME] = NULL;
|
||||
}
|
||||
|
||||
if (pages[TAB_CONFIG])
|
||||
{
|
||||
DestroyWindow(pages[TAB_CONFIG]);
|
||||
pages[TAB_CONFIG] = NULL;
|
||||
}
|
||||
|
||||
startupdlg = NULL;
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case WIN_STARTWIN_CANCEL:
|
||||
if (mode == TAB_CONFIG) done = 0;
|
||||
else quitevent++;
|
||||
return TRUE;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (hbmp)
|
||||
{
|
||||
DeleteObject(hbmp);
|
||||
hbmp = NULL;
|
||||
}
|
||||
|
||||
if (pages[TAB_GAME])
|
||||
{
|
||||
DestroyWindow(pages[TAB_GAME]);
|
||||
pages[TAB_GAME] = NULL;
|
||||
}
|
||||
|
||||
if (pages[TAB_CONFIG])
|
||||
{
|
||||
DestroyWindow(pages[TAB_CONFIG]);
|
||||
pages[TAB_CONFIG] = NULL;
|
||||
}
|
||||
|
||||
startupdlg = NULL;
|
||||
case WIN_STARTWIN_START:
|
||||
done = 1;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case WIN_STARTWIN_CANCEL:
|
||||
if (mode == TAB_CONFIG) done = 0;
|
||||
else quitevent++;
|
||||
return TRUE;
|
||||
case WIN_STARTWIN_START:
|
||||
done = 1;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
case WM_CTLCOLORSTATIC:
|
||||
if ((HWND)lParam == pages[TAB_MESSAGES])
|
||||
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
|
||||
break;
|
||||
|
||||
case WM_CTLCOLORSTATIC:
|
||||
if ((HWND)lParam == pages[TAB_MESSAGES])
|
||||
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -590,16 +590,16 @@ int startwin_run(void)
|
|||
{
|
||||
switch (GetMessage(&msg, NULL, 0,0))
|
||||
{
|
||||
case 0:
|
||||
done = 1;
|
||||
break;
|
||||
case -1:
|
||||
return -1;
|
||||
default:
|
||||
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
break;
|
||||
case 0:
|
||||
done = 1;
|
||||
break;
|
||||
case -1:
|
||||
return -1;
|
||||
default:
|
||||
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue