shithub: patch

ref: 2663fd26c74a163a30328f9fecbe8b5f46c977f6
dir: /graveyard/doomn-sawup/

View raw version
does not work. second part should also be removed.

diff -Naur a/sys/src/games/doom/i_sound.c b/sys/src/games/doom/i_sound.c
--- a/sys/src/games/doom/i_sound.c	Wed Jul 29 13:45:35 2015
+++ b/sys/src/games/doom/i_sound.c	Sun Aug  2 23:51:32 2015
@@ -333,33 +333,21 @@
 	int			rightvol;
 	int			leftvol;
 
-	/* Chainsaw troubles.
-	** Play these sound effects only one at a time. */
-	if ( id == sfx_sawup ||
-	     id == sfx_sawidl ||
-	     id == sfx_sawful ||
-	     id == sfx_sawhit ||
-	     id == sfx_stnmov ||
-	     id == sfx_pistol )
+	for (i=0 ; (i<NUM_CHANNELS) && (channels[i]) ; i++)
 	{
-		/* Loop all channels, check. */
-		for (i=0 ; i < NUM_CHANNELS ; i++)
-		{
-			/* Active and using the same SFX? */
-			if( (channels[i]) && (channelids[i] == id) )
-			{
-				/* Reset. */
+		if(id == sfx_sawidl && channelids[i] == sfx_sawup)	/* don't play during sawup */
+			return 0;
+		if(channelids[i] == id)
+			switch(id){	/* to be played only one at a time */
+			case sfx_sawup:
+			case sfx_sawidl:
+			case sfx_sawful:
+			case sfx_sawhit:
+			case sfx_stnmov:
+			case sfx_pistol:
 				channels[i] = 0;
-				/* We are sure that iff,
-				**  there will only be one. */
-				break;
+				continue;
 			}
-		}
-	}
-
-	/* Loop all channels to find oldest SFX. */
-	for (i=0 ; (i<NUM_CHANNELS) && (channels[i]) ; i++)
-	{
 		if(channelstart[i] < oldest)
 		{
 			oldestnum = i;
@@ -383,7 +371,7 @@
 	*/
 	channels[slot] = (uchar*) S_sfx[id].data;
 	/* Set pointer to end of raw data. */
-	channelsend[slot] = channels[slot] + lengths[id];
+	channelsend[slot] = channels[slot] + (id == sfx_sawful ? lengths[id] / 2 : lengths[id]);
 
 	/* Reset current handle number, limited to 0..100. */
 	if (!handlenums)