fix for non pow2 width textures in software from doom-legacy
This commit is contained in:
1 parent
3b34f0a972
commit
96f5a8adb3
3 files changed
+39
-5
No files matched your search
+32
-1
@@ -473,11 +473,28 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col)
|
||||
{
|
||||
UINT8 *data;
|
||||
|
||||
col &= texturewidthmask[tex];
|
||||
data = texturecache[tex];
|
||||
|
||||
const INT16 texwidth = textures[tex]->width;
|
||||
|
||||
if (texturewidthmask[tex])
|
||||
col &= texturewidthmask[tex]; // set by load textures
|
||||
else
|
||||
{
|
||||
// Odd width texture, cannot just mask.
|
||||
// Sometime gets colnum = -1 or = width, even without tiling.
|
||||
// Test LostCiv, Map 20, crates.
|
||||
col = ( col < 0 ) ?
|
||||
texwidth - (((-col - 1) % texwidth) + 1)
|
||||
: col % texwidth;
|
||||
}
|
||||
|
||||
if (!data)
|
||||
{
|
||||
// This must be here because cache can be freed by other operations.
|
||||
// To prevent must lock individual texture cache on every draw.
|
||||
data = R_GenerateTexture(tex);
|
||||
}
|
||||
|
||||
return data + LONG(texturecolumnofs[tex][col]);
|
||||
}
|
||||
@@ -662,9 +679,23 @@ void R_LoadTextures(void)
|
||||
|
||||
Z_Free(patchlump);
|
||||
|
||||
// determine width power of 2
|
||||
#if 1
|
||||
// [WDJ] only need to determine if exact power of 2.
|
||||
k = 1;
|
||||
while (k < texture->width)
|
||||
k<<=1;
|
||||
#else
|
||||
// Largest power of 2 that fits within width.
|
||||
k = 1;
|
||||
while (k << 1 <= texture->width)
|
||||
k <<= 1;
|
||||
#endif
|
||||
if (k != texture->width)
|
||||
{
|
||||
// Odd width
|
||||
k = 1; // make texturewidthmask = 0
|
||||
}
|
||||
|
||||
texturewidthmask[i] = k - 1;
|
||||
textureheight[i] = texture->height << FRACBITS;
|
||||
|
||||
@@ -55,7 +55,6 @@ typedef struct
|
||||
UINT8 type; // TEXTURETYPE_
|
||||
INT16 width, height;
|
||||
boolean holes;
|
||||
|
||||
// All the patches[patchcount] are drawn back to front into the cached texture.
|
||||
INT16 patchcount;
|
||||
texpatch_t patches[0];
|
||||
|
||||
+7
-3
@@ -306,8 +306,10 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
else
|
||||
dc->texturemid -= (textureheight[texnum])*times;
|
||||
|
||||
const INT16 colnum = maskedtexturecol[dc->x];
|
||||
|
||||
// calculate lighting
|
||||
if (maskedtexturecol[dc->x] != INT16_MAX)
|
||||
if (colnum != INT16_MAX)
|
||||
{
|
||||
// Check for overflows first
|
||||
if (R_OverflowTest(dc))
|
||||
@@ -337,7 +339,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
dc->iscale = 0xffffffffu / (unsigned)spryscale;
|
||||
|
||||
// draw the texture
|
||||
col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc->x]) - 3);
|
||||
col = (column_t *)((UINT8 *)R_GetColumn(texnum, colnum) - 3);
|
||||
|
||||
auto set_light_vars = [&](INT32 k)
|
||||
{
|
||||
@@ -434,7 +436,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
dc->iscale = 0xffffffffu / (unsigned)spryscale;
|
||||
|
||||
// draw the texture
|
||||
col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc->x]) - 3);
|
||||
col = (column_t *)((UINT8 *)R_GetColumn(texnum, colnum) - 3);
|
||||
|
||||
colfunc_2s(dc, col);
|
||||
}
|
||||
@@ -1190,6 +1192,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
INT32 bottom;
|
||||
INT32 i;
|
||||
|
||||
// Loop over width
|
||||
for (; rw_x < rw_stopx; rw_x++)
|
||||
{
|
||||
// mark floor / ceiling areas
|
||||
@@ -1563,6 +1566,7 @@ static void R_MarkSegBounds(void)
|
||||
INT32 top, bottom;
|
||||
INT16 topclip, bottomclip;
|
||||
|
||||
// Loop over width
|
||||
for (; rw_x < rw_stopx; rw_x++)
|
||||
{
|
||||
// mark floor / ceiling areas
|
||||
|
||||
Reference in new issue
Block a user