Fix V_DrawStretchyFixedPatch and V_DrawCroppedPatch

This commit is contained in:
Lactozilla 2023-11-28 13:46:03 -03:00
parent 5b8158d779
commit 51b0126d6d

View file

@ -676,8 +676,6 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
if (!desttop) if (!desttop)
return; return;
deststop = desttop + vid.rowbytes * vid.width;
if (scrn & V_NOSCALESTART) if (scrn & V_NOSCALESTART)
{ {
x >>= FRACBITS; x >>= FRACBITS;
@ -778,9 +776,12 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
dest = deststart + (destend - desttop); dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup)); dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
UINT8 *col_start = screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac) for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
{ {
if (dest >= screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = patchdrawfunc(dest, source, ofs); *dest = patchdrawfunc(dest, source, ofs);
dest++; dest++;
} }
@ -795,7 +796,6 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN
UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t);
UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT);
UINT32 blendmode = ((scrn & V_BLENDMASK) >> V_BLENDSHIFT); UINT32 blendmode = ((scrn & V_BLENDMASK) >> V_BLENDSHIFT);
// boolean flip = false;
fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; fixed_t col, ofs, colfrac, rowfrac, fdup, vdup;
INT32 dup; INT32 dup;
@ -944,7 +944,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN
if (!desttop) if (!desttop)
return; return;
deststop = desttop + vid.rowbytes * vid.width; int stop_pos = vid.height;
if (scrn & V_NOSCALESTART) if (scrn & V_NOSCALESTART)
{ {
@ -1011,7 +1011,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN
if (stplyr == &players[displayplayer]) // Player 1's screen, crop at the bottom if (stplyr == &players[displayplayer]) // Player 1's screen, crop at the bottom
{ {
// Just put a big old stop sign halfway through the screen // Just put a big old stop sign halfway through the screen
deststop -= vid.height>>1; stop_pos -= vid.height>>1;
} }
else //if (stplyr == &players[secondarydisplayplayer]) // Player 2's screen, crop at the top else //if (stplyr == &players[secondarydisplayplayer]) // Player 2's screen, crop at the top
{ {
@ -1050,9 +1050,12 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN
else else
ofs = sy-(topdelta<<FRACBITS); ofs = sy-(topdelta<<FRACBITS);
UINT8 *col_start = screens[0] + (x*vid.height);
deststop = col_start + stop_pos;
for (; dest < deststop && (ofs>>FRACBITS) < column->length && ((ofs - sy) + (topdelta<<FRACBITS)) < h; ofs += rowfrac) for (; dest < deststop && (ofs>>FRACBITS) < column->length && ((ofs - sy) + (topdelta<<FRACBITS)) < h; ofs += rowfrac)
{ {
if (dest >= screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = patchdrawfunc(dest, source, ofs); *dest = patchdrawfunc(dest, source, ofs);
dest++; dest++;
} }