Update R_DrawFloorSprite_NPO2_8 and R_DrawTranslucentFloorSprite_NPO2_8 to have the lastest NPO2 optimizations
This commit is contained in:
parent
5e890ee6f8
commit
389763a550
|
@ -818,6 +818,8 @@ void R_DrawFloorSprite_NPO2_8 (void)
|
||||||
fixed_t xposition;
|
fixed_t xposition;
|
||||||
fixed_t yposition;
|
fixed_t yposition;
|
||||||
fixed_t xstep, ystep;
|
fixed_t xstep, ystep;
|
||||||
|
fixed_t x, y;
|
||||||
|
fixed_t fixedwidth, fixedheight;
|
||||||
|
|
||||||
UINT16 *source;
|
UINT16 *source;
|
||||||
UINT8 *translation;
|
UINT8 *translation;
|
||||||
|
@ -836,20 +838,39 @@ void R_DrawFloorSprite_NPO2_8 (void)
|
||||||
translation = ds_translation;
|
translation = ds_translation;
|
||||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||||
|
|
||||||
|
fixedwidth = ds_flatwidth << FRACBITS;
|
||||||
|
fixedheight = ds_flatheight << FRACBITS;
|
||||||
|
|
||||||
|
// Fix xposition and yposition if they are out of bounds.
|
||||||
|
if (xposition < 0)
|
||||||
|
xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth);
|
||||||
|
else if (xposition >= fixedwidth)
|
||||||
|
xposition %= fixedwidth;
|
||||||
|
if (yposition < 0)
|
||||||
|
yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight);
|
||||||
|
else if (yposition >= fixedheight)
|
||||||
|
yposition %= fixedheight;
|
||||||
|
|
||||||
while (count-- && dest <= deststop)
|
while (count-- && dest <= deststop)
|
||||||
{
|
{
|
||||||
fixed_t x = (xposition >> FRACBITS);
|
// The loops here keep the texture coordinates within the texture.
|
||||||
fixed_t y = (yposition >> FRACBITS);
|
// They will rarely iterate multiple times, and are cheaper than a modulo operation,
|
||||||
|
// even if using libdivide.
|
||||||
// Carefully align all of my Friends.
|
if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop
|
||||||
if (x < 0)
|
while (xposition < 0)
|
||||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
xposition += fixedwidth;
|
||||||
if (y < 0)
|
else
|
||||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
while (xposition >= fixedwidth)
|
||||||
|
xposition -= fixedwidth;
|
||||||
x %= ds_flatwidth;
|
if (ystep < 0)
|
||||||
y %= ds_flatheight;
|
while (yposition < 0)
|
||||||
|
yposition += fixedheight;
|
||||||
|
else
|
||||||
|
while (yposition >= fixedheight)
|
||||||
|
yposition -= fixedheight;
|
||||||
|
|
||||||
|
x = (xposition >> FRACBITS);
|
||||||
|
y = (yposition >> FRACBITS);
|
||||||
val = source[((y * ds_flatwidth) + x)];
|
val = source[((y * ds_flatwidth) + x)];
|
||||||
if (val & 0xFF00)
|
if (val & 0xFF00)
|
||||||
*dest = colormap[translation[val & 0xFF]];
|
*dest = colormap[translation[val & 0xFF]];
|
||||||
|
@ -867,6 +888,8 @@ void R_DrawTranslucentFloorSprite_NPO2_8 (void)
|
||||||
fixed_t xposition;
|
fixed_t xposition;
|
||||||
fixed_t yposition;
|
fixed_t yposition;
|
||||||
fixed_t xstep, ystep;
|
fixed_t xstep, ystep;
|
||||||
|
fixed_t x, y;
|
||||||
|
fixed_t fixedwidth, fixedheight;
|
||||||
|
|
||||||
UINT16 *source;
|
UINT16 *source;
|
||||||
UINT8 *translation;
|
UINT8 *translation;
|
||||||
|
@ -885,20 +908,39 @@ void R_DrawTranslucentFloorSprite_NPO2_8 (void)
|
||||||
translation = ds_translation;
|
translation = ds_translation;
|
||||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||||
|
|
||||||
|
fixedwidth = ds_flatwidth << FRACBITS;
|
||||||
|
fixedheight = ds_flatheight << FRACBITS;
|
||||||
|
|
||||||
|
// Fix xposition and yposition if they are out of bounds.
|
||||||
|
if (xposition < 0)
|
||||||
|
xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth);
|
||||||
|
else if (xposition >= fixedwidth)
|
||||||
|
xposition %= fixedwidth;
|
||||||
|
if (yposition < 0)
|
||||||
|
yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight);
|
||||||
|
else if (yposition >= fixedheight)
|
||||||
|
yposition %= fixedheight;
|
||||||
|
|
||||||
while (count-- && dest <= deststop)
|
while (count-- && dest <= deststop)
|
||||||
{
|
{
|
||||||
fixed_t x = (xposition >> FRACBITS);
|
// The loops here keep the texture coordinates within the texture.
|
||||||
fixed_t y = (yposition >> FRACBITS);
|
// They will rarely iterate multiple times, and are cheaper than a modulo operation,
|
||||||
|
// even if using libdivide.
|
||||||
// Carefully align all of my Friends.
|
if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop
|
||||||
if (x < 0)
|
while (xposition < 0)
|
||||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
xposition += fixedwidth;
|
||||||
if (y < 0)
|
else
|
||||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
while (xposition >= fixedwidth)
|
||||||
|
xposition -= fixedwidth;
|
||||||
x %= ds_flatwidth;
|
if (ystep < 0)
|
||||||
y %= ds_flatheight;
|
while (yposition < 0)
|
||||||
|
yposition += fixedheight;
|
||||||
|
else
|
||||||
|
while (yposition >= fixedheight)
|
||||||
|
yposition -= fixedheight;
|
||||||
|
|
||||||
|
x = (xposition >> FRACBITS);
|
||||||
|
y = (yposition >> FRACBITS);
|
||||||
val = source[((y * ds_flatwidth) + x)];
|
val = source[((y * ds_flatwidth) + x)];
|
||||||
if (val & 0xFF00)
|
if (val & 0xFF00)
|
||||||
*dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest);
|
*dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest);
|
||||||
|
|
Loading…
Reference in a new issue