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
This commit is contained in:
TimeServ 2011-07-06 05:53:25 +00:00
parent c6f4994293
commit a88b23e1f3
9 changed files with 167 additions and 78 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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<<PITCHSHIFT))
{
signed char data;
sfx = (signed char *)sc->data;
for (i=0 ; i<count ; i++)
{
data = sfx[ch->pos>>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 ; i<count ; i++)
{
paintbuffer[i].s[0] += ch->vol[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<<PITCHSHIFT;
}
}
void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
@ -520,6 +567,45 @@ void SND_PaintChannelFrom16Stereo (channel_t *ch, sfxcache_t *sc, int count)
}
}
void SND_PaintChannelFrom16_4Speaker (channel_t *ch, sfxcache_t *sc, int count)
{
int vol[4];
signed short *sfx;
int i;
vol[0] = ch->vol[0];
vol[1] = ch->vol[1];
vol[2] = ch->vol[2];
vol[3] = ch->vol[3];
if (ch->rate != (1<<PITCHSHIFT))
{
signed short data;
sfx = (signed short *)sc->data;
for (i=0 ; i<count ; i++)
{
data = sfx[ch->pos>>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<count ; i++)
{
paintbuffer[i].s[0] += (sfx[i] * vol[0]) >> 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<<PITCHSHIFT;
}
}
void SND_PaintChannelFrom16_6Speaker (channel_t *ch, sfxcache_t *sc, int count)
{
int vol[6];
@ -565,9 +651,9 @@ void SND_PaintChannelFrom16_6Speaker (channel_t *ch, sfxcache_t *sc, int count)
}
}
void SND_PaintChannelFrom16_4Speaker (channel_t *ch, sfxcache_t *sc, int count)
void SND_PaintChannelFrom16_8Speaker (channel_t *ch, sfxcache_t *sc, int count)
{
int vol[4];
int vol[8];
signed short *sfx;
int i;
@ -575,6 +661,10 @@ void SND_PaintChannelFrom16_4Speaker (channel_t *ch, sfxcache_t *sc, int count)
vol[1] = ch->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<<PITCHSHIFT))
{
@ -588,17 +678,25 @@ void SND_PaintChannelFrom16_4Speaker (channel_t *ch, sfxcache_t *sc, int count)
paintbuffer[i].s[1] += (vol[1] * data)>>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<count ; i++)
{
paintbuffer[i].s[0] += (sfx[i] * vol[0]) >> 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<<PITCHSHIFT;
}

View File

@ -50,7 +50,6 @@ typedef struct vrect_s
typedef struct
{
pixel_t *colormap; // 256 * VID_GRADES size
int fullbright; // index of first fullbright color
unsigned width; /*virtual 2d width*/

View File

@ -806,8 +806,6 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
}
#endif
vid.colormap = host_colormap;
// interpret command-line params
// set vid parameters

View File

@ -66,8 +66,6 @@ qboolean GLVID_Init(rendererstate_t *info, unsigned char *palette)
//don't care if opengl failed.
vid.numpages = 2;
vid.colormap = host_colormap;
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
// initialise the NSApplication and the screen
initCocoa(info);

View File

@ -363,7 +363,6 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
vid.pixelwidth = info->width;
vid.pixelheight = info->height;
vid.numpages = 3;
vid.colormap = host_colormap;
if (vid.pixelwidth <= 640)
{

View File

@ -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))