Change RGB32k to a union of BYTE[32][32][32] and BYTE[32*32*32]

- Clang's optional runtime array bounds checking doesn't understand when we
  intentionally "overflow" by doing this:
    RGB32k[0][0][colorval]
  It will warn that it was accessed at an index will past the bounds
  of type 'BYTE [32]', which makes it less than useful for catching real
  array bounds overflows. So now do this:
    RGB32k.All[colorval]
  And if you want this:
    RGB32k[r][g][b]
  Now do this:
    RGB32k.RGB[r][g][b]
This commit is contained in:
Randy Heit 2015-03-08 18:05:02 -05:00
parent 308a036955
commit e259087c19
13 changed files with 88 additions and 77 deletions

View file

@ -303,7 +303,7 @@ bool wipe_doBurn (int ticks)
DWORD fg = fg2rgb[fromnew[x]];
DWORD bg = bg2rgb[fromold[x]];
fg = (fg+bg) | 0x1f07c1f;
to[x] = RGB32k[0][0][fg & (fg>>15)];
to[x] = RGB32k.All[fg & (fg>>15)];
done = false;
}
}
@ -354,7 +354,7 @@ bool wipe_doFade (int ticks)
DWORD fg = fg2rgb[fromnew[x]];
DWORD bg = bg2rgb[fromold[x]];
fg = (fg+bg) | 0x1f07c1f;
to[x] = RGB32k[0][0][fg & (fg>>15)];
to[x] = RGB32k.All[fg & (fg>>15)];
}
fromnew += SCREENWIDTH;
fromold += SCREENWIDTH;

View file

@ -270,7 +270,7 @@ void R_FillAddColumn (void)
{
DWORD bg;
bg = (fg + bg2rgb[*dest]) | 0x1f07c1f;
*dest = RGB32k[0][0][bg & (bg>>15)];
*dest = RGB32k.All[bg & (bg>>15)];
dest += pitch;
} while (--count);
@ -303,7 +303,7 @@ void R_FillAddClampColumn (void)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
dest += pitch;
} while (--count);
@ -335,7 +335,7 @@ void R_FillSubClampColumn (void)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
dest += pitch;
} while (--count);
@ -367,7 +367,7 @@ void R_FillRevSubClampColumn (void)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
dest += pitch;
} while (--count);
@ -569,7 +569,7 @@ void R_DrawAddColumnP_C (void)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
*dest = RGB32k[0][0][fg & (fg>>15)];
*dest = RGB32k.All[fg & (fg>>15)];
dest += pitch;
frac += fracstep;
} while (--count);
@ -650,7 +650,7 @@ void R_DrawTlatedAddColumnP_C (void)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
*dest = RGB32k[0][0][fg & (fg>>15)];
*dest = RGB32k.All[fg & (fg>>15)];
dest += pitch;
frac += fracstep;
} while (--count);
@ -686,7 +686,7 @@ void R_DrawShadedColumnP_C (void)
DWORD val = colormap[source[frac>>FRACBITS]];
DWORD fg = fgstart[val<<8];
val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f;
*dest = RGB32k[0][0][val & (val>>15)];
*dest = RGB32k.All[val & (val>>15)];
dest += pitch;
frac += fracstep;
@ -728,7 +728,7 @@ void R_DrawAddClampColumnP_C ()
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
dest += pitch;
frac += fracstep;
} while (--count);
@ -770,7 +770,7 @@ void R_DrawAddClampTranslatedColumnP_C ()
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest = RGB32k[0][0][(a>>15) & a];
*dest = RGB32k.All[(a>>15) & a];
dest += pitch;
frac += fracstep;
} while (--count);
@ -810,7 +810,7 @@ void R_DrawSubClampColumnP_C ()
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
dest += pitch;
frac += fracstep;
} while (--count);
@ -851,7 +851,7 @@ void R_DrawSubClampTranslatedColumnP_C ()
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][(a>>15) & a];
*dest = RGB32k.All[(a>>15) & a];
dest += pitch;
frac += fracstep;
} while (--count);
@ -891,7 +891,7 @@ void R_DrawRevSubClampColumnP_C ()
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
dest += pitch;
frac += fracstep;
} while (--count);
@ -932,7 +932,7 @@ void R_DrawRevSubClampTranslatedColumnP_C ()
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][(a>>15) & a];
*dest = RGB32k.All[(a>>15) & a];
dest += pitch;
frac += fracstep;
} while (--count);
@ -1227,7 +1227,7 @@ void R_DrawSpanTranslucentP_C (void)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
*dest++ = RGB32k[0][0][fg & (fg>>15)];
*dest++ = RGB32k.All[fg & (fg>>15)];
xfrac += xstep;
yfrac += ystep;
} while (--count);
@ -1245,7 +1245,7 @@ void R_DrawSpanTranslucentP_C (void)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
*dest++ = RGB32k[0][0][fg & (fg>>15)];
*dest++ = RGB32k.All[fg & (fg>>15)];
xfrac += xstep;
yfrac += ystep;
} while (--count);
@ -1292,7 +1292,7 @@ void R_DrawSpanMaskedTranslucentP_C (void)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
*dest = RGB32k[0][0][fg & (fg>>15)];
*dest = RGB32k.All[fg & (fg>>15)];
}
dest++;
xfrac += xstep;
@ -1317,7 +1317,7 @@ void R_DrawSpanMaskedTranslucentP_C (void)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
*dest = RGB32k[0][0][fg & (fg>>15)];
*dest = RGB32k.All[fg & (fg>>15)];
}
dest++;
xfrac += xstep;
@ -1364,7 +1364,7 @@ void R_DrawSpanAddClampP_C (void)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest++ = RGB32k[0][0][a & (a>>15)];
*dest++ = RGB32k.All[a & (a>>15)];
xfrac += xstep;
yfrac += ystep;
} while (--count);
@ -1385,7 +1385,7 @@ void R_DrawSpanAddClampP_C (void)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest++ = RGB32k[0][0][a & (a>>15)];
*dest++ = RGB32k.All[a & (a>>15)];
xfrac += xstep;
yfrac += ystep;
} while (--count);
@ -1435,7 +1435,7 @@ void R_DrawSpanMaskedAddClampP_C (void)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
}
dest++;
xfrac += xstep;
@ -1463,7 +1463,7 @@ void R_DrawSpanMaskedAddClampP_C (void)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
}
dest++;
xfrac += xstep;
@ -1908,7 +1908,7 @@ fixed_t tmvline1_add ()
DWORD fg = fg2rgb[colormap[pix]];
DWORD bg = bg2rgb[*dest];
fg = (fg+bg) | 0x1f07c1f;
*dest = RGB32k[0][0][fg & (fg>>15)];
*dest = RGB32k.All[fg & (fg>>15)];
}
frac += fracstep;
dest += pitch;
@ -1936,7 +1936,7 @@ void tmvline4_add ()
DWORD fg = fg2rgb[palookupoffse[i][pix]];
DWORD bg = bg2rgb[dest[i]];
fg = (fg+bg) | 0x1f07c1f;
dest[i] = RGB32k[0][0][fg & (fg>>15)];
dest[i] = RGB32k.All[fg & (fg>>15)];
}
vplce[i] += vince[i];
}
@ -1971,7 +1971,7 @@ fixed_t tmvline1_addclamp ()
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
}
frac += fracstep;
dest += pitch;
@ -2004,7 +2004,7 @@ void tmvline4_addclamp ()
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
dest[i] = RGB32k[0][0][a & (a>>15)];
dest[i] = RGB32k.All[a & (a>>15)];
}
vplce[i] += vince[i];
}
@ -2038,7 +2038,7 @@ fixed_t tmvline1_subclamp ()
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
}
frac += fracstep;
dest += pitch;
@ -2070,7 +2070,7 @@ void tmvline4_subclamp ()
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[i] = RGB32k[0][0][a & (a>>15)];
dest[i] = RGB32k.All[a & (a>>15)];
}
vplce[i] += vince[i];
}
@ -2104,7 +2104,7 @@ fixed_t tmvline1_revsubclamp ()
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][a & (a>>15)];
*dest = RGB32k.All[a & (a>>15)];
}
frac += fracstep;
dest += pitch;
@ -2136,7 +2136,7 @@ void tmvline4_revsubclamp ()
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[i] = RGB32k[0][0][a & (a>>15)];
dest[i] = RGB32k.All[a & (a>>15)];
}
vplce[i] += vince[i];
}
@ -2421,7 +2421,7 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation,
int g = GPART(color);
int b = BPART(color);
// dc_color is used by the rt_* routines. It is indexed into dc_srcblend.
dc_color = RGB32k[r>>3][g>>3][b>>3];
dc_color = RGB32k.RGB[r>>3][g>>3][b>>3];
if (style.Flags & STYLEF_InvertSource)
{
r = 255 - r;

View file

@ -354,7 +354,7 @@ void rt_add1col (int hx, int sx, int yl, int yh)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
*dest = RGB32k[0][0][fg & (fg>>15)];
*dest = RGB32k.All[fg & (fg>>15)];
source += 4;
dest += pitch;
} while (--count);
@ -387,14 +387,14 @@ void STACK_ARGS rt_add4cols_c (int sx, int yl, int yh)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
dest[0] = RGB32k[0][0][fg & (fg>>15)];
dest[0] = RGB32k.All[fg & (fg>>15)];
fg = colormap[source[1]];
bg = dest[1];
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
dest[1] = RGB32k[0][0][fg & (fg>>15)];
dest[1] = RGB32k.All[fg & (fg>>15)];
fg = colormap[source[2]];
@ -402,14 +402,14 @@ void STACK_ARGS rt_add4cols_c (int sx, int yl, int yh)
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
dest[2] = RGB32k[0][0][fg & (fg>>15)];
dest[2] = RGB32k.All[fg & (fg>>15)];
fg = colormap[source[3]];
bg = dest[3];
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
dest[3] = RGB32k[0][0][fg & (fg>>15)];
dest[3] = RGB32k.All[fg & (fg>>15)];
source += 4;
dest += pitch;
@ -455,7 +455,7 @@ void rt_shaded1col (int hx, int sx, int yl, int yh)
DWORD val = colormap[*source];
DWORD fg = fgstart[val<<8];
val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f;
*dest = RGB32k[0][0][val & (val>>15)];
*dest = RGB32k.All[val & (val>>15)];
source += 4;
dest += pitch;
} while (--count);
@ -487,19 +487,19 @@ void STACK_ARGS rt_shaded4cols_c (int sx, int yl, int yh)
val = colormap[source[0]];
val = (Col2RGB8[64-val][dest[0]] + fgstart[val<<8]) | 0x1f07c1f;
dest[0] = RGB32k[0][0][val & (val>>15)];
dest[0] = RGB32k.All[val & (val>>15)];
val = colormap[source[1]];
val = (Col2RGB8[64-val][dest[1]] + fgstart[val<<8]) | 0x1f07c1f;
dest[1] = RGB32k[0][0][val & (val>>15)];
dest[1] = RGB32k.All[val & (val>>15)];
val = colormap[source[2]];
val = (Col2RGB8[64-val][dest[2]] + fgstart[val<<8]) | 0x1f07c1f;
dest[2] = RGB32k[0][0][val & (val>>15)];
dest[2] = RGB32k.All[val & (val>>15)];
val = colormap[source[3]];
val = (Col2RGB8[64-val][dest[3]] + fgstart[val<<8]) | 0x1f07c1f;
dest[3] = RGB32k[0][0][val & (val>>15)];
dest[3] = RGB32k.All[val & (val>>15)];
source += 4;
dest += pitch;
@ -536,7 +536,7 @@ void rt_addclamp1col (int hx, int sx, int yl, int yh)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
*dest = RGB32k[0][0][(a>>15) & a];
*dest = RGB32k.All[(a>>15) & a];
source += 4;
dest += pitch;
} while (--count);
@ -572,7 +572,7 @@ void STACK_ARGS rt_addclamp4cols_c (int sx, int yl, int yh)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
dest[0] = RGB32k[0][0][(a>>15) & a];
dest[0] = RGB32k.All[(a>>15) & a];
a = fg2rgb[colormap[source[1]]] + bg2rgb[dest[1]];
b = a;
@ -581,7 +581,7 @@ void STACK_ARGS rt_addclamp4cols_c (int sx, int yl, int yh)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
dest[1] = RGB32k[0][0][(a>>15) & a];
dest[1] = RGB32k.All[(a>>15) & a];
a = fg2rgb[colormap[source[2]]] + bg2rgb[dest[2]];
b = a;
@ -590,7 +590,7 @@ void STACK_ARGS rt_addclamp4cols_c (int sx, int yl, int yh)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
dest[2] = RGB32k[0][0][(a>>15) & a];
dest[2] = RGB32k.All[(a>>15) & a];
a = fg2rgb[colormap[source[3]]] + bg2rgb[dest[3]];
b = a;
@ -599,7 +599,7 @@ void STACK_ARGS rt_addclamp4cols_c (int sx, int yl, int yh)
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
dest[3] = RGB32k[0][0][(a>>15) & a];
dest[3] = RGB32k.All[(a>>15) & a];
source += 4;
dest += pitch;
@ -649,7 +649,7 @@ void rt_subclamp1col (int hx, int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][(a>>15) & a];
*dest = RGB32k.All[(a>>15) & a];
source += 4;
dest += pitch;
} while (--count);
@ -684,7 +684,7 @@ void STACK_ARGS rt_subclamp4cols (int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[0] = RGB32k[0][0][(a>>15) & a];
dest[0] = RGB32k.All[(a>>15) & a];
a = (fg2rgb[colormap[source[1]]] | 0x40100400) - bg2rgb[dest[1]];
b = a;
@ -692,7 +692,7 @@ void STACK_ARGS rt_subclamp4cols (int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[1] = RGB32k[0][0][(a>>15) & a];
dest[1] = RGB32k.All[(a>>15) & a];
a = (fg2rgb[colormap[source[2]]] | 0x40100400) - bg2rgb[dest[2]];
b = a;
@ -700,7 +700,7 @@ void STACK_ARGS rt_subclamp4cols (int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[2] = RGB32k[0][0][(a>>15) & a];
dest[2] = RGB32k.All[(a>>15) & a];
a = (fg2rgb[colormap[source[3]]] | 0x40100400) - bg2rgb[dest[3]];
b = a;
@ -708,7 +708,7 @@ void STACK_ARGS rt_subclamp4cols (int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[3] = RGB32k[0][0][(a>>15) & a];
dest[3] = RGB32k.All[(a>>15) & a];
source += 4;
dest += pitch;
@ -758,7 +758,7 @@ void rt_revsubclamp1col (int hx, int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
*dest = RGB32k[0][0][(a>>15) & a];
*dest = RGB32k.All[(a>>15) & a];
source += 4;
dest += pitch;
} while (--count);
@ -793,7 +793,7 @@ void STACK_ARGS rt_revsubclamp4cols (int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[0] = RGB32k[0][0][(a>>15) & a];
dest[0] = RGB32k.All[(a>>15) & a];
a = (bg2rgb[dest[1]] | 0x40100400) - fg2rgb[colormap[source[1]]];
b = a;
@ -801,7 +801,7 @@ void STACK_ARGS rt_revsubclamp4cols (int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[1] = RGB32k[0][0][(a>>15) & a];
dest[1] = RGB32k.All[(a>>15) & a];
a = (bg2rgb[dest[2]] | 0x40100400) - fg2rgb[colormap[source[2]]];
b = a;
@ -809,7 +809,7 @@ void STACK_ARGS rt_revsubclamp4cols (int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[2] = RGB32k[0][0][(a>>15) & a];
dest[2] = RGB32k.All[(a>>15) & a];
a = (bg2rgb[dest[3]] | 0x40100400) - fg2rgb[colormap[source[3]]];
b = a;
@ -817,7 +817,7 @@ void STACK_ARGS rt_revsubclamp4cols (int sx, int yl, int yh)
b = b - (b >> 5);
a &= b;
a |= 0x01f07c1f;
dest[3] = RGB32k[0][0][(a>>15) & a];
dest[3] = RGB32k.All[(a>>15) & a];
source += 4;
dest += pitch;

View file

@ -2500,7 +2500,7 @@ void R_DrawParticle (vissprite_t *vis)
{
DWORD bg = bg2rgb[*dest];
bg = (fg+bg) | 0x1f07c1f;
*dest++ = RGB32k[0][0][bg & (bg>>15)];
*dest++ = RGB32k.All[bg & (bg>>15)];
} while (--count);
dest += spacing;
} while (--ycount);

View file

@ -551,7 +551,7 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR;
DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR;
DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR;
*pixelp = RGB32k[r >> 27][g >> 27][b >> 27];
*pixelp = RGB32k.RGB[r >> 27][g >> 27][b >> 27];
}
else
{
@ -637,7 +637,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
// Pick colors from the palette for each of the four colors.
/*if (!tcbuf)*/ for (i = 3; i >= 0; --i)
{
palcol[i] = color[i].a ? RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0;
palcol[i] = color[i].a ? RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0;
}
// Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y)
@ -717,7 +717,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu
// Pick colors from the palette for each of the four colors.
if (!tcbuf) for (i = 3; i >= 0; --i)
{
palcol[i] = RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
}
// Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y)
@ -822,7 +822,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu
// Pick colors from the palette for each of the four colors.
if (!tcbuf) for (i = 3; i >= 0; --i)
{
palcol[i] = RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
}
// Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y)

View file

@ -406,7 +406,7 @@ void FJPEGTexture::MakeTexture ()
case JCS_RGB:
for (int x = Width; x > 0; --x)
{
*out = RGB32k[in[0]>>3][in[1]>>3][in[2]>>3];
*out = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
out += Height;
in += 3;
}
@ -430,7 +430,7 @@ void FJPEGTexture::MakeTexture ()
int r = in[3] - (((256-in[0])*in[3]) >> 8);
int g = in[3] - (((256-in[1])*in[3]) >> 8);
int b = in[3] - (((256-in[2])*in[3]) >> 8);
*out = RGB32k[r >> 3][g >> 3][b >> 3];
*out = RGB32k.RGB[r >> 3][g >> 3][b >> 3];
out += Height;
in += 4;
}

View file

@ -534,7 +534,7 @@ void FMultiPatchTexture::MakeTexture ()
{
if (*out == 0 && in[3] != 0)
{
*out = RGB32k[in[2]>>3][in[1]>>3][in[0]>>3];
*out = RGB32k.RGB[in[2]>>3][in[1]>>3][in[0]>>3];
}
out += Height;
in += 4;

View file

@ -528,7 +528,7 @@ void FPCXTexture::MakeTexture()
{
for(int x=0; x < Width; x++)
{
Pixels[y+Height*x] = RGB32k[row[0]>>3][row[1]>>3][row[2]>>3];
Pixels[y+Height*x] = RGB32k.RGB[row[0]>>3][row[1]>>3][row[2]>>3];
row+=3;
}
}

View file

@ -521,7 +521,7 @@ void FPNGTexture::MakeTexture ()
{
for (y = Height; y > 0; --y)
{
*out++ = RGB32k[in[0]>>3][in[1]>>3][in[2]>>3];
*out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
in += pitch;
}
in -= backstep;
@ -564,7 +564,7 @@ void FPNGTexture::MakeTexture ()
{
for (y = Height; y > 0; --y)
{
*out++ = in[3] < 128 ? 0 : RGB32k[in[0]>>3][in[1]>>3][in[2]>>3];
*out++ = in[3] < 128 ? 0 : RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
in += pitch;
}
in -= backstep;

View file

@ -393,7 +393,7 @@ void FTGATexture::MakeTexture ()
for(int x=0;x<Width;x++)
{
int v = LittleLong(*p);
Pixels[x*Height+y] = RGB32k[(v>>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f];
Pixels[x*Height+y] = RGB32k.RGB[(v>>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f];
p+=step_x;
}
}
@ -405,7 +405,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height+y] = RGB32k[p[2]>>3][p[1]>>3][p[0]>>3];
Pixels[x*Height+y] = RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3];
p+=step_x;
}
}
@ -419,7 +419,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height+y] = RGB32k[p[2]>>3][p[1]>>3][p[0]>>3];
Pixels[x*Height+y] = RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3];
p+=step_x;
}
}
@ -431,7 +431,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height+y] = p[3] >= 128? RGB32k[p[2]>>3][p[1]>>3][p[0]>>3] : 0;
Pixels[x*Height+y] = p[3] >= 128? RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3] : 0;
p+=step_x;
}
}

View file

@ -893,7 +893,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level)
DWORD fg = fg2rgb[basecolor];
DWORD bg = bg2rgb[*spot];
bg = (fg+bg) | 0x1f07c1f;
*spot = RGB32k[0][0][bg&(bg>>15)];
*spot = RGB32k.All[bg&(bg>>15)];
}
void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor)

View file

@ -141,7 +141,7 @@ extern "C" {
DWORD Col2RGB8[65][256];
DWORD *Col2RGB8_LessPrecision[65];
DWORD Col2RGB8_Inverse[65][256];
BYTE RGB32k[32][32][32];
ColorTable32k RGB32k;
}
static DWORD Col2RGB8_2[63][256];
@ -387,7 +387,7 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
bg = bg2rgb[(*spot)&0xff];
bg = (fg+bg) | 0x1f07c1f;
*spot = RGB32k[0][0][bg&(bg>>15)];
*spot = RGB32k.All[bg&(bg>>15)];
spot++;
}
spot += gap;
@ -658,7 +658,7 @@ static void BuildTransTable (const PalEntry *palette)
for (r = 0; r < 32; r++)
for (g = 0; g < 32; g++)
for (b = 0; b < 32; b++)
RGB32k[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2));
RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2));
int x, y;

View file

@ -432,7 +432,18 @@ EXTERN_CVAR (Float, Gamma)
// Translucency tables
// RGB32k is a normal R5G5B5 -> palette lookup table.
extern "C" BYTE RGB32k[32][32][32];
// Use a union so we can "overflow" without warnings.
// Otherwise, we get stuff like this from Clang (when compiled
// with -fsanitize=bounds) while running:
// src/v_video.cpp:390:12: runtime error: index 1068 out of bounds for type 'BYTE [32]'
// src/r_draw.cpp:273:11: runtime error: index 1057 out of bounds for type 'BYTE [32]'
union ColorTable32k
{
BYTE RGB[32][32][32];
BYTE All[32 *32 *32];
};
extern "C" ColorTable32k RGB32k;
// Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a
// special R10B10G10 format for efficient blending computation.