ref: 26684157e0d0b5885f33e88c4d31805f48fa5d15
parent: 9639189ce55ff3124aa4c5956503d21d4206372c
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Dec 3 00:44:25 EST 2023
break yet fix transparencies; colormaps and fullbright stuff will need a different way to work
--- a/d_local.h
+++ b/d_local.h
@@ -78,8 +78,6 @@
(((alpha)*(((ca)>> 8)&0xff) + (255-(alpha))*(((cb)>> 8)&0xff))>> 8) << 8 | \
(((alpha)*(((ca)>>16)&0xff) + (255-(alpha))*(((cb)>>16)&0xff))>> 8) << 16)
-#define CIND(p) ((p)>>24)
-
/*
static inline pixel_t
blendalpha(pixel_t ca, pixel_t cb, int alpha)
--- a/d_polyse.c
+++ b/d_polyse.c
@@ -125,8 +125,7 @@
z = fv->v[5]>>16;
zbuf = zspantable[fv->v[1]] + fv->v[0];
if (z >= *zbuf){
- int pix = CIND(skintable[fv->v[3]>>16][fv->v[2]>>16]);
- pixel_t p = colormap[pix + (fv->v[4] & 0xFF00)];
+ pixel_t p = skintable[fv->v[3]>>16][fv->v[2]>>16];
int n = d_scantable[fv->v[1]] + fv->v[0];
if(r_drawflags & DRAW_BLEND){
d_viewbuffer[n] = blendalpha(p, d_viewbuffer[n], alpha);
@@ -337,7 +336,7 @@
z = new[5]>>16;
zbuf = zspantable[new[1]] + new[0];
if (z >= *zbuf){
- pixel_t p = d_pcolormap[CIND(skintable[new[3]>>16][new[2]>>16])];
+ pixel_t p = skintable[new[3]>>16][new[2]>>16];
int n = d_scantable[new[1]] + new[0];
if(r_drawflags & DRAW_BLEND){
d_viewbuffer[n] = blendalpha(p, d_viewbuffer[n], alpha);
@@ -576,8 +575,9 @@
do
{
+pixel_t addlight(pixel_t x, int light);
if ((lzi >> 16) >= *lpz){
- pixel_t p = colormap[CIND(*lptex) + (llight & 0xFF00)];
+ pixel_t p = addlight(*lptex, llight);
if(r_drawflags & DRAW_BLEND){
*lpdest = blendalpha(
p,
--- a/d_sky.c
+++ b/d_sky.c
@@ -101,7 +101,7 @@
{
m = r_skysource[1][((t[1] & R_SKY_TMASK) >> 9) +
((s[1] & R_SKY_SMASK) >> 16)];
- if(m == 0)
+ if((m & 0xffffff) == 0)
*pdest = r_skysource[0][((t[0] & R_SKY_TMASK) >> 9) +
((s[0] & R_SKY_SMASK) >> 16)];
else
--- a/draw.c
+++ b/draw.c
@@ -82,8 +82,14 @@
*/
void Draw_Init (void)
{
+ int i;
if(W_ReadPixels(wad_gfx, "conchars", draw_chars, nelem(draw_chars)) < 0)
fatal("Draw_Init: %s", lerr());
+ /* black is transparent */
+ for(i = 0; i < nelem(draw_chars); i++){
+ if((draw_chars[i] & 0xffffff) == 0)
+ draw_chars[i] = 0;
+ }
if((draw_disc = Draw_PicFromWad("disc")) == nil)
fatal("Draw_Init: %s", lerr());
if((draw_backtile = Draw_PicFromWad("backtile")) == nil)
@@ -261,7 +267,7 @@
for(v=0; v<pic->height; v++){
for(u=0; u<pic->width; u++)
if(opaque(tpix = source[u]))
- dest[u] = q1pal[translation[CIND(tpix)]];
+ dest[u] = tpix;
dest += vid.rowbytes;
source += pic->width;
}
@@ -269,21 +275,21 @@
for(v=0; v<pic->height; v++){
for(u=0; u<pic->width; u+=8){
if(opaque(tpix = source[u]))
- dest[u] = q1pal[translation[CIND(tpix)]];
+ dest[u] = tpix;
if(opaque(tpix = source[u+1]))
- dest[u+1] = q1pal[translation[CIND(tpix)]];
+ dest[u+1] = tpix;
if(opaque(tpix = source[u+2]))
- dest[u+2] = q1pal[translation[CIND(tpix)]];
+ dest[u+2] = tpix;
if(opaque(tpix = source[u+3]))
- dest[u+3] = q1pal[translation[CIND(tpix)]];
+ dest[u+3] = tpix;
if(opaque(tpix = source[u+4]))
- dest[u+4] = q1pal[translation[CIND(tpix)]];
+ dest[u+4] = tpix;
if(opaque(tpix = source[u+5]))
- dest[u+5] = q1pal[translation[CIND(tpix)]];
+ dest[u+5] = tpix;
if(opaque(tpix = source[u+6]))
- dest[u+6] = q1pal[translation[CIND(tpix)]];
+ dest[u+6] = tpix;
if(opaque(tpix = source[u+7]))
- dest[u+7] = q1pal[translation[CIND(tpix)]];
+ dest[u+7] = tpix;
}
dest += vid.rowbytes;
source += pic->width;
@@ -306,8 +312,8 @@
while (drawline--)
{
for (x=0 ; x<8 ; x++)
- if(source[x] != 0) /* black is transparent */
- dest[x] = q1pal[0x60 + CIND(source[x])];
+ if((source[x] & 0xffffff) != 0)
+ dest[x] = source[x];
source += 128;
dest += 320;
}
--- a/model.h
+++ b/model.h
@@ -53,6 +53,7 @@
struct texture_s *anim_next; // in the animation sequence
struct texture_s *alternate_anims; // bmodels in frmae 1 use these
int offsets[MIPLEVELS]; // four mip maps stored
+ pixel_t data[];
} texture_t;
enum {
--- a/model_bsp30.c
+++ b/model_bsp30.c
@@ -162,7 +162,7 @@
x = p + pixels;
palsz = le16(x);
if(palsz == 256)
- pal3torgbx(p, (pixel_t*)(tx+1), pixels, x);
+ pal3torgbx(p, tx->data, pixels, x);
}else{
// alternative: outside, in a wad
for(j = 0; j < mod->numwads; j++){
@@ -174,6 +174,12 @@
}
if(strncmp(tx->name, "sky", 3) == 0)
R_InitSky(tx);
+ else if(tx->name[0] == '{'){
+ for(j = 0; j < pixels; j++){
+ if((tx->data[j] & 0xffffff) == 0x0000ff)
+ tx->data[j] = 0;
+ }
+ }
}
// sequence the animations
--- a/quakedef.h
+++ b/quakedef.h
@@ -179,7 +179,7 @@
extern double realtime; // not bounded in any way, changed at
// start of every frame, never reset
-#define opaque(p) (((p)>>24) != 0xff)
+#define opaque(p) ((p) != 0)
extern pixel_t q1pal[256];
void pal3torgbx(byte *in, pixel_t *out, int n, byte *pal);
--- a/r_surf.c
+++ b/r_surf.c
@@ -278,7 +278,7 @@
//=============================================================================
-static pixel_t
+pixel_t
addlight(pixel_t x, int light)
{
int r, g, b, y;
@@ -292,15 +292,6 @@
b = (b * (63-y)+16) >> 5; b = min(b, 255);
x = (x & ~0xffffff) | r<<16 | g<<8 | b<<0;
-/*
- t = (255*256 - (int)blocklights[i]) >> (8 - VID_CBITS);
-
- if (t < (1 << 6))
- t = (1 << 6);
-
- blocklights[i] = t;
-*/
-
return x;
}
@@ -311,7 +302,7 @@
*/
static void R_DrawSurfaceBlock8_mip0 (void)
{
- int v, i, lightstep, lighttemp, light, lightleft, lightright;
+ int b, v, i, lightstep, lighttemp, light, lightleft, lightright;
pixel_t *psource, *prowdest;
psource = pbasesource;
@@ -332,30 +323,11 @@
lightstep = lighttemp >> 4;
light = lightright;
- if(1 || currententity->model->ver == BSP30VERSION){
- int j;
- for(j = 15; j >= 0; j--){
- prowdest[j] = addlight(psource[j], light);
- light += lightstep;
- }
- }else{
- prowdest[15] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[15])];
- prowdest[14] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[14])];
- prowdest[13] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[13])];
- prowdest[12] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[12])];
- prowdest[11] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[11])];
- prowdest[10] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[10])];
- prowdest[9] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[9])];
- prowdest[8] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[8])];
- prowdest[7] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[7])];
- prowdest[6] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[6])];
- prowdest[5] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[5])];
- prowdest[4] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[4])];
- prowdest[3] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[3])];
- prowdest[2] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[2])];
- prowdest[1] = vid.colormap[((light += lightstep) & 0xFF00) + CIND(psource[1])];
- prowdest[0] = vid.colormap[(light & 0xFF00) + CIND(psource[0])];
+ for(b = 15; b >= 0; b--){
+ prowdest[b] = addlight(psource[b], light);
+ light += lightstep;
}
+
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
@@ -376,7 +348,7 @@
static void R_DrawSurfaceBlock8_mip1 (void)
{
int v, i, b, lightstep, lighttemp, light, lightleft, lightright;
- pixel_t pix, *psource, *prowdest;
+ pixel_t *psource, *prowdest;
psource = pbasesource;
prowdest = prowdestbase;
@@ -396,18 +368,9 @@
lightstep = lighttemp >> 3;
light = lightright;
-
- if(currententity->model->ver == BSP30VERSION){
- for(b = 7; b >= 0; b--){
- prowdest[b] = addlight(psource[b], light);
- light += lightstep;
- }
- }else{
- for (b=7; b>=0; b--){
- pix = psource[b];
- prowdest[b] = vid.colormap[(light & 0xFF00) + CIND(pix)];
- light += lightstep;
- }
+ for(b = 7; b >= 0; b--){
+ prowdest[b] = addlight(psource[b], light);
+ light += lightstep;
}
psource += sourcetstep;
@@ -430,7 +393,7 @@
static void R_DrawSurfaceBlock8_mip2 (void)
{
int v, i, b, lightstep, lighttemp, light, lightleft, lightright;
- pixel_t pix, *psource, *prowdest;
+ pixel_t *psource, *prowdest;
psource = pbasesource;
prowdest = prowdestbase;
@@ -450,18 +413,9 @@
lightstep = lighttemp >> 2;
light = lightright;
-
- if(1 || currententity->model->ver == BSP30VERSION){
- for(b = 3; b >= 0; b--){
- prowdest[b] = addlight(psource[b], light);
- light += lightstep;
- }
- }else{
- for (b=3; b>=0; b--){
- pix = psource[b];
- prowdest[b] = vid.colormap[(light & 0xFF00) + CIND(pix)];
- light += lightstep;
- }
+ for(b = 3; b >= 0; b--){
+ prowdest[b] = addlight(psource[b], light);
+ light += lightstep;
}
psource += sourcetstep;
@@ -504,17 +458,9 @@
lightstep = lighttemp >> 1;
light = lightright;
-
- if(1 || currententity->model->ver == BSP30VERSION){
- for (b=1; b>=0; b--){
- prowdest[b] = addlight(psource[b], light);
- light += lightstep;
- }
- }else{
- for (b=1; b>=0; b--){
- prowdest[b] = vid.colormap[(light & 0xFF00) + CIND(psource[b])];
- light += lightstep;
- }
+ for(b = 1; b >= 0; b--){
+ prowdest[b] = addlight(psource[b], light);
+ light += lightstep;
}
psource += sourcetstep;
--- a/unix/vid.c
+++ b/unix/vid.c
@@ -101,10 +101,11 @@
uchar *p;
for(p = p0, fp=fbpal; fp<fbpal+nelem(fbpal); p+=3, fp++)
- *fp = p[0] << 16 | p[1] << 8 | p[2];
+ *fp = 0xff<<24 | p[0] << 16 | p[1] << 8 | p[2];
for(p = p0, x = 0; x < 256; x++, p += 3)
- q1pal[x] = x<<24 | p[0]<<16 | p[1]<<8 | p[2];
+ q1pal[x] = 0xff<<24 | x<<24 | p[0]<<16 | p[1]<<8 | p[2];
+ q1pal[255] &= 0;
scr_fullupdate = 0;
}
--- a/wad.c
+++ b/wad.c
@@ -142,11 +142,11 @@
if(wad->ver == WAD_VER2){
for(i = 0; i < n; i++)
- q->data[i] = q1pal[*p++];
+ q->data[i] = q1pal[p[i]];
}else if(wad->ver == WAD_VER3 && palsz > 0){
for(i = 0; i < n; i++){
j = (*p++)*3;
- q->data[i] = j < palsz*3 ? (pal[j+0]<<16 | pal[j+1]<<8 | pal[j+2]) : 0;
+ q->data[i] = j < palsz*3 ? (0xff<<24 | pal[j+0]<<16 | pal[j+1]<<8 | pal[j+2]) : 0;
}
}
@@ -182,7 +182,7 @@
}
for(n = 0; n < num; n++){
x = (*t++)*3;
- *out++ = x < palsz*3 ? (pal[x+0]<<16 | pal[x+1]<<8 | pal[x+2]) : 0;
+ *out++ = x < palsz*3 ? (0xff<<24 | pal[x+0]<<16 | pal[x+1]<<8 | pal[x+2]) : 0;
}
}
return num;