wrap prevention code now takes flipped patches into account

This commit is contained in:
Monster Iestyn 2016-03-25 20:04:49 +00:00
parent 76d71bda92
commit 3698c2583d

View file

@ -336,6 +336,8 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
const column_t *column; const column_t *column;
UINT8 *desttop, *dest, *deststart, *destend; UINT8 *desttop, *dest, *deststart, *destend;
const UINT8 *source, *deststop; const UINT8 *source, *deststop;
fixed_t pwidth; // patch width
fixed_t offx = 0; // x offset
if (rendermode == render_none) if (rendermode == render_none)
return; return;
@ -476,25 +478,36 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
} }
} }
deststart = desttop;
if (pscale != FRACUNIT) // scale width properly if (pscale != FRACUNIT) // scale width properly
{ {
fixed_t pwidth = SHORT(patch->width)<<FRACBITS; pwidth = SHORT(patch->width)<<FRACBITS;
pwidth = FixedMul(pwidth, pscale); pwidth = FixedMul(pwidth, pscale);
pwidth = FixedMul(pwidth, dupx<<FRACBITS); pwidth = FixedMul(pwidth, dupx<<FRACBITS);
pwidth >>= FRACBITS; pwidth >>= FRACBITS;
destend = desttop + pwidth;
} }
else else
destend = desttop + SHORT(patch->width) * dupx; pwidth = SHORT(patch->width) * dupx;
for (col = 0; (col>>FRACBITS) < SHORT(patch->width); col += colfrac, ++x, desttop++) deststart = desttop;
destend = desttop + pwidth;
for (col = 0; (col>>FRACBITS) < SHORT(patch->width); col += colfrac, ++offx, desttop++)
{ {
INT32 topdelta, prevdelta = -1; INT32 topdelta, prevdelta = -1;
if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) if (flip) // offx is measured from right edge instead of left
continue; {
if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
break; break;
if (x+pwidth-offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
continue;
}
else
{
if (x+offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
continue;
if (x+offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
break;
}
column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[col>>FRACBITS])); column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[col>>FRACBITS]));
while (column->topdelta != 0xff) while (column->topdelta != 0xff)