mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-23 03:52:12 -04:00
improve "blocky fuzz" rendering, remove branches (#2027)
This commit is contained in:
parent
4115c9500f
commit
bc2f6d3aeb
92
src/r_draw.c
92
src/r_draw.c
@ -26,6 +26,7 @@
|
|||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "i_video.h"
|
#include "i_video.h"
|
||||||
|
#include "m_fixed.h"
|
||||||
#include "r_bsp.h"
|
#include "r_bsp.h"
|
||||||
#include "r_bmaps.h"
|
#include "r_bmaps.h"
|
||||||
#include "r_defs.h"
|
#include "r_defs.h"
|
||||||
@ -326,16 +327,18 @@ void R_DrawSkyColumn(void)
|
|||||||
//
|
//
|
||||||
|
|
||||||
#define FUZZTABLE 50
|
#define FUZZTABLE 50
|
||||||
|
#define FUZZOFF 1
|
||||||
|
|
||||||
// killough 11/98: convert fuzzoffset to be screenwidth-independent
|
// killough 11/98: convert fuzzoffset to be screenwidth-independent
|
||||||
static const int fuzzoffset[FUZZTABLE] = {
|
static const int fuzzoffset[FUZZTABLE] =
|
||||||
0,-1,0,-1,0,0,-1,
|
{
|
||||||
0,0,-1,0,0,0,-1,
|
FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
|
||||||
0,0,0,-1,-1,-1,-1,
|
FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
|
||||||
0,-1,-1,0,0,0,0,-1,
|
FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,
|
||||||
0,-1,0,0,-1,-1,0,
|
FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
|
||||||
0,-1,-1,-1,-1,0,0,
|
FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,
|
||||||
0,0,-1,0,0,-1,0
|
FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,
|
||||||
|
FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF
|
||||||
};
|
};
|
||||||
|
|
||||||
static int fuzzpos = 0;
|
static int fuzzpos = 0;
|
||||||
@ -423,50 +426,45 @@ static void R_DrawFuzzColumn_orig(void)
|
|||||||
// why_i_left_doom.html
|
// why_i_left_doom.html
|
||||||
|
|
||||||
*dest =
|
*dest =
|
||||||
fullcolormap[6 * 256
|
fullcolormap[6 * 256 + dest[linesize * fuzzoffset[fuzzpos]]];
|
||||||
+ dest[fuzzoffset[fuzzpos] ? -linesize : linesize]];
|
|
||||||
dest += linesize; // killough 11/98
|
dest += linesize; // killough 11/98
|
||||||
|
|
||||||
++fuzzpos;
|
++fuzzpos;
|
||||||
|
|
||||||
if (fuzzpos == FUZZTABLE)
|
// Clamp table lookup index.
|
||||||
fuzzpos = 0;
|
fuzzpos &= (fuzzpos - FUZZTABLE) >> (8 * sizeof(fuzzpos) - 1); // killough 1/99
|
||||||
|
|
||||||
} while (--count);
|
} while (--count);
|
||||||
|
|
||||||
// [crispy] if the line at the bottom had to be cut off,
|
// [crispy] if the line at the bottom had to be cut off,
|
||||||
// draw one extra line using only pixels of that line and the one above
|
// draw one extra line using only pixels of that line and the one above
|
||||||
if (cutoff)
|
if (cutoff)
|
||||||
{
|
{
|
||||||
*dest = fullcolormap[6 * 256 + dest[linesize * fuzzoffset[fuzzpos]]];
|
*dest = fullcolormap
|
||||||
|
[6 * 256 + dest[linesize * (fuzzoffset[fuzzpos] - FUZZOFF) / 2]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// [FG] "blocky" spectre drawing for hires mode
|
// [FG] "blocky" spectre drawing for hires mode
|
||||||
|
|
||||||
|
static int fuzzblocksize;
|
||||||
|
|
||||||
static void R_DrawFuzzColumn_block(void)
|
static void R_DrawFuzzColumn_block(void)
|
||||||
{
|
{
|
||||||
boolean cutoff = false;
|
boolean cutoff = false;
|
||||||
const int nx = video.xscale >> FRACBITS;
|
|
||||||
const int ny = video.yscale >> FRACBITS;
|
|
||||||
|
|
||||||
if (dc_x % nx)
|
if (dc_x % fuzzblocksize)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_yl += ny;
|
|
||||||
dc_yl -= dc_yl % ny;
|
|
||||||
dc_yh -= dc_yh % ny;
|
|
||||||
|
|
||||||
if (!dc_yl)
|
if (!dc_yl)
|
||||||
{
|
{
|
||||||
dc_yl = ny;
|
dc_yl = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dc_yh >= viewheight - ny)
|
if (dc_yh == viewheight - 1)
|
||||||
{
|
{
|
||||||
dc_yh = viewheight - 2 * ny;
|
dc_yh = viewheight - 2;
|
||||||
cutoff = true;
|
cutoff = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,40 +482,47 @@ static void R_DrawFuzzColumn_block(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
++count;
|
||||||
|
|
||||||
byte *dest = ylookup[dc_yl] + columnofs[dc_x];
|
byte *dest = ylookup[dc_yl] + columnofs[dc_x];
|
||||||
|
|
||||||
count += ny;
|
int lines = fuzzblocksize - (dc_yl % fuzzblocksize);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// [FG] draw only even pixels as (nx * ny) squares
|
count -= lines;
|
||||||
// using the same fuzzoffset value
|
|
||||||
const int offset = fuzzoffset[fuzzpos] ? -ny * linesize : ny * linesize;
|
|
||||||
const byte fuzz = fullcolormap[6 * 256 + dest[offset]];
|
|
||||||
|
|
||||||
for (int i = 0; i < ny && count - i > 0; i++)
|
// if (count < 0)
|
||||||
|
// {
|
||||||
|
// lines += count;
|
||||||
|
// count = 0;
|
||||||
|
// }
|
||||||
|
const int mask = count >> (8 * sizeof(mask) - 1);
|
||||||
|
lines += count & mask;
|
||||||
|
count &= ~mask;
|
||||||
|
|
||||||
|
const byte fuzz =
|
||||||
|
fullcolormap[6 * 256 + dest[linesize * fuzzoffset[fuzzpos]]];
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
memset(dest, fuzz, nx);
|
memset(dest, fuzz, fuzzblocksize);
|
||||||
dest += linesize;
|
dest += linesize;
|
||||||
}
|
} while (--lines);
|
||||||
|
|
||||||
++fuzzpos;
|
++fuzzpos;
|
||||||
|
|
||||||
if (fuzzpos == FUZZTABLE)
|
// Clamp table lookup index.
|
||||||
fuzzpos = 0;
|
fuzzpos &= (fuzzpos - FUZZTABLE) >> (8 * sizeof(fuzzpos) - 1); // killough 1/99
|
||||||
|
|
||||||
} while ((count -= ny) > 0);
|
lines = fuzzblocksize;
|
||||||
|
} while (count);
|
||||||
|
|
||||||
if (cutoff)
|
if (cutoff)
|
||||||
{
|
{
|
||||||
const int offset = ny * linesize * fuzzoffset[fuzzpos];
|
const byte fuzz = fullcolormap
|
||||||
const byte fuzz = fullcolormap[6 * 256 + dest[offset]];
|
[6 * 256 + dest[linesize * (fuzzoffset[fuzzpos] - FUZZOFF) / 2]];
|
||||||
|
memset(dest, fuzz, fuzzblocksize);
|
||||||
for (int i = 0; i < ny; i++)
|
|
||||||
{
|
|
||||||
memset(dest, fuzz, nx);
|
|
||||||
dest += linesize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,6 +535,7 @@ void R_SetFuzzColumnMode(void)
|
|||||||
{
|
{
|
||||||
if (fuzzcolumn_mode && current_video_height > SCREENHEIGHT)
|
if (fuzzcolumn_mode && current_video_height > SCREENHEIGHT)
|
||||||
{
|
{
|
||||||
|
fuzzblocksize = FixedToInt(video.yscale);
|
||||||
R_DrawFuzzColumn = R_DrawFuzzColumn_block;
|
R_DrawFuzzColumn = R_DrawFuzzColumn_block;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user