git-svn-id: https://svn.eduke32.com/eduke32@642 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2008-03-14 21:04:28 +00:00
parent 9fc846754f
commit 02c5d0b87b
11 changed files with 87 additions and 153 deletions

View file

@ -15,7 +15,7 @@ BUILD32_ON_64 = 0
# Debugging options # Debugging options
RELEASE?=1 RELEASE?=1
NOSOUND?=0 NOSOUND?=0
USE_OPENAL?=0 USE_OPENAL?=1
# build locations # build locations
@ -82,10 +82,6 @@ AUDIOLIB_FX_SDL=$(OBJ)/ll_man.$o \
$(OBJ)/pitch.$o \ $(OBJ)/pitch.$o \
$(OBJ)/multivoc.$o $(OBJ)/multivoc.$o
ifeq ($(USE_OPENAL),1)
AUDIOLIB_FX_SDL += $(OBJ)/openal.$o
endif
AUDIOLIB_MUSIC_SDL=$(OBJ)/sdlmusic.$o AUDIOLIB_MUSIC_SDL=$(OBJ)/sdlmusic.$o
AUDIOLIB_FX=$(OBJ)/pitch.$o \ AUDIOLIB_FX=$(OBJ)/pitch.$o \

View file

@ -5379,7 +5379,7 @@ int spawn(int j, int pn)
break; break;
case WATERDRIP__STATIC: case WATERDRIP__STATIC:
if ((j >= 0 && sprite[j].statnum == 10) || sprite[j].statnum == 1) if (j >= 0 && (sprite[j].statnum == 10 || sprite[j].statnum == 1))
{ {
sp->shade = 32; sp->shade = 32;
if (sprite[j].pal != 1) if (sprite[j].pal != 1)
@ -7995,7 +7995,7 @@ static void nonsharedkeys(void)
if (playmusicMAP(&map[(unsigned char)music_select].musicfn[0],music_select)) if (playmusicMAP(&map[(unsigned char)music_select].musicfn[0],music_select))
Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn1[0]); Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn1[0]);
else else
Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn1[0]); Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn[0]);
FTA(26,g_player[myconnectindex].ps); FTA(26,g_player[myconnectindex].ps);
} }
return; return;
@ -8806,7 +8806,7 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
break; break;
} }
#ifdef USE_OPENAL
i = pathsearchmode; i = pathsearchmode;
pathsearchmode = 1; pathsearchmode = 1;
if (findfrompath(fn,&tfn) < 0) if (findfrompath(fn,&tfn) < 0)
@ -8827,7 +8827,6 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
if (AL_DefineMusic(ID,fn)) if (AL_DefineMusic(ID,fn))
initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
#endif
} }
} }
break; break;

View file

@ -442,6 +442,7 @@ static const char *keyw[] =
"digitalnumberz", // 312 "digitalnumberz", // 312
"spritenopal", // 313 "spritenopal", // 313
"hitradiusvar", // 314 "hitradiusvar", // 314
"rotatesprite16", // 315
"<null>" "<null>"
}; };
@ -3528,6 +3529,7 @@ static int parsecommand(void)
transvar(); transvar();
return 0; return 0;
case CON_ROTATESPRITE16:
case CON_ROTATESPRITE: case CON_ROTATESPRITE:
if (parsing_event == 0 && parsing_state == 0) if (parsing_event == 0 && parsing_state == 0)
{ {

View file

@ -799,5 +799,6 @@ enum keywords
CON_DIGITALNUMBERZ, // 312 CON_DIGITALNUMBERZ, // 312
CON_SPRITENOPAL, // 313 CON_SPRITENOPAL, // 313
CON_HITRADIUSVAR, // 314 CON_HITRADIUSVAR, // 314
CON_ROTATESPRITE16, // 315
END END
}; };

View file

@ -5601,6 +5601,7 @@ static int parse(void)
break; break;
} }
case CON_ROTATESPRITE16:
case CON_ROTATESPRITE: case CON_ROTATESPRITE:
insptr++; insptr++;
{ {
@ -5610,7 +5611,8 @@ static int parse(void)
int x1=GetGameVarID(*insptr++,g_i,g_p), y1=GetGameVarID(*insptr++,g_i,g_p); int x1=GetGameVarID(*insptr++,g_i,g_p), y1=GetGameVarID(*insptr++,g_i,g_p);
int x2=GetGameVarID(*insptr++,g_i,g_p), y2=GetGameVarID(*insptr++,g_i,g_p); int x2=GetGameVarID(*insptr++,g_i,g_p), y2=GetGameVarID(*insptr++,g_i,g_p);
rotatesprite(x<<16,y<<16,z,a,tilenum,shade,pal,2|orientation,x1,y1,x2,y2); if (tw == CON_ROTATESPRITE){x<<=16;y<<=16;}
rotatesprite(x,y,z,a,tilenum,shade,pal,2|orientation,x1,y1,x2,y2);
break; break;
} }
@ -6298,7 +6300,7 @@ static int parse(void)
} }
if (fta_quotes[sq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,sq); if (fta_quotes[sq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,sq);
if (fta_quotes[dq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,dq); if (fta_quotes[dq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,dq);
insptr += 5; insptr += 4;
break; break;
} }

View file

@ -25,9 +25,6 @@ Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu)
#include "dsl.h" #include "dsl.h"
#include "compat.h" #include "compat.h"
#ifdef USE_OPENAL
#include "openal.h"
#endif
#include "SDL.h" #include "SDL.h"
#include "SDL_mixer.h" #include "SDL_mixer.h"
@ -118,10 +115,6 @@ static void mixer_callback(int chan, void *stream, int len, void *udata)
/* len should equal _BufferSize, else this is screwed up */ /* len should equal _BufferSize, else this is screwed up */
#ifdef USE_OPENAL
AL_Update();
#endif
stptr = (Uint8 *)stream; stptr = (Uint8 *)stream;
if (_remainder > 0) if (_remainder > 0)

View file

@ -39,6 +39,9 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
#include <duke3d.h> #include <duke3d.h>
#ifdef _WIN32 #ifdef _WIN32
#include "dsoundout.h" #include "dsoundout.h"
#ifdef USE_OPENAL
#include "openal.h"
#endif
#else #else
#include "dsl.h" #include "dsl.h"
#endif #endif
@ -49,9 +52,6 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
#include "pitch.h" #include "pitch.h"
#include "multivoc.h" #include "multivoc.h"
#include "_multivc.h" #include "_multivc.h"
#ifdef USE_OPENAL
#include "openal.h"
#endif
#define STEREO 1 #define STEREO 1
#define SIXTEEN_BIT 2 #define SIXTEEN_BIT 2
@ -2865,6 +2865,7 @@ int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, int sampleb
MV_SetReverseStereo(FALSE); MV_SetReverseStereo(FALSE);
// Initialize the sound card // Initialize the sound card
#if defined(_WIN32)
#ifdef USE_OPENAL #ifdef USE_OPENAL
if (AL_Init()) if (AL_Init())
{ {
@ -2879,7 +2880,7 @@ int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, int sampleb
} }
} }
#endif #endif
#if defined(_WIN32)
status = DSOUND_Init(soundcard, MixRate, numchannels, samplebits, TotalBufferSize); status = DSOUND_Init(soundcard, MixRate, numchannels, samplebits, TotalBufferSize);
if (status != DSOUND_Ok) if (status != DSOUND_Ok)
{ {
@ -2979,11 +2980,10 @@ int MV_Shutdown(void)
MV_StopPlayback(); MV_StopPlayback();
// Shutdown the sound card // Shutdown the sound card
#ifdef USE_OPENAL
if (!openal_disabled)
AL_Shutdown();
#endif
#if defined(_WIN32) #if defined(_WIN32)
#ifdef USE_OPENAL
AL_Shutdown();
#endif
DSOUND_Shutdown(); DSOUND_Shutdown();
#else #else
DSL_Shutdown(); DSL_Shutdown();

View file

@ -191,7 +191,6 @@ void MUSIC_SetVolume
volume = max(0, volume); volume = max(0, volume);
volume = min(volume, 255); volume = min(volume, 255);
#ifdef USE_OPENAL #ifdef USE_OPENAL
if (!openal_disabled)
AL_SetMusicVolume(volume); AL_SetMusicVolume(volume);
#endif #endif
if (MUSIC_SoundDevice != -1) if (MUSIC_SoundDevice != -1)
@ -300,7 +299,6 @@ void MUSIC_Continue
{ {
#ifdef USE_OPENAL #ifdef USE_OPENAL
if (!openal_disabled)
AL_Continue(); AL_Continue();
#endif #endif
MIDI_ContinueSong(); MIDI_ContinueSong();
@ -320,7 +318,6 @@ void MUSIC_Pause
{ {
#ifdef USE_OPENAL #ifdef USE_OPENAL
if (!openal_disabled)
AL_Pause(); AL_Pause();
#endif #endif
MIDI_PauseSong(); MIDI_PauseSong();
@ -340,7 +337,6 @@ int MUSIC_StopSong
{ {
#ifdef USE_OPENAL #ifdef USE_OPENAL
if (!openal_disabled)
AL_Stop(); AL_Stop();
#endif #endif
MUSIC_StopFade(); MUSIC_StopFade();
@ -366,9 +362,9 @@ int MUSIC_PlaySong
int status; int status;
#ifdef USE_OPENAL #ifdef USE_OPENAL
if (!openal_disabled) AL_PlaySong((char *)song,loopflag);
AL_PlaySong((unsigned char *)song,loopflag);
if(openal_disabled || AL_isntALmusic()) if(AL_isntALmusic())
#endif #endif
{ {
MUSIC_StopSong(); MUSIC_StopSong();

View file

@ -29,7 +29,7 @@ typedef struct SD
sounddef def; sounddef def;
}sounddef1; }sounddef1;
sounddef1 sounds1[2]; sounddef1 music;
#ifdef _WIN32 #ifdef _WIN32
// Windows // Windows
@ -262,6 +262,7 @@ extern ov_callbacks cb;
int AL_Init() int AL_Init()
{ {
Bmemset(&music,0,sizeof(music)); // "music.def.size=0" means music not playing
if (loadaldriver()) if (loadaldriver())
{ {
initprintf("Failed loading OpenAL driver.\nDownload OpenAL 1.1 or greater from http://www.openal.org/downloads.html."); initprintf("Failed loading OpenAL driver.\nDownload OpenAL 1.1 or greater from http://www.openal.org/downloads.html.");
@ -319,23 +320,12 @@ int AL_Init()
} }
else initprintf("OpenAL initialization failed.\n"); else initprintf("OpenAL initialization failed.\n");
ALdoing="Open";
balGenBuffers(16, sounds1[1].buffers);
check(1);
balGenSources(1,&sounds1[1].source);
check(1);
return 0; return 0;
} }
void AL_Shutdown() void AL_Shutdown()
{ {
ALdoing="Delete source"; if (openal_disabled)return;
balDeleteSources(1,&sounds1[1].source);
check(1);
ALdoing="Delete buffers";
balDeleteBuffers(16, sounds1[1].buffers);
check(1);
ALdoing="Shut"; ALdoing="Shut";
balcMakeContextCurrent(NULL); balcMakeContextCurrent(NULL);
@ -346,9 +336,8 @@ void AL_Shutdown()
unloadaldriver(); unloadaldriver();
} }
#define BUFFER_SIZE (4096 * 4*8*8) #define BUFFER_SIZE 65536 // (4096 * 4*8*8)
int AL_MusicVolume; int AL_MusicVolume;
sounddef1 music;
extern int Musicsize; extern int Musicsize;
@ -428,12 +417,11 @@ void AL_Stop()
Bmemset(&music,0,sizeof(sounddef1)); Bmemset(&music,0,sizeof(sounddef1));
} }
static char pcm[BUFFER_SIZE];
int stream(ALuint buffer) int stream(ALuint buffer)
{ {
ALsizei size=0; ALsizei size=0;
int section,result; int section,result;
static char pcm[BUFFER_SIZE];
while (size<BUFFER_SIZE) while (size<BUFFER_SIZE)
{ {

View file

@ -54,10 +54,6 @@ Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu)
#include <SDL_mixer.h> #include <SDL_mixer.h>
#include "music.h" #include "music.h"
#ifdef USE_OPENAL
#include "openal.h"
#endif
#define __FX_TRUE (1 == 1) #define __FX_TRUE (1 == 1)
#define __FX_FALSE (!__FX_TRUE) #define __FX_FALSE (!__FX_TRUE)
@ -324,7 +320,7 @@ int MUSIC_Init(int SoundCard, int Address)
// Use an external MIDI player if the user has specified to do so // Use an external MIDI player if the user has specified to do so
char *command = getenv("EDUKE32_MIDI_CMD"); char *command = getenv("EDUKE32_MIDI_CMD");
external_midi = (command != NULL && command[0] != 0); external_midi = (command != NULL && command[0] != 0);
if (external_midi) if(external_midi)
Mix_SetMusicCMD(command); Mix_SetMusicCMD(command);
init_debugging(); init_debugging();
@ -349,7 +345,7 @@ int MUSIC_Shutdown(void)
musdebug("shutting down sound subsystem."); musdebug("shutting down sound subsystem.");
// TODO - make sure this is being called from the menu -- SA // TODO - make sure this is being called from the menu -- SA
if (external_midi) if(external_midi)
Mix_SetMusicCMD(NULL); Mix_SetMusicCMD(NULL);
MUSIC_StopSong(); MUSIC_StopSong();
@ -380,11 +376,6 @@ void MUSIC_SetVolume(int volume)
volume = max(0, volume); volume = max(0, volume);
volume = min(volume, 255); volume = min(volume, 255);
#ifdef USE_OPENAL
if (!openal_disabled)
AL_SetMusicVolume(volume);
#endif
Mix_VolumeMusic(volume >> 1); // convert 0-255 to 0-128. Mix_VolumeMusic(volume >> 1); // convert 0-255 to 0-128.
} // MUSIC_SetVolume } // MUSIC_SetVolume
@ -421,37 +412,21 @@ int MUSIC_SongPlaying(void)
void MUSIC_Continue(void) void MUSIC_Continue(void)
{ {
#ifdef USE_OPENAL
if (!openal_disabled)
AL_Continue();
#endif
if (Mix_PausedMusic()) if (Mix_PausedMusic())
Mix_ResumeMusic(); Mix_ResumeMusic();
else if (music_songdata else if (music_songdata)
#ifdef USE_OPENAL
&& (openal_disabled || AL_isntALmusic())
#endif
)
MUSIC_PlaySong((unsigned char *)music_songdata, MUSIC_PlayOnce); MUSIC_PlaySong((unsigned char *)music_songdata, MUSIC_PlayOnce);
} // MUSIC_Continue } // MUSIC_Continue
void MUSIC_Pause(void) void MUSIC_Pause(void)
{ {
#ifdef USE_OPENAL
if (!openal_disabled)
AL_Pause();
#endif
Mix_PauseMusic(); Mix_PauseMusic();
} // MUSIC_Pause } // MUSIC_Pause
int MUSIC_StopSong(void) int MUSIC_StopSong(void)
{ {
#ifdef USE_OPENAL
if (!openal_disabled)
AL_Stop();
#endif
//if (!fx_initialized) //if (!fx_initialized)
if (!Mix_QuerySpec(NULL, NULL, NULL)) if (!Mix_QuerySpec(NULL, NULL, NULL))
{ {
@ -475,6 +450,7 @@ int MUSIC_StopSong(void)
int MUSIC_PlaySong(unsigned char *song, int loopflag) int MUSIC_PlaySong(unsigned char *song, int loopflag)
{ {
//SDL_RWops *rw; //SDL_RWops *rw;
MUSIC_StopSong(); MUSIC_StopSong();
music_songdata = (char *)song; music_songdata = (char *)song;
@ -492,12 +468,13 @@ int MUSIC_PlaySong(unsigned char *song, int loopflag)
music_musicchunk = Mix_LoadMUS_RW(rw); music_musicchunk = Mix_LoadMUS_RW(rw);
Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_PlayOnce) ? 0 : -1); Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_PlayOnce) ? 0 : -1);
*/ */
return(MUSIC_Ok); return(MUSIC_Ok);
} // MUSIC_PlaySong } // MUSIC_PlaySong
// Duke3D-specific. --ryan. // Duke3D-specific. --ryan.
void PlayMusic(char *_filename, int loopflag) void PlayMusic(char *_filename)
{ {
//char filename[MAX_PATH]; //char filename[MAX_PATH];
//strcpy(filename, _filename); //strcpy(filename, _filename);
@ -509,89 +486,67 @@ void PlayMusic(char *_filename, int loopflag)
void *song; void *song;
int rc; int rc;
#ifdef USE_OPENAL MUSIC_StopSong();
if (!openal_disabled) initprintf("trying to play %s\n",_filename);
// 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)
{ {
int fp; kclose(handle);
int l; return;
} // if
fp = kopen4load(_filename,0); song = malloc(size);
if (song == NULL)
if (fp == -1) return;
l = kfilelength(fp);
MUSIC_StopSong();
Musicsize=0;
if (!MusicPtr)MusicPtr=Bcalloc(1,l);
else MusicPtr=Brealloc(MusicPtr,l);
Musicsize=l;
kread(fp, MusicPtr, l);
kclose(fp);
AL_PlaySong((char *)MusicPtr,loopflag);
}
if (openal_disabled || AL_isntALmusic())
#endif
{ {
MUSIC_StopSong(); kclose(handle);
return;
} // if
rc = kread(handle, song, size);
kclose(handle);
if (rc != size)
{
Bfree(song);
return;
} // if
// save the file somewhere, so SDL_mixer can load it
{
char *user = getenv("USERNAME");
if (user) Bsprintf(tempbuf,"duke3d_%s.%d",user,getpid());
else Bsprintf(tempbuf,"duke3d.%d",getpid());
GetUnixPathFromEnvironment(filename, BMAX_PATH, tempbuf);
handle = SafeOpenWrite(filename, filetype_binary);
// Read from a groupfile, write it to disk so SDL_mixer can read it.
// Lame. --ryan.
handle = kopen4load(_filename, 0);
if (handle == -1) if (handle == -1)
return; return;
size = kfilelength(handle); midifn = Bstrdup(filename);
if (size == -1)
SafeWrite(handle, song, size);
close(handle);
Bfree(song);
//music_songdata = song;
music_musicchunk = Mix_LoadMUS(filename);
initprintf("filename: %s\n",filename);
if (music_musicchunk != NULL)
{ {
kclose(handle); // !!! FIXME: I set the music to loop. Hope that's okay. --ryan.
return; initprintf("playing..\n");
Musicsize = size;
Mix_PlayMusic(music_musicchunk, -1);
} // if } // if
song = malloc(size);
if (song == NULL)
{
kclose(handle);
return;
} // if
rc = kread(handle, song, size);
kclose(handle);
if (rc != size)
{
Bfree(song);
return;
} // if
// save the file somewhere, so SDL_mixer can load it
{
char *user = getenv("USERNAME");
if (user) Bsprintf(tempbuf,"duke3d-%s.%d.mid",user,getpid());
else Bsprintf(tempbuf,"duke3d.%d.mid",getpid());
GetUnixPathFromEnvironment(filename, BMAX_PATH, tempbuf);
handle = SafeOpenWrite(filename, filetype_binary);
if (handle == -1)
return;
midifn = Bstrdup(filename);
SafeWrite(handle, song, size);
close(handle);
Bfree(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
}
} }
} }

View file

@ -32,9 +32,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "util_lib.h" #include "util_lib.h"
#include "osd.h" #include "osd.h"
#ifdef _WIN32
#ifdef USE_OPENAL #ifdef USE_OPENAL
#include "openal.h" #include "openal.h"
#endif #endif
#endif
#define LOUDESTVOLUME 150 #define LOUDESTVOLUME 150