* 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://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@401 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2011-01-18 06:50:35 +00:00
parent 8354026d8e
commit c3ec785b66

View file

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