From 3698c2583d36a0d302e2b005cea221d838ad80af Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 25 Mar 2016 20:04:49 +0000 Subject: [PATCH] wrap prevention code now takes flipped patches into account --- src/v_video.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 3eb71bb0..b9bdb271 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -336,6 +336,8 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t const column_t *column; UINT8 *desttop, *dest, *deststart, *destend; const UINT8 *source, *deststop; + fixed_t pwidth; // patch width + fixed_t offx = 0; // x offset if (rendermode == render_none) 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 { - fixed_t pwidth = SHORT(patch->width)<width)<>= FRACBITS; - destend = desttop + pwidth; } 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; - if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) - continue; - if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) - break; + if (flip) // offx is measured from right edge instead of left + { + if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION) + 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])); while (column->topdelta != 0xff)