From 9ea9f53493c42381e4c794b36c06dd4a18d82d33 Mon Sep 17 00:00:00 2001 From: ewasylishen Date: Fri, 28 Jul 2017 20:50:03 +0000 Subject: [PATCH] snd_mix.c: Fix clang warnings about bit-shifting negative numbers (which is implementation-defined) git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1448 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/snd_mix.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/quakespasm/Quake/snd_mix.c b/quakespasm/Quake/snd_mix.c index 2cf97a14..8dc3e02f 100644 --- a/quakespasm/Quake/snd_mix.c +++ b/quakespasm/Quake/snd_mix.c @@ -38,7 +38,7 @@ static void Snd_WriteLinearBlastStereo16 (void) for (i = 0; i < snd_linear_count; i += 2) { - val = snd_p[i] >> 8; + val = snd_p[i] / 256; if (val > 0x7fff) snd_out[i] = 0x7fff; else if (val < (short)0x8000) @@ -46,7 +46,7 @@ static void Snd_WriteLinearBlastStereo16 (void) else snd_out[i] = val; - val = snd_p[i+1] >> 8; + val = snd_p[i+1] / 256; if (val > 0x7fff) snd_out[i+1] = 0x7fff; else if (val < (short)0x8000) @@ -108,7 +108,7 @@ static void S_TransferPaintBuffer (int endtime) short *out = (short *)shm->buffer; while (count--) { - val = *p >> 8; + val = *p / 256; p+= step; if (val > 0x7fff) val = 0x7fff; @@ -123,13 +123,13 @@ static void S_TransferPaintBuffer (int endtime) unsigned char *out = shm->buffer; while (count--) { - val = *p >> 8; + val = *p / 256; p+= step; if (val > 0x7fff) val = 0x7fff; else if (val < (short)0x8000) val = (short)0x8000; - out[out_idx] = (val >> 8) + 128; + out[out_idx] = (val / 256) + 128; out_idx = (out_idx + 1) & out_mask; } } @@ -138,13 +138,13 @@ static void S_TransferPaintBuffer (int endtime) signed char *out = (signed char *) shm->buffer; while (count--) { - val = *p >> 8; + val = *p / 256; p+= step; if (val > 0x7fff) val = 0x7fff; else if (val < (short)0x8000) val = (short)0x8000; - out[out_idx] = (val >> 8); + out[out_idx] = (val / 256); out_idx = (out_idx + 1) & out_mask; } } @@ -407,8 +407,8 @@ void S_PaintChannels (int endtime) // clipping for (i=0; i> 1; - paintbuffer[i].right = CLAMP(-32768 << 8, paintbuffer[i].right, 32767 << 8) >> 1; + paintbuffer[i].left = CLAMP(-32768 * 256, paintbuffer[i].left, 32767 * 256) / 2; + paintbuffer[i].right = CLAMP(-32768 * 256, paintbuffer[i].right, 32767 * 256) / 2; } // apply a lowpass filter @@ -431,8 +431,8 @@ void S_PaintChannels (int endtime) { s = i & (MAX_RAW_SAMPLES - 1); // lower music by 6db to match sfx - paintbuffer[i - paintedtime].left += s_rawsamples[s].left >> 1; - paintbuffer[i - paintedtime].right += s_rawsamples[s].right >> 1; + paintbuffer[i - paintedtime].left += s_rawsamples[s].left / 2; + paintbuffer[i - paintedtime].right += s_rawsamples[s].right / 2; } // if (i != end) // Con_Printf ("partial stream\n"); @@ -505,8 +505,8 @@ static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, in leftvol = ch->leftvol * snd_vol; rightvol = ch->rightvol * snd_vol; - leftvol >>= 8; - rightvol >>= 8; + leftvol /= 256; + rightvol /= 256; sfx = (signed short *)sc->data + ch->pos; for (i = 0; i < count; i++)