diff -u battalionSource.orig/Makefile battalionSource/Makefile --- battalionSource.orig/Makefile Thu Jan 16 11:31:58 1997 +++ battalionSource/Makefile Mon Jul 10 23:45:12 2000 @@ -23,7 +23,7 @@ # (the program should compile with no warning messages - if you # see a warning message please let me know about it) # ------------------------------------------------------------ -CC = CC +CC = gcc # STEP 2: IF YOU WANT TO COMPILE WITH THE MESA LIBRARIES THEN @@ -51,11 +51,11 @@ # with the other Makefile.) # # ------------------------------------------------------------ -OS = -DSGIVERSION +#OS = -DSGIVERSION # or #OS = -DSUNVERSION # or -#OS = -DLINUXVERSION +OS = -DLINUXVERSION # or #OS = -DHPVERSION # or @@ -77,8 +77,10 @@ # in audio.c then everything works fine. # # ------------------------------------------------------------ -AUDIOLIB = -laudio -laudiofile -AUDIODEF = -DSGIAUDIO +#AUDIOLIB = -laudio -laudiofile +#AUDIODEF = -DSGIAUDIO +AUDIOLIB = $(shell sdl-config --libs) -lSDL_mixer +AUDIODEF = $(shell sdl-config --cflags) -DSDLAUDIO # STEP 6: IF YOU ARE COMPILING FOR A SUN AND WANT (RUDIMENTARY) @@ -110,8 +112,8 @@ all: $(TARGET) -$(OBJ): $(?:.o=.c) - $(CC) $(CFLAGS) $(LIBFLAG) $(OS) $(WHICHLIB) $(AUDIODEF) -c $? +.c.o: + $(CC) $(CFLAGS) $(LIBFLAG) $(OS) $(WHICHLIB) $(AUDIODEF) -c $< $(TARGET): $(OBJ) $(CC) -o $(TARGET) $(OBJ) $(LIBFLAGS) $(GLIB) $(LIBS) $(AUDIOLIB) diff -u battalionSource.orig/audio.c battalionSource/audio.c --- battalionSource.orig/audio.c Thu Jan 16 11:31:59 1997 +++ battalionSource/audio.c Sun Jul 16 20:10:27 2000 @@ -64,6 +64,14 @@ #endif +#ifdef SDLAUDIO +int playingBeam, playingMusic; + +typedef Mix_Chunk *MixSound; +MixSound snd[MAXSOUNDS]; +int sndType[MIX_CHANNELS]; +#endif + /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ /* small sound routines to avoid having to use external variables*/ @@ -242,7 +250,41 @@ SHPlayPause(monsterbeamRefNum); -# else +#else +#ifdef SDLAUDIO + int audio_rate; + Uint16 audio_format; + int audio_channels; + + /* Initialize variables */ + audio_rate = 22050; + audio_format = AUDIO_U16; + audio_channels = 2; + + noSound = 1; + soundOn = 0; + musicOn = 0; + if ((SDL_Init(SDL_INIT_AUDIO) >= 0) && + (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) >= 0)) + { + noSound = 0; + } + + if (!noSound) { + InitAudio("SOUNDS/beam.wav", dataPath, 0); + InitAudio("SOUNDS/boom.wav", dataPath, 1); + InitAudio("SOUNDS/crash.wav", dataPath, 2); + InitAudio("SOUNDS/monsterbeam.wav", dataPath, 3); + InitAudio("SOUNDS/rocket.wav", dataPath, 4); + InitAudio("SOUNDS/slag.wav", dataPath, 5); + InitAudio("SOUNDS/tank.wav", dataPath, 6); + InitAudio("SOUNDS/tech.wav", dataPath, 7); + + /* Load all background music into memory */ + InitAudio("MUSIC/newm1.wav", dataPath, 10); + InitAudio("MUSIC/newm2.wav", dataPath, 11); + } +#else /* Other than SGI or Solaris or Macintosh*/ noSound = 1; @@ -252,6 +294,7 @@ #endif #endif #endif +#endif garbage = dataPath; /* to avoid compiler warning */ } @@ -330,6 +373,19 @@ #endif +#ifdef SDLAUDIO + int n; + + musicCount = 0; + deadCount = 0; + + playingTankFire = playingHeloRocket = playingTankMaser = 0; + playingExplosion = playingSlag = playingTech = 0; + playingBeam = playingMusic = 0; + + for (n = 0; n < MIX_CHANNELS; n++) + sndType[n] = -1; +#endif } @@ -368,7 +424,7 @@ s = s->next; } #endif -# ifdef SUNAUDIO +#if defined(SUNAUDIO) && defined(SDLAUDIO) playingHeloRocket = playingTech = playingTankMaser = playingSlag = 0; @@ -484,6 +540,23 @@ } #endif +#ifdef SDLAUDIO + int i; + + if (soundType == MUSIC) + playingMusic = 0; + else if (soundType == MONSTERBEAM) + playingBeam = 0; + for (i = 0; i < MIX_CHANNELS; i++) + { + if (sndType[i] == soundType) + { + Mix_HaltChannel(i); + sndType[i] = -1; + } + } +#endif + garbage = soundType; /* to avoid compiler warning */ } @@ -849,6 +922,94 @@ } } #endif +#ifdef SDLAUDIO + +static int deadMusic[MAXDEADMUSIC] = {15, 16}; + +static int theMusic[MAXMUSIC] = {10, 11, 10, 11, 10}; + + int soundDelay; + + if (!noSound) { + soundDelay = showframes; + + if (soundDelay <= 1) + soundDelay = 1; + + if (soundDelay > 30) + soundDelay = 30; + + if (((theSound == MUSIC) && musicOn) || + ((theSound != MUSIC) && soundOn)) { + + switch (theSound) { + case MUSIC: + if (!playingMusic) { + OutAudio(theMusic[musicCount]); + musicCount = (musicCount+1) % MAXMUSIC; + /* each music sample is 5 secs long */ + playingMusic = soundDelay * 20; ; + } + break; + + case TANKFIRE: + if (!playingTankFire) { + OutAudio(6); + playingTankFire = soundDelay / 5; + if (playingTankFire < 2) + playingTankFire = 2; + } + break; + + case HELOROCKET: + if (!playingHeloRocket) { + OutAudio(4); + playingHeloRocket = 1; + } + break; + + case TANKMASER: + OutAudio(0); + break; + + case EXPLOSION: + if (!playingExplosion) { + OutAudio(1); + playingExplosion = soundDelay / 5; + if (playingExplosion < 2) + playingExplosion = 2; + } + break; + + case MONSTERBEAM: + if (!playingBeam) { + OutAudio(3); + playingBeam = 5 /*soundDelay / 5*/; + } + break; + + case SLAG: + if (!playingSlag) { + OutAudio(5); + playingSlag = 1; + } + break; + + case CRASH: + OutAudio(2); + break; + + case TECHSHOOT: + if (!playingTech) { + OutAudio(7); + playingTech = 1; + } + break; + } + } + } + +#endif garbage = theSound; } @@ -965,6 +1126,22 @@ # endif +#ifdef SDLAUDIO + int channel; + + channel = Mix_PlayChannel(-1, snd[sCounter], 0); + if (channel >= 0 && channel < MIX_CHANNELS) + { + if (sCounter == 3) + sndType[channel] = MONSTERBEAM; + else if (sCounter == 0) + sndType[channel] = TANKMASER; + else if (sCounter >= 10) + sndType[channel] = MUSIC; + else + sndType[channel] = -1; + } +#endif garbage = sCounter; /* to avoid compiler warning */ } @@ -1083,9 +1260,17 @@ close(audiofd); # endif +#ifdef SDLAUDIO + char fullPath[MAXPATH]; + + strcpy(fullPath, dataPath); + strcat(fullPath, fileName); + snd[sCounter] = Mix_LoadWAV(fullPath); +#endif garbName = fileName; garbPath = dataPath; garbCount = sCounter; } + diff -u battalionSource.orig/battalion.h battalionSource/battalion.h --- battalionSource.orig/battalion.h Thu Jan 16 11:31:59 1997 +++ battalionSource/battalion.h Sat Jul 15 13:35:10 2000 @@ -101,6 +101,11 @@ # include #endif +#ifdef SDLAUDIO +#include +#include +#endif + #ifdef HPVERSION /* to get non-blocking I/O under HP-UX */ /* from Neil Harkin */