From: boyns@hercules.sdsu.edu (Mark Boyns)
Newsgroups: rec.games.xtank.play
Subject: xtank1.3f sound patches
Date: 19 Nov 1992 19:30:27 GMT
Organization: San Diego State University, College of Sciences
NNTP-Posting-Host: hercules.sdsu.edu
X-Newsreader: TIN [version 1.1 PL7]

Here are the patches sound in xtank1.3f.
See below for more information.

Mark
boyns@sciences.sdsu.edu

----------------------------------------------------------------------

#
# xtank1.3f sound patches by Mark Boyns
#
# This sound patch to xtank1.3f will only work on Sun workstations
# with sound support.  As far as I know this patch will only work
# with an original xtank1.3f.
#
# Sound in xtank also requires that you have rplay version 2.0.
# The older version of rplay will not work correctly.  If you
# do not have rplay2.0 you can obtain it via anonymous ftp
# at sounds.sdsu.edu.  Sound files can also be obtained at
# sounds.sdsu.edu in the /pub/sounds/xtank directory.
#
# This patch does not really add any new sound features except
# now specific sounds can be turned on/off in the Sounds/list
# file.  The Imakefile in the Src directory expects to find
# rplay.h in /usr/include, Src/Include, or /usr/local/include
# and librplay.a in /usr/local/lib.  If these are in different
# places you will have to edit the Imakefile in Src.
#
# To apply this patch
# % cd your_xtank_directory (the one with Imakefile.Config)
# % patch -p0 < sound-patches >& patchresults
#
# Send problems/question/comments to boyns@sciences.sdsu.edu.
#
# Have fun...
#
# Mark
#
*** /dev/null	Thu Nov 19 10:28:12 1992
--- Sounds/list	Thu Nov 19 10:41:09 1992
***************
*** 0 ****
--- 1,48 ----
+ #
+ # This file contains the names of sound files used for sounds.
+ # The order of these sounds must correspond to the numbers in
+ # $(XTANK_DIR)/Src/Include/Sound.h.  Currenly only the first
+ # two strings on each line are read and anything else is ignored.
+ # The second string can be either "on" or "off" which will turn
+ # that sound on/off during the game.  Yes, I know it would be nice to 
+ # be able to turn on/off sounds inside xtank.
+ # 
+ click1.au		on	# lmg
+ click1.au		on	# mg 
+ click1.au		on	# hmg 
+ click1.au		on	# lrifle 
+ click1.au		on	# rifle 
+ click1.au		on	# hrifle 
+ click1.au		on	# lcannon 
+ click1.au		on	# cannon 
+ click1.au		on	# hcannon 
+ click1.au		on	# lrocket 
+ click1.au		on	# rocket 
+ click1.au		on	# hrocket 
+ click1.au		on	# acid 
+ click1.au		on	# flame 
+ drip.au		on	# mine 
+ Missle1.au		on	# seeker 
+ click1.au		on	# slick 
+ click1.au		on	# procket 
+ click1.au		on	# umissle 
+ click1.au		on	# harm 
+ click1.au		on	# disc 
+ bong.au		on	# vehicle hit wall
+ better_boing.au	on	# vehicle hit vehicle
+ arrp.au		on	# bullet hit vehicle
+ tap2.au		on	# bullet hit wall
+ boom.au		on	# tank explosion
+ arrp.au		on	# gleam explosion
+ arrp.au		on	# dam0 explosion
+ arrp.au		on	# dam1 explosion
+ arrp.au		on	# dam2 explosion
+ arrp.au		on	# dam3 explosion
+ arrp.au		on	# dam4 explosion
+ arrp.au		on	# exhaust explosion
+ arrp.au		on	# electric explosion
+ arrp.au		on	# damage explosion
+ sub_dive_horn.au	on	# start
+ game_over.au		on	# end
+ Sonar.au		on	# sonar
+ blip.au		on	# blip
*** /dev/null	Thu Nov 19 10:28:12 1992
--- Src/Include/sound.h	Fri Nov 13 11:22:36 1992
***************
*** 0 ****
--- 1,70 ----
+ #ifdef SOUND
+ 
+ #ifndef	_sound_h
+ #define	_sound_h
+ 
+ /*
+  * This file contains the sound indexes into the sound table
+  * The indexes here must be consistent with those in the file Sounds/list
+  */
+ 
+ /*
+  * maximum number of sounds
+  */
+ #define MAX_SOUNDS			128
+ 
+ /*
+  * sounds for all the types of weapons
+  */
+ #define LMG_SOUND			0
+ #define MG_SOUND			1
+ #define HMG_SOUND			2
+ #define LRIFLE_SOUND			3
+ #define RIFLE_SOUND			4
+ #define HRIFLE_SOUND			5
+ #define LCANNON_SOUND			6
+ #define CANNON_SOUND			7
+ #define HCANNON_SOUND			8
+ #define LROCKET_SOUND			9
+ #define ROCKET_SOUND			10
+ #define HROCKET_SOUND			11
+ #define ACID_SOUND			12
+ #define FLAME_SOUND			13
+ #define MINE_SOUND			14
+ #define SEEKER_SOUND			15
+ #define SLICK_SOUND			16
+ #define PROCKET_SOUND			17
+ #define UMISSLE_SOUND			18
+ #define HARM_SOUND			19
+ #define DISC_SOUND			20
+ /*
+  * things hitting things sounds
+  */
+ #define VEHICLE_HIT_WALL_SOUND	21
+ #define VEHICLE_HIT_VEHICLE_SOUND	22
+ #define BULLET_HIT_VEHICLE_SOUND	23
+ #define BULLET_HIT_WALL_SOUND		24
+ /*
+  * explosion sounds
+  */
+ #define TANK_EXPLOSION_SOUND		25
+ #define GLEAM_EXPLOSION_SOUND		26
+ #define DAM0_EXPLOSION_SOUND		27
+ #define DAM1_EXPLOSION_SOUND		28
+ #define DAM2_EXPLOSION_SOUND		29
+ #define DAM3_EXPLOSION_SOUND		30
+ #define DAM4_EXPLOSION_SOUND		31
+ #define EXHAUST_EXPLOSION_SOUND	32
+ #define ELECTRIC_EXPLOSION_SOUND	33
+ #define DAMAGE_EXPLOSION_SOUND	34
+ /*
+  * misc sounds
+  */
+ #define START_SOUND			35
+ #define END_SOUND			36
+ #define SONAR_SOUND			37
+ #define BLIP_SOUND			38
+ 
+ #endif	_sound_h
+ 
+ #endif SOUND
*** /dev/null	Thu Nov 19 10:28:12 1992
--- Src/sound.c	Thu Nov 19 10:22:42 1992
***************
*** 0 ****
--- 1,209 ----
+ #ifdef SOUND
+ #include "limits.h"
+ #include "xtank.h"
+ #include "graphics.h"
+ #include "gr.h"
+ #include "xtanklib.h"
+ #include "vehicle.h"
+ #include "globals.h"
+ #include "terminal.h"
+ #include "assert.h"
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <netdb.h>
+ #include <stdio.h>
+ #include "sound.h"
+ #include "rplay.h"
+ 
+ extern Terminal	*terminal[];
+ extern int	num_terminals;
+ extern Settings	settings;
+ extern char	pathname[], soundsdir[];
+ 
+ /*
+  * the sound table
+  */
+ RPLAY	*sound_table[MAX_SOUNDS];
+ 
+ /*
+  * create RPLAY packets for all the sounds in Sounds/list
+  */
+ init_sounds()
+ {
+ 	char		buf[MAXPATHLEN];
+ 	char		name[MAXPATHLEN];
+ 	char		status[32];
+ 	int		nsounds = 0;
+ 	FILE		*fp;
+ 
+ 	strcpy(name, pathname);
+ 	strcat(name, "/");
+ 	strcat(name, soundsdir);
+ 	strcat(name, "/");
+ 	strcat(name, "list");
+ 
+ 	fp = fopen(name, "r");
+ 	if (fp == NULL) {
+ 		fprintf(stderr, "Could not open file %s.\n", name);
+ 		exit(1);
+ 	}
+ 
+ 	while(fgets(buf, sizeof(buf), fp) != NULL) {
+ 		switch(buf[0]) {
+ 		case '#':
+ 		case '\n':
+ 		case '\0':
+ 		case ' ':
+ 		case '\t':
+ 			continue;
+ 		}
+ 		sscanf(buf, "%s %s", name, status);
+ 		if (strcmp(status, "on") == 0) {		/* ON */
+ 			sound_table[nsounds] = rplay_create();
+ 			if (sound_table[nsounds] == NULL) {
+ 				rplay_perror("rplay_create");
+ 				exit(1);
+ 			}
+ 			if (rplay_set(sound_table[nsounds], RPLAY_PLAY, name, NULL) < 0) {
+ 				rplay_perror("rplay_set");
+ 				exit(1);
+ 			}
+ 		}
+ 		else if (strcmp(status, "off") == 0) {		/* OFF */
+ 			sound_table[nsounds] = NULL;
+ 		}
+ 		else {
+ 			fprintf(stderr, "Unknown sound status '%s'.\n", status);
+ 		}
+ 		nsounds++;
+ 	} 
+ }
+ 
+ /*
+  * initialize sound for the given terminal
+  */
+ init_terminal_sound(t)
+ Terminal	*t;
+ {
+ 	char		*p, *rindex();
+ 	Video		*vidptr;
+ 	char		hostname[MAXHOSTNAMELEN];
+ 	int		i;
+ 
+ 	draw_text_rc(ANIM_WIN, 0, 1, "Initializing Sounds...", M_FONT, WHITE);
+ 	sync_output(TRUE);
+ 
+ 	/*
+ 	 * get the display hostname 
+ 	 */
+ 	vidptr = (Video *)t->video;
+ 	strcat(hostname, vidptr->display_name);
+ 	p = rindex(hostname, ':');
+ 	*p = '\0';
+ 	if (*hostname == '\0') {
+ 		gethostname(hostname, sizeof(hostname));
+ 	}
+ 
+ 	/*
+ 	 * initialize rplayd connection
+ 	 */
+ 	t->rplay_fd = rplay_open(hostname);
+ 	if (t->rplay_fd < 0) {
+ 		rplay_perror(hostname);
+ 		return;
+ 	}
+ 
+ 	play_terminal(t, SONAR_SOUND);
+ }
+ 
+ /*
+  * play a sound on a terminal
+  */
+ play_terminal(t, index)
+ Terminal	*t;
+ int		index;
+ {
+ 	if (!settings.si.no_sound) {
+ 		if (t->rplay_fd > 0 && sound_table[index] > 0)
+ 			rplay(t->rplay_fd, sound_table[index]);
+ 	}
+ }
+ 
+ /*
+  * play a sound on all terminals
+  */
+ play_all(index)
+ int	index;
+ {
+ 	if (!settings.si.no_sound) {
+ 		int	x;
+ 	
+ 		for(x = 0; x < num_terminals; x++)
+ 			if (terminal[x]->rplay_fd > 0 && sound_table[index] != NULL)
+ 				rplay(terminal[x]->rplay_fd, sound_table[index]);
+ 	}
+ }
+ 
+ /*
+  * play a sound on the terminal "owning" or watching this tank
+  */
+ play_owner(vehicle, index)
+ Vehicle		*vehicle;
+ int		index;
+ {
+ 	if (!settings.si.no_sound) {
+ 		int	x, y;
+ 
+ 		for (x = 0; x < vehicle->owner->num_players; x++) {
+ 			y = vehicle->owner->player[x];
+ 			if (terminal[y]->rplay_fd > 0 && sound_table[index] != NULL)
+ 				rplay(terminal[y]->rplay_fd, sound_table[index]);
+ 		}
+ 	}
+ }
+ 
+ /*
+  * play a sound on the terminal that has this location in view
+  */
+ play_in_view(loc, index)
+ Loc	*loc;
+ int	index;
+ {
+ 	if (!settings.si.no_sound) {
+ 		int	x, dx, dy;
+ 		int	t_x = loc->x;
+ 		int	t_y = loc->y;
+ 
+ 		for (x = 0; x < num_terminals; x++) {
+ 			dx = t_x - terminal[x]->loc.x;
+ 			dy = t_y - terminal[x]->loc.y;
+ 			if (dx >= 0 && dx <= ANIM_WIN_WIDTH && dy >= 0 && dy <= ANIM_WIN_HEIGHT &&
+ 				terminal[x]->rplay_fd > 0 && sound_table[index] != NULL)
+ 				rplay(terminal[x]->rplay_fd, sound_table[index]);
+ 		}
+ 	}
+ }
+ 
+ /*
+  * play a sound on the terminal that has this location in view
+  */
+ play_in_view_x_y(t_x, t_y, index)
+ int	t_x;
+ int	t_y;
+ int	index;
+ {
+ 	if (!settings.si.no_sound) {
+ 		int	x, dx, dy;
+ 
+ 		for (x = 0; x < num_terminals; x++) {
+ 			dx = t_x - terminal[x]->loc.x;
+ 			dy = t_y - terminal[x]->loc.y;
+ 			if (dx >= 0 && dx <= ANIM_WIN_WIDTH && dy >= 0 && dy <= ANIM_WIN_HEIGHT &&
+ 				terminal[x]->rplay_fd > 0 && sound_table[index] != NULL)
+ 				rplay(terminal[x]->rplay_fd, sound_table[index]);
+ 		}
+ 	}
+ }
+ #endif SOUND
Common subdirectories: ./Bin and ../xtank1.3f-sound/Bin
Common subdirectories: ./Doc and ../xtank1.3f-sound/Doc
Common subdirectories: ./Help and ../xtank1.3f-sound/Help
diff -c -r ./Imakefile.Config ../xtank1.3f-sound/Imakefile.Config
*** ./Imakefile.Config	Sat Sep 12 12:37:30 1992
--- ../xtank1.3f-sound/Imakefile.Config	Fri Nov 13 12:50:24 1992
***************
*** 173,179 ****
  DEFINES2        = -DX11 -DUNIX -DS1024x864 -DKEYPAD_DETECT \
  		-DSTINGY_REDRAW -DBATCH_LINES -DBATCH_POINTS \
  		-DBATCH_COLOR_LINES \
! 		-DCODE_SIZE=0x20000 -DSTACK_SIZE=0x8000 $(ARCH_DEFINES)
  
  DEFINES         = -DXTANK_DIR=\"/src/pub/xtank\" $(DEFINES2) \
  		-DALLDEFINES="\"$(DEFINES2)\""
--- 173,180 ----
  DEFINES2        = -DX11 -DUNIX -DS1024x864 -DKEYPAD_DETECT \
  		-DSTINGY_REDRAW -DBATCH_LINES -DBATCH_POINTS \
  		-DBATCH_COLOR_LINES \
! 		-DCODE_SIZE=0x20000 -DSTACK_SIZE=0x8000 $(ARCH_DEFINES) \
! 		-DSOUND
  
  DEFINES         = -DXTANK_DIR=\"/src/pub/xtank\" $(DEFINES2) \
  		-DALLDEFINES="\"$(DEFINES2)\""
Common subdirectories: ./Mazes and ../xtank1.3f-sound/Mazes
Common subdirectories: ./Programs and ../xtank1.3f-sound/Programs
Common subdirectories: ./Src and ../xtank1.3f-sound/Src
Common subdirectories: ./Todo and ../xtank1.3f-sound/Todo
Common subdirectories: ./Util and ../xtank1.3f-sound/Util
Common subdirectories: ./Vehicles and ../xtank1.3f-sound/Vehicles
diff -c -r ./Bin/xtank ../xtank1.3f-sound/Bin/xtank
*** ./Bin/xtank	Sat Feb  1 14:00:59 1992
--- ../xtank1.3f-sound/Bin/xtank	Thu Nov 19 10:25:43 1992
***************
*** 3,8 ****
--- 3,9 ----
  XTANK_VEHICLES=Vehicles
  XTANK_MAZES=Mazes
  XTANK_PROGRAMS=Programs
+ XTANK_SOUNDS=Sounds
  
  #
  # rpotter thinks this is a kludge, I think it is funny! (lidl)
Common subdirectories: ./Doc/Src and ../xtank1.3f-sound/Doc/Src
Common subdirectories: ./Programs/Old and ../xtank1.3f-sound/Programs/Old
Common subdirectories: ./Programs/Old/Old and ../xtank1.3f-sound/Programs/Old/Old
Common subdirectories: ./Src/Fixed-Point and ../xtank1.3f-sound/Src/Fixed-Point
diff -c -r ./Src/Imakefile ../xtank1.3f-sound/Src/Imakefile
*** ./Src/Imakefile	Sat Sep 12 12:36:46 1992
--- ../xtank1.3f-sound/Src/Imakefile	Fri Nov 13 13:14:23 1992
***************
*** 17,23 ****
                      program.c radar.c repair.c scroll.c setup.c setups.c \
                      status.c sysdep.c thread.c unix.c update.c util.c \
                      vdesign.c vehicle.c players.c newfile.c vload.c \
!                     version.c $(SRCS2)
               OBJS = 3d.o XMultiSync.o actions.o animate.o box.o camo.o \
                      collision.o cosell.o disc.o display.o escher.o \
                      explosion.o file.o game.o gr.o graphics.o highlib.o \
--- 17,23 ----
                      program.c radar.c repair.c scroll.c setup.c setups.c \
                      status.c sysdep.c thread.c unix.c update.c util.c \
                      vdesign.c vehicle.c players.c newfile.c vload.c \
!                     version.c sound.c $(SRCS2)
               OBJS = 3d.o XMultiSync.o actions.o animate.o box.o camo.o \
                      collision.o cosell.o disc.o display.o escher.o \
                      explosion.o file.o game.o gr.o graphics.o highlib.o \
***************
*** 27,33 ****
                      program.o radar.o repair.o scroll.o setup.o setups.o \
                      status.o sysdep.o thread.o unix.o update.o util.o \
                      vdesign.o vehicle.o players.o newfile.o vload.o \
!                     version.o $(OBJS2)
               INCL = Include/bullet.h Include/common.h Include/cosell.h \
                      Include/disc.h Include/game.h Include/globals.h \
                      Include/gr.h Include/graphics.h Include/icounter.h \
--- 27,33 ----
                      program.o radar.o repair.o scroll.o setup.o setups.o \
                      status.o sysdep.o thread.o unix.o update.o util.o \
                      vdesign.o vehicle.o players.o newfile.o vload.o \
!                     version.o sound.o $(OBJS2)
               INCL = Include/bullet.h Include/common.h Include/cosell.h \
                      Include/disc.h Include/game.h Include/globals.h \
                      Include/gr.h Include/graphics.h Include/icounter.h \
***************
*** 41,47 ****
                      Include/team.h Include/terminal.h Include/thread.h \
                      Include/tread-defs.h Include/vdesc.h Include/vehicle.h \
                      Include/vehicleparts.h Include/vstructs.h \
!                     Include/weapon-defs.h Include/xtank.h Include/xtanklib.h
              XINCL = Include/x11.h
  
  /**/# Note that both x11.c and mazeconv.c are included in other .c files,
--- 41,48 ----
                      Include/team.h Include/terminal.h Include/thread.h \
                      Include/tread-defs.h Include/vdesc.h Include/vehicle.h \
                      Include/vehicleparts.h Include/vstructs.h \
!                     Include/weapon-defs.h Include/xtank.h Include/xtanklib.h \
! 		    Include/sound.h
              XINCL = Include/x11.h
  
  /**/# Note that both x11.c and mazeconv.c are included in other .c files,
***************
*** 49,59 ****
  
  /**/# Important things that Xtank wants to find
  
!    EXTRA_INCLUDES = -I. -IInclude
  
  /**/# Everybody needs the following libraries
  
!   EXTRA_LIBRARIES = -LPrograms -lxtankrobots -lm
  
  /**/# Start of System Dependent Things
  /**/# (e.g. libraries, linker flags and so forth)
--- 50,60 ----
  
  /**/# Important things that Xtank wants to find
  
!    EXTRA_INCLUDES = -I. -IInclude -I/usr/local/include
  
  /**/# Everybody needs the following libraries
  
!   EXTRA_LIBRARIES = -LPrograms -lxtankrobots -lm -L/usr/local/lib -lrplay
  
  /**/# Start of System Dependent Things
  /**/# (e.g. libraries, linker flags and so forth)
Common subdirectories: ./Src/Include and ../xtank1.3f-sound/Src/Include
Common subdirectories: ./Src/Objects and ../xtank1.3f-sound/Src/Objects
Common subdirectories: ./Src/Old and ../xtank1.3f-sound/Src/Old
Common subdirectories: ./Src/Programs and ../xtank1.3f-sound/Src/Programs
diff -c -r ./Src/explosion.c ../xtank1.3f-sound/Src/explosion.c
*** ./Src/explosion.c	Sat Sep 12 12:51:48 1992
--- ../xtank1.3f-sound/Src/explosion.c	Fri Nov 13 11:28:33 1992
***************
*** 13,18 ****
--- 13,21 ----
  #include "bullet.h"
  #include "graphics.h"
  #include "loc.h"
+ #ifdef SOUND
+ #include "sound.h"
+ #endif SOUND
  
  
  #define EXP_SPREAD 15
***************
*** 32,37 ****
--- 35,75 ----
  
      if (eset->number >= MAX_EXPS)
  	return;
+ 
+ #ifdef SOUND
+      switch (type) {
+         case EXP_TANK:
+                 play_in_view(loc, TANK_EXPLOSION_SOUND);
+                 break;
+         case EXP_GLEAM:
+                 play_in_view(loc, GLEAM_EXPLOSION_SOUND);
+                 break;
+         case EXP_DAM0:
+                 play_in_view(loc, DAM0_EXPLOSION_SOUND);
+                 break;
+         case EXP_DAM1:
+                 play_in_view(loc, DAM1_EXPLOSION_SOUND);
+                 break;
+         case EXP_DAM2:
+                 play_in_view(loc, DAM2_EXPLOSION_SOUND);
+                 break;
+         case EXP_DAM3:
+                 play_in_view(loc, DAM3_EXPLOSION_SOUND);
+                 break;
+         case EXP_DAM4:
+                 play_in_view(loc, DAM4_EXPLOSION_SOUND);
+                 break;
+         case EXP_EXHAUST:
+                 play_in_view(loc, EXHAUST_EXPLOSION_SOUND);
+                 break;
+         case EXP_ELECTRIC:
+                 play_in_view(loc, ELECTRIC_EXPLOSION_SOUND);
+                 break;
+         default:
+                 play_in_view(loc, DAMAGE_EXPLOSION_SOUND);
+     }
+ #endif SOUND
+ 
      e = eset->list[eset->number++];
      e->x = (int) loc->x;
      e->y = (int) loc->y;
diff -c -r ./Src/file.c ../xtank1.3f-sound/Src/file.c
*** ./Src/file.c	Sun Sep 13 18:06:56 1992
--- ../xtank1.3f-sound/Src/file.c	Fri Nov 13 13:47:59 1992
***************
*** 139,144 ****
--- 139,147 ----
  char pathname[MAXPATHLEN];
  char headersdir[MAXPATHLEN];	/* full name of directory to find headers in */
  char vehiclesdir[MAXNAMLEN], mazesdir[MAXNAMLEN], programsdir[MAXNAMLEN];
+ #ifdef SOUND
+ char soundsdir[MAXNAMLEN];
+ #endif SOUND
  char username[MAX_STRING], displayname[256];
  
  #ifdef NEED_AUX_FONT
***************
*** 187,193 ****
      (void) strcpy(filename, "XVDIR:list");
  #endif /* AMIGA */
  
!     draw_text_rc(ANIM_WIN, 0, 1, "Reading vehicle list...", M_FONT, WHITE);
      sync_output(TRUE);
      if ((file = fopen(filename, "r")) != NULL)
      {
--- 190,196 ----
      (void) strcpy(filename, "XVDIR:list");
  #endif /* AMIGA */
  
!     draw_text_rc(ANIM_WIN, 0, 2, "Reading vehicle list...", M_FONT, WHITE);
      sync_output(TRUE);
      if ((file = fopen(filename, "r")) != NULL)
      {
***************
*** 215,221 ****
      (void) strcpy(filename, "XMDIR:list");
  #endif /* AMIGA */
  
!     draw_text_rc(ANIM_WIN, 0, 2, "Reading maze list...", M_FONT, WHITE);
      sync_output(TRUE);
      if ((file = fopen(filename, "r")) != NULL)
      {
--- 218,224 ----
      (void) strcpy(filename, "XMDIR:list");
  #endif /* AMIGA */
  
!     draw_text_rc(ANIM_WIN, 0, 3, "Reading maze list...", M_FONT, WHITE);
      sync_output(TRUE);
      if ((file = fopen(filename, "r")) != NULL)
      {
***************
*** 748,753 ****
--- 751,759 ----
  	strcpy(vehiclesdir, (p = getenv("XTANK_VEHICLES")) ? p : "Vehicles");
  	strcpy(mazesdir, (p = getenv("XTANK_MAZES")) ? p : "Mazes");
  	strcpy(programsdir, (p = getenv("XTANK_PROGRAMS")) ? p : "Programs");
+ #ifdef SOUND
+ 	strcpy(soundsdir, (p = getenv("XTANK_SOUNDS")) ? p : "Sounds");
+ #endif SOUND
  	if ((p = getenv("XTANK_HEADERS")) != NULL) {
  		strcpy(headersdir, p);
  	} else {
diff -c -r ./Src/gr.c ../xtank1.3f-sound/Src/gr.c
*** ./Src/gr.c	Sun Aug 30 14:15:11 1992
--- ../xtank1.3f-sound/Src/gr.c	Fri Nov 13 13:02:25 1992
***************
*** 134,139 ****
--- 134,143 ----
      /* Initialize 3D values for terminal */
      init_terminal_3d(t);
  
+ #ifdef SOUND
+     init_terminal_sound(t);
+ #endif SOUND
+ 
      return 0;
  }
  
***************
*** 174,179 ****
--- 178,188 ----
  close_terminal(t)
  Terminal *t;
  {
+ #ifdef SOUND
+ 	if (t->rplay_fd > 0) {
+ 		rplay_close(t->rplay_fd);
+ 	}
+ #endif SOUND
  	close_video((Video *) t->video);
  	free((char *) t);
  }
diff -c -r ./Src/hit.c ../xtank1.3f-sound/Src/hit.c
*** ./Src/hit.c	Sun Sep 13 00:04:34 1992
--- ../xtank1.3f-sound/Src/hit.c	Fri Nov 13 13:03:58 1992
***************
*** 66,73 ****
  #include "terminal.h"
  #include "cosell.h"
  #include "globals.h"
  
- 
  extern Map real_map;
  extern Settings settings;
  
--- 66,75 ----
  #include "terminal.h"
  #include "cosell.h"
  #include "globals.h"
+ #ifdef SOUND
+ #include "sound.h"
+ #endif SOUND
  
  extern Map real_map;
  extern Settings settings;
  
***************
*** 116,121 ****
--- 118,127 ----
      Side side;
      int has_ramplate1, has_ramplate2;
  
+ #ifdef SOUND
+     play_in_view(v1->loc, VEHICLE_HIT_VEHICLE_SOUND);
+ #endif SOUND
+ 
  #ifdef GDEBUG
      int itemp1, itemp2;
      static FILE *statfile = NULL;
***************
*** 257,262 ****
--- 263,272 ----
  	int dx, dy, damage, damage1, damage2;
  	int has_ramplate = FALSE;
  
+ #ifdef SOUND
+ 	play_in_view(v->loc, VEHICLE_HIT_WALL_SOUND);
+ #endif SOUND
+ 
  #ifdef GDEBUG
  	int itemp1, itemp2;
  	static FILE *statfile = NULL;
***************
*** 684,689 ****
--- 694,702 ----
  	b->flags &= ~wl;
  	/* tell all the combatants to update their map */
  	invalidate_maps();
+ #ifdef SOUND
+ 	play_in_view_x_y(x, y, TANK_EXPLOSION_SOUND);
+ #endif SOUND
      }
  
      return damage;
diff -c -r ./Src/init.c ../xtank1.3f-sound/Src/init.c
*** ./Src/init.c	Sun Aug 30 14:15:12 1992
--- ../xtank1.3f-sound/Src/init.c	Fri Nov 13 11:40:42 1992
***************
*** 100,105 ****
--- 100,108 ----
  	    FALSE,		/* Boolean no_nametags */
  	    TRUE,		/* Boolean team_score GHS */
  	    FALSE,		/* Boolean no_radar */
+ #ifdef SOUND
+ 	    FALSE,		/* Boolean no_sound */
+ #endif SOUND
  	    TRUE,		/* Boolean player_teleport */
  	    TRUE,		/* Boolean disc_teleport */
  	    TRUE,		/* Boolean teleport_from_team */
diff -c -r ./Src/interface.c ../xtank1.3f-sound/Src/interface.c
*** ./Src/interface.c	Sat Sep 12 12:51:47 1992
--- ../xtank1.3f-sound/Src/interface.c	Fri Nov 13 11:45:14 1992
***************
*** 254,259 ****
--- 254,262 ----
  			"Ultimate:Own Goal", "Robots don't Win",
  			"Scale Armor to Max", "No name tags",
  			"Team Scoring", "Disable RADAR",
+ #ifdef SOUND
+ 			"Disable Sound",
+ #endif SOUND
  			"Players can Teleport", "Discs can Teleport",
  			"'port from team", "'port from neutral",
  			"'port to team", "'port to neutral",
***************
*** 357,376 ****
  		menu_set_hil(&menu_sys, FLAGS_MENU, 14);
      if (settings.si.no_radar)
  		menu_set_hil(&menu_sys, FLAGS_MENU, 15);
      if (settings.si.player_teleport)
- 	menu_set_hil(&menu_sys, FLAGS_MENU, 16);
-     if (settings.si.disc_teleport)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 17);
!     if (settings.si.teleport_from_team)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 18);
!     if (settings.si.teleport_from_neutral)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 19);
!     if (settings.si.teleport_to_team)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 20);
!     if (settings.si.teleport_to_neutral)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 21);
!     if (settings.si.teleport_any_to_any)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 22);
  
  }
  
--- 360,383 ----
  		menu_set_hil(&menu_sys, FLAGS_MENU, 14);
      if (settings.si.no_radar)
  		menu_set_hil(&menu_sys, FLAGS_MENU, 15);
+ #ifdef SOUND
+     if (settings.si.no_sound)
+ 		menu_set_hil(&menu_sys, FLAGS_MENU, 16);
+ #endif SOUND
      if (settings.si.player_teleport)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 17);
!     if (settings.si.disc_teleport)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 18);
!     if (settings.si.teleport_from_team)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 19);
!     if (settings.si.teleport_from_neutral)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 20);
!     if (settings.si.teleport_to_team)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 21);
!     if (settings.si.teleport_to_neutral)
  	menu_set_hil(&menu_sys, FLAGS_MENU, 22);
+     if (settings.si.teleport_any_to_any)
+ 	menu_set_hil(&menu_sys, FLAGS_MENU, 23);
  
  }
  
***************
*** 937,960 ****
  			settings.si.no_radar ^= TRUE;
  			break;
  		case 16:
! 			settings.si.player_teleport ^= TRUE;
  			break;
  		case 17:
! 			settings.si.disc_teleport ^= TRUE;
  			break;
  		case 18:
! 			settings.si.teleport_from_team ^= TRUE;
  			break;
  		case 19:
! 			settings.si.teleport_from_neutral ^= TRUE;
  			break;
  		case 20:
! 			settings.si.teleport_to_team ^= TRUE;
  			break;
  		case 21:
! 			settings.si.teleport_to_neutral ^= TRUE;
  			break;
  		case 22:
  			settings.si.teleport_any_to_any ^= TRUE;
  			break;
  	}
--- 944,970 ----
  			settings.si.no_radar ^= TRUE;
  			break;
  		case 16:
! 			settings.si.no_sound ^= TRUE;
  			break;
  		case 17:
! 			settings.si.player_teleport ^= TRUE;
  			break;
  		case 18:
! 			settings.si.disc_teleport ^= TRUE;
  			break;
  		case 19:
! 			settings.si.teleport_from_team ^= TRUE;
  			break;
  		case 20:
! 			settings.si.teleport_from_neutral ^= TRUE;
  			break;
  		case 21:
! 			settings.si.teleport_to_team ^= TRUE;
  			break;
  		case 22:
+ 			settings.si.teleport_to_neutral ^= TRUE;
+ 			break;
+ 		case 23:
  			settings.si.teleport_any_to_any ^= TRUE;
  			break;
  	}
diff -c -r ./Src/lowlib.c ../xtank1.3f-sound/Src/lowlib.c
*** ./Src/lowlib.c	Sun Sep 13 00:04:36 1992
--- ../xtank1.3f-sound/Src/lowlib.c	Fri Nov 13 11:49:44 1992
***************
*** 83,88 ****
--- 83,91 ----
  #include "outpost.h"
  #include "globals.h"
  #include "graphics.h"
+ #ifdef SOUND
+ #include "sound.h"
+ #endif SOUND
  
  extern Weapon_stat weapon_stat[];
  extern Armor_stat armor_stat[];
***************
*** 694,699 ****
--- 697,769 ----
  
      cv->frame_weapon_fired = frame;
  
+ #ifdef SOUND
+         switch(w->type) {
+         case LMG:
+                 play_in_view(cv->loc, LMG_SOUND);
+                 break;
+         case MG:
+                 play_in_view(cv->loc, MG_SOUND);
+                 break;
+         case HMG:
+                 play_in_view(cv->loc, HMG_SOUND);
+                 break;
+         case LRIFLE:
+                 play_in_view(cv->loc, LRIFLE_SOUND);
+                 break;
+         case RIFLE:
+                 play_in_view(cv->loc, RIFLE_SOUND);
+                 break;
+         case HRIFLE:
+                 play_in_view(cv->loc, HRIFLE_SOUND);
+                 break;
+         case LCANNON:
+                 play_in_view(cv->loc, LCANNON_SOUND);
+                 break;
+         case CANNON:
+                 play_in_view(cv->loc, CANNON_SOUND);
+                 break;
+         case HCANNON:
+                 play_in_view(cv->loc, HCANNON_SOUND);
+                 break;
+         case LROCKET:
+                 play_in_view(cv->loc, LROCKET_SOUND);
+                 break;
+         case ROCKET:
+                 play_in_view(cv->loc, ROCKET_SOUND);
+                 break;
+         case HROCKET:
+                 play_in_view(cv->loc, HROCKET_SOUND);
+                 break;
+         case ACID:
+                 play_in_view(cv->loc, ACID_SOUND);
+                 break;
+         case FLAME:
+                 play_in_view(cv->loc, FLAME_SOUND);
+                 break;
+         case MINE:
+                 play_in_view(cv->loc, MINE_SOUND);
+                 break;
+         case SEEKER:
+                 play_in_view(cv->loc, SEEKER_SOUND);
+                 break;
+         case SLICK:
+                 play_in_view(cv->loc, SLICK_SOUND);
+                 break;
+         case PROCKET:
+                 play_in_view(cv->loc, PROCKET_SOUND);
+                 break;
+         case UMISSLE:
+                 play_in_view(cv->loc, UMISSLE_SOUND);
+                 break;
+         case HARM:
+                 play_in_view(cv->loc, HARM_SOUND);
+                 break;
+         case DISC:
+                 play_in_view(cv->loc, DISC_SOUND);
+                 break;
+         }
+ #endif SOUND
      }
  
      check_time();
diff -c -r ./Src/main.c ../xtank1.3f-sound/Src/main.c
*** ./Src/main.c	Sat Sep 12 12:51:46 1992
--- ../xtank1.3f-sound/Src/main.c	Fri Nov 13 13:49:19 1992
***************
*** 286,291 ****
--- 286,294 ----
      init_settings();
      init_threader();
      init_msg_sys();
+ #ifdef SOUND
+     init_sounds();
+ #endif SOUND
  
      /* Rotate vehicle objects */
      debug("Rotating vehicle objects");
diff -c -r ./Src/radar.c ../xtank1.3f-sound/Src/radar.c
*** ./Src/radar.c	Sun Sep 13 00:04:42 1992
--- ../xtank1.3f-sound/Src/radar.c	Fri Nov 13 11:52:12 1992
***************
*** 52,57 ****
--- 52,60 ----
  #include "vehicle.h"
  #include "globals.h"
  #include "bullet.h"
+ #ifdef SOUND
+ #include "sound.h"
+ #endif SOUND
  
  extern Map real_map;
  
***************
*** 212,217 ****
--- 215,223 ----
  
              if (vehicle_flags) {
  #endif /* !NO_CAMO */
+ #ifdef SOUND
+ 		play_owner(v, BLIP_SOUND);
+ #endif SOUND
  		b = &r->blip[r->num_blips++];
  		b->x = grid2map(x) + MAP_BOX_SIZE / 4;
  		b->y = grid2map(y) + MAP_BOX_SIZE / 4;
diff -c -r ./Src/setup.c ../xtank1.3f-sound/Src/setup.c
*** ./Src/setup.c	Sun Aug 30 14:15:21 1992
--- ../xtank1.3f-sound/Src/setup.c	Fri Nov 13 11:53:54 1992
***************
*** 65,70 ****
--- 65,73 ----
  #include "globals.h"
  #include "assert.h"
  #include "bullet.h"
+ #ifdef SOUND
+ #include "sound.h"
+ #endif SOUND
  
  extern Map real_map;
  extern Boolean game_paused;
***************
*** 296,304 ****
--- 299,315 ----
  
  	game_running = True;
  
+ #ifdef SOUND
+ 	play_all(START_SOUND);
+ #endif SOUND
+ 
  	do {
  	    status = animate();
  	} while (status == GAME_RUNNING);
+ 
+ #ifdef SOUND
+ 	play_all(END_SOUND);
+ #endif SOUND
  
  	game_running = False;
  
diff -c -r ./Src/Include/settings.h ../xtank1.3f-sound/Src/Include/settings.h
*** ./Src/Include/settings.h	Sun Aug 30 14:15:51 1992
--- ../xtank1.3f-sound/Src/Include/settings.h	Fri Nov 13 11:22:06 1992
***************
*** 18,23 ****
--- 18,26 ----
      Boolean no_nametags;	/* whether vehicles are anonymous */
      Boolean team_score;		/* whether to use team scoring */
      Boolean no_radar;		/* turns everyone's radar off */
+ #ifdef SOUND
+     Boolean no_sound;		/* turns everyone's sound off */
+ #endif SOUND
      Boolean player_teleport;	/* whether players can teleport */
      Boolean disc_teleport;	/* whether discs can teleport */
      Boolean teleport_from_team;		/* whether we can teleport from */
diff -c -r ./Src/Include/terminal.h ../xtank1.3f-sound/Src/Include/terminal.h
*** ./Src/Include/terminal.h	Sun Aug 30 14:15:53 1992
--- ../xtank1.3f-sound/Src/Include/terminal.h	Fri Nov 13 11:20:28 1992
***************
*** 57,62 ****
--- 57,65 ----
  				   vehicle */
      int mouse_speed;		/* True if this terminal sets vehicle speed */
  							/* by mouse clicks */
+ #ifdef SOUND
+     int	  rplay_fd;
+ #endif SOUND
  } Terminal;