* snd_mix.c (SND_PaintChannelFrom16): multiplication might cause

integer overflow as observed in the warpspasm mod depending on
  the volume level. so, moved the left shifting to left/right
  volume before the multiplication.


git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@401 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2011-01-18 06:50:35 +00:00
parent 368dc1f993
commit f918de5d64

View file

@ -302,13 +302,19 @@ static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
leftvol = ch->leftvol * snd_vol;
rightvol = ch->rightvol * snd_vol;
leftvol >>= 8;
rightvol >>= 8;
sfx = (signed short *)sc->data + ch->pos;
for (i = 0; i < count; i++)
{
data = sfx[i];
left = (data * leftvol) >> 8;
right = (data * rightvol) >> 8;
// this was causing integer overflow as observed in quakespasm
// with the warpspasm mod moved <<8 to left/right volume above.
// left = (data * leftvol) >> 8;
// right = (data * rightvol) >> 8;
left = data * leftvol;
right = data * rightvol;
paintbuffer[i].left += left;
paintbuffer[i].right += right;
}