Skip to content

Commit

Permalink
Heretic: true color - initials
Browse files Browse the repository at this point in the history
  • Loading branch information
JNechaevsky committed Nov 16, 2023
1 parent 743a24f commit e381e8e
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/heretic/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@ void D_BindVariables(void)
M_BindIntVariable("crispy_playercoords", &crispy->playercoords);
M_BindIntVariable("crispy_secretmessage", &crispy->secretmessage);
M_BindIntVariable("crispy_soundmono", &crispy->soundmono);
#ifdef CRISPY_TRUECOLOR
M_BindIntVariable("crispy_truecolor", &crispy->truecolor);
#endif
M_BindIntVariable("crispy_uncapped", &crispy->uncapped);
M_BindIntVariable("crispy_vsync", &crispy->vsync);
M_BindIntVariable("crispy_widescreen", &crispy->widescreen);
Expand Down
25 changes: 23 additions & 2 deletions src/heretic/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ void F_Ticker(void)

void F_TextWrite(void)
{
byte *src, *dest;
byte *src;
pixel_t *dest;
int x, y;
int count;
const char *ch;
Expand All @@ -164,6 +165,7 @@ void F_TextWrite(void)
dest = I_VideoBuffer;
for (y = 0; y < SCREENHEIGHT; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
Expand All @@ -174,6 +176,12 @@ void F_TextWrite(void)
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
#else
for (x = 0; x < SCREENWIDTH; x++)
{
*dest++ = colormaps[src[((y & 63) << 6) + (x & 63)]];
}
#endif
}

// V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
Expand Down Expand Up @@ -220,7 +228,8 @@ void F_TextWrite(void)
void F_DrawPatchCol(int x, patch_t * patch, int col)
{
column_t *column;
byte *source, *dest, *desttop;
byte *source;
pixel_t *dest, *desttop;
int count;

column = (column_t *) ((byte *) patch + LONG(patch->columnofs[col]));
Expand Down Expand Up @@ -325,8 +334,10 @@ void F_DemonScroll(void)
void F_DrawUnderwater(void)
{
static boolean underwawa = false;
#ifndef CRISPY_TRUECOLOR
const char *lumpname;
byte *palette;
#endif

// The underwater screen has its own palette, which is rather annoying.
// The palette doesn't correspond to the normal palette. Because of
Expand All @@ -340,10 +351,15 @@ void F_DrawUnderwater(void)
{
underwawa = true;
V_DrawFilledBox(0, 0, SCREENWIDTH, SCREENHEIGHT, 0);
#ifndef CRISPY_TRUECOLOR
lumpname = DEH_String("E2PAL");
palette = W_CacheLumpName(lumpname, PU_STATIC);
I_SetPalette(palette);
W_ReleaseLumpName(lumpname);
#else
// [JN] TODO - E2END using different palette
I_SetPalette(0);
#endif
V_DrawFullscreenRawOrPatch(W_GetNumForName(DEH_String("E2END")));
}
paused = false;
Expand All @@ -354,10 +370,15 @@ void F_DrawUnderwater(void)
case 2:
if (underwawa)
{
#ifndef CRISPY_TRUECOLOR
lumpname = DEH_String("PLAYPAL");
palette = W_CacheLumpName(lumpname, PU_STATIC);
I_SetPalette(palette);
W_ReleaseLumpName(lumpname);
#else
// [JN] TODO - E2END using different palette
I_SetPalette(0);
#endif
underwawa = false;
}
V_DrawFullscreenRawOrPatch(W_GetNumForName(DEH_String("TITLE")));
Expand Down
13 changes: 12 additions & 1 deletion src/heretic/in_lude.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ static const char *NameForMap(int map)

void IN_Start(void)
{
#ifndef CRISPY_TRUECOLOR
I_SetPalette(W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE));
#else
I_SetPalette(0);
#endif
IN_LoadPics();
IN_InitStats();
intermission = true;
Expand Down Expand Up @@ -618,13 +622,14 @@ void IN_DrawStatBack(void)
int y;

byte *src;
byte *dest;
pixel_t *dest;

src = W_CacheLumpName(DEH_String("FLOOR16"), PU_CACHE);
dest = I_VideoBuffer;

for (y = 0; y < SCREENHEIGHT; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
Expand All @@ -635,6 +640,12 @@ void IN_DrawStatBack(void)
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
#else
for (x = 0; x < SCREENWIDTH; x++)
{
*dest++ = colormaps[src[((y & 63) << 6) + (x & 63)]];
}
#endif
}
}

Expand Down
28 changes: 27 additions & 1 deletion src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1792,8 +1792,12 @@ boolean MN_Responder(event_t * event)
//set the msg to be cleared
players[consoleplayer].message = NULL;
paused = false;
#ifndef CRISPY_TRUECOLOR
I_SetPalette(W_CacheLumpName
("PLAYPAL", PU_CACHE));
#else
I_SetPalette (0);
#endif
D_StartTitle(); // go to intro/demo mode.
break;

Expand Down Expand Up @@ -2028,7 +2032,17 @@ boolean MN_Responder(event_t * event)
{
usegamma = 0;
}
#ifndef CRISPY_TRUECOLOR
I_SetPalette((byte *) W_CacheLumpName("PLAYPAL", PU_CACHE));
#else
{
extern void R_InitColormaps (void);
I_SetPalette (0);
R_InitColormaps();
setsizeneeded = true;
//viewactive = false; // [JN] Needed?
}
#endif
return true;
}
// [crispy] those two can be considered as shortcuts for the ENGAGE cheat
Expand Down Expand Up @@ -2438,7 +2452,11 @@ void MN_DrawInfo(void)
{
lumpindex_t lumpindex; // [crispy]

#ifndef CRISPY_TRUECOLOR
I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE));
#else
I_SetPalette (0);
#endif

// [crispy] Refactor to allow for use of V_DrawFullscreenRawOrPatch

Expand Down Expand Up @@ -2543,7 +2561,8 @@ static void DrawMouseMenu(void)

static void M_DrawCrispnessBackground(void)
{
byte *src, *dest;
byte *src;
pixel_t *dest;
int x, y;

if (gamemode == shareware)
Expand All @@ -2558,6 +2577,7 @@ static void M_DrawCrispnessBackground(void)

for (y = 0; y < SCREENHEIGHT; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
Expand All @@ -2568,6 +2588,12 @@ static void M_DrawCrispnessBackground(void)
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
#else
for (x = 0; x < SCREENWIDTH; x++)
{
*dest++ = colormaps[src[(y & 63) * 64 + (x & 63)]];
}
#endif
}

SB_state = -1;
Expand Down
4 changes: 4 additions & 0 deletions src/heretic/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,11 @@ void P_DeathThink(player_t * player)
{
if (player == &players[consoleplayer])
{
#ifndef CRISPY_TRUECOLOR
I_SetPalette(W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE));
#else
I_SetPalette(0);
#endif
inv_ptr = 0;
curpos = 0;
newtorch = 0;
Expand Down
70 changes: 70 additions & 0 deletions src/heretic/r_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ void R_InitSpriteLumps(void)

void R_InitColormaps(void)
{
#ifndef CRISPY_TRUECOLOR
int lump, length;
//
// load in the light tables
Expand All @@ -528,6 +529,75 @@ void R_InitColormaps(void)
length = W_LumpLength(lump);
colormaps = Z_Malloc(length, PU_STATIC, 0);
W_ReadLump(lump, colormaps);
#else
byte *playpal;
int c, i, j = 0;
byte r, g, b;
extern byte **gamma2table;

// [crispy] intermediate gamma levels
if (!gamma2table)
{
extern void I_SetGammaTable (void);
I_SetGammaTable();
}

playpal = W_CacheLumpName("PLAYPAL", PU_STATIC);

if (!colormaps)
{
colormaps = (lighttable_t*) Z_Malloc((NUMCOLORMAPS + 1) * 256 * sizeof(lighttable_t), PU_STATIC, 0);
}

if (crispy->truecolor)
{
for (c = 0; c < NUMCOLORMAPS; c++)
{
const float scale = 1. * c / NUMCOLORMAPS;

for (i = 0; i < 256; i++)
{
r = gamma2table[usegamma][playpal[3 * i + 0]] * (1. - scale) + gamma2table[usegamma][0] * scale;
g = gamma2table[usegamma][playpal[3 * i + 1]] * (1. - scale) + gamma2table[usegamma][0] * scale;
b = gamma2table[usegamma][playpal[3 * i + 2]] * (1. - scale) + gamma2table[usegamma][0] * scale;

colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
}

// [crispy] Invulnerability (c == COLORMAPS)
// [JN] TODO - inacurate, should be fine-tuned
for (i = 0; i < 256; i++)

This comment has been minimized.

Copy link
@fabiangreffrath

fabiangreffrath Nov 17, 2023

Owner

If you can't match the golden tint of the invulnerability colormap (I guess we don't have the formula for this), then you might either want to use the CR_GOLD translation table, or just load the COLORMAP lump and use its last translation table.

This comment has been minimized.

Copy link
@JNechaevsky

JNechaevsky Nov 17, 2023

Author Collaborator

We don't have this formula. 😕
AFAIR, Raven didn't released sources of their tools. Yep, I was thinking about COLORMAP fallback for invulnerability and know it is possible, but before give up I want to try to replicate it as accurate as possible first, otherwise why we need full set of true colors?

This comment has been minimized.

Copy link
@fabiangreffrath

fabiangreffrath Nov 17, 2023

Owner

I could live with an unreproducible invulnerability colormap as the one exception. 😉

This comment has been minimized.

Copy link
@JNechaevsky

JNechaevsky Nov 17, 2023

Author Collaborator

Ah, looks likes it is better to use COLORMAP for generating. I have no luck with making colors "exact enough" to represent vanilla look: paletted and true color. It's again feels dull and lack of conrast.

On top of that I've got typical problem of "Carmack's typo" a.k.a "where are my blue colors gone" (screenshot).

Will commit this change soon, but all remainings have to wait until evening - today is my last day before one week vacation. It's impossible to concentrate on the code while everyone is distracting with double power! But honestly, things gets far better once I've left IT department and become a secretary of the final certification commission, still here, in same institute. 🙂

This comment has been minimized.

Copy link
@fabiangreffrath

fabiangreffrath Nov 17, 2023

Owner

On top of that I've got typical problem of "Carmack's typo" a.k.a "where are my blue colors gone"

Well, you don't even add any blue channel value, only r and g, so no wonder that you end up entirely wthout any blue. 😉

Will commit this change soon, but all remainings have to wait until evening - today is my last day before one week vacation. It's impossible to concentrate on the code while everyone is distracting with double power! But honestly, things gets far better once I've left IT department and become a secretary of the final certification commission, still here, in same institute. 🙂

Sounds like a change to the better. 👍 Congratulations and have a nice vacation!

{
const byte gold =
(byte) (0.500 * playpal[3 * i + 0] +
0.500 * playpal[3 * i + 1]);
r = g = gamma2table[usegamma][gold];
// [JN] Decrease green channel intensity
g /= 1.500;

colormaps[j++] = 0xff000000 | (r << 16) | (g << 8);
}
}
else
{
byte *const colormap = W_CacheLumpName("COLORMAP", PU_STATIC);

for (c = 0; c <= NUMCOLORMAPS; c++)
{
for (i = 0; i < 256; i++)
{
r = gamma2table[usegamma][playpal[3 * colormap[c * 256 + i] + 0]] & ~3;
g = gamma2table[usegamma][playpal[3 * colormap[c * 256 + i] + 1]] & ~3;
b = gamma2table[usegamma][playpal[3 * colormap[c * 256 + i] + 2]] & ~3;

colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
}

W_ReleaseLumpName("COLORMAP");
}
#endif

// [crispy] initialize color translation and color string tables
{
Expand Down
Loading

2 comments on commit e381e8e

@JNechaevsky
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiangreffrath, a moment of your attention please. It's not about review or PR, there is more work needs to be done. But I have a very bad feeling...

Have a look at this lava please, it's in non true color mode:
image

And here, in true color:
image

And it's not limited to lava only. It feels like the game is loosing it's charm. Original palleted colors are daring, catchy and brave, but in true color they feels a bit dull. It's not a problem of true color implementation itself, GZDoom have exactly same problem. In other words: by trying to make the game looking nicer, it becomes uglier instead. In Doom, however, it feels absolutely opposite, probably because of there were no too-high-contrast colors in original palette. Or is it just me?

Anyways, what is your recommendation? Should I proceed?

@fabiangreffrath
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have read before that Heretic would look dull and washed out with truecolor rendering, but have never seen it before. However, it's right, the game looks a lot different, less poppy and candy. However, I wouldn't say I don't like it at all.

Please don't feel discouraged because the results don't look like you expected them. It would be a shame if you abandoned all the work on truecolor rendering for a purely subjective impression. Please proceed! 🙏

Please sign in to comment.