mirror of
https://git.code.sf.net/p/quake/nuq
synced 2025-02-17 17:41:31 +00:00
back out the last changes as they break compiling
This commit is contained in:
parent
2a6086bc72
commit
63895493c3
1 changed files with 53 additions and 87 deletions
140
source/snd_mix.c
140
source/snd_mix.c
|
@ -393,16 +393,17 @@ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
|
|
||||||
void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
|
void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
{
|
{
|
||||||
int leftvol, rightvol;
|
int leftvol, rightvol;
|
||||||
signed short *sfx;
|
signed short *sfx;
|
||||||
unsigned int i = 0;
|
int i = 0;
|
||||||
unsigned int left_phase, right_phase; // never allowed < 0 anyway
|
unsigned int left_phase, right_phase; // never allowed < 0 anyway
|
||||||
unsigned int olp, orp, nlp, nrp;
|
int oldphase = ch->oldphase * 2;
|
||||||
|
int phase = ch->phase * 2;
|
||||||
|
|
||||||
int dir = (phase - oldphase) > 0 ? 1 : -1;
|
int dir = (phase - oldphase) > 0 ? 1 : -1;
|
||||||
int ldir;
|
int ldir;
|
||||||
int rdir;
|
int rdir;
|
||||||
|
|
||||||
leftvol = ch->leftvol;
|
leftvol = ch->leftvol;
|
||||||
rightvol = ch->rightvol;
|
rightvol = ch->rightvol;
|
||||||
|
|
||||||
|
@ -412,98 +413,63 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
sfx = (signed short *)sc->data + ch->pos;
|
sfx = (signed short *)sc->data + ch->pos;
|
||||||
ch->pos += count;
|
ch->pos += count;
|
||||||
|
|
||||||
if (phase >= 0) {
|
if (oldphase >= 0) {
|
||||||
left_phase = phase;
|
left_phase = oldphase;
|
||||||
right_phase = 0;
|
right_phase = 0;
|
||||||
} else {
|
} else {
|
||||||
left_phase = 0;
|
left_phase = 0;
|
||||||
right_phase = -phase;
|
right_phase = -oldphase;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (olphase != phase) {
|
#define PAINT_CHANNELS do { \
|
||||||
if (oldphase >= 0) {
|
int data = sfx[i]; \
|
||||||
olp = oldphase;
|
int left = (data * leftvol) >> 8; \
|
||||||
orp = 0;
|
int right = (data * rightvol) >> 8; \
|
||||||
} else {
|
paintbuffer[i + left_phase / 2].left += left; \
|
||||||
olp = 0;
|
paintbuffer[i + right_phase / 2].right += right;\
|
||||||
orp = -oldphase;
|
} while (0)
|
||||||
|
|
||||||
|
if (oldphase != phase) {
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if ((oldphase ^ phase) & ~((~0u)>>1)) {
|
||||||
|
// phase change crosses 0
|
||||||
|
c = min (count, abs(oldphase));
|
||||||
|
count -= c;
|
||||||
|
if (oldphase > 0) {
|
||||||
|
ldir = -1;
|
||||||
|
rdir = 0;
|
||||||
|
} else {
|
||||||
|
ldir = 0;
|
||||||
|
rdir = -1;
|
||||||
|
}
|
||||||
|
for ( ; c; c--, i++) {
|
||||||
|
PAINT_CHANNELS;
|
||||||
|
left_phase += ldir;
|
||||||
|
right_phase += rdir;
|
||||||
|
}
|
||||||
|
oldphase = 0;
|
||||||
}
|
}
|
||||||
nlp = left_phase;
|
// oldphase and phase [now] on same size of 0
|
||||||
nrp = right_phase;
|
c = min (count, abs (phase - oldphase));
|
||||||
if (olp == nlp) {
|
count -= c;
|
||||||
// static left phase
|
if (phase > 0) {
|
||||||
if (nrp > orp) {
|
ldir = dir;
|
||||||
// increasing right phase
|
rdir = 0;
|
||||||
int c = min (count, nrp - orp);
|
|
||||||
count -= c;
|
|
||||||
for (; c; c--, i++) {
|
|
||||||
int data = sfx[i];
|
|
||||||
int left = (data * leftvol) >> 8;
|
|
||||||
int right = (data * rightvol) >> 8;
|
|
||||||
paintbuffer[i + left_phase].left += left;
|
|
||||||
paintbuffer[i + orp].right += right;
|
|
||||||
orp++;
|
|
||||||
paintbuffer[i + orp].right += right;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// decreasing right phase (static right phase not valid here)
|
|
||||||
int c = min (count, (orp - nrp) * 2);
|
|
||||||
for (; c > 0; c-=2, i++) {
|
|
||||||
int data = sfx[i];
|
|
||||||
int left = (data * leftvol) >> 8;
|
|
||||||
int right = (data * rightvol) >> 8;
|
|
||||||
paintbuffer[i + left_phase].left += left;
|
|
||||||
paintbuffer[i + orp].right += right;
|
|
||||||
orp--;
|
|
||||||
i++;
|
|
||||||
paintbuffer[i + left_phase].left += left;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (olp < nlp) {
|
|
||||||
// increasing left phase
|
|
||||||
if (nrp < orp) {
|
|
||||||
// decreasing right phase
|
|
||||||
} else {
|
|
||||||
// static right phase (increasing right phase not valid)
|
|
||||||
int c = min (count, nrp - orp);
|
|
||||||
count -= c;
|
|
||||||
for (; c; c--, i++) {
|
|
||||||
int data = sfx[i];
|
|
||||||
int left = (data * leftvol) >> 8;
|
|
||||||
int right = (data * rightvol) >> 8;
|
|
||||||
paintbuffer[i + olp].left += left;
|
|
||||||
paintbuffer[i + right_phase].right += right;
|
|
||||||
orp++;
|
|
||||||
paintbuffer[i + right_phase].right += right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// decreasing left phase
|
ldir = 0;
|
||||||
if (nrp > orp) {
|
rdir = dir;
|
||||||
// increasing right phase
|
}
|
||||||
} else {
|
for ( ; c; c--, i++) {
|
||||||
// static right phase (decreasing right phase not valid)
|
PAINT_CHANNELS;
|
||||||
int c = min (count, (orp - nrp) * 2);
|
left_phase += ldir;
|
||||||
for (; c > 0; c-=2, i++) {
|
right_phase += rdir;
|
||||||
int data = sfx[i];
|
|
||||||
int left = (data * leftvol) >> 8;
|
|
||||||
int right = (data * rightvol) >> 8;
|
|
||||||
paintbuffer[i + left_phase].left += left;
|
|
||||||
paintbuffer[i + orp].right += right;
|
|
||||||
orp--;
|
|
||||||
i++;
|
|
||||||
paintbuffer[i + left_phase].left += left;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; count ; count--, i++) {
|
for (; count ; count--, i++) {
|
||||||
int data = sfx[i];
|
PAINT_CHANNELS;
|
||||||
int left = (data * leftvol) >> 8;
|
|
||||||
int right = (data * rightvol) >> 8;
|
|
||||||
paintbuffer[i + left_phase].left += left;
|
|
||||||
paintbuffer[i + right_phase].right += right;
|
|
||||||
}
|
}
|
||||||
|
#undef PAINT_CHANNELS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue