From a88b23e1f3d8c7106d251522dc5020efb9b65fd4 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Wed, 6 Jul 2011 05:53:25 +0000 Subject: [PATCH] use colormap only for determining fullbrights, commit in sound paint funcs git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3847 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_main.c | 1 - engine/client/quakedef.h | 1 - engine/client/renderer.c | 39 ++++---- engine/client/snd_mix.c | 196 +++++++++++++++++++++++++++---------- engine/client/vid.h | 1 - engine/gl/gl_vidlinuxglx.c | 2 - engine/gl/gl_vidmacos.c | 2 - engine/gl/gl_vidmorphos.c | 1 - engine/gl/gl_vidnt.c | 2 - 9 files changed, 167 insertions(+), 78 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 9ba25ee47..aa034317d 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -230,7 +230,6 @@ int host_framecount; int host_hunklevel; qbyte *host_basepal; -qbyte *host_colormap; qbyte *h2playertranslations; cvar_t host_speeds = SCVAR("host_speeds","0"); // set for running times diff --git a/engine/client/quakedef.h b/engine/client/quakedef.h index 8608e9247..0749b3605 100644 --- a/engine/client/quakedef.h +++ b/engine/client/quakedef.h @@ -238,7 +238,6 @@ extern cvar_t password; extern qboolean host_initialized; // true if into command execution extern double host_frametime; extern qbyte *host_basepal; -extern qbyte *host_colormap; extern qbyte *h2playertranslations; extern int host_framecount; // incremented every frame, never reset extern double realtime; // not bounded in any way, changed at diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 79313bfdf..74634df6d 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -939,8 +939,6 @@ qboolean R_ApplyRenderer_Load (rendererstate_t *newr) if (host_basepal) BZ_Free(host_basepal); - if (host_colormap) - BZ_Free(host_colormap); host_basepal = (qbyte *)FS_LoadMallocFile ("gfx/palette.lmp"); if (!host_basepal) { @@ -953,28 +951,31 @@ qboolean R_ApplyRenderer_Load (rendererstate_t *newr) } else { - host_colormap = BZ_Malloc(256*VID_GRADES); - if (ReadPCXData(pcx, com_filesize, 256, VID_GRADES, host_colormap)) - goto q2colormap; //skip the colormap.lmp file as we already read it + //if (ReadPCXData(pcx, com_filesize, 256, VID_GRADES, colormap)) + goto q2colormap; //skip the colormap.lmp file as we already read it } } - host_colormap = (qbyte *)FS_LoadMallocFile ("gfx/colormap.lmp"); - if (!host_colormap) + { - vid.fullbright=0; - } - else - { - j = VID_GRADES-1; - data = host_colormap + j*256; - vid.fullbright=0; - for (i = 255; i >= 0; i--) + qbyte *colormap = (qbyte *)FS_LoadMallocFile ("gfx/colormap.lmp"); + if (!colormap) { - if (host_colormap[i] == data[i]) - vid.fullbright++; - else - break; + vid.fullbright=0; } + else + { + j = VID_GRADES-1; + data = colormap + j*256; + vid.fullbright = 0; + for (i = 255; i >= 0; i--) + { + if (colormap[i] == data[i]) + vid.fullbright++; + else + break; + } + } + BZ_Free(colormap); } if (h2playertranslations) diff --git a/engine/client/snd_mix.c b/engine/client/snd_mix.c index e3178bf10..19460e829 100644 --- a/engine/client/snd_mix.c +++ b/engine/client/snd_mix.c @@ -29,45 +29,23 @@ portable_samplegroup_t paintbuffer[PAINTBUFFER_SIZE]; int *snd_p, snd_vol; short *snd_out; -static int paintskip[6][6] = -{ - {6}, - {1, 5}, - {1, 1, 4}, - {1, 1, 1, 3}, - {1, 1, 1, 1, 2}, - {1, 1, 1, 1, 1, 1} -}; - -static int chnskip[6][6] = -{ - {0}, - {1, -1}, - {1, 1, -2}, - {1, 1, 1, -3}, - {1, 1, 1, 1, -4}, - {1, 1, 1, 1, 1, -5} -}; - void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime) { unsigned int startidx, out_idx; unsigned int count; unsigned int outlimit; int *p; - int *skip; - int *cskip; int val; int snd_vol; short *pbuf; + int i, numc; p = (int *) paintbuffer; - skip = paintskip[sc->sn.numchannels-1]; - cskip = chnskip[sc->sn.numchannels-1]; count = (endtime - sc->paintedtime) * sc->sn.numchannels; outlimit = sc->sn.samples; startidx = out_idx = (sc->paintedtime * sc->sn.numchannels) % outlimit; snd_vol = (volume.value*voicevolumemod)*256; + numc = sc->sn.numchannels; pbuf = sc->Lock(sc); if (!pbuf) @@ -76,35 +54,41 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime) if (sc->sn.samplebits == 16) { short *out = (short *) pbuf; - while (count--) + while (count) { - val = (*p * snd_vol) >> 8; - p += *skip; - if (val > 0x7fff) - val = 0x7fff; - else if (val < (short)0x8000) - val = (short)0x8000; - out[out_idx] = val; - out_idx = (out_idx + 1) % outlimit; - skip += *cskip; - cskip += *cskip; + for (i = 0; i < numc; i++) + { + val = (*p * snd_vol) >> 8; + p++; + if (val > 0x7fff) + val = 0x7fff; + else if (val < (short)0x8000) + val = (short)0x8000; + out[out_idx] = val; + out_idx = (out_idx + 1) % outlimit; + } + p += MAXSOUNDCHANNELS - numc; + count -= numc; } } else if (sc->sn.samplebits == 8) { unsigned char *out = (unsigned char *) pbuf; - while (count--) + while (count) { - val = (*p * snd_vol) >> 8; - p += *skip; - if (val > 0x7fff) - val = 0x7fff; - else if (val < (short)0x8000) - val = (short)0x8000; - out[out_idx] = (val>>8) + 128; - out_idx = (out_idx + 1) % outlimit; - skip += *cskip; - cskip += *cskip; + for (i = 0; i < numc; i++) + { + val = (*p * snd_vol) >> 8; + p++; + if (val > 0x7fff) + val = 0x7fff; + else if (val < (short)0x8000) + val = (short)0x8000; + out[out_idx] = (val>>8) + 128; + out_idx = (out_idx + 1) % outlimit; + } + p += MAXSOUNDCHANNELS - numc; + count -= numc; } } @@ -126,6 +110,8 @@ void SND_PaintChannelFrom8_4Speaker (channel_t *ch, sfxcache_t *sc, int count); void SND_PaintChannelFrom16_4Speaker (channel_t *ch, sfxcache_t *sc, int count); void SND_PaintChannelFrom8_6Speaker (channel_t *ch, sfxcache_t *sc, int count); void SND_PaintChannelFrom16_6Speaker (channel_t *ch, sfxcache_t *sc, int count); +void SND_PaintChannelFrom8_8Speaker (channel_t *ch, sfxcache_t *sc, int count); +void SND_PaintChannelFrom16_8Speaker (channel_t *ch, sfxcache_t *sc, int count); void SND_PaintChannelFrom8Stereo (channel_t *ch, sfxcache_t *sc, int count); void SND_PaintChannelFrom16Stereo (channel_t *ch, sfxcache_t *sc, int count); @@ -224,6 +210,8 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) { if (scache->numchannels==2) SND_PaintChannelFrom8Stereo(ch, scache, count); + else if (sc->sn.numchannels == 8) + SND_PaintChannelFrom8_8Speaker(ch, scache, count); else if (sc->sn.numchannels == 6) SND_PaintChannelFrom8_6Speaker(ch, scache, count); else if (sc->sn.numchannels == 4) @@ -235,6 +223,8 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime) { if (scache->numchannels==2) SND_PaintChannelFrom16Stereo(ch, scache, count); + else if (sc->sn.numchannels == 8) + SND_PaintChannelFrom16_8Speaker(ch, scache, count); else if (sc->sn.numchannels == 6) SND_PaintChannelFrom16_6Speaker(ch, scache, count); else if (sc->sn.numchannels == 4) @@ -446,6 +436,63 @@ void SND_PaintChannelFrom8_6Speaker (channel_t *ch, sfxcache_t *sc, int count) } } +void SND_PaintChannelFrom8_8Speaker (channel_t *ch, sfxcache_t *sc, int count) +{ + signed char *sfx; + int i; + + if (ch->vol[0] > 255) + ch->vol[0] = 255; + if (ch->vol[1] > 255) + ch->vol[1] = 255; + if (ch->vol[2] > 255) + ch->vol[2] = 255; + if (ch->vol[3] > 255) + ch->vol[3] = 255; + if (ch->vol[4] > 255) + ch->vol[4] = 255; + if (ch->vol[5] > 255) + ch->vol[5] = 255; + if (ch->vol[6] > 255) + ch->vol[6] = 255; + if (ch->vol[7] > 255) + ch->vol[7] = 255; + + if (ch->rate != (1<data; + for (i=0 ; ipos>>PITCHSHIFT]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += ch->vol[0] * data; + paintbuffer[i].s[1] += ch->vol[1] * data; + paintbuffer[i].s[2] += ch->vol[2] * data; + paintbuffer[i].s[3] += ch->vol[3] * data; + paintbuffer[i].s[4] += ch->vol[4] * data; + paintbuffer[i].s[5] += ch->vol[5] * data; + paintbuffer[i].s[6] += ch->vol[6] * data; + paintbuffer[i].s[7] += ch->vol[7] * data; + } + } + else + { + sfx = (signed char *)sc->data + (ch->pos>>PITCHSHIFT); + for (i=0 ; ivol[0] * sfx[i]; + paintbuffer[i].s[1] += ch->vol[1] * sfx[i]; + paintbuffer[i].s[2] += ch->vol[2] * sfx[i]; + paintbuffer[i].s[3] += ch->vol[3] * sfx[i]; + paintbuffer[i].s[4] += ch->vol[4] * sfx[i]; + paintbuffer[i].s[5] += ch->vol[5] * sfx[i]; + paintbuffer[i].s[6] += ch->vol[6] * sfx[i]; + paintbuffer[i].s[7] += ch->vol[7] * sfx[i]; + } + ch->pos += count<vol[0]; + vol[1] = ch->vol[1]; + vol[2] = ch->vol[2]; + vol[3] = ch->vol[3]; + + if (ch->rate != (1<data; + for (i=0 ; ipos>>PITCHSHIFT]; + ch->pos += ch->rate; + paintbuffer[i].s[0] += (vol[0] * data)>>8; + paintbuffer[i].s[1] += (vol[1] * data)>>8; + paintbuffer[i].s[2] += (vol[2] * data)>>8; + paintbuffer[i].s[3] += (vol[3] * data)>>8; + } + } + else + { + sfx = (signed short *)sc->data + ch->pos; + for (i=0 ; i> 8; + paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8; + paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8; + paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8; + } + ch->pos += count<vol[1]; vol[2] = ch->vol[2]; vol[3] = ch->vol[3]; + vol[4] = ch->vol[4]; + vol[5] = ch->vol[5]; + vol[6] = ch->vol[6]; + vol[7] = ch->vol[7]; if (ch->rate != (1<>8; paintbuffer[i].s[2] += (vol[2] * data)>>8; paintbuffer[i].s[3] += (vol[3] * data)>>8; + paintbuffer[i].s[4] += (vol[4] * data)>>8; + paintbuffer[i].s[5] += (vol[5] * data)>>8; + paintbuffer[i].s[6] += (vol[6] * data)>>8; + paintbuffer[i].s[7] += (vol[7] * data)>>8; } } else { - sfx = (signed short *)sc->data + ch->pos; + sfx = (signed short *)sc->data + (ch->pos>>PITCHSHIFT); for (i=0 ; i> 8; paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8; paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8; paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8; + paintbuffer[i].s[4] += (sfx[i] * vol[4]) >> 8; + paintbuffer[i].s[5] += (sfx[i] * vol[5]) >> 8; + paintbuffer[i].s[6] += (sfx[i] * vol[6]) >> 8; + paintbuffer[i].s[7] += (sfx[i] * vol[7]) >> 8; } ch->pos += count<width; vid.pixelheight = info->height; vid.numpages = 3; - vid.colormap = host_colormap; if (vid.pixelwidth <= 640) { diff --git a/engine/gl/gl_vidnt.c b/engine/gl/gl_vidnt.c index fcc575a4a..5837e3996 100644 --- a/engine/gl/gl_vidnt.c +++ b/engine/gl/gl_vidnt.c @@ -1879,8 +1879,6 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette) vid_initialized = false; vid_initializing = true; - vid.colormap = host_colormap; - VID_SetPalette (palette); if (!GLVID_SetMode (info, palette))