Skip to content

Commit

Permalink
Import tutti-frutti fix from obsidian (which was taken from Boom).
Browse files Browse the repository at this point in the history
  • Loading branch information
tm512 committed Jan 20, 2012
1 parent f678d2e commit 122e9f5
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
56 changes: 46 additions & 10 deletions src/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void R_DrawColumn (void)
int count;
byte* dest;
fixed_t frac;
fixed_t fracstep;
fixed_t fracstep;

count = dc_yh - dc_yl;

Expand Down Expand Up @@ -137,16 +137,52 @@ void R_DrawColumn (void)
// Inner loop that does the actual texture mapping,
// e.g. a DDA-lile scaling.
// This is as fast as it gets.
do
// [tm512] - Fix tutti-frutti bug - 01/20/2012
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
*dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]];

dest += SCREENWIDTH;
frac += fracstep;

} while (count--);
int heightmask = dc_texheight - 1;

if (dc_texheight & heightmask) // Texture height is not a power of 2
{
heightmask ++;
heightmask <<= FRACBITS;

if (frac < 0)
{
while ((frac += heightmask) < 0);
}
else
{
while (frac >= heightmask)
{
frac -= heightmask;
}
}

do
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
*dest = dc_colormap [dc_source [frac >> FRACBITS]];
dest += SCREENWIDTH;

if ((frac += fracstep) >= heightmask)
{
frac -= heightmask;
}
} while (count--);
}
else
{
do
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
*dest = dc_colormap [dc_source [(frac >> FRACBITS) & heightmask]];
dest += SCREENWIDTH;
frac += fracstep;
} while (count--);
}
}
}


Expand Down
1 change: 1 addition & 0 deletions src/r_draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern int dc_yl;
extern int dc_yh;
extern fixed_t dc_iscale;
extern fixed_t dc_texturemid;
int dc_texheight;

// first pixel in a column
extern byte* dc_source;
Expand Down
1 change: 1 addition & 0 deletions src/r_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ void R_DrawPlanes (void)
angle = (viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
dc_x = x;
dc_source = R_GetColumn(skytexture, angle);
dc_texheight = textureheight [skytexture] >> FRACBITS;
colfunc ();
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/r_segs.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include "r_local.h"
#include "r_sky.h"
#include "r_draw.h"


// OPTIMIZE: closed two sided lines as single sided
Expand Down Expand Up @@ -289,6 +290,7 @@ void R_RenderSegLoop (void)
dc_yh = yh;
dc_texturemid = rw_midtexturemid;
dc_source = R_GetColumn(midtexture,texturecolumn);
dc_texheight = textureheight [midtexture] >> FRACBITS;
colfunc ();
ceilingclip[rw_x] = viewheight;
floorclip[rw_x] = -1;
Expand All @@ -311,6 +313,7 @@ void R_RenderSegLoop (void)
dc_yh = mid;
dc_texturemid = rw_toptexturemid;
dc_source = R_GetColumn(toptexture,texturecolumn);
dc_texheight = textureheight [toptexture] >> FRACBITS;
colfunc ();
ceilingclip[rw_x] = mid;
}
Expand Down Expand Up @@ -341,6 +344,7 @@ void R_RenderSegLoop (void)
dc_texturemid = rw_bottomtexturemid;
dc_source = R_GetColumn(bottomtexture,
texturecolumn);
dc_texheight = textureheight [bottomtexture] >> FRACBITS;
colfunc ();
floorclip[rw_x] = mid;
}
Expand Down
2 changes: 2 additions & 0 deletions src/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "w_wad.h"

#include "r_local.h"
#include "r_draw.h"

#include "doomstat.h"

Expand Down Expand Up @@ -379,6 +380,7 @@ void R_DrawMaskedColumn (column_t* column)

// Drawn by either R_DrawColumn
// or (SHADOW) R_DrawFuzzColumn.
dc_texheight = 0;
colfunc ();
}
column = (column_t *)( (byte *)column + column->length + 4);
Expand Down

0 comments on commit 122e9f5

Please sign in to comment.