Skip to content

Commit

Permalink
Light table improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyPtn committed Oct 22, 2024
1 parent f9b8221 commit 0b302ef
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
4 changes: 0 additions & 4 deletions linuxdoom-1.10/r_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,6 @@ void R_InitColormaps(void) {
// Load in the light tables,
// 256 byte align tables.
auto lump = W_GetNumForName("COLORMAP");
auto length = W_LumpLength(lump) + 255;
colormaps.resize(length);
// TODO JONNY wtf
//colormaps = (std::byte *)((reinterpret_cast<intptr_t>(colormaps) + 255) & ~0xff);
W_ReadLump(lump, colormaps.data());
}

Expand Down
2 changes: 1 addition & 1 deletion linuxdoom-1.10/r_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void R_DrawFuzzColumn(void) {
// a pixel that is either one column
// left or right of the current one.
// Add index from colormap to index.
*dest = colormaps[6 * 256 + static_cast<int>(dest[fuzzoffset[fuzzpos]])];
*dest = colormaps[6][static_cast<int>(dest[fuzzoffset[fuzzpos]])];

// Clamp table lookup index.
if (++fuzzpos == FUZZTABLE)
Expand Down
7 changes: 3 additions & 4 deletions linuxdoom-1.10/r_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ void R_InitLightTables(void) {
if (level >= NUMCOLORMAPS)
level = NUMCOLORMAPS - 1;

zlight[i][j] = colormaps.data() + level * 256;
zlight[i][j] = colormaps[level].data();
}
}
}
Expand Down Expand Up @@ -631,7 +631,7 @@ void R_ExecuteSetViewSize(void) {
if (level >= NUMCOLORMAPS)
level = NUMCOLORMAPS - 1;

scalelight[i][j] = colormaps.data() + level * 256;
scalelight[i][j] = colormaps[level].data();
}
}
}
Expand Down Expand Up @@ -703,8 +703,7 @@ void R_SetupFrame(player_t *player) {
sscount = 0;

if (player->fixedcolormap) {
fixedcolormap =
colormaps.data() + player->fixedcolormap * 256 * sizeof(lighttable_t);
fixedcolormap = colormaps[player->fixedcolormap].data();

walllights = scalelightfixed;

Expand Down
2 changes: 1 addition & 1 deletion linuxdoom-1.10/r_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void R_DrawPlanes(void) {
// i.e. colormaps[0] is used.
// Because of this hack, sky is not affected
// by INVUL inverse mapping.
dc_colormap = colormaps.data();
dc_colormap = colormaps[0].data();
dc_texturemid = skytexturemid;
for (x = pl->minx; x <= pl->maxx; x++) {
dc_yl = static_cast<int>(pl->top[x]);
Expand Down
3 changes: 2 additions & 1 deletion linuxdoom-1.10/r_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ extern fixed_t *spritewidth;
extern fixed_t *spriteoffset;
extern fixed_t *spritetopoffset;

inline std::vector<lighttable_t> colormaps;
using colormap = std::array<lighttable_t,256>;
inline std::array<colormap,34> colormaps;

extern int scaledviewwidth;

Expand Down
4 changes: 2 additions & 2 deletions linuxdoom-1.10/r_things.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ void R_ProjectSprite(mobj_t *thing) {
vis->colormap = fixedcolormap;
} else if (thing->frame & FF_FULLBRIGHT) {
// full bright
vis->colormap = colormaps.data();
vis->colormap = colormaps[0].data();
} else {
// diminished light
index = xscale >> (LIGHTSCALESHIFT - detailshift);
Expand Down Expand Up @@ -586,7 +586,7 @@ void R_DrawPSprite(pspdef_t *psp) {
vis->colormap = fixedcolormap;
} else if (psp->state->frame & FF_FULLBRIGHT) {
// full bright
vis->colormap = colormaps.data();
vis->colormap = colormaps[0].data();
} else {
// local light
vis->colormap = spritelights[MAXLIGHTSCALE - 1];
Expand Down

0 comments on commit 0b302ef

Please sign in to comment.