Internally, work with 24-bit palettes instead of 18-bit.

git-svn-id: https://svn.eduke32.com/eduke32@5349 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-09-23 17:55:11 +00:00
parent c0e7dba4c1
commit 064461a06f
19 changed files with 231 additions and 203 deletions

View file

@ -841,7 +841,7 @@ EXTERN char *faketiledata[MAXTILES];
EXTERN char spritecol2d[MAXTILES][2];
EXTERN uint8_t tilecols[MAXTILES];
extern char vgapal16[4*256];
extern uint8_t vgapal16[4*256];
extern uint32_t drawlinepat;
@ -1043,11 +1043,11 @@ void E_RenderArtDataIntoBuffer(palette_t * pic, uint8_t const * buf, int32_t buf
int32_t qloadkvx(int32_t voxindex, const char *filename);
intptr_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz);
void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
void makepalookup(int32_t palnum, const char *remapbuf, int8_t r, int8_t g, int8_t b, char noFloorPal);
void makepalookup(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal);
//void setvgapalette(void);
void setbasepal(int32_t id, uint8_t const *table);
void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags);
void setpalettefade(char r, char g, char b, char offset);
void setpalettefade(uint8_t r, uint8_t g, uint8_t b, uint8_t offset);
void squarerotatetile(int16_t tilenume);
void fade_screen_black(int32_t moreopaquep);

View file

@ -699,7 +699,7 @@ int32_t app_main(int32_t argc, const char **argv)
allocache(&waloff[i], sx*sy, &walock[i]);
newtile = (char *)waloff[i];
col = getclosestcol(128>>2, 128>>2, 0);
col = getclosestcol(128, 128, 0);
for (j=0; j<(signed)sizeof(R); j++)
R[j] *= col;

View file

@ -203,7 +203,7 @@ static void tile_from_truecolpic(int32_t tile, const palette_t *picptr, int32_t
{
palette_t const *const col = &picptr[ofs + i];
faketilebuffer[(i * siz.y) + j] =
(col->f < alphacut) ? 255 : getclosestcol(col->b >> 2, col->g >> 2, col->r >> 2);
(col->f < alphacut) ? 255 : getclosestcol(col->b, col->g, col->r);
}
}
@ -553,9 +553,9 @@ static int32_t defsparser(scriptfile *script)
g = clamp(g, 0, 63);
b = clamp(b, 0, 63);
vgapal16[col*4+0] = b; // blue
vgapal16[col*4+1] = g; // green
vgapal16[col*4+2] = r; // red
vgapal16[col*4+0] = b<<2; // blue
vgapal16[col*4+1] = g<<2; // green
vgapal16[col*4+2] = r<<2; // red
}
}
break;
@ -572,7 +572,7 @@ static int32_t defsparser(scriptfile *script)
g = clamp(g, 0, 63);
b = clamp(b, 0, 63);
makepalookup(p, NULL, r, g, b, 1);
makepalookup(p, NULL, r<<2, g<<2, b<<2, 1);
}
break;
case T_NOFLOORPALRANGE:
@ -2152,7 +2152,7 @@ static int32_t defsparser(scriptfile *script)
// NOTE: all palookups are initialized, i.e. non-NULL!
// NOTE2: aliasing (pal==remappal) is OK
makepalookup(pal, palookup[remappal], red, green, blue,
makepalookup(pal, palookup[remappal], red<<2, green<<2, blue<<2,
remappal==0 ? 1 : (nofloorpal == -1 ? g_noFloorPal[remappal] : nofloorpal));
}
break;

View file

@ -1222,8 +1222,8 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t),
#ifdef YAX_DEBUG_YMOSTS
if (getrendermode() == REND_CLASSIC && numyaxbunches>0)
{
char purple = getclosestcol(63, 0, 63);
char yellow = getclosestcol(63, 63, 0);
char purple = getclosestcol(255, 0, 255);
char yellow = getclosestcol(255, 255, 0);
begindrawing();
for (i=0; i<numyaxbunches; i++)
@ -2332,12 +2332,17 @@ static int32_t *lastx;
int32_t halfxdim16, midydim16;
#define FASTPALGRIDSIZ 8
static int32_t rdist[129], gdist[129], bdist[129];
#define FASTPALCOLDEPTH 256
#define FASTPALRIGHTSHIFT 3
#define FASTPALRGBDIST (FASTPALCOLDEPTH*2+1)
static int32_t rdist[FASTPALRGBDIST], gdist[FASTPALRGBDIST], bdist[FASTPALRGBDIST];
#define FASTPALGRIDSIZ (FASTPALCOLDEPTH>>FASTPALRIGHTSHIFT)
static char colhere[((FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2))>>3];
static char colhead[(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)];
static int32_t colnext[256];
static char coldist[8] = {0,1,2,3,4,3,2,1};
#define FASTPALCOLDIST (1<<FASTPALRIGHTSHIFT)
#define FASTPALCOLDISTMASK (FASTPALCOLDIST-1)
static uint8_t coldist[FASTPALCOLDIST];
static int32_t colscan[27];
static int16_t clipnum;
@ -2374,12 +2379,12 @@ int16_t numscans, numbunches;
static int16_t numhits;
int16_t capturecount = 0;
char vgapal16[4*256] =
uint8_t vgapal16[4*256] =
{
00,00,00,00, 42,00,00,00, 00,42,00,00, 42,42,00,00, 00,00,42,00,
42,00,42,00, 00,21,42,00, 42,42,42,00, 21,21,21,00, 63,21,21,00,
21,63,21,00, 63,63,21,00, 21,21,63,00, 63,21,63,00, 21,63,63,00,
63,63,63,00
0,0,0,0, 170,0,0,0, 0,170,0,0, 170,170,0,0, 0,0,170,0,
170,0,170,0, 0,85,170,0, 170,170,170,0, 85,85,85,0, 255,85,85,0,
85,255,85,0, 255,255,85,0, 85,85,255,0, 255,85,255,0, 85,255,255,0,
255,255,255,0
};
int16_t searchit;
@ -5345,8 +5350,8 @@ static void drawalls(int32_t bunch)
# endif
{
static char fn[32], tmpbuf[80];
char purple = getclosestcol(63, 0, 63);
char yellow = getclosestcol(63, 63, 0);
char purple = getclosestcol(255, 0, 255);
char yellow = getclosestcol(255, 255, 0);
char *bakframe = (char *)Xaligned_alloc(16, xdim*ydim);
begindrawing(); //{{{
@ -8255,43 +8260,46 @@ static int32_t loadtables(void)
//
static void initfastcolorlookup_scale(int32_t rscale, int32_t gscale, int32_t bscale)
{
int32_t i, j;
j = 0;
for (i=64; i>=0; i--)
int32_t j = 0;
for (int i=256; i>=0; i--)
{
//j = (i-64)*(i-64);
rdist[i] = rdist[128-i] = j*rscale;
gdist[i] = gdist[128-i] = j*gscale;
bdist[i] = bdist[128-i] = j*bscale;
j += 129-(i<<1);
rdist[i] = rdist[FASTPALCOLDEPTH*2-i] = j*rscale;
gdist[i] = gdist[FASTPALCOLDEPTH*2-i] = j*gscale;
bdist[i] = bdist[FASTPALCOLDEPTH*2-i] = j*bscale;
j += FASTPALRGBDIST-(i<<1);
}
}
void initfastcolorlookup_palette(void)
{
int32_t i, j, x, y, z;
const char *pal1;
Bmemset(colhere,0,sizeof(colhere));
Bmemset(colhead,0,sizeof(colhead));
pal1 = (char *)&palette[768-3];
for (i=255; i>=0; i--,pal1-=3)
char const *pal1 = (char *)&palette[768-3];
for (int i=255; i>=0; i--,pal1-=3)
{
j = (pal1[0]>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ
+ (pal1[1]>>3)*FASTPALGRIDSIZ + (pal1[2]>>3)
+ FASTPALGRIDSIZ*FASTPALGRIDSIZ + FASTPALGRIDSIZ+1;
int32_t const j = (pal1[0]>>FASTPALRIGHTSHIFT)*FASTPALGRIDSIZ*FASTPALGRIDSIZ
+ (pal1[1]>>FASTPALRIGHTSHIFT)*FASTPALGRIDSIZ + (pal1[2]>>FASTPALRIGHTSHIFT)
+ FASTPALGRIDSIZ*FASTPALGRIDSIZ + FASTPALGRIDSIZ + 1;
if (colhere[j>>3]&pow2char[j&7]) colnext[i] = colhead[j]; else colnext[i] = -1;
colhead[j] = i;
colhere[j>>3] |= pow2char[j&7];
}
i = 0;
}
static void initfastcolorlookup_gridvectors(void)
{
int i = 0;
int32_t x, y, z;
for (x=-FASTPALGRIDSIZ*FASTPALGRIDSIZ; x<=FASTPALGRIDSIZ*FASTPALGRIDSIZ; x+=FASTPALGRIDSIZ*FASTPALGRIDSIZ)
for (y=-FASTPALGRIDSIZ; y<=FASTPALGRIDSIZ; y+=FASTPALGRIDSIZ)
for (z=-1; z<=1; z++)
colscan[i++] = x+y+z;
i = colscan[13]; colscan[13] = colscan[26]; colscan[26] = i;
for (i = 0; i < FASTPALCOLDIST/2; i++)
coldist[i] = i;
for (; i < FASTPALCOLDIST; i++)
coldist[i] = FASTPALCOLDIST-i;
}
@ -8315,6 +8323,7 @@ static void maybe_alloc_palookup(int32_t palnum);
static void loadpalette(void)
{
initfastcolorlookup_scale(30, 59, 11);
initfastcolorlookup_gridvectors();
int32_t fil;
if ((fil = kopen4load("palette.dat",0)) == -1)
@ -8326,6 +8335,9 @@ static void loadpalette(void)
if (kread_and_test(fil,palette,768))
return kclose(fil);
for (int k = 0; k < 768; k++)
palette[k] <<= 2;
initfastcolorlookup_palette();
paletteloaded |= PALETTE_MAIN;
@ -8570,10 +8582,10 @@ void generatefogpals(void)
for (int32_t j=1; j<=255-3; j++)
if (!palookup[j] && !palookup[j+1] && !palookup[j+2] && !palookup[j+3])
{
makepalookup(j, NULL, 15, 15, 15, 1);
makepalookup(j+1, NULL, 15, 0, 0, 1);
makepalookup(j+2, NULL, 0, 15, 0, 1);
makepalookup(j+3, NULL, 0, 0, 15, 1);
makepalookup(j, NULL, 60, 60, 60, 1);
makepalookup(j+1, NULL, 60, 0, 0, 1);
makepalookup(j+2, NULL, 0, 60, 0, 1);
makepalookup(j+3, NULL, 0, 0, 60, 1);
break;
}
@ -8602,18 +8614,17 @@ void getclosestcol_flush(void)
// <lastokcol> must be in [0 .. 255].
int32_t getclosestcol_lim(int32_t r, int32_t g, int32_t b, int32_t lastokcol)
{
const int j = (r>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ
+ (g>>3)*FASTPALGRIDSIZ + (b>>3)
const int j = (r>>FASTPALRIGHTSHIFT)*FASTPALGRIDSIZ*FASTPALGRIDSIZ
+ (g>>FASTPALRIGHTSHIFT)*FASTPALGRIDSIZ + (b>>FASTPALRIGHTSHIFT)
+ FASTPALGRIDSIZ*FASTPALGRIDSIZ
+ FASTPALGRIDSIZ+1;
+ FASTPALGRIDSIZ + 1;
#ifdef DEBUGGINGAIDS
Bassert(lastokcol >= 0 && lastokcol <= 255);
#endif
r = 64-r, g = 64-g, b = 64-b;
uint32_t const col = r | (g<<8) | (b<<16);
uint32_t col = (r + (g<<8) + (b<<16));
int mindist = -1;
int const k = (numclosestcolresults > COLRESULTSIZ) ? (COLRESULTSIZ-4) : (numclosestcolresults-4);
@ -8643,8 +8654,14 @@ int32_t getclosestcol_lim(int32_t r, int32_t g, int32_t b, int32_t lastokcol)
skip:
getclosestcol_results[numclosestcolresults & (COLRESULTSIZ-1)] = col;
mindist = min(rdist[coldist[r&7]+64+8], gdist[coldist[g&7]+64+8]);
mindist = min(mindist, bdist[coldist[b&7]+64+8]) + 1;
int const minrdist = rdist[coldist[r&FASTPALCOLDISTMASK]+FASTPALCOLDEPTH];
int const mingdist = gdist[coldist[g&FASTPALCOLDISTMASK]+FASTPALCOLDEPTH];
int const minbdist = bdist[coldist[b&FASTPALCOLDISTMASK]+FASTPALCOLDEPTH];
mindist = min(minrdist, mingdist);
mindist = min(mindist, minbdist) + 1;
r = FASTPALCOLDEPTH-r, g = FASTPALCOLDEPTH-g, b = FASTPALCOLDEPTH-b;
int retcol = -1;
@ -12435,9 +12452,9 @@ void E_RenderArtDataIntoBuffer(palette_t * const pic, uint8_t const * const buf,
index *= 3;
// pic is BGRA
picrow[x].r = palette[index+2]<<2;
picrow[x].g = palette[index+1]<<2;
picrow[x].b = palette[index]<<2;
picrow[x].r = palette[index+2];
picrow[x].g = palette[index+1];
picrow[x].b = palette[index];
picrow[x].f = 255;
}
}
@ -15570,7 +15587,7 @@ int32_t setpalookup(int32_t palnum, const uint8_t *shtab)
//
// makepalookup
//
void makepalookup(int32_t palnum, const char *remapbuf, int8_t r, int8_t g, int8_t b, char noFloorPal)
void makepalookup(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal)
{
int32_t i, j;
@ -15602,9 +15619,6 @@ void makepalookup(int32_t palnum, const char *remapbuf, int8_t r, int8_t g, int8
maybe_alloc_palookup(palnum);
if ((r|g|b|63) != 63)
return;
if ((r|g|b) == 0)
{
// "black fog"/visibility case -- only remap color indices
@ -15699,9 +15713,9 @@ void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags)
for (i=0; i<256; i++)
{
// save palette without any brightness adjustment
curpalette[i].r = dapal[i*3+0] << 2;
curpalette[i].g = dapal[i*3+1] << 2;
curpalette[i].b = dapal[i*3+2] << 2;
curpalette[i].r = dapal[i*3+0];
curpalette[i].g = dapal[i*3+1];
curpalette[i].b = dapal[i*3+2];
curpalette[i].f = 0;
// brightness adjust the palette
@ -15784,11 +15798,11 @@ static void setpalettefade_calc(uint8_t offset)
p = getpal(i);
curpalettefaded[i].b =
p.b + (((palfadergb.b - p.b) * offset) >> 6);
p.b + (((palfadergb.b - p.b) * offset) >> 8);
curpalettefaded[i].g =
p.g + (((palfadergb.g - p.g) * offset) >> 6);
p.g + (((palfadergb.g - p.g) * offset) >> 8);
curpalettefaded[i].r =
p.r + (((palfadergb.r - p.r) * offset) >> 6);
p.r + (((palfadergb.r - p.r) * offset) >> 8);
curpalettefaded[i].f = 0;
}
}
@ -15798,16 +15812,16 @@ static void setpalettefade_calc(uint8_t offset)
//
// setpalettefade
//
void setpalettefade(char r, char g, char b, char offset)
void setpalettefade(uint8_t r, uint8_t g, uint8_t b, uint8_t offset)
{
palfadergb.r = min(63,r) << 2;
palfadergb.g = min(63,g) << 2;
palfadergb.b = min(63,b) << 2;
palfadergb.r = r;
palfadergb.g = g;
palfadergb.b = b;
#ifdef DEBUG_PALETTEFADE
if (offset)
offset = max(offset, 32);
offset = max(offset, 128);
#endif
palfadedelta = min(63,offset) << 2;
palfadedelta = offset;
setpalettefade_calc(offset);

View file

@ -340,10 +340,10 @@ static const _prprogrambit prprogrambits[PR_BIT_COUNT] = {
"\n"
" vec3 texelNear = texture2D(basePalMap, vec2(colorIndexNear, 0.5)).rgb;\n"
" vec3 texelFar = texture2D(basePalMap, vec2(colorIndexFar, 0.5)).rgb;\n"
" diffuseTexel.rgb = texture2D(basePalMap, vec2(colorIndexFullbright, 0.5)).rgb * 4.0;\n"
" diffuseTexel.rgb = texture2D(basePalMap, vec2(colorIndexFullbright, 0.5)).rgb;\n"
"\n"
" if (isLightingPass == 0) {\n"
" result.rgb = mix(texelNear, texelFar, fract(shadeLookup)) * 4.0;\n"
" result.rgb = mix(texelNear, texelFar, fract(shadeLookup));\n"
" result.a = 1.0;\n"
" if (colorIndex == 256.0)\n"
" result.a = 0.0;\n"

View file

@ -283,9 +283,9 @@ void polymost_glreset()
{
for (int i=0; i<=MAXPALOOKUPS-1; i++)
{
fogtable[i].r = palookupfog[i].r * (1.f/63.f);
fogtable[i].g = palookupfog[i].g * (1.f/63.f);
fogtable[i].b = palookupfog[i].b * (1.f/63.f);
fogtable[i].r = palookupfog[i].r * (1.f/255.f);
fogtable[i].g = palookupfog[i].g * (1.f/255.f);
fogtable[i].b = palookupfog[i].b * (1.f/255.f);
fogtable[i].a = 0;
}

View file

@ -7831,55 +7831,55 @@ static void InitCustomColors(void)
palette_t *edcol;
/* blue */
vgapal16[9*4+0] = 63;
vgapal16[9*4+1] = 31;
vgapal16[9*4+2] = 7;
vgapal16[9*4+0] = 252;
vgapal16[9*4+1] = 124;
vgapal16[9*4+2] = 28;
/* orange */
vgapal16[31*4+0] = 20; // blue
vgapal16[31*4+1] = 45; // green
vgapal16[31*4+2] = 60; // red
vgapal16[31*4+0] = 80; // blue
vgapal16[31*4+1] = 180; // green
vgapal16[31*4+2] = 240; // red
vgapal16[39*4+0] = 36;
vgapal16[39*4+1] = 53;
vgapal16[39*4+2] = 63;
vgapal16[39*4+0] = 144;
vgapal16[39*4+1] = 212;
vgapal16[39*4+2] = 252;
/* light yellow */
vgapal16[22*4+0] = 51;
vgapal16[22*4+1] = 63;
vgapal16[22*4+2] = 63;
vgapal16[22*4+0] = 204;
vgapal16[22*4+1] = 252;
vgapal16[22*4+2] = 252;
/* grey */
vgapal16[23*4+0] = 45;
vgapal16[23*4+1] = 45;
vgapal16[23*4+2] = 45;
vgapal16[23*4+0] = 180;
vgapal16[23*4+1] = 180;
vgapal16[23*4+2] = 180;
/* blue */
vgapal16[24*4+0] = 51;
vgapal16[24*4+1] = 41;
vgapal16[24*4+2] = 12;
vgapal16[24*4+0] = 204;
vgapal16[24*4+1] = 164;
vgapal16[24*4+2] = 48;
vgapal16[32*4+0] = 60;
vgapal16[32*4+1] = 50;
vgapal16[32*4+2] = 21;
vgapal16[32*4+0] = 240;
vgapal16[32*4+1] = 200;
vgapal16[32*4+2] = 84;
// grid color
vgapal16[25*4+0] = 16;
vgapal16[25*4+1] = 14;
vgapal16[25*4+2] = 14;
vgapal16[25*4+0] = 64;
vgapal16[25*4+1] = 56;
vgapal16[25*4+2] = 56;
vgapal16[26*4+0] = 24;
vgapal16[26*4+1] = 24;
vgapal16[26*4+2] = 24;
vgapal16[26*4+0] = 96;
vgapal16[26*4+1] = 96;
vgapal16[26*4+2] = 96;
vgapal16[33*4+0] = 0;//15; // blue
vgapal16[33*4+1] = 0;//30; // green
vgapal16[33*4+2] = 48;//45; // red
vgapal16[33*4+0] = 0; //60; // blue
vgapal16[33*4+1] = 0; //120; // green
vgapal16[33*4+2] = 192; //180; // red
vgapal16[41*4+0] = 0;//24;
vgapal16[41*4+1] = 0;//40;
vgapal16[41*4+2] = 63;//48;
vgapal16[41*4+0] = 0; //96;
vgapal16[41*4+1] = 0; //160;
vgapal16[41*4+2] = 252; //192;
for (i = 0; i<256; i++)
{

View file

@ -1029,6 +1029,9 @@ void G_LoadLookups(void)
if (kread_and_test(fp, paldata, 768))
return kclose(fp);
for (int k = 0; k < 768; k++)
paldata[k] <<= 2;
setbasepal(basepalnum, paldata);
}

View file

@ -527,13 +527,13 @@ RECHECK:
goto RECHECK;
}
fadepal(0,0,0, 0,63,7);
fadepal(0,0,0, 0,252,28);
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 1); // JBF 20040308
G_DrawBackground();
M_DisplayMenus();
//g_player[myconnectindex].ps->palette = palette;
nextpage();
fadepal(0,0,0, 63,0,-7);
fadepal(0,0,0, 252,0,-28);
ud.reccnt = 0;
}
else

View file

@ -2826,17 +2826,13 @@ static int32_t G_PlaySoundWhileNoInput(int32_t soundnum)
void G_FadePalette(int32_t r,int32_t g,int32_t b,int32_t e)
{
setpalettefade(r,g,b,e&63);
int32_t tc;
setpalettefade(r,g,b,e);
if ((e&128) == 0)
{
int32_t tc;
nextpage();
tc = totalclock;
while (totalclock < tc + 4)
G_HandleAsync();
}
nextpage();
tc = totalclock;
while (totalclock < tc + 4)
G_HandleAsync();
}
// START and END limits are always inclusive!
@ -2918,17 +2914,17 @@ static void G_DisplayExtraScreens(void)
flushperms();
//g_player[myconnectindex].ps->palette = palette;
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 1); // JBF 20040308
fadepal(0,0,0, 0,63,7);
fadepal(0,0,0, 0,252,28);
I_ClearAllInput();
rotatesprite_fs(160<<16,100<<16,65536L,0,3291,0,0,2+8+64+BGSTRETCH);
fadepaltile(0,0,0, 63,0,-7, 3291);
fadepaltile(0,0,0, 252,0,-28, 3291);
while (!I_CheckAllInput())
G_HandleAsync();
fadepaltile(0,0,0, 0,63,7, 3291);
fadepaltile(0,0,0, 0,252,28, 3291);
I_ClearAllInput();
rotatesprite_fs(160<<16,100<<16,65536L,0,3290,0,0,2+8+64+BGSTRETCH);
fadepaltile(0,0,0, 63,0,-7,3290);
fadepaltile(0,0,0, 252,0,-28,3290);
while (!I_CheckAllInput())
G_HandleAsync();
@ -2946,15 +2942,15 @@ static void G_DisplayExtraScreens(void)
flushperms();
//g_player[myconnectindex].ps->palette = palette;
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 1); // JBF 20040308
fadepal(0,0,0, 0,63,7);
fadepal(0,0,0, 0,252,28);
I_ClearAllInput();
totalclock = 0;
rotatesprite_fs(160<<16,100<<16,65536L,0,TENSCREEN,0,0,2+8+64+BGSTRETCH);
fadepaltile(0,0,0, 63,0,-7,TENSCREEN);
fadepaltile(0,0,0, 252,0,-28,TENSCREEN);
while (!I_CheckAllInput() && totalclock < 2400)
G_HandleAsync();
fadepaltile(0,0,0, 0,63,7, TENSCREEN);
fadepaltile(0,0,0, 0,252,28, TENSCREEN);
I_ClearAllInput();
#ifdef __ANDROID__
inExtraScreens = 0;
@ -3370,9 +3366,9 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
char *ptr = (char *)waloff[CROSSHAIR];
int32_t i, ii;
if (DefaultCrosshairColors.f == 0 || g_crosshairSum == r+(g<<1)+(b<<2)) return;
if (DefaultCrosshairColors.f == 0 || g_crosshairSum == r+(g<<8)+(b<<16)) return;
g_crosshairSum = r+(g<<1)+(b<<2);
g_crosshairSum = r+(g<<8)+(b<<16);
CrosshairColors.r = r;
CrosshairColors.g = g;
CrosshairColors.b = b;
@ -3387,8 +3383,8 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
if (ii <= 0) return;
if (getrendermode() == REND_CLASSIC)
i = getclosestcol(CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2);
else i = getclosestcol(63, 63, 63); // use white in GL so we can tint it to the right color
i = getclosestcol(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
else i = getclosestcol(255, 255, 255); // use white in GL so we can tint it to the right color
do
{
@ -3398,7 +3394,7 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
}
while (--ii);
makepalookup(CROSSHAIR_PAL, NULL, CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2,1);
makepalookup(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b,1);
#ifdef USE_OPENGL
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
@ -3459,7 +3455,7 @@ int32_t m32_numdebuglines=0;
static void M32_drawdebug(void)
{
int i, col=getclosestcol(63,63,63);
int i, col=getclosestcol(255,255,255);
int x=4, y=8;
if (m32_numdebuglines>0)
@ -3514,9 +3510,9 @@ static void palaccum_add(palaccum_t *pa, const palette_t *pal, int32_t f)
static void G_FadePalaccum(const palaccum_t *pa)
{
setpalettefade(tabledivide32_noinline(pa->r, pa->sumf),
tabledivide32_noinline(pa->g, pa->sumf),
tabledivide32_noinline(pa->b, pa->sumf), pa->maxf);
setpalettefade(tabledivide32_noinline(pa->r, pa->sumf)<<2,
tabledivide32_noinline(pa->g, pa->sumf)<<2,
tabledivide32_noinline(pa->b, pa->sumf)<<2, pa->maxf<<2);
}
@ -4428,7 +4424,7 @@ static void G_ReadGLFrame(void)
for (x = 0; x < 320; x++)
{
const palette_t *pix = &frame[base + mulscale16(x, xf)];
pic[320 * y + x] = getclosestcol(pix->r >> 2, pix->g >> 2, pix->b >> 2);
pic[320 * y + x] = getclosestcol(pix->r, pix->g, pix->b);
}
}
@ -10619,7 +10615,7 @@ static void G_DisplayLogo(void)
setview(0,0,xdim-1,ydim-1);
clearallviews(0L);
G_FadePalette(0,0,0,63);
G_FadePalette(0,0,0,252);
flushperms();
nextpage();
@ -10641,7 +10637,7 @@ static void G_DisplayLogo(void)
{
Net_GetPackets();
G_PlayAnim("logo.anm");
G_FadePalette(0,0,0,63);
G_FadePalette(0,0,0,252);
I_ClearAllInput();
}
@ -10664,7 +10660,7 @@ static void G_DisplayLogo(void)
if (!NAM)
{
//g_player[myconnectindex].ps->palette = drealms;
//G_FadePalette(0,0,0,63);
//G_FadePalette(0,0,0,252);
if (logoflags & LOGO_3DRSCREEN)
{
@ -10683,7 +10679,7 @@ static void G_DisplayLogo(void)
{
kclose(i);
G_PlayAnim("3dr.anm");
G_FadePalette(0, 0, 0, 63);
G_FadePalette(0,0,0,252);
I_ClearAllInput();
}
else
@ -10691,11 +10687,11 @@ static void G_DisplayLogo(void)
clearallviews(0);
P_SetGamePalette(g_player[myconnectindex].ps, DREALMSPAL, 8 + 2 + 1); // JBF 20040308
fadepal(0, 0, 0, 0, 63, 7);
fadepal(0,0,0, 0,252,28);
flushperms();
rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + BGSTRETCH);
nextpage();
fadepaltile(0, 0, 0, 63, 0, -7, DREALMS);
fadepaltile(0,0,0, 252,0,-28, DREALMS);
totalclock = 0;
while (totalclock < (120 * 7) && !I_CheckAllInput())
{
@ -10712,7 +10708,7 @@ static void G_DisplayLogo(void)
}
nextpage();
}
fadepaltile(0, 0, 0, 0, 63, 7, DREALMS);
fadepaltile(0,0,0, 0,252,28, DREALMS);
}
}
@ -10735,7 +10731,7 @@ static void G_DisplayLogo(void)
flushperms();
rotatesprite_fs(160<<16,100<<16,65536L,0,BETASCREEN,0,0,2+8+64+BGSTRETCH);
KB_FlushKeyboardQueue();
fadepaltile(0,0,0, 63,0,-7,BETASCREEN);
fadepaltile(0,0,0, 252,0,-28,BETASCREEN);
totalclock = 0;
while (
@ -12301,10 +12297,10 @@ static void G_DoOrderScreen(void)
for (i=0; i<4; i++)
{
fadepal(0,0,0, 0,63,7);
fadepal(0,0,0, 0,252,28);
I_ClearAllInput();
rotatesprite_fs(160<<16,100<<16,65536L,0,ORDERING+i,0,0,2+8+64+BGSTRETCH);
fadepal(0,0,0, 63,0,-7);
fadepal(0,0,0, 252,0,-28);
while (!I_CheckAllInput())
G_HandleAsync();
}
@ -12352,7 +12348,7 @@ static void G_BonusCutscenes(void)
clearallviews(0L);
rotatesprite_fs(0,50<<16,65536L,0,VICTORY1,0,0,2+8+16+64+128+BGSTRETCH);
nextpage();
fadepal(0,0,0, 63,0,-1);
fadepal(0,0,0, 252,0,-4);
I_ClearAllInput();
totalclock = 0;
@ -12406,7 +12402,7 @@ static void G_BonusCutscenes(void)
if (I_CheckAllInput()) break;
}
fadepal(0,0,0, 0,63,1);
fadepal(0,0,0, 0,252,4);
}
if (G_GetLogoFlags() & LOGO_NOE1ENDSCREEN)
@ -12416,9 +12412,9 @@ static void G_BonusCutscenes(void)
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308
rotatesprite_fs(160<<16,100<<16,65536L,0,3292,0,0,2+8+64+BGSTRETCH);
fadepal(0,0,0, 63,0,-1);
fadepal(0,0,0, 252,0,-4);
G_HandleEventsWhileNoInput();
fadepal(0,0,0, 0,63,1);
fadepal(0,0,0, 0,252,4);
VOL1_END:
S_StopMusic();
@ -12438,14 +12434,14 @@ VOL1_END:
if (ud.lockout == 0 && !(G_GetLogoFlags() & LOGO_NOE2BONUSSCENE))
{
fadepal(0,0,0, 63,0,-1);
fadepal(0,0,0, 252,0,-4);
G_PlayAnim("cineov2.anm");
I_ClearAllInput();
clearallviews(0L);
nextpage();
S_PlaySound(PIPEBOMB_EXPLODE);
fadepal(0,0,0, 0,63,1);
fadepal(0,0,0, 0,252,4);
}
if (G_GetLogoFlags() & LOGO_NOE2ENDSCREEN)
@ -12454,9 +12450,9 @@ VOL1_END:
I_ClearAllInput();
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308
rotatesprite_fs(160<<16,100<<16,65536L,0,3293,0,0,2+8+64+BGSTRETCH);
fadepal(0,0,0, 63,0,-1);
fadepal(0,0,0, 252,0,-4);
G_HandleEventsWhileNoInput();
fadepal(0,0,0, 0,63,1);
fadepal(0,0,0, 0,252,4);
break;
@ -12472,7 +12468,7 @@ VOL1_END:
if (ud.lockout == 0 && !(G_GetLogoFlags() & LOGO_NOE4BONUSSCENE))
{
fadepal(0,0,0, 63,0,-1);
fadepal(0,0,0, 252,0,-4);
I_ClearAllInput();
t = G_PlayAnim("vol4e1.anm");
@ -12506,7 +12502,7 @@ end_vol4e:
G_FadePalette(0,0,0,0);
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308
// G_FadePalette(0,0,0,63);
// G_FadePalette(0,0,0,252);
clearallviews(0L);
menutext(160,60,0,0,"Thanks to all our");
menutext(160,60+16,0,0,"fans for giving");
@ -12515,11 +12511,11 @@ end_vol4e:
menutext(160,70+16+16+16+16,0,0,"sequel soon.");
nextpage();
fadepal(0,0,0, 63,0,-3);
fadepal(0,0,0, 252,0,-12);
nextpage();
I_ClearAllInput();
G_HandleEventsWhileNoInput();
fadepal(0,0,0, 0,63,3);
fadepal(0,0,0, 0,252,12);
if (G_GetLogoFlags() & LOGO_NODUKETEAMPIC)
goto VOL4_END;
@ -12535,7 +12531,7 @@ VOL4_DUKETEAM:
clearallviews(0L);
nextpage();
G_FadePalette(0,0,0,63);
G_FadePalette(0,0,0,252);
VOL4_END:
FX_StopAllSounds();
@ -12553,7 +12549,7 @@ VOL4_END:
nextpage();
if (ud.lockout == 0 && !(G_GetLogoFlags() & LOGO_NOE3BONUSSCENE))
{
fadepal(0,0,0, 63,0,-1);
fadepal(0,0,0, 252,0,-4);
G_PlayAnim("cineov3.anm");
I_ClearAllInput();
ototalclock = totalclock+200;
@ -12612,7 +12608,7 @@ ENDANM:
clearallviews(0L);
nextpage();
G_FadePalette(0,0,0,63);
G_FadePalette(0,0,0,252);
}
I_ClearAllInput();
@ -12772,7 +12768,7 @@ void G_BonusScreen(int32_t bonusonly)
}
fadepal(0,0,0, 0,63,7);
fadepal(0,0,0, 0,252,28);
setview(0,0,xdim-1,ydim-1);
clearallviews(0L);
nextpage();
@ -12787,7 +12783,7 @@ void G_BonusScreen(int32_t bonusonly)
G_BonusCutscenes();
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308
G_FadePalette(0,0,0,63); // JBF 20031228
G_FadePalette(0,0,0,252); // JBF 20031228
KB_FlushKeyboardQueue();
totalclock = 0;
bonuscnt = 0;
@ -12806,7 +12802,7 @@ void G_BonusScreen(int32_t bonusonly)
nextpage();
I_ClearAllInput();
fadepal(0,0,0, 63,0,-7);
fadepal(0,0,0, 252,0,-28);
totalclock = 0;
while (totalclock < TICRATE*10)
@ -12826,7 +12822,7 @@ void G_BonusScreen(int32_t bonusonly)
}
}
fadepal(0,0,0, 0,63,7);
fadepal(0,0,0, 0,252,28);
}
if (bonusonly || (g_netServer || ud.multimode > 1)) return;
@ -12845,7 +12841,7 @@ void G_BonusScreen(int32_t bonusonly)
nextpage();
I_ClearAllInput();
fadepal(0,0,0, 63,0,-1);
fadepal(0,0,0, 252,0,-4);
bonuscnt = 0;
totalclock = 0;

View file

@ -292,9 +292,9 @@ int32_t ANIM_LoadAnim(const uint8_t *buffer, int32_t length)
// load the color palette
for (i = 0; i < 768; i += 3)
{
anim->pal[i+2] = (*buffer++)>>2;
anim->pal[i+1] = (*buffer++)>>2;
anim->pal[i] = (*buffer++)>>2;
anim->pal[i+2] = *buffer++;
anim->pal[i+1] = *buffer++;
anim->pal[i] = *buffer++;
buffer++;
}

View file

@ -93,6 +93,8 @@ local function shtab_mt__index(sht, idx)
end
local pal256_t = bcarray.new("uint8_t", 256, "color index 256-tuple")
local SIZEOF_PAL256 = ffi.sizeof(pal256_t)
-- The shade table type, effectively a bound-checked uint8_t [32][256]:
shtab_t = bcarray.new(pal256_t, 32, "shade table", nil, nil, { __index = shtab_mt__index })
local SIZEOF_SHTAB = ffi.sizeof(shtab_t)
@ -202,8 +204,8 @@ end
local function check_colcomp(a)
if (type(a) ~= "number" or not (a >= 0 and a < 64)) then
error("color component must be in the range [0 .. 64)", 3)
if (type(a) ~= "number" or not (a >= 0 and a < 256)) then
error("color component must be in the range [0 .. 256)", 3)
end
end
@ -325,7 +327,13 @@ if (ismapster32) then
return nil, errmsg
end
local n1 = C.fwrite(C.palette, 3, 256, f)
local truncpal = pal256_t()
ffi.copy(truncpal, C.palette, SIZEOF_PAL256)
for i=0,255 do
truncpal[i] = bit.rshift(truncpal[i], 2)
end
local n1 = C.fwrite(truncpal, 3, 256, f)
f:write("\032\000") -- int16_t numshades
local n3 = C.fwrite(sht, 256, 32, f)
local n4 = C.fwrite(tab, 256, 256, f)
@ -385,7 +393,13 @@ if (ismapster32) then
for i=1,5 do
local bpi = (i==3 or i==4) and 4+3-i or i
if (C.fwrite(C.basepaltable[bpi], 1, 768, f) ~= 768) then
local truncbasepal = pal256_t()
ffi.copy(truncbasepal, C.basepaltable[bpi], SIZEOF_PAL256)
for j=0,255 do
truncbasepal[j] = bit.rshift(truncbasepal[j], 2)
end
if (C.fwrite(truncbasepal, 1, 768, f) ~= 768) then
return nil, "failed writing base palette"
end
end

View file

@ -2,7 +2,7 @@
Usage: in Mapster32,
> lua "shadexfog=reload'shadexfog'"
-- for example
> lua "shadexfog.create(100, 63,63,63)"
> lua "shadexfog.create(100, 255,255,255)"
> lua "shadexfog.translate(100, 2)"
In EDuke32, simply pass this module at the command line.
--]]
@ -62,7 +62,7 @@ end
-- palookup, called a "shade-x-fog" palookup set in the following.
--
-- Pals <startpalnum> .. <startpalnum>+31 will be taken.
-- <fogr>, <fogg>, <fogb>: intensities of the fog color, [0 .. 63]
-- <fogr>, <fogg>, <fogb>: intensities of the fog color, [0 .. 255]
function shadexfog.create(startpalnum, fogr, fogg, fogb)
local MAXPALNUM = 255-31-engine.RESERVEDPALS
if (not (startpalnum >= 1 and startpalnum <= MAXPALNUM)) then
@ -130,7 +130,7 @@ function shadexfog.translate(startpalnum, fogintensity, vis)
end
if (gv.LUNATIC_CLIENT == gv.LUNATIC_CLIENT_EDUKE32 and LUNATIC_FIRST_TIME) then
shadexfog.create(100, 63,63,63)
shadexfog.create(100, 255,255,255)
print("created shadexfog palookups")
end
@ -406,7 +406,7 @@ function shadexfog.create_additive_trans(startblendidx, numtables, fullbrightsOK
function(r,g,b, R,G,B, level, numtabs)
local f = level/numtabs
return min(f*r+R, 63), min(f*g+G, 63), min(f*b+B, 63)
return min(f*r+R, 255), min(f*g+G, 255), min(f*b+B, 255)
end,
numtables, fullbrightsOK
@ -420,7 +420,7 @@ function shadexfog.create_brightpass_trans(startblendidx, numtables, fullbrights
function(r,g,b, R,G,B, alpha, numtabs)
local a = alpha/numtabs
local F = 1 - min(a, (R+G+B) / (3*63))
local F = 1 - min(a, (R+G+B) / (3*255))
local f = 1 - F
return f*r+F*R, f*g+F*G, f*b+F*B
end,
@ -491,9 +491,9 @@ engine.registerMenuFunc(
CreateMenuFunction{
[0] = shadexfog.create,
{ "Starting palnum", 100, MAXUSERPALOOKUP-31 },
{ "Red fog color [0-63]", 0, 63 },
{ "Green fog color [0-63]", 0, 63 },
{ "Blue fog color [0-63]", 0, 63 },
{ "Red fog color [0-255]", 0, 255 },
{ "Green fog color [0-255]", 0, 255 },
{ "Blue fog color [0-255]", 0, 255 },
},
formatHelp
@ -505,7 +505,7 @@ Creates 32 shade tables corresponding to different *shade levels*
of a fog palookup, together called a *shade-x-fog* palookup set.
Pals <startpalnum> to <startpalnum>+31 will be taken.
<fogr>, <fogg>, <fogb>: intensities of the fog color, [0 .. 63]
<fogr>, <fogg>, <fogb>: intensities of the fog color, [0 .. 255]
]]
)

View file

@ -2192,7 +2192,7 @@ badindex:
insptr++;
{
int32_t r = Gv_GetVarX(*insptr++), g = Gv_GetVarX(*insptr++), b = Gv_GetVarX(*insptr++);
Gv_SetVarX(*insptr++, getclosestcol((r>>2)&63, (g>>2)&63, (b>>2)&63));
Gv_SetVarX(*insptr++, getclosestcol(r, g, b));
continue;
}

View file

@ -1728,7 +1728,7 @@ static void G_FadeLoad(int32_t r, int32_t g, int32_t b, int32_t start, int32_t e
return;
}
G_FadePalette(r,g,b,start|128);
setpalettefade(r,g,b,start);
flushperms();
G_DoLoadScreen(" ", tc);
}
@ -1942,9 +1942,9 @@ int32_t G_EnterLevel(int32_t g)
ud.playerbest = CONFIG_GetMapBestTime(MapInfo[mii].filename);
G_FadeLoad(0,0,0, 63,0, -7, 4, -1);
G_FadeLoad(0,0,0, 252,0, -28, 4, -1);
G_CacheMapData();
G_FadeLoad(0,0,0, 0,63, 7, 4, -2);
G_FadeLoad(0,0,0, 0,252, 28, 4, -2);
if (ud.recstat != 2)
{

View file

@ -296,8 +296,6 @@ playanm(short anim_num)
numframes = ANIMnumframes;
palptr = ANIM_GetPalette();
for (i = 0; i < 768; i++)
ANIMvesapal[i] = palptr[i]>>2;
tilesiz[ANIM_TILE(ANIMnum)].x = 200;
tilesiz[ANIM_TILE(ANIMnum)].y = 320;

View file

@ -280,16 +280,16 @@ InitPalette(void)
for (i = 0; i < 256; i++)
tempbuf[i] = i;
// palette for underwater
makepalookup(PALETTE_DIVE, tempbuf, 0, 0, 15, TRUE);
makepalookup(PALETTE_DIVE, tempbuf, 0, 0, 60, TRUE);
#define FOG_AMT 15
#define FOG_AMT 60
for (i = 0; i < 256; i++)
tempbuf[i] = i;
makepalookup(PALETTE_FOG, tempbuf, FOG_AMT, FOG_AMT, FOG_AMT, TRUE);
for (i = 0; i < 256; i++)
tempbuf[i] = i;
makepalookup(PALETTE_DIVE_LAVA, tempbuf, 11, 0, 0, TRUE);
makepalookup(PALETTE_DIVE_LAVA, tempbuf, 44, 0, 0, TRUE);
//
// 1 Range changes
@ -460,9 +460,9 @@ void GetPaletteFromVESA(unsigned char *pal)
int i;
for (i=0; i<256; i++)
{
pal[i*3+0] = curpalette[i].r>>2;
pal[i*3+1] = curpalette[i].g>>2;
pal[i*3+2] = curpalette[i].b>>2;
pal[i*3+0] = curpalette[i].r;
pal[i*3+1] = curpalette[i].g;
pal[i*3+2] = curpalette[i].b;
}
// fprintf(stderr,"GetPaletteFromVESA() called\n");
}

View file

@ -5020,14 +5020,17 @@ FadeOut(unsigned char targetcolor, unsigned int clicks)
// intersections of these lines.
static int faderamp[32] =
{
64,60,56,52,48,44, // y=64-4x
// y=64-4x
252,240,224,208,192,176,
40,39,38,38,37, // y=44.8-(16/20)x
36,35,34,34,33,
32,31,30,30,29,
28,27,26,26,25,
// y=44.8-(16/20)x
160,156,152,152,148,
144,140,136,136,132,
128,124,120,120,116,
112,108,104,104,100,
24,20,16,12,8, 4 // y=128-4x
// y=128-4x
96,80,64,48,32,16
};
unsigned char ppalette[MAX_SW_PLAYERS_REG][768];

View file

@ -584,10 +584,10 @@ int32_t app_main(int32_t argc, const char **argv)
makepalookup(16,tempbuf,0,0,0,1);
for (j=0; j<256; j++) tempbuf[j] = j;
makepalookup(17,tempbuf,24,24,24,1);
makepalookup(17,tempbuf,96,96,96,1);
for (j=0; j<256; j++) tempbuf[j] = j; //(j&31)+32;
makepalookup(18,tempbuf,8,8,48,1);
makepalookup(18,tempbuf,32,32,192,1);
fillemptylookups();