diff --git a/src/d_main.c b/src/d_main.c index 444e3796..f18ff9b5 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -247,7 +247,7 @@ void D_Display (void) // save the current screen if about to wipe if ((wipe = gamestate != wipegamestate) && NOTSTRICTMODE(screen_melt)) - wipe_StartScreen(0, 0, video.unscaledw, video.unscaledh); + wipe_StartScreen(0, 0, video.unscaledw, SCREENHEIGHT); if (gamestate == GS_LEVEL && gametic) HU_Erase(); @@ -356,7 +356,7 @@ void D_Display (void) } // wipe update - wipe_EndScreen(0, 0, video.unscaledw, video.unscaledh); + wipe_EndScreen(0, 0, video.unscaledw, SCREENHEIGHT); wipestart = I_GetTime () - 1; @@ -370,7 +370,7 @@ void D_Display (void) } while (!tics); wipestart = nowtime; - done = wipe_ScreenWipe(wipe_Melt, 0, 0, video.unscaledw, video.unscaledh, tics); + done = wipe_ScreenWipe(wipe_Melt, 0, 0, video.unscaledw, SCREENHEIGHT, tics); M_Drawer(); // menu is drawn even on top of wipes I_FinishUpdate(); // page flip or blit buffer } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 04c144b5..6670bacf 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1405,8 +1405,8 @@ boolean HU_DemoProgressBar(boolean force) return false; } - V_FillRect(0, video.unscaledh - 2, progress, 1, v_darkest_color); - V_FillRect(0, video.unscaledh - 1, progress, 1, v_lightest_color); + V_FillRect(0, SCREENHEIGHT - 2, progress, 1, v_darkest_color); + V_FillRect(0, SCREENHEIGHT - 1, progress, 1, v_lightest_color); return true; } diff --git a/src/i_video.c b/src/i_video.c index dece3c8a..41b17b53 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -960,6 +960,7 @@ static void I_GetScreenDimensions(void) // [FG] For performance reasons, SDL2 insists that the screen pitch, i.e. // the *number of bytes* that one horizontal row of pixels occupy in // memory, must be a multiple of 4. + video.unscaledw = (video.unscaledw + 3) & ~3; video.width = (video.width + 3) & ~3; video.height = (video.height + 3) & ~3; diff --git a/src/i_video.h b/src/i_video.h index 487fec27..c7c130c5 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -33,7 +33,6 @@ typedef struct int width; int height; int unscaledw; - int unscaledh; int deltaw; fixed_t xscale; diff --git a/src/m_snapshot.c b/src/m_snapshot.c index 0a66251f..3c0985d0 100644 --- a/src/m_snapshot.c +++ b/src/m_snapshot.c @@ -114,24 +114,16 @@ static void M_TakeSnapshot (void) current_snapshot = malloc(snapshot_size * sizeof(**snapshots)); } - int x, y; - vrect_t rect; - rect.w = NONWIDEWIDTH; - rect.h = SCREENHEIGHT; - byte *p = current_snapshot; const byte *s = I_VideoBuffer; + int x, y; for (y = 0; y < SCREENHEIGHT; y++) { for (x = video.deltaw; x < NONWIDEWIDTH + video.deltaw; x++) { - rect.x = x; - rect.y = y; - V_ScaleRect(&rect); - - *p++ = s[rect.sy * video.width + rect.sx]; + *p++ = s[V_ScaleY(y) * video.width + V_ScaleX(x)]; } } diff --git a/src/r_main.c b/src/r_main.c index 087f2b34..a226cca1 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -27,7 +27,6 @@ #include "r_draw.h" #include "r_sky.h" #include "r_voxel.h" -#include "m_bbox.h" #include "v_video.h" #include "am_map.h" #include "st_stuff.h" @@ -448,18 +447,18 @@ void R_ExecuteSetViewSize (void) { scaledviewwidth_nonwide = NONWIDEWIDTH; scaledviewwidth = video.unscaledw; - scaledviewheight = video.unscaledh; // killough 11/98 + scaledviewheight = SCREENHEIGHT; // killough 11/98 } // [crispy] hard-code to SCREENWIDTH and SCREENHEIGHT minus status bar height else if (setblocks == 10) { scaledviewwidth_nonwide = NONWIDEWIDTH; scaledviewwidth = video.unscaledw; - scaledviewheight = video.unscaledh - ST_HEIGHT; + scaledviewheight = SCREENHEIGHT - ST_HEIGHT; } else { - const int st_screen = video.unscaledh - ST_HEIGHT; + const int st_screen = SCREENHEIGHT - ST_HEIGHT; scaledviewwidth_nonwide = setblocks * 32; scaledviewheight = (setblocks * st_screen / 10) & ~7; // killough 11/98 @@ -475,7 +474,7 @@ void R_ExecuteSetViewSize (void) if (scaledviewwidth == video.unscaledw) scaledviewy = 0; else - scaledviewy = (video.unscaledh - ST_HEIGHT - scaledviewheight) / 2; + scaledviewy = (SCREENHEIGHT - ST_HEIGHT - scaledviewheight) / 2; view.x = scaledviewx; view.y = scaledviewy; @@ -486,12 +485,12 @@ void R_ExecuteSetViewSize (void) viewwidth = view.sw; viewheight = view.sh; - viewwidth_nonwide = (scaledviewwidth_nonwide * video.xscale) >> FRACBITS; + viewwidth_nonwide = V_ScaleX(scaledviewwidth_nonwide); viewwindowx = view.sx; viewwindowy = view.sy; - viewblocks = (MIN(setblocks, 10) * video.yscale) >> FRACBITS; + viewblocks = V_ScaleX(MIN(setblocks, 10)); centery = viewheight/2; centerx = viewwidth/2; diff --git a/src/r_segs.c b/src/r_segs.c index b63bf606..da9da9c1 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -21,7 +21,7 @@ #include "doomstat.h" #include "i_video.h" -#include "p_tick.h" +#include "v_video.h" #include "r_main.h" #include "r_bsp.h" #include "r_plane.h" @@ -157,7 +157,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2) { if (!fixedcolormap) // calculate lighting { // killough 11/98: - unsigned index = spryscale >> (LIGHTSCALESHIFT + (video.xscale >> FRACBITS)); + unsigned index = FixedDiv(spryscale, video.xscale) >> LIGHTSCALESHIFT; if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; @@ -374,7 +374,7 @@ static void R_RenderSegLoop (void) texturecolumn >>= FRACBITS; // calculate lighting - index = rw_scale >> (LIGHTSCALESHIFT + (video.xscale >> FRACBITS)); // killough 11/98 + index = FixedDiv(rw_scale, video.xscale) >> LIGHTSCALESHIFT; // killough 11/98 if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; diff --git a/src/r_things.c b/src/r_things.c index 53000b8f..40785079 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -664,7 +664,7 @@ void R_ProjectSprite (mobj_t* thing) vis->colormap[0] = vis->colormap[1] = fullcolormap; // full bright // killough 3/20/98 else { // diminished light - int index = xscale>>(LIGHTSCALESHIFT+hires); // killough 11/98 + int index = FixedDiv(xscale, video.xscale) >> LIGHTSCALESHIFT; // killough 11/98 if (index >= MAXLIGHTSCALE) index = MAXLIGHTSCALE-1; vis->colormap[0] = spritelights[index]; diff --git a/src/r_voxel.c b/src/r_voxel.c index 6901a72f..1a3bc2a6 100644 --- a/src/r_voxel.c +++ b/src/r_voxel.c @@ -696,7 +696,7 @@ boolean VX_ProjectVoxel (mobj_t * thing) else { // diminished light - int index = xscale >> (LIGHTSCALESHIFT + hires); // killough 11/98 + int index = FixedDiv(xscale, video.xscale) >> LIGHTSCALESHIFT; // killough 11/98 if (index < 0) index = 0; if (index > MAXLIGHTSCALE-1) index = MAXLIGHTSCALE-1; diff --git a/src/st_stuff.c b/src/st_stuff.c index 343c90d6..83680f4d 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -325,11 +325,8 @@ static void ST_DrawSolidBackground(int st_x) // [FG] temporarily draw status bar to background buffer V_DrawPatch(st_x, 0, sbar); - vrect_t rect; - rect.w = MIN(SHORT(sbar->width), video.unscaledw); - rect.h = ST_HEIGHT; - const int offset = MAX(st_x + video.deltaw - SHORT(sbar->leftoffset), 0); + const int width = MIN(SHORT(sbar->width), video.unscaledw); const int depth = 16; int v; @@ -345,16 +342,12 @@ static void ST_DrawSolidBackground(int st_x) { for (x = 0; x < depth; x++) { - rect.x = x + offset; - rect.y = y; - V_ScaleRect(&rect); - - byte *c = st_backing_screen + rect.sy * video.width + rect.sx; + byte *c = st_backing_screen + V_ScaleY(y) * video.width + V_ScaleX(x + offset); r += pal[3 * c[0] + 0]; g += pal[3 * c[0] + 1]; b += pal[3 * c[0] + 2]; - c += rect.sw - 2 * rect.sx - 1; + c += V_ScaleX(width - 2 * x - 1); r += pal[3 * c[0] + 0]; g += pal[3 * c[0] + 1]; b += pal[3 * c[0] + 2]; @@ -410,7 +403,7 @@ void ST_refreshBackground(boolean force) const byte *src = W_CacheLumpNum(firstflat + R_FlatNumForName(name), PU_CACHE); - V_TileBlock64(video.unscaledh - ST_HEIGHT, video.unscaledw, ST_HEIGHT, src); + V_TileBlock64(SCREENHEIGHT - ST_HEIGHT, video.unscaledw, ST_HEIGHT, src); // [crispy] preserve bezel bottom edge if (scaledviewwidth == video.unscaledw) diff --git a/src/v_video.c b/src/v_video.c index 13f0b1d9..ba52010f 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -427,7 +427,7 @@ static void V_DrawMaskedColumn(patch_column_t *patchcol, const int ytop, if (columntop >= 0) { // SoM: Make sure the lut is never referenced out of range - if (columntop >= video.unscaledh) + if (columntop >= SCREENHEIGHT) return; patchcol->y1 = y1lookup[columntop]; @@ -441,10 +441,10 @@ static void V_DrawMaskedColumn(patch_column_t *patchcol, const int ytop, if (columntop + column->length - 1 < 0) continue; - if (columntop + column->length - 1 < video.unscaledh) + if (columntop + column->length - 1 < SCREENHEIGHT) patchcol->y2 = y2lookup[columntop + column->length - 1]; else - patchcol->y2 = y2lookup[video.unscaledh - 1]; + patchcol->y2 = y2lookup[SCREENHEIGHT - 1]; // SoM: The failsafes should be completely redundant now... // haleyjd 05/13/08: fix clipping; y2lookup not clamped properly @@ -620,6 +620,16 @@ void V_ScaleRect(vrect_t *rect) rect->sh = y2lookup[rect->y + rect->h - 1] - rect->sy + 1; } +int V_ScaleX(int x) +{ + return x1lookup[x]; +} + +int V_ScaleY(int y) +{ + return y1lookup[y]; +} + static void V_ClipRect(vrect_t *rect) { // clip to left and top edges @@ -633,8 +643,8 @@ static void V_ClipRect(vrect_t *rect) // clip right and bottom edges if (rect->cx2 >= video.unscaledw) rect->cx2 = video.unscaledw - 1; - if (rect->cy2 >= video.unscaledh) - rect->cy2 = video.unscaledh - 1; + if (rect->cy2 >= SCREENHEIGHT) + rect->cy2 = SCREENHEIGHT - 1; // determine clipped width and height rect->cw = rect->cx2 - rect->cx1 + 1; @@ -699,9 +709,9 @@ void V_CopyRect(int srcx, int srcy, pixel_t *source, #ifdef RANGECHECK // rejection if source rect is off-screen if (srcx + width < 0 || srcy + height < 0 || - srcx >= video.unscaledw || srcy >= video.unscaledh || + srcx >= video.unscaledw || srcy >= SCREENHEIGHT || destx + width < 0 || desty + height < 0 || - destx >= video.unscaledw || desty >= video.unscaledh) + destx >= video.unscaledw || desty >= SCREENHEIGHT) { I_Error("Bad V_CopyRect"); } @@ -947,7 +957,7 @@ void V_DrawBackground(const char *patchname) { const byte *src = W_CacheLumpNum(firstflat + R_FlatNumForName(patchname), PU_CACHE); - V_TileBlock64(0, video.unscaledw, video.unscaledh, src); + V_TileBlock64(0, video.unscaledw, SCREENHEIGHT, src); } // diff --git a/src/v_video.h b/src/v_video.h index 613f05d5..5f802178 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -111,6 +111,8 @@ typedef struct } vrect_t; void V_ScaleRect(vrect_t *rect); +int V_ScaleX(int x); +int V_ScaleY(int y); // Allocates buffer screens, call before R_Init. void V_Init (void);