From e85d8d61857a9a97c3116cfac840cc95466bdc1d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Oct 2025 21:22:01 +0200 Subject: [PATCH] fix most things MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix patch drawers mostly (V_FLIP seems broken) fix VID_BlitLinearScreen fix wöter ripples fix screenshots gif recording is still wonky, but atleast doesent draw complete garbage wipes are still broken flipcam and encore aswell --- src/am_map.c | 2 +- src/d_main.c | 2 +- src/f_wipe.c | 4 +- src/r_draw_span.cpp | 14 ++-- src/r_plane.cpp | 7 +- src/sdl/i_video.c | 10 ++- src/v_video.c | 200 ++++++++++++++++++++++++++++---------------- 7 files changed, 151 insertions(+), 88 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index e3c3c988c..df37287a0 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -785,7 +785,7 @@ static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc) { if (xx < 0 || yy < 0 || xx >= f_w || yy >= f_h) return; // off the screen - am_buf[(yy*f_w) + xx] = cc; + am_buf[(xx*f_h) + yy] = cc; } // diff --git a/src/d_main.c b/src/d_main.c index dd13c7b77..069af2872 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -609,7 +609,7 @@ static boolean D_Display(void) { if (rendermode == render_soft) { - VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.width); + VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.height, vid.height); } lastdraw = false; diff --git a/src/f_wipe.c b/src/f_wipe.c index 4c3a067c6..5a12ccb41 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -314,7 +314,7 @@ void F_WipeStartScreen(void) } #endif wipe_scr_start = vid.screens[3]; - I_ReadScreen(wipe_scr_start, 1); + M_Memcpy(wipe_scr_start, vid.screens[0], vid.width*vid.height); #endif } @@ -331,7 +331,7 @@ void F_WipeEndScreen(void) } #endif wipe_scr_end = vid.screens[4]; - I_ReadScreen(wipe_scr_end, 1); + M_Memcpy(wipe_scr_end, vid.screens[0], vid.width*vid.height); V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start); #endif } diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp index b855d00b0..e8cc629a0 100644 --- a/src/r_draw_span.cpp +++ b/src/r_draw_span.cpp @@ -255,7 +255,7 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds) if constexpr (Type & DS_RIPPLE) { - dsrc = vid.screens[1] + (ds->y + ds->bgofs) * stride + ds->x1; + dsrc = vid.screens[1] + (ds->y + ds->bgofs) + ds->x1 * stride; } else { @@ -370,8 +370,8 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds) colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps); *dest = R_DrawSpanPixel(ds, dsrc, colormap, bit, source); dest += stride; - ds->x1++; dsrc += stride; + ds->x1++; u += stepu; v += stepv; } @@ -407,7 +407,9 @@ void R_DrawFogSpan(drawspandata_t* ds) intptr_t count = ds->x2 - ds->x1 + 1; - while (count >= 4) + const INT32 stride = vid.height; + + /*while (count >= 4) { dest[0] = colormap[dest[0]]; dest[1] = colormap[dest[1]]; @@ -416,12 +418,12 @@ void R_DrawFogSpan(drawspandata_t* ds) dest += 4; count -= 4; - } + }*/ while (count--) { *dest = colormap[*dest]; - dest++; + dest += stride; } } @@ -442,7 +444,7 @@ void R_DrawFogSpan_Tilted(drawspandata_t* ds) { UINT8 *colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps); *dest = colormap[*dest]; - dest++; + dest += stride; } while (--width >= 0); } diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 475e8a44d..d852ef56c 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1156,13 +1156,14 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle } } - offset = (scry*vid.width) + scrx; + //offset = (scry*vid.width) + scrx; + offset = (scrx*vid.height) + scry; // No idea if this works VID_BlitLinearScreen(renderscreen + offset, - vid.screens[1] + (top*vid.width), // intentionally not +offset + vid.screens[1] + top, // intentionally not +offset viewwidth, bottom-top, - vid.width, vid.width); + vid.height, vid.height); } } } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 95613d5c6..3927437bc 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1416,7 +1416,13 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale) if (rendermode != render_soft) I_Error("I_ReadScreen: called while in non-software mode"); else if (scale == 1) - VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.width, vid.width); + { + UINT8 *buffer = vid.screens[0]; + + for (int y = 0; y < vid.height; y++) + for (int x = 0; x < vid.width; x++) + scr[(y * vid.width) + x] = buffer[(x * vid.height) + y]; + } else { UINT8 * restrict source = vid.screens[0]; @@ -1426,7 +1432,7 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale) // uintptr_t is even better since it's guaranteed to be the size of a pointer for (uintptr_t y = 0; y < h; y += scale) for (uintptr_t x = 0; x < w; x += scale) - *scr++ = source[y*vid.width + x]; + *scr++ = source[y*vid.height + x]; } } diff --git a/src/v_video.c b/src/v_video.c index 4be79150f..3f5e4ea67 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -614,9 +614,6 @@ static void CV_constextsize_OnChange(void) // -------------------------------------------------------------------------- void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes) { - //:skull: - return; - if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)height) { size_t i = srcrowbytes * width; @@ -846,7 +843,6 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca } desttop += (x*vid.height) + y; - if (pscale != FRACUNIT) // scale width properly { pwidth = patch->width<>FRACBITS) < patch->width; col += colfrac, ++offx, desttop += vid.height) { INT32 topdelta, prevdelta = -1; @@ -869,14 +863,14 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca { if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION) break; - if (x+pwidth-offx >= stride) // don't draw off the right of the screen (WRAP PREVENTION) + 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 >= stride) // don't draw off the right of the screen (WRAP PREVENTION) + if (x+offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) break; } column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS])); @@ -925,7 +919,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca UINT8 *col_start = vid.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 && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac) { if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION) *dest = *(v_colormap + source[ofs>>FRACBITS]); @@ -951,7 +945,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca UINT8 *col_start = vid.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 && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac) { if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION) *dest = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff)); @@ -972,13 +966,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca dest = desttop; if (scrn & V_FLIP) dest = deststart + (destend - desttop); - dest += FixedInt(FixedMul(topdelta<>FRACBITS) < column->length; ofs += rowfrac) + UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height); + deststop = col_start + vid.height; + + for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac) { - if (dest >= vid.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 = *(v_translevel + (((*(v_colormap + source[ofs>>FRACBITS]))<<8)&0xff00) + (*dest&0xff)); - dest += stride; + dest++; } column = (const column_t *)((const UINT8 *)column + column->length + 4); } @@ -1048,13 +1045,10 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (!desttop) return; - deststop = desttop + vid.width * vid.height; - if (scrn & V_NOSCALESTART) { x >>= FRACBITS; y >>= FRACBITS; - desttop += (y*vid.width) + x; } else { @@ -1088,20 +1082,18 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ y += (vid.height - (BASEVIDHEIGHT * vid.dup)) / 2; } } - - desttop += (y*vid.width) + x; } - const INT32 stride = vid.width; + desttop += (y*vid.width) + x; - for (col = sx<>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) + for (col = sx<>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop += vid.height) { INT32 topdelta, prevdelta = -1; if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) continue; - if (x >= stride) // don't draw off the right of the screen (WRAP PREVENTION) + if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) break; column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS])); @@ -1119,17 +1111,20 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ dest = desttop; if (topdelta-sy > 0) { - dest += FixedInt(FixedMul((topdelta-sy)<>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) + UINT8 *col_start = vid.screens[0] + (x*vid.height); + deststop = col_start + vid.height; + + for (; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) { - if (dest >= vid.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 = source[ofs>>FRACBITS]; - dest += stride; + dest++; } column = (const column_t *)((const UINT8 *)column + column->length + 4); } @@ -1146,17 +1141,20 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ dest = desttop; if (topdelta-sy > 0) { - dest += FixedInt(FixedMul((topdelta-sy)<>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) + UINT8 *col_start = vid.screens[0] + (x*vid.height); + deststop = col_start + vid.height; + + for (; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) { - if (dest >= vid.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 = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff)); - dest += stride; + dest++; } column = (const column_t *)((const UINT8 *)column + column->length + 4); } @@ -1198,8 +1196,8 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const I_Error("Bad V_DrawBlock"); #endif - dest = vid.screens[scrn] + y*vid.width + x; - deststop = vid.screens[scrn] + vid.width * vid.height; + dest = vid.screens[scrn] + x*vid.height + y; + deststop = vid.screens[scrn] + vid.height * vid.width; while (height--) { @@ -1218,7 +1216,7 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const // alug: now with translucency support X) void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) { - UINT8 *dest; + UINT8 *dest, *desttop; const UINT8 *deststop; UINT32 alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT); @@ -1294,8 +1292,8 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (y + h > vid.height) h = vid.height-y; - dest = vid.screens[0] + y*vid.width + x; - deststop = vid.screens[0] + vid.width * vid.height; + dest = desttop = vid.screens[0] + x*vid.height + y; + deststop = vid.screens[0] + vid.height * vid.width; if (alphalevel) { @@ -1321,16 +1319,31 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (alphalevel) { const UINT8 *fadetable = ((UINT8 *)transtables + ((alphalevel-1)<= 0) && dest < deststop; dest += vid.width) + for (;(--h >= 0) && desttop < deststop; desttop++) { - for (x = 0; x < w; x++) - dest[x] = fadetable[dest[x]]; + dest = desttop; + + UINT8 *row_end = dest + (w * vid.height); + while (dest < row_end) + { + *dest = fadetable[*dest]; + dest += vid.height; + } } } else { - for (;(--h >= 0) && dest < deststop; dest += vid.width) - memset(dest, c, w); + for (;(--h >= 0) && desttop < deststop; desttop++) + { + dest = desttop; + + UINT8 *row_end = dest + (w * vid.height); + while (dest < row_end) + { + *dest = c; + dest += vid.height; + } + } } } @@ -1376,8 +1389,8 @@ static UINT32 V_GetHWConsBackColor(void) void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) { - UINT8 *dest; - INT32 u, v; + UINT8 *dest, *desttop; + INT32 v; UINT32 alphalevel = 0; if (rendermode == render_none) @@ -1444,7 +1457,7 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (y + h > vid.height) h = vid.height-y; - dest = vid.screens[0] + y*vid.width + x; + dest = desttop = vid.screens[0] + x*vid.height + y; if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) { @@ -1469,11 +1482,14 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (!alphalevel) { - for (v = 0; v < h; v++, dest += vid.width) + for (v = 0; v < h; v++, desttop++) { - for (u = 0; u < w; u++) + dest = desttop; + UINT8 *row_end = dest + w*vid.height; + while (dest < row_end) { - dest[u] = consolebgmap[dest[u]]; + *dest = consolebgmap[*dest]; + dest += vid.height; } } } @@ -1484,11 +1500,14 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) w = clip(w,vid.width); h = clip(h,vid.height); #undef clip - for (v = 0; v < h; v++, dest += vid.width) + for (v = 0; v < h; v++, desttop++) { - for (u = 0; u < w; u++) + dest = desttop; + UINT8 *row_end = dest + w*vid.height; + while (dest < row_end) { - dest[u] = fadetable[consolebgmap[dest[u]]]; + *dest = fadetable[consolebgmap[*dest]]; + dest += vid.height; } } } @@ -1503,7 +1522,8 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) // void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c) { - UINT8 *dest; + UINT8 *dest, *desttop; + const UINT8 *deststop; INT32 w, h, wait = 0; @@ -1578,19 +1598,28 @@ void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c) if (h > w) h = w; - dest = vid.screens[0] + y*vid.width + x; - deststop = vid.screens[0] + vid.width * vid.height; + dest = desttop = vid.screens[0] + x*vid.height + y; + deststop = vid.screens[0] + vid.height * vid.width; c &= 255; - for (;(--h >= 0) && dest < deststop; dest += vid.width) + for (;(--h >= 0) && desttop < deststop; desttop++) { - memset(dest, c, w); + dest = desttop; + + UINT8 *row_end = dest + (w * vid.height); + while (dest < row_end) + { + *dest = c; + dest += vid.height; + } + if (wait) wait--; else w--; } + } // @@ -1601,7 +1630,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum) INT32 u, v; fixed_t dx, dy, xfrac, yfrac; const UINT8 *src, *deststop; - UINT8 *flat, *dest; + UINT8 *flat, *dest, *desttop; size_t size, lflatsize, flatshift; #ifdef HWRENDER @@ -1648,7 +1677,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum) flat = W_CacheLumpNum(flatnum, PU_CACHE); - dest = vid.screens[0] + y*vid.dup*vid.width + x*vid.dup; + dest = desttop = vid.screens[0] + y*vid.dup*vid.width + x*vid.dup; deststop = vid.screens[0] + vid.width * vid.height; // from V_DrawScaledPatch @@ -1672,15 +1701,18 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum) dy = FixedDiv(FRACUNIT, vid.dup<<(FRACBITS-2)); yfrac = 0; - for (v = 0; v < h; v++, dest += vid.width) + for (v = 0; v < h; v++, desttop++) { xfrac = 0; src = flat + (((yfrac>>FRACBITS) & (lflatsize - 1)) << flatshift); + dest = desttop; + for (u = 0; u < w; u++) { - if (&dest[u] > deststop) + if (dest > deststop) return; - dest[u] = src[(xfrac>>FRACBITS)&(lflatsize-1)]; + *dest = src[(xfrac>>FRACBITS)&(lflatsize-1)]; + dest += vid.height; xfrac += dx; } yfrac += dy; @@ -1846,7 +1878,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength) : ((color & 0xFF00) // Color is not palette index? ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. : ((UINT8 *)transtables + ((9-strength)<postimg & POSTIMG_WATER) { - INT32 y; + INT32 y, x; // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; INT32 newpix; @@ -3618,7 +3659,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) for (y = yoffset; y < yoffset+viewheight; y++) { sine = (FINESINE(disStart)*5)>>FRACBITS; - newpix = abs(sine); + /*newpix = abs(sine); if (sine < 0) { @@ -3641,7 +3682,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; newpix--; } - } + }*/ /* Unoptimized version @@ -3657,6 +3698,18 @@ void V_DoPostProcessor(INT32 view, INT32 param) tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); }*/ + for (x = 0; x < vid.width; x++) + { + newpix = (x + sine); + + if (newpix < 0) + newpix = 0; + else if (newpix >= vid.width) + newpix = vid.width-1; + + tmpscr[y + x*vid.height] = srcscr[y+newpix*vid.height]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); + } + disStart += 22;//the offset into the displacement map, increment each game loop disStart &= FINEMASK; //clip it to FINEMASK } @@ -3667,7 +3720,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) } else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave { - INT32 y; + INT32 y, x; // Make sure table is built if (heatshifter == NULL || lastheight != viewheight) @@ -3692,11 +3745,12 @@ void V_DoPostProcessor(INT32 view, INT32 param) if (heatshifter[heatindex[view]++]) { // Shift this row of pixels to the right by 2 - tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; - M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + tmpscr[y] = srcscr[y]; + for (x = vid.dup; x < vid.width; x++) + tmpscr[y+x*vid.height] = srcscr[y+(x-vid.dup)*vid.height]; } - else - M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); + else for (x = 0; x < vid.width; x++) + tmpscr[y+x*vid.height] = srcscr[y+x*vid.height]; heatindex[view] %= viewheight; } @@ -3763,7 +3817,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) } VID_BlitLinearScreen(srcscr+vid.width*yoffset+xoffset, tmpscr+vid.width*yoffset+xoffset, - viewwidth, viewheight, vid.width, vid.width); + viewwidth, viewheight, vid.height, vid.height); #endif }