diff --git a/src/am_map.c b/src/am_map.c index c84131d0..cdc2cc93 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -612,11 +612,11 @@ static void AM_LevelInit(void) // // killough 11/98: ... finally add hires support :) - f_w = (SCREENWIDTH) << hires; + f_w = video.width; if (automapoverlay && scaledviewheight == SCREENHEIGHT) - f_h = (SCREENHEIGHT) << hires; + f_h = video.height; else - f_h = (SCREENHEIGHT-ST_HEIGHT) << hires; + f_h = video.height - ((ST_HEIGHT * video.yscale) >> FRACBITS); AM_enableSmoothLines(); @@ -689,16 +689,17 @@ void AM_Stop (void) // void AM_Start() { - static int lastlevel = -1, lastepisode = -1, last_hires = -1, last_widescreen = -1, last_viewheight = -1; + static int lastlevel = -1, lastepisode = -1, last_width = -1, last_height = -1, last_viewheight = -1; if (!stopped) AM_Stop(); stopped = false; - if (lastlevel != gamemap || lastepisode != gameepisode || hires!=last_hires - || widescreen != last_widescreen || viewheight != last_viewheight) + if (lastlevel != gamemap || lastepisode != gameepisode || + last_width != video.width || last_height != video.height || + viewheight != last_viewheight) { - last_hires = hires; // killough 11/98 - last_widescreen = widescreen; + last_height = video.height; + last_width = video.width; last_viewheight = viewheight; AM_LevelInit(); lastlevel = gamemap; @@ -899,9 +900,9 @@ boolean AM_Responder } if (automapoverlay && scaledviewheight == SCREENHEIGHT) - f_h = (SCREENHEIGHT) << hires; + f_h = video.height; else - f_h = (SCREENHEIGHT-ST_HEIGHT) << hires; + f_h = video.height - ((ST_HEIGHT * video.yscale) >> FRACBITS); AM_activateNewScale(); } @@ -956,15 +957,17 @@ boolean AM_Responder if (!followplayer) { + int scaled_f_paninc = (f_paninc * video.xscale) >> FRACBITS; if (buttons_state[PAN_RIGHT]) - m_paninc.x += FTOM(f_paninc << hires); + m_paninc.x += FTOM(scaled_f_paninc); if (buttons_state[PAN_LEFT]) - m_paninc.x += -FTOM(f_paninc << hires); + m_paninc.x += -FTOM(scaled_f_paninc); + scaled_f_paninc = (f_paninc * video.yscale) >> FRACBITS; if (buttons_state[PAN_UP]) - m_paninc.y += FTOM(f_paninc << hires); + m_paninc.y += FTOM(scaled_f_paninc); if (buttons_state[PAN_DOWN]) - m_paninc.y += -FTOM(f_paninc << hires); + m_paninc.y += -FTOM(scaled_f_paninc); } if (!mousewheelzoom) @@ -2179,8 +2182,8 @@ static void AM_drawMarks(void) for (i=0;i> FRACBITS; + int h = (6 * video.yscale) >> FRACBITS; int fx; int fy; int j = i; @@ -2199,13 +2202,15 @@ static void AM_drawMarks(void) { int d = j % 10; - if (d==1) // killough 2/22/98: less spacing for '1' - fx += 1<> FRACBITS); if (fx >= f_x && fx < f_w - w && fy >= f_y && fy < f_h - h) - V_DrawPatch((fx >> hires) - WIDESCREENDELTA, fy >> hires, marknums[d]); + V_DrawPatch(((fx << FRACBITS) / video.xscale) - video.deltaw, + (fy << FRACBITS) / video.yscale, + marknums[d]); - fx -= w - (1<> FRACBITS); // killough 2/22/98: 1 space backwards j /= 10; } diff --git a/src/d_main.c b/src/d_main.c index f0822fa6..2a79d753 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, SCREENWIDTH, SCREENHEIGHT); + wipe_StartScreen(0, 0, video.unscaledw, video.unscaledh); if (gamestate == GS_LEVEL && gametic) HU_Erase(); @@ -299,7 +299,7 @@ void D_Display (void) } // see if the border needs to be updated to the screen - if (gamestate == GS_LEVEL && automap_off && scaledviewwidth != SCREENWIDTH) + if (gamestate == GS_LEVEL && automap_off && scaledviewwidth != video.unscaledw) { if (menuactive || menuactivestate || !viewactivestate) borderdrawcount = 3; @@ -329,14 +329,16 @@ void D_Display (void) // draw pause pic if (paused) { + int x = scaledviewx; int y = 4; - int x = (viewwindowx>>hires); patch_t *patch = W_CacheLumpName("M_PAUSE", PU_CACHE); + x += (scaledviewwidth - SHORT(patch->width)) / 2 - video.deltaw; + if (!automapactive) - y += (viewwindowy>>hires); - V_DrawPatchDirect(x + (scaledviewwidth - SHORT(patch->width)) / 2 - WIDESCREENDELTA, - y, patch); + y += scaledviewy; + + V_DrawPatch(x, y, patch); } // menus go directly to the screen @@ -354,7 +356,7 @@ void D_Display (void) } // wipe update - wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); + wipe_EndScreen(0, 0, video.unscaledw, video.unscaledh); wipestart = I_GetTime () - 1; @@ -368,7 +370,7 @@ void D_Display (void) } while (!tics); wipestart = nowtime; - done = wipe_ScreenWipe(wipe_Melt,0,0,SCREENWIDTH,SCREENHEIGHT,tics); + done = wipe_ScreenWipe(wipe_Melt, 0, 0, video.unscaledw, video.unscaledh, tics); M_Drawer(); // menu is drawn even on top of wipes I_FinishUpdate(); // page flip or blit buffer } @@ -2488,8 +2490,6 @@ void D_DoomMain(void) // 1/18/98 killough: Z_Init call moved to i_main.c // init subsystems - I_Printf(VB_INFO, "V_Init: allocate screens."); // killough 11/98: moved down to here - V_Init(); I_Printf(VB_INFO, "W_Init: Init WADfiles."); W_InitMultipleFiles(wadfiles); @@ -2646,6 +2646,9 @@ void D_DoomMain(void) I_Printf(VB_INFO, "S_Init: Setting up sound."); S_Init(snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ ); + // [FG] init graphics (video.widedelta) before HUD widgets + I_InitGraphics(); + I_Printf(VB_INFO, "HU_Init: Setting up heads up display."); HU_Init(); M_SetMenuFontSpacing(); @@ -2804,9 +2807,6 @@ void D_DoomMain(void) I_SetFastdemoTimer(true); } - // [FG] init graphics (WIDESCREENDELTA) before HUD widgets - I_InitGraphics(); - if (startloadgame >= 0) { char *file; diff --git a/src/doomdef.h b/src/doomdef.h index 80f2e78b..59ee66af 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -81,11 +81,11 @@ typedef enum // allows us to avoid the overhead of dynamic allocation // when multiple screen sizes are supported -#define ORIGWIDTH 320 // [crispy] -#define ORIGHEIGHT 200 // [crispy] +#define SCREENWIDTH 320 +#define SCREENHEIGHT 200 -#define MAX_SCREENWIDTH 1152 // [FG] corresponds to 2.4:1 in hires mode -#define MAX_SCREENHEIGHT (ORIGHEIGHT << 1) // [crispy] +#define MAX_SCREENWIDTH (1152 * 8) // [FG] corresponds to 2.4:1 in hires mode +#define MAX_SCREENHEIGHT (400 * 8) // [crispy] // The maximum number of players, multiplayer/networking. #define MAXPLAYERS 4 diff --git a/src/f_finale.c b/src/f_finale.c index b99c0d06..18e72380 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -713,6 +713,8 @@ void F_CastDrawer (void) static void F_DrawPatchCol(int x, patch_t *patch, int col) { +// TODO +#if 0 const column_t *column = (const column_t *)((byte *) patch + LONG(patch->columnofs[col])); @@ -740,6 +742,7 @@ static void F_DrawPatchCol(int x, patch_t *patch, int col) *dest = *source++; column = (column_t *)(source+1); } +#endif } @@ -771,7 +774,7 @@ void F_BunnyScroll (void) if (pillar_width > 0) { // [crispy] fill pillarboxes in widescreen mode - memset(I_VideoBuffer, 0, (SCREENWIDTH<width)) / 2; + p1offset = (SCREENWIDTH - SHORT(p1->width)) / 2; - if (SHORT(p2->width) == ORIGWIDTH) + if (SHORT(p2->width) == SCREENWIDTH) { // Unity or original PFUBs. // PFUB1 only contains the pixels that scroll off. - p2offset = ORIGWIDTH - p1offset; + p2offset = SCREENWIDTH - p1offset; } else { // Widescreen mod PFUBs. // Right side of PFUB2 and left side of PFUB1 are identical. - p2offset = ORIGWIDTH + p1offset; + p2offset = SCREENWIDTH + p1offset; } for (x = pillar_width; x < SCREENWIDTH - pillar_width; x++) { - int x2 = x - WIDESCREENDELTA + scrolled; + int x2 = x - video.deltaw + scrolled; if (x2 < p2offset) F_DrawPatchCol (x, p1, x2 - p1offset); @@ -808,8 +811,8 @@ void F_BunnyScroll (void) return; if (finalecount < 1180) { - V_DrawPatch ((ORIGWIDTH-13*8)/2, - (ORIGHEIGHT-8*8)/2, + V_DrawPatch ((SCREENWIDTH-13*8)/2, + (SCREENHEIGHT-8*8)/2, W_CacheLumpName ("END0",PU_CACHE)); laststage = 0; return; @@ -825,8 +828,8 @@ void F_BunnyScroll (void) } sprintf (name,"END%i",stage); - V_DrawPatch ((ORIGWIDTH-13*8)/2, - (ORIGHEIGHT-8*8)/2, + V_DrawPatch ((SCREENWIDTH-13*8)/2, + (SCREENHEIGHT-8*8)/2, W_CacheLumpName (name,PU_CACHE)); } diff --git a/src/f_wipe.c b/src/f_wipe.c index 641a5379..ad826278 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -78,7 +78,7 @@ static int *y; static int wipe_initMelt(int width, int height, int ticks) { int i; - const int hires_size = 1 << hires; + const int hires_size = (video.yscale >> FRACBITS); // copy start screen to main screen memcpy(wipe_scr, wipe_scr_start, width*height); @@ -159,7 +159,7 @@ static int wipe_exitMelt(int width, int height, int ticks) int wipe_StartScreen(int x, int y, int width, int height) { - int size = (hires ? SCREENWIDTH * SCREENHEIGHT * 4 : SCREENWIDTH * SCREENHEIGHT); + int size = video.width * video.height; wipe_scr_start = Z_Malloc(size * sizeof(*wipe_scr_start), PU_STATIC, NULL); I_ReadScreen(wipe_scr_start); return 0; @@ -167,7 +167,7 @@ int wipe_StartScreen(int x, int y, int width, int height) int wipe_EndScreen(int x, int y, int width, int height) { - int size = (hires ? SCREENWIDTH * SCREENHEIGHT * 4 : SCREENWIDTH * SCREENHEIGHT); + int size = video.width * video.height; wipe_scr_end = Z_Malloc(size * sizeof(*wipe_scr_end), PU_STATIC, NULL); I_ReadScreen(wipe_scr_end); V_DrawBlock(x, y, width, height, wipe_scr_start); // restore start scr. @@ -188,8 +188,9 @@ int wipe_ScreenWipe(int wipeno, int x, int y, int width, int height, int ticks) { static boolean go; // when zero, stop the wipe - if (hires) // killough 11/98: hires support - width <<= 1, height <<= 1, ticks <<= 1; + width = video.width; + height = video.height; + ticks = (ticks * video.yscale) >> FRACBITS; if (!go) // initial stuff { diff --git a/src/hu_lib.c b/src/hu_lib.c index 04057d16..d8eed132 100644 --- a/src/hu_lib.c +++ b/src/hu_lib.c @@ -35,10 +35,10 @@ void HUlib_set_margins (void) if (hud_widescreen_widgets) { - left_margin -= WIDESCREENDELTA; + left_margin -= video.deltaw; } - right_margin = ORIGWIDTH - left_margin; + right_margin = SCREENWIDTH - left_margin; } // [FG] vertical alignment @@ -57,7 +57,7 @@ static int align_offset[num_offsets]; void HUlib_reset_align_offsets (void) { - int bottom = ORIGHEIGHT - 1; + int bottom = SCREENHEIGHT - 1; if (scaledviewheight < SCREENHEIGHT || (crispy_hud && hud_active > 0) || @@ -224,19 +224,19 @@ static int horz_align_widget(const hu_widget_t *const w, const hu_line_t *const } else if (h_align == align_center) { - return ORIGWIDTH/2 - l->width/2; + return SCREENWIDTH/2 - l->width/2; } // [FG] align_direct if (hud_widescreen_widgets) { - if (w->x < ORIGWIDTH/2) + if (w->x < SCREENWIDTH/2) { - return w->x - WIDESCREENDELTA; + return w->x - video.deltaw; } else { - return w->x + WIDESCREENDELTA; + return w->x + video.deltaw; } } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index b8cdf8b2..382829cf 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -572,9 +572,6 @@ void HU_Start(void) message_count = (message_timer * TICRATE) / 1000 + 1; chat_count = (chat_msg_timer * TICRATE) / 1000 + 1; - // [crispy] re-calculate WIDESCREENDELTA - I_GetScreenDimensions(); - // create the message widget HUlib_init_multiline(&w_message, message_list ? hud_msg_lines : 1, &doom_font, colrngs[hudcolor_mesg], @@ -1318,8 +1315,8 @@ mobj_t *crosshair_target; // [Alaux] Lock crosshair on target static void HU_UpdateCrosshair(void) { - crosshair.x = ORIGWIDTH/2; - crosshair.y = (screenblocks <= 10) ? (ORIGHEIGHT-ST_HEIGHT)/2 : ORIGHEIGHT/2; + crosshair.x = SCREENWIDTH/2; + crosshair.y = (screenblocks <= 10) ? (SCREENHEIGHT-ST_HEIGHT)/2 : SCREENHEIGHT/2; if (hud_crosshair_health) crosshair.cr = ColorByHealth(plr->health, 100, st_invul); @@ -1366,14 +1363,14 @@ static void HU_UpdateCrosshair(void) void HU_UpdateCrosshairLock(int x, int y) { - int w = (crosshair.w << hires); - int h = (crosshair.h << hires); + int w = (crosshair.w * video.xscale) >> FRACBITS; + int h = (crosshair.h * video.yscale) >> FRACBITS; x = viewwindowx + BETWEEN(w, viewwidth - w - 1, x); y = viewwindowy + BETWEEN(h, viewheight - h - 1, y); - crosshair.x = (x >> hires) - WIDESCREENDELTA; - crosshair.y = (y >> hires); + crosshair.x = (x << FRACBITS) / video.xscale - video.deltaw; + crosshair.y = (y << FRACBITS) / video.yscale; } void HU_DrawCrosshair(void) @@ -1396,7 +1393,7 @@ void HU_DrawCrosshair(void) // [crispy] print a bar indicating demo progress at the bottom of the screen boolean HU_DemoProgressBar(boolean force) { - const int progress = SCREENWIDTH * playback_tic / playback_totaltics; + const int progress = video.unscaledw * playback_tic / playback_totaltics; static int old_progress = 0; if (old_progress < progress) @@ -1408,8 +1405,8 @@ boolean HU_DemoProgressBar(boolean force) return false; } - V_DrawHorizLine(0, SCREENHEIGHT - 2, progress, v_darkest_color); - V_DrawHorizLine(0, SCREENHEIGHT - 1, progress, v_lightest_color); + V_DrawHorizLine(0, video.unscaledh - 2, progress, v_darkest_color); + V_DrawHorizLine(0, video.unscaledh - 1, progress, v_lightest_color); return true; } @@ -2007,14 +2004,14 @@ static boolean HU_AddHUDCoords (char *name, int hud, int x, int y) // [FG] relative alignment to the edges if (x < 0) { - x += ORIGWIDTH; + x += SCREENWIDTH; } if (y < 0) { - y += ORIGHEIGHT; + y += SCREENHEIGHT; } - if (x < 0 || x >= ORIGWIDTH || y < 0 || y >= ORIGHEIGHT) + if (x < 0 || x >= SCREENWIDTH || y < 0 || y >= SCREENHEIGHT) { return false; } diff --git a/src/hu_stuff.h b/src/hu_stuff.h index cdb69a02..48ff9f26 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -25,12 +25,6 @@ #define HU_BROADCAST 5 -//#define HU_MSGREFRESH KEY_ENTER // phares -#define HU_MSGX (0 - WIDESCREENDELTA) -#define HU_MSGY 0 -#define HU_MSGWIDTH 64 /* in characters */ -#define HU_MSGHEIGHT 1 /* in lines */ - #define HU_MSGTIMEOUT (4*TICRATE) // diff --git a/src/i_video.c b/src/i_video.c index 812dfe4d..dca0d14c 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -44,10 +44,7 @@ #include "icon.c" -int SCREENWIDTH, SCREENHEIGHT; -int NONWIDEWIDTH; // [crispy] non-widescreen SCREENWIDTH -int WIDESCREENDELTA; // [crispy] horizontal widescreen offset -angle_t FOV; +video_t video; boolean use_vsync; // killough 2/8/98: controls whether vsync is called int hires, default_hires; // killough 11/98 @@ -421,7 +418,7 @@ static inline void I_UpdateRender (void) } static void I_DrawDiskIcon(), I_RestoreDiskBackground(); -static unsigned int disk_to_draw, disk_to_restore; +//static unsigned int disk_to_draw, disk_to_restore; static void CreateUpscaledTexture(boolean force); @@ -456,6 +453,8 @@ void I_FinishUpdate(void) toggle_exclusive_fullscreen = false; } +// TODO +#if 0 // draws little dots on the bottom of the screen if (devparm) { @@ -490,6 +489,7 @@ void I_FinishUpdate(void) s[(SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0; } } +#endif // [FG] [AM] Real FPS counter { @@ -556,7 +556,7 @@ void I_FinishUpdate(void) void I_ReadScreen(byte *scr) { - int size = hires ? SCREENWIDTH*SCREENHEIGHT*4 : SCREENWIDTH*SCREENHEIGHT; + int size = video.width * video.height; // haleyjd memcpy(scr, I_VideoBuffer, size); @@ -566,10 +566,12 @@ void I_ReadScreen(byte *scr) // killough 10/98: init disk icon // -static pixel_t *diskflash, *old_data; +//static pixel_t *diskflash, *old_data; static void I_InitDiskFlash(void) { +// TODO +#if 0 pixel_t temp[32*32]; if (diskflash) @@ -582,9 +584,10 @@ static void I_InitDiskFlash(void) old_data = Z_Malloc((16< rect.h * screen_width) + else if (rect.w * actualheight > rect.h * video.width) { int temp = rect.w; - rect.w = rect.h * screen_width / actualheight; + rect.w = rect.h * video.width / actualheight; rect.x = (temp - rect.w) / 2; } - else if (rect.h * screen_width > rect.w * actualheight) + else if (rect.h * video.width > rect.w * actualheight) { int temp = rect.h; - rect.h = rect.w * actualheight / screen_width; + rect.h = rect.w * actualheight / video.width; rect.y = (temp - rect.h) / 2; } @@ -887,30 +895,36 @@ static void I_GetWindowPosition(int *x, int *y, int w, int h) } } -// [crispy] re-calculate SCREENWIDTH, SCREENHEIGHT, NONWIDEWIDTH and WIDESCREENDELTA void I_GetScreenDimensions(void) { SDL_DisplayMode mode; int w = 16, h = 9; - int ah; - SCREENWIDTH = ORIGWIDTH; - SCREENHEIGHT = ORIGHEIGHT; - - NONWIDEWIDTH = SCREENWIDTH; - - ah = use_aspect ? (6 * SCREENHEIGHT / 5) : SCREENHEIGHT; + int unscaled_ah = use_aspect ? (6 * SCREENHEIGHT / 5) : SCREENHEIGHT; if (SDL_GetCurrentDisplayMode(video_display, &mode) == 0) { // [crispy] sanity check: really widescreen display? - if (mode.w * ah >= mode.h * SCREENWIDTH) + if (mode.w * unscaled_ah >= mode.h * SCREENWIDTH) { w = mode.w; h = mode.h; } } + if (hires) + { + video.height = use_aspect ? (5 * mode.h / 6) : mode.h; + actualheight = mode.h; + } + else + { + video.height = SCREENHEIGHT; + actualheight = unscaled_ah; + } + + video.unscaledh = SCREENHEIGHT; + if (widescreen) { switch(widescreen) @@ -931,38 +945,36 @@ void I_GetScreenDimensions(void) break; } - SCREENWIDTH = w * ah / h; - // [crispy] make sure SCREENWIDTH is an integer multiple of 4 ... - - // [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. - // And for a paletted framebuffer with only one byte per pixel - // this means we need to keep the *number of pixels* a multiple of 4. - // - // Now, in widescreen mode, 240 px * 16 / 9 = 426.7 px. - // The widescreen status bar graphic of the Unity port is 426 px wide. - // This, however, is not a multiple of 4, so we have to *round up* - // to 428 px for it to fit on screen (with one blank px left and right). - // In hires mode, 480 px * 16 / 9 = 853.3 px. - // In order to fit the widescreen status bar graphic exactly twice on - // screen, we *round down* to 2 * 426 px = 852 px. - - if (hires) - { - SCREENWIDTH = ((2 * SCREENWIDTH) & (int)~3) / 2; - } - else - { - SCREENWIDTH = (SCREENWIDTH + 3) & (int)~3; - } - // [crispy] ... but never exceeds MAX_SCREENWIDTH (array size!) - SCREENWIDTH = MIN(SCREENWIDTH, MAX_SCREENWIDTH / 2); + video.unscaledw = w * unscaled_ah / h; + video.width = w * actualheight / h; + } + else + { + video.unscaledw = SCREENWIDTH; + video.width = 4 * actualheight / 3; } - WIDESCREENDELTA = (SCREENWIDTH - NONWIDEWIDTH) / 2; + // [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; - FOV = 2 * atan(SCREENWIDTH / (1.2 * SCREENHEIGHT) * 3 / 4) / M_PI * ANG180; + // [crispy] ... but never exceeds MAX_SCREENWIDTH (array size!) + video.width = MIN(video.width, MAX_SCREENWIDTH); + video.height = MIN(video.height, MAX_SCREENHEIGHT); + + video.deltaw = (video.unscaledw - NONWIDEWIDTH) / 2; + + video.fov = 2 * atan(video.unscaledw / (1.2 * video.unscaledh) * 3 / 4) / M_PI * ANG180; + + video.xscale = (video.width << FRACBITS) / video.unscaledw; + video.yscale = (video.height << FRACBITS) / video.unscaledh; + video.xstep = ((video.unscaledw << FRACBITS) / video.width) + 1; + video.ystep = ((video.unscaledh << FRACBITS) / video.height) + 1; + + printf("render resolution: %dx%d\n", video.width, video.height); } static void CreateUpscaledTexture(boolean force) @@ -971,8 +983,8 @@ static void CreateUpscaledTexture(boolean force) int w, h, w_upscale, h_upscale; static int h_upscale_old, w_upscale_old; - const int screen_width = (SCREENWIDTH << hires); - const int screen_height = (SCREENHEIGHT << hires); + const int screen_width = video.width; + const int screen_height = video.height; SDL_GetRendererInfo(renderer, &info); @@ -1066,24 +1078,28 @@ static int scalefactor; static void I_ResetGraphicsMode(void) { int w, h; - static int old_w, old_h; + int window_w, window_h; + //static int old_w, old_h; uint32_t pixel_format; I_GetScreenDimensions(); - w = (SCREENWIDTH << hires); - h = (SCREENHEIGHT << hires); + w = video.width; + h = video.height; + window_w = SCREENWIDTH * 2; + window_h = SCREENHEIGHT * 2; blit_rect.w = w; blit_rect.h = h; - actualheight = use_aspect ? (6 * h / 5) : h; - I_Printf(VB_DEBUG, "I_ResetGraphicsMode: Rendering resolution %dx%d", w, actualheight); - SDL_SetWindowMinimumSize(screen, w, actualheight); + SDL_SetWindowMinimumSize(screen, window_w, window_h); + +// TODO +#if 0 if (!fullscreen) { SDL_GetWindowSize(screen, &window_width, &window_height); @@ -1110,6 +1126,7 @@ static void I_ResetGraphicsMode(void) old_w = w; old_h = actualheight; +#endif if (!fullscreen) { @@ -1145,10 +1162,6 @@ static void I_ResetGraphicsMode(void) I_VideoBuffer = sdlscreen->pixels; V_RestoreBuffer(); - // Clear the screen to black. - - memset(I_VideoBuffer, 0, w * h * sizeof(*I_VideoBuffer)); - pixel_format = SDL_GetWindowPixelFormat(screen); // [FG] create intermediate ARGB frame buffer diff --git a/src/i_video.h b/src/i_video.h index c63f8ccd..39af7656 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -23,16 +23,30 @@ #include "doomtype.h" +#include "doomdef.h" #include "tables.h" -extern int SCREENWIDTH; -extern int SCREENHEIGHT; -extern int NONWIDEWIDTH; // [crispy] non-widescreen SCREENWIDTH -extern int WIDESCREENDELTA; // [crispy] horizontal widescreen offset +#define NONWIDEWIDTH SCREENWIDTH // [crispy] non-widescreen SCREENWIDTH -extern angle_t FOV; +typedef struct +{ + int width; + int height; + int unscaledw; + int unscaledh; + int deltaw; -void I_GetScreenDimensions (void); // [crispy] re-calculate WIDESCREENDELTA + fixed_t xscale; + fixed_t yscale; + fixed_t xstep; + fixed_t ystep; + + angle_t fov; +} video_t; + +extern video_t video; + +void I_GetScreenDimensions(void); enum { diff --git a/src/m_menu.c b/src/m_menu.c index 7dab9546..e79e7bd8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -814,22 +814,22 @@ static void M_DrawBorderedSnapshot (int n) { const char *txt = "n/a"; - const int snapshot_x = MAX((WIDESCREENDELTA + SaveDef.x + SKULLXOFF - snapshot_width) / 2, 8); + const int snapshot_x = MAX((video.deltaw + SaveDef.x + SKULLXOFF - snapshot_width) / 2, 8); const int snapshot_y = LoadDef.y + MAX((load_end * LINEHEIGHT - snapshot_height) * n / load_end, 0); // [FG] a snapshot window smaller than 80*48 px is considered too small - if (snapshot_width < ORIGWIDTH/4) + if (snapshot_width < SCREENWIDTH/4) return; if (!M_DrawSnapshot(n, snapshot_x, snapshot_y, snapshot_width, snapshot_height)) { - M_WriteText(snapshot_x + snapshot_width/2 - M_StringWidth(txt)/2 - WIDESCREENDELTA, + M_WriteText(snapshot_x + snapshot_width/2 - M_StringWidth(txt)/2 - video.deltaw, snapshot_y + snapshot_height/2 - M_StringHeight(txt)/2, txt); } txt = M_GetSavegameTime(n); - M_DrawString(snapshot_x + snapshot_width/2 - M_GetPixelWidth(txt)/2 - WIDESCREENDELTA, + M_DrawString(snapshot_x + snapshot_width/2 - M_GetPixelWidth(txt)/2 - video.deltaw, snapshot_y + snapshot_height + M_StringHeight(txt), CR_GOLD, txt); @@ -1026,11 +1026,11 @@ void M_ReadSaveStrings(void) // [FG] shift savegame descriptions a bit to the right // to make room for the snapshots on the left - SaveDef.x = LoadDef.x = M_X_LOADSAVE + MIN(M_LOADSAVE_WIDTH/2, WIDESCREENDELTA); + SaveDef.x = LoadDef.x = M_X_LOADSAVE + MIN(M_LOADSAVE_WIDTH/2, video.deltaw); // [FG] fit the snapshots into the resulting space - snapshot_width = MIN((WIDESCREENDELTA + SaveDef.x + 2 * SKULLXOFF) & ~7, ORIGWIDTH/2); // [FG] multiple of 8 - snapshot_height = MIN((snapshot_width * ORIGHEIGHT / ORIGWIDTH) & ~7, ORIGHEIGHT/2); + snapshot_width = MIN((video.deltaw + SaveDef.x + 2 * SKULLXOFF) & ~7, SCREENWIDTH/2); // [FG] multiple of 8 + snapshot_height = MIN((snapshot_width * SCREENHEIGHT / SCREENWIDTH) & ~7, SCREENHEIGHT/2); for (i = 0 ; i < load_end ; i++) { @@ -2422,8 +2422,8 @@ void M_DrawSetting(setup_menu_t* s) for (i = 0 ; i < char_width ; i++) colorblock[i] = PAL_WHITE; - if (x+cursor_start-1+WIDESCREENDELTA+char_width < SCREENWIDTH) - V_DrawBlock(x+cursor_start-1+WIDESCREENDELTA,y+7,char_width,1,colorblock); + if (x+cursor_start-1+video.deltaw+char_width < video.unscaledw) + V_DrawBlock(x+cursor_start-1+video.deltaw,y+7,char_width,1,colorblock); } // Draw the setting for the item @@ -2545,7 +2545,7 @@ void M_DrawScreenItems(setup_menu_t* src) strcpy(menu_buffer, "Warning: Changes are pending until next game"); } - x_warn = ORIGWIDTH/2 - M_GetPixelWidth(menu_buffer)/2; + x_warn = SCREENWIDTH/2 - M_GetPixelWidth(menu_buffer)/2; M_DrawMenuString(x_warn, M_Y_WARN, CR_RED); } @@ -6977,7 +6977,7 @@ void M_DrawTitle(int x, int y, const char *patch, const char *alttext, int pages { // patch doesn't exist, draw some text in place of it M_snprintf(menu_buffer, sizeof(menu_buffer), "%s", alttext); - M_DrawMenuString(ORIGWIDTH/2 - M_StringWidth(alttext)/2, + M_DrawMenuString(SCREENWIDTH/2 - M_StringWidth(alttext)/2, y + 8 - M_StringHeight(alttext)/2, // assumes patch height 16 CR_TITLE); } @@ -6986,7 +6986,7 @@ void M_DrawTitle(int x, int y, const char *patch, const char *alttext, int pages { M_snprintf(menu_buffer, sizeof(menu_buffer), "page %d/%d", mult_screens_index + 1, pages - 1); - M_DrawMenuString(ORIGWIDTH/2 - M_StringWidth(menu_buffer)/2, + M_DrawMenuString(SCREENWIDTH/2 - M_StringWidth(menu_buffer)/2, M_Y_PREVNEXT, CR_TITLE); } } @@ -7094,7 +7094,7 @@ void M_Init(void) if (W_CheckNumForName("M_GDHIGH") != -1) { patch_t *patch = W_CacheLumpName("M_GDHIGH", PU_CACHE); - if (OptionsDef.x + 175 + SHORT(patch->width) >= ORIGWIDTH) + if (OptionsDef.x + 175 + SHORT(patch->width) >= SCREENWIDTH) { if (W_CheckNumForName("M_DISP") != -1) strcpy(OptionsMenu[scrnsize].name, "M_DISP"); diff --git a/src/m_snapshot.c b/src/m_snapshot.c index d107cef5..ca2cd3ec 100644 --- a/src/m_snapshot.c +++ b/src/m_snapshot.c @@ -28,7 +28,7 @@ static const char snapshot_str[] = "WOOF_SNAPSHOT"; static const int snapshot_len = arrlen(snapshot_str); -static const int snapshot_size = ORIGWIDTH * ORIGHEIGHT; +static const int snapshot_size = SCREENWIDTH * SCREENHEIGHT; static byte *snapshots[10]; static byte *current_snapshot; @@ -97,12 +97,14 @@ char *M_GetSavegameTime (int i) return savegametimes[i]; } -// [FG] take a snapshot in ORIGWIDTH*ORIGHEIGHT resolution, i.e. +// [FG] take a snapshot in SCREENWIDTH*SCREENHEIGHT resolution, i.e. // in hires mode only only each second pixel in each second row is saved, // in widescreen mode only the non-widescreen part in the middle is saved static void M_TakeSnapshot (void) { +// TODO +#if 0 const int inc = hires ? 2 : 1; int x, y; byte *p; @@ -123,11 +125,12 @@ static void M_TakeSnapshot (void) { for (x = 0; x < (NONWIDEWIDTH << hires); x += inc) { - *p++ = s[y * (SCREENWIDTH << hires) + (WIDESCREENDELTA << hires) + x]; + *p++ = s[y * (SCREENWIDTH << hires) + (video.widedelta << hires) + x]; } } R_SetViewSize(old_screenblocks); +#endif } void M_WriteSnapshot (byte *p) @@ -146,6 +149,8 @@ void M_WriteSnapshot (byte *p) boolean M_DrawSnapshot (int n, int x, int y, int w, int h) { +// TODO +#if 0 byte *dest = I_VideoBuffer + y * (SCREENWIDTH << (2 * hires)) + (x << hires); if (!snapshots[n]) @@ -162,8 +167,8 @@ boolean M_DrawSnapshot (int n, int x, int y, int w, int h) } else { - const fixed_t step_x = (ORIGWIDTH << FRACBITS) / (w << hires); - const fixed_t step_y = (ORIGHEIGHT << FRACBITS) / (h << hires); + const fixed_t step_x = (SCREENWIDTH << FRACBITS) / (w << hires); + const fixed_t step_y = (SCREENHEIGHT << FRACBITS) / (h << hires); int destx, desty; fixed_t srcx, srcy; byte *destline, *srcline; @@ -171,7 +176,7 @@ boolean M_DrawSnapshot (int n, int x, int y, int w, int h) for (desty = 0, srcy = 0; desty < (h << hires); desty++, srcy += step_y) { destline = dest + desty * (SCREENWIDTH << hires); - srcline = snapshots[n] + (srcy >> FRACBITS) * ORIGWIDTH; + srcline = snapshots[n] + (srcy >> FRACBITS) * SCREENWIDTH; for (destx = 0, srcx = 0; destx < (w << hires); destx++, srcx += step_x) { @@ -179,6 +184,7 @@ boolean M_DrawSnapshot (int n, int x, int y, int w, int h) } } } +#endif return true; } diff --git a/src/r_draw.c b/src/r_draw.c index 432ff0aa..ac34a40a 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -29,8 +29,6 @@ #define MAXWIDTH MAX_SCREENWIDTH /* kilough 2/8/98 */ #define MAXHEIGHT MAX_SCREENHEIGHT -#define SBARHEIGHT 32 /* status bar height at bottom of screen */ - // // All drawing to the view buffer is accomplished in this file. // The other refresh files only know about ccordinates, @@ -44,12 +42,14 @@ byte *viewimage; int viewwidth; int scaledviewwidth; int scaledviewheight; // killough 11/98 +int scaledviewx; +int scaledviewy; int viewheight; int viewwindowx; int viewwindowy; -byte *ylookup[MAXHEIGHT]; -int columnofs[MAXWIDTH]; -int linesize = ORIGWIDTH; // killough 11/98 +static byte *ylookup[MAXHEIGHT]; +static int columnofs[MAXWIDTH]; +static int linesize = SCREENWIDTH; // killough 11/98 // Color tables for different players, // translate a limited part to another @@ -524,6 +524,8 @@ static void R_DrawFuzzColumn_orig(void) // draw only even pixels as 2x2 squares // using the same fuzzoffset value +// TODO +#if 0 static void R_DrawFuzzColumn_block(void) { int count; @@ -595,6 +597,7 @@ static void R_DrawFuzzColumn_block(void) dest[1] = fuzz; } } +#endif // [FG] spectre drawing mode: 0 original, 1 blocky (hires) @@ -602,9 +605,12 @@ int fuzzcolumn_mode; void (*R_DrawFuzzColumn) (void) = R_DrawFuzzColumn_orig; void R_SetFuzzColumnMode (void) { +// TODO +#if 0 if (fuzzcolumn_mode && hires) R_DrawFuzzColumn = R_DrawFuzzColumn_block; else +#endif R_DrawFuzzColumn = R_DrawFuzzColumn_orig; } @@ -802,34 +808,34 @@ void R_DrawSpan (void) // of a pixel to draw. // -void R_InitBuffer(int width, int height) -{ - int i; +void R_InitBuffer(void) +{ + int i; - linesize = SCREENWIDTH << hires; // killough 11/98 + linesize = video.width; // killough 11/98 // Handle resize, // e.g. smaller view windows // with border and/or status bar. - viewwindowx = (SCREENWIDTH-width) >> !hires; // killough 11/98 - // Column offset. For windows. - for (i = width << hires ; i--; ) // killough 11/98 + for (i = viewwidth; i--; ) // killough 11/98 columnofs[i] = viewwindowx + i; - + // Same with base row offset. - viewwindowy = width==SCREENWIDTH ? 0 : (SCREENHEIGHT-SBARHEIGHT-height)>>1; - - viewwindowy <<= hires; // killough 11/98 - // Preclaculate all row offsets. - for (i = height << hires; i--; ) - ylookup[i] = I_VideoBuffer + (i+viewwindowy)*linesize; // killough 11/98 -} + for (i = viewheight; i--; ) + ylookup[i] = I_VideoBuffer + (i + viewwindowy) * linesize; // killough 11/98 + + if (background_buffer != NULL) + { + Z_Free(background_buffer); + background_buffer = NULL; + } +} void R_DrawBorder (int x, int y, int w, int h) { @@ -838,47 +844,47 @@ void R_DrawBorder (int x, int y, int w, int h) patch = W_CacheLumpName("brdr_t", PU_CACHE); for (i = 0; i < w; i += 8) - V_DrawPatch(x + i - WIDESCREENDELTA, y - 8, patch); + V_DrawPatch(x + i - video.deltaw, y - 8, patch); patch = W_CacheLumpName("brdr_b", PU_CACHE); for (i = 0; i < w; i += 8) - V_DrawPatch(x + i - WIDESCREENDELTA, y + h, patch); + V_DrawPatch(x + i - video.deltaw, y + h, patch); patch = W_CacheLumpName("brdr_l", PU_CACHE); for (j = 0; j < h; j += 8) - V_DrawPatch(x - 8 - WIDESCREENDELTA, y + j, patch); + V_DrawPatch(x - 8 - video.deltaw, y + j, patch); patch = W_CacheLumpName("brdr_r", PU_CACHE); for (j = 0; j < h; j += 8) - V_DrawPatch(x + w - WIDESCREENDELTA, y + j, patch); + V_DrawPatch(x + w - video.deltaw, y + j, patch); // Draw beveled edge. - V_DrawPatch(x - 8 - WIDESCREENDELTA, + V_DrawPatch(x - 8 - video.deltaw, y - 8, W_CacheLumpName("brdr_tl", PU_CACHE)); - V_DrawPatch(x + w - WIDESCREENDELTA, + V_DrawPatch(x + w - video.deltaw, y - 8, W_CacheLumpName("brdr_tr", PU_CACHE)); - V_DrawPatch(x - 8 - WIDESCREENDELTA, + V_DrawPatch(x - 8 - video.deltaw, y + h, W_CacheLumpName("brdr_bl", PU_CACHE)); - V_DrawPatch(x + w - WIDESCREENDELTA, + V_DrawPatch(x + w - video.deltaw, y + h, W_CacheLumpName("brdr_br", PU_CACHE)); } void R_FillBackScreen (void) { - if (scaledviewwidth == SCREENWIDTH) + if (scaledviewwidth == video.unscaledw) return; // Allocate the background buffer if necessary if (background_buffer == NULL) { - int size = (hires ? SCREENWIDTH * SCREENHEIGHT * 4 : SCREENWIDTH * SCREENHEIGHT); + int size = video.width * video.height; background_buffer = Z_Malloc(size * sizeof(*background_buffer), PU_STATIC, NULL); } @@ -886,7 +892,7 @@ void R_FillBackScreen (void) V_DrawBackground(gamemode == commercial ? "GRNROCK" : "FLOOR7_2"); - R_DrawBorder(viewwindowx >> hires, viewwindowy >> hires, scaledviewwidth, scaledviewheight); + R_DrawBorder(scaledviewx, scaledviewy, scaledviewwidth, scaledviewheight); V_RestoreBuffer(); } @@ -895,16 +901,10 @@ void R_FillBackScreen (void) // Copy a screen buffer. // -static void R_VideoErase(unsigned ofs, int count) -{ - if (hires) // killough 11/98: hires support - { - ofs = ofs*4 - (ofs % SCREENWIDTH)*2; // recompose offset - memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count *= 2); // LFB copy. - ofs += SCREENWIDTH*2; - } - memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count); // LFB copy. -} +static void R_VideoErase(int x, int y, int w, int h) +{ + V_CopyRect(x, y, background_buffer, w, h, x, y); +} // // R_DrawViewBorder @@ -917,28 +917,23 @@ static void R_VideoErase(unsigned ofs, int count) // void R_DrawViewBorder(void) -{ - int side, ofs, i; - - if (scaledviewwidth == SCREENWIDTH || background_buffer == NULL) - return; +{ + int side; - // copy top - for (ofs = 0, i = viewwindowy >> hires; i--; ofs += SCREENWIDTH) - R_VideoErase(ofs, SCREENWIDTH); + if (scaledviewwidth == video.unscaledw || background_buffer == NULL) + return; - // copy sides - for (side = viewwindowx >> hires, i = scaledviewheight; i--;) - { - R_VideoErase(ofs, side); - ofs += SCREENWIDTH; - R_VideoErase(ofs - side, side); - } + // copy top + R_VideoErase(0, 0, video.unscaledw, scaledviewy); - // copy bottom - for (i = viewwindowy >> hires; i--; ofs += SCREENWIDTH) - R_VideoErase(ofs, SCREENWIDTH); -} + // copy sides + side = scaledviewx; + R_VideoErase(0, scaledviewy, side, scaledviewheight); + R_VideoErase(video.unscaledw - side, scaledviewy, side, scaledviewheight); + + // copy bottom + R_VideoErase(0, scaledviewy + scaledviewheight, video.unscaledw, scaledviewy); +} //---------------------------------------------------------------------------- // diff --git a/src/r_draw.h b/src/r_draw.h index d3dc9575..488bcafc 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -30,7 +30,6 @@ extern fixed_t dc_iscale; extern fixed_t dc_texturemid; extern int dc_texheight; // killough extern byte dc_skycolor; -extern int linesize; // killough 11/98 // first pixel in a column extern byte *dc_source; @@ -77,7 +76,7 @@ extern const byte *ds_brightmap; // Span blitting for rows, floor/ceiling. No Spectre effect needed. void R_DrawSpan(void); -void R_InitBuffer(int width, int height); +void R_InitBuffer(void); // Initialize color translation tables, for player rendering etc. void R_InitTranslationTables(void); diff --git a/src/r_main.c b/src/r_main.c index 57459c8d..44bed1db 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -29,6 +29,7 @@ #include "r_voxel.h" #include "m_bbox.h" #include "v_video.h" +#include "am_map.h" #include "st_stuff.h" #include "hu_stuff.h" @@ -307,7 +308,7 @@ static void R_InitTextureMapping (void) clipangle = xtoviewangle[0]; - vx_clipangle = clipangle - (FOV - ANG90); + vx_clipangle = clipangle - (video.fov - ANG90); } // @@ -397,7 +398,7 @@ void R_InitLightTables (void) for (j=0; j>= LIGHTSCALESHIFT)/DISTMAP; if (level < 0) @@ -439,47 +440,59 @@ void R_SetViewSize(int blocks) void R_ExecuteSetViewSize (void) { int i, j; - extern void AM_Start(void); + vrect_t view; setsizeneeded = false; if (setblocks == 11) { scaledviewwidth_nonwide = NONWIDEWIDTH; - scaledviewwidth = SCREENWIDTH; - scaledviewheight = SCREENHEIGHT; // killough 11/98 + scaledviewwidth = video.unscaledw; + scaledviewheight = video.unscaledh; // killough 11/98 } // [crispy] hard-code to SCREENWIDTH and SCREENHEIGHT minus status bar height else if (setblocks == 10) { scaledviewwidth_nonwide = NONWIDEWIDTH; - scaledviewwidth = SCREENWIDTH; - scaledviewheight = SCREENHEIGHT-ST_HEIGHT; + scaledviewwidth = video.unscaledw; + scaledviewheight = video.unscaledh - ST_HEIGHT; } else { - scaledviewwidth_nonwide = setblocks*32; - scaledviewheight = (setblocks*168/10) & ~7; // killough 11/98 - if (widescreen) - { - const int widescreen_edge_aligner = (8 << hires) - 1; + const int st_screen = video.unscaledh - ST_HEIGHT; - scaledviewwidth = scaledviewheight*SCREENWIDTH/(SCREENHEIGHT-ST_HEIGHT); - // [crispy] make sure scaledviewwidth is an integer multiple of the bezel patch width - scaledviewwidth = (scaledviewwidth + widescreen_edge_aligner) & (int)~widescreen_edge_aligner; - scaledviewwidth = MIN(scaledviewwidth, SCREENWIDTH); - } + scaledviewwidth_nonwide = setblocks * 32; + scaledviewheight = (setblocks * st_screen / 10) & ~7; // killough 11/98 + + if (widescreen) + scaledviewwidth = (scaledviewheight * video.unscaledw / st_screen) & ~7; else - { scaledviewwidth = scaledviewwidth_nonwide; - } } - viewwidth = scaledviewwidth << hires; // killough 11/98 - viewheight = scaledviewheight << hires; // killough 11/98 - viewwidth_nonwide = scaledviewwidth_nonwide << hires; + scaledviewx = (video.unscaledw - scaledviewwidth) / 2; - viewblocks = MIN(setblocks, 10) << hires; + if (scaledviewwidth == video.unscaledw) + scaledviewy = 0; + else + scaledviewy = (video.unscaledh - ST_HEIGHT - scaledviewheight) / 2; + + view.x = scaledviewx; + view.y = scaledviewy; + view.w = scaledviewwidth; + view.h = scaledviewheight; + + V_ClipRect(&view); + V_ScaleRect(&view); + + viewwidth = view.sw; + viewheight = view.sh; + viewwidth_nonwide = (scaledviewwidth_nonwide * video.xscale) >> FRACBITS; + + viewwindowx = view.sx; + viewwindowy = view.sy; + + viewblocks = (MIN(setblocks, 10) * video.yscale) >> FRACBITS; centery = viewheight/2; centerx = viewwidth/2; @@ -489,13 +502,13 @@ void R_ExecuteSetViewSize (void) projection = centerxfrac_nonwide; viewheightfrac = viewheight<<(FRACBITS+1); // [FG] sprite clipping optimizations - R_InitBuffer(scaledviewwidth, scaledviewheight); // killough 11/98 + R_InitBuffer(); // killough 11/98 R_InitTextureMapping(); // psprite scales - pspritescale = FixedDiv(viewwidth_nonwide, ORIGWIDTH); // killough 11/98 - pspriteiscale= FixedDiv(ORIGWIDTH, viewwidth_nonwide); // killough 11/98 + pspritescale = FixedDiv(viewwidth_nonwide, SCREENWIDTH); // killough 11/98 + pspriteiscale= FixedDiv(SCREENWIDTH, viewwidth_nonwide); // killough 11/98 // thing clipping for (i=0 ; i>hires, 47, 47, c); R_DrawViewBorder(); } +#endif // check for new console commands. NetUpdate (); diff --git a/src/r_plane.c b/src/r_plane.c index 9c0eeb93..a9925b37 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -408,12 +408,12 @@ static void do_draw_plane(visplane_t *pl) else if (!vertically_scrolling) { // Make sure the fade-to-color effect doesn't happen too early - fixed_t diff = dc_texturemid - ORIGHEIGHT / 2 * FRACUNIT; + fixed_t diff = dc_texturemid - SCREENHEIGHT / 2 * FRACUNIT; if (diff < 0) { diff += textureheight[texture]; diff %= textureheight[texture]; - dc_texturemid = ORIGHEIGHT / 2 * FRACUNIT + diff; + dc_texturemid = SCREENHEIGHT / 2 * FRACUNIT + diff; } dc_skycolor = R_GetSkyColor(texture); colfunc = R_DrawSkyColumn; diff --git a/src/r_segs.c b/src/r_segs.c index 73db06bb..d392b27c 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -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+hires); + unsigned index = spryscale >> (LIGHTSCALESHIFT + (video.xscale >> FRACBITS)); if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; @@ -374,7 +374,7 @@ static void R_RenderSegLoop (void) texturecolumn >>= FRACBITS; // calculate lighting - index = rw_scale>>(LIGHTSCALESHIFT+hires); // killough 11/98 + index = rw_scale >> (LIGHTSCALESHIFT + (video.xscale >> FRACBITS)); // killough 11/98 if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; diff --git a/src/r_state.h b/src/r_state.h index 69ca7abe..cc359cb2 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -44,8 +44,10 @@ extern lighttable_t *fullcolormap; // killough 3/20/98 extern int viewwidth; extern int scaledviewwidth; +extern int scaledviewx; extern int viewheight; extern int scaledviewheight; // killough 11/98 +extern int scaledviewy; extern int firstflat; diff --git a/src/r_voxel.c b/src/r_voxel.c index 37024312..6901a72f 100644 --- a/src/r_voxel.c +++ b/src/r_voxel.c @@ -813,6 +813,7 @@ static void VX_DrawColumn (vissprite_t * spr, int x, int y) boolean shadow = ((spr->mobjflags & MF_SHADOW) != 0); + int linesize = video.width; byte * dest = I_VideoBuffer + viewwindowy * linesize + viewwindowx; // iterate over screen columns diff --git a/src/st_stuff.c b/src/st_stuff.c index d3384d3c..69ad5932 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -24,6 +24,7 @@ #include "doomstat.h" #include "m_random.h" #include "i_video.h" +#include "v_video.h" #include "w_wad.h" #include "st_stuff.h" #include "hu_stuff.h" // [FG] hud_displayed @@ -182,7 +183,7 @@ extern boolean inhelpscreens; // killough 2/8/98: weapon info position macros UNUSED, removed here // graphics are drawn to a backing screen and blitted to the real screen -pixel_t *st_backing_screen = NULL; +static pixel_t *st_backing_screen = NULL; // main player in game static player_t *plyr; @@ -317,153 +318,157 @@ void ST_Stop(void); int st_solidbackground; -void ST_refreshBackground(boolean force) +static void ST_DrawSolidBackground(void) { - if (st_classicstatusbar) +// TODO +#if 0 + // [FG] calculate average color of the 16px left and right of the status bar + const int vstep[][2] = {{0, 1}, {1, 2}, {2, ST_HEIGHT}}; + const int hstep = video.width; + const int lo = MAX(st_x + video.widedelta - SHORT(sbar->leftoffset), 0); + const int w = MIN(SHORT(sbar->width), SCREENWIDTH); + const int depth = 16; + byte *pal = W_CacheLumpName("PLAYPAL", PU_STATIC); + int v; + + // [FG] temporarily draw status bar to background buffer + V_DrawPatch(st_x, 0, sbar); + + // [FG] separate colors for the top rows + for (v = 0; v < arrlen(vstep); v++) + { + int x, y; + const int v0 = vstep[v][0], v1 = vstep[v][1]; + unsigned r = 0, g = 0, b = 0; + byte col; + + for (y = v0; y < v1; y++) { - const int st_x = (SHORT(sbar->width) > ORIGWIDTH && SHORT(sbar->leftoffset) == 0) ? - ST_X + (ORIGWIDTH - SHORT(sbar->width)) / 2 : - ST_X; - - V_UseBuffer(st_backing_screen); - - if (SCREENWIDTH != ST_WIDTH) + for (x = 0; x < depth; x++) { - int x, y; - byte *dest = st_backing_screen; + byte *c = st_backing_screen + y * hstep + ((x + lo) << hires); + r += pal[3 * c[0] + 0]; + g += pal[3 * c[0] + 1]; + b += pal[3 * c[0] + 2]; - if (st_solidbackground) - { - // [FG] calculate average color of the 16px left and right of the status bar - const int vstep[][2] = {{0, 1}, {1, 2}, {2, ST_HEIGHT}}; - const int hstep = hires ? (4 * SCREENWIDTH) : SCREENWIDTH; - const int lo = MAX(st_x + WIDESCREENDELTA - SHORT(sbar->leftoffset), 0); - const int w = MIN(SHORT(sbar->width), SCREENWIDTH); - const int depth = 16; - byte *pal = W_CacheLumpName("PLAYPAL", PU_STATIC); - int v; - - // [FG] temporarily draw status bar to background buffer - V_DrawPatch(st_x, 0, sbar); - - // [FG] separate colors for the top rows - for (v = 0; v < arrlen(vstep); v++) - { - const int v0 = vstep[v][0], v1 = vstep[v][1]; - unsigned r = 0, g = 0, b = 0; - byte col; - - for (y = v0; y < v1; y++) - { - for (x = 0; x < depth; x++) - { - byte *c = dest + y * hstep + ((x + lo) << hires); - r += pal[3 * c[0] + 0]; - g += pal[3 * c[0] + 1]; - b += pal[3 * c[0] + 2]; - - c += (w - 2 * x - 1) << hires; - r += pal[3 * c[0] + 0]; - g += pal[3 * c[0] + 1]; - b += pal[3 * c[0] + 2]; - } - } - - r /= 2 * depth * (v1 - v0); - g /= 2 * depth * (v1 - v0); - b /= 2 * depth * (v1 - v0); - - // [FG] tune down to half saturation (for empiric reasons) - col = I_GetPaletteIndex(pal, r/2, g/2, b/2); - - // [FG] fill background buffer with average status bar color - for (y = (v0 << hires); y < (v1 << hires); y++) - { - memset(dest + y * (SCREENWIDTH << hires), col, (SCREENWIDTH << hires)); - } - } - - Z_ChangeTag (pal, PU_CACHE); - } - else - { - // [crispy] this is our own local copy of R_FillBackScreen() to - // fill the entire background of st_backing_screen with the bezel pattern, - // so it appears to the left and right of the status bar in widescreen mode - byte *src; - const char *name = (gamemode == commercial) ? "GRNROCK" : "FLOOR7_2"; - - src = W_CacheLumpNum(firstflat + R_FlatNumForName(name), PU_CACHE); - - if (hires) - { - for (y = (SCREENHEIGHT-ST_HEIGHT)<<1; y < SCREENHEIGHT<<1; y++) - for (x = 0; x < SCREENWIDTH<<1; x += 2) - { - const byte dot = src[(((y>>1)&63)<<6) + ((x>>1)&63)]; - - *dest++ = dot; - *dest++ = dot; - } - } - else - { - for (y = SCREENHEIGHT-ST_HEIGHT; y < SCREENHEIGHT; y++) - for (x = 0; x < SCREENWIDTH; x++) - { - *dest++ = src[((y&63)<<6) + (x&63)]; - } - } - - // [crispy] preserve bezel bottom edge - if (scaledviewwidth == SCREENWIDTH) - { - patch_t *const patch = W_CacheLumpName("brdr_b", PU_CACHE); - - for (x = 0; x < WIDESCREENDELTA; x += 8) - { - V_DrawPatch(x - WIDESCREENDELTA, 0, patch); - V_DrawPatch(ORIGWIDTH + WIDESCREENDELTA - x - 8, 0, patch); - } - } - } + c += (w - 2 * x - 1) << hires; + r += pal[3 * c[0] + 0]; + g += pal[3 * c[0] + 1]; + b += pal[3 * c[0] + 2]; } - - // [crispy] center unity rerelease wide status bar - V_DrawPatch(st_x, 0, sbar); - - // draw right side of bar if needed (Doom 1.0) - if (sbarr) - V_DrawPatch(ST_ARMSBGX, 0, sbarr); - - if (st_notdeathmatch) - V_DrawPatch(ST_ARMSBGX, 0, armsbg); - - // killough 3/7/98: make face background change with displayplayer - if (netgame) - V_DrawPatch(ST_FX, 0, faceback[displayplayer]); - - V_RestoreBuffer(); - - // [crispy] copy entire SCREENWIDTH, to preserve the pattern - // to the left and right of the status bar in widescren mode - if (!force) - { - V_CopyRect(ST_X, 0, st_backing_screen, SCREENWIDTH, ST_HEIGHT, ST_X, ST_Y); - } - else - { - if (WIDESCREENDELTA > 0 && !st_firsttime) - { - V_CopyRect(0, 0, st_backing_screen, WIDESCREENDELTA, ST_HEIGHT, 0, ST_Y); - V_CopyRect(ORIGWIDTH + WIDESCREENDELTA, 0, st_backing_screen, - WIDESCREENDELTA, ST_HEIGHT, ORIGWIDTH + WIDESCREENDELTA, ST_Y); - } - } - } + + r /= 2 * depth * (v1 - v0); + g /= 2 * depth * (v1 - v0); + b /= 2 * depth * (v1 - v0); + + // [FG] tune down to half saturation (for empiric reasons) + col = I_GetPaletteIndex(pal, r/2, g/2, b/2); + + // [FG] fill background buffer with average status bar color + for (y = (v0 << hires); y < (v1 << hires); y++) + { + memset(dest + y * (SCREENWIDTH << hires), col, (SCREENWIDTH << hires)); + } + } + + Z_ChangeTag (pal, PU_CACHE); +#endif } +void ST_refreshBackground(boolean force) +{ + int st_x; + + if (!st_classicstatusbar) + { + return; + } + + if (SHORT(sbar->width) > video.unscaledw && SHORT(sbar->leftoffset) == 0) + { + st_x = ST_X + (video.unscaledw - SHORT(sbar->width)) / 2; + } + else + { + st_x = ST_X; + } + + V_UseBuffer(st_backing_screen); + + if (video.unscaledw != ST_WIDTH) + { +// TODO +#if 0 + if (st_solidbackground) + { + ST_DrawSolidBackground(); + } + else +#endif + { + // [crispy] this is our own local copy of R_FillBackScreen() to fill + // the entire background of st_backing_screen with the bezel + // pattern, so it appears to the left and right of the status bar + // in widescreen mode + const char *name = (gamemode == commercial) ? "GRNROCK" : "FLOOR7_2"; + + const byte *src = W_CacheLumpNum(firstflat + R_FlatNumForName(name), PU_CACHE); + + V_TileBlock64(video.unscaledh - ST_HEIGHT, video.unscaledw, ST_HEIGHT, src); + + // [crispy] preserve bezel bottom edge + if (scaledviewwidth == video.unscaledw) + { + int x; + patch_t *patch = W_CacheLumpName("brdr_b", PU_CACHE); + + for (x = 0; x < video.deltaw; x += 8) + { + V_DrawPatch(x - video.deltaw, 0, patch); + V_DrawPatch(video.unscaledw - x - 8 - video.deltaw, 0, patch); + } + } + } + } + + // [crispy] center unity rerelease wide status bar + V_DrawPatch(st_x, 0, sbar); + + // draw right side of bar if needed (Doom 1.0) + if (sbarr) + V_DrawPatch(ST_ARMSBGX, 0, sbarr); + + if (st_notdeathmatch) + V_DrawPatch(ST_ARMSBGX, 0, armsbg); + + // killough 3/7/98: make face background change with displayplayer + if (netgame) + V_DrawPatch(ST_FX, 0, faceback[displayplayer]); + + V_RestoreBuffer(); + + // [crispy] copy entire video.unscaledw, to preserve the pattern to the left + // and right of the status bar in widescren mode + if (!force) + { + V_CopyRect(ST_X, 0, st_backing_screen, + video.unscaledw, ST_HEIGHT, + ST_X, ST_Y); + } + else + { + if (video.deltaw > 0 && !st_firsttime) + { + V_CopyRect(0, 0, st_backing_screen, + video.deltaw, ST_HEIGHT, + 0, ST_Y); + V_CopyRect(video.unscaledw - video.deltaw, 0, st_backing_screen, + video.deltaw, ST_HEIGHT, + video.unscaledw - video.deltaw, ST_Y); + } + } +} // Respond to keyboard input events, // intercept cheats. @@ -881,8 +886,8 @@ void ST_drawWidgets(void) // clear area if (!st_crispyhud && st_statusbaron) { - V_CopyRect(WIDESCREENDELTA, 0, st_backing_screen, ST_WIDTH, ST_HEIGHT, - WIDESCREENDELTA, ST_Y); + V_CopyRect(video.deltaw, 0, st_backing_screen, ST_WIDTH, ST_HEIGHT, + video.deltaw, ST_Y); } // used by w_arms[] widgets @@ -1277,7 +1282,7 @@ static void ST_MoveHud (void) static int odelta = 0; if (st_crispyhud && hud_active == 2) - distributed_delta = WIDESCREENDELTA; + distributed_delta = video.deltaw; else distributed_delta = 0; @@ -1333,12 +1338,17 @@ static int StatusBarBufferHeight(void) void ST_Init(void) { - int st_height, size; + vrect_t rect; ST_loadData(); - st_height = StatusBarBufferHeight(); - size = SCREENWIDTH * (st_height << (2 * hires)); + rect.x = 0; + rect.y = 0; + rect.w = video.unscaledw; + rect.h = StatusBarBufferHeight(); + + V_ClipRect(&rect); + V_ScaleRect(&rect); if (st_backing_screen) { @@ -1346,7 +1356,7 @@ void ST_Init(void) } // killough 11/98: allocate enough for hires - st_backing_screen = Z_Malloc(size, PU_STATIC, 0); + st_backing_screen = Z_Malloc(rect.sw * rect.sh * sizeof(*st_backing_screen), PU_STATIC, 0); } void ST_Warnings(void) diff --git a/src/st_stuff.h b/src/st_stuff.h index ffabcda3..e6e01b0a 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -29,8 +29,8 @@ // Now sensitive for scaling. #define ST_HEIGHT 32 -#define ST_WIDTH ORIGWIDTH -#define ST_Y (ORIGHEIGHT - ST_HEIGHT) +#define ST_WIDTH SCREENWIDTH +#define ST_Y (SCREENHEIGHT - ST_HEIGHT) // // STATUS BAR diff --git a/src/v_video.c b/src/v_video.c index f309e8ce..2bc062b6 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -22,6 +22,8 @@ //----------------------------------------------------------------------------- #include "doomstat.h" +#include "doomtype.h" +#include "r_draw.h" #include "r_main.h" #include "m_bbox.h" #include "w_wad.h" /* needed for color translation lump lookup */ @@ -283,67 +285,281 @@ void WriteGeneratedLumpWad(const char *filename) free(lumps); } -// -// V_CopyRect -// -// Copies a source rectangle in a screen buffer to a destination -// rectangle in another screen buffer. Source origin in srcx,srcy, -// destination origin in destx,desty, common size in width and height. -// Source buffer specfified by srcscrn, destination buffer by destscrn. -// -// Marks the destination rectangle on the screen dirty. -// -// No return value. +#define WIDE_SCREENWIDTH 576 // corresponds to 2.4:1 in original resolution -void V_CopyRect(int srcx, int srcy, pixel_t *source, - int width, int height, - int destx, int desty ) +static int x1lookup[WIDE_SCREENWIDTH + 1]; +static int y1lookup[SCREENHEIGHT + 1]; +static int x2lookup[WIDE_SCREENWIDTH + 1]; +static int y2lookup[SCREENHEIGHT + 1]; +static int linesize; + +#define V_ADDRESS(buffer, x, y) ((buffer) + (y) * linesize + (x)) + +typedef struct { - byte *src; - byte *dest; + int x; + int y1, y2; + + fixed_t frac; + fixed_t step; + + byte *source; + byte *translation; +} patch_column_t; + +static void (*drawcolfunc)(const patch_column_t *patchcol); + +static void V_DrawPatchColumn(const patch_column_t *patchcol) +{ + int count; + byte *dest; // killough + fixed_t frac; // killough + fixed_t fracstep; + + count = patchcol->y2 - patchcol->y1 + 1; + + if (count <= 0) // Zero length, column does not exceed a pixel. + { + return; + } #ifdef RANGECHECK - if (srcx<0 - ||srcx+width >SCREENWIDTH - || srcy<0 - || srcy+height>SCREENHEIGHT - ||destx<0||destx/*+width*/>SCREENWIDTH - || desty<0 - || desty/*+height*/>SCREENHEIGHT) - I_Error ("Bad V_CopyRect"); + if ((unsigned int)patchcol->x >= (unsigned int)video.width || + (unsigned int)patchcol->y1 >= (unsigned int)video.height) + { + I_Error("V_DrawPatchColumn: %i to %i at %i", patchcol->y1, patchcol->y2, + patchcol->x); + } #endif - // [FG] prevent framebuffer overflows - if (destx + width > SCREENWIDTH) - width = SCREENWIDTH - destx; - if (desty + height > SCREENHEIGHT) - height = SCREENHEIGHT - desty; + dest = V_ADDRESS(dest_screen, patchcol->x, patchcol->y1); - if (hires) // killough 11/98: hires support + // Determine scaling, which is the only mapping to be done. + fracstep = patchcol->step; + frac = patchcol->frac + ((patchcol->y1 * fracstep) & 0xFFFF); + + // Inner loop that does the actual texture mapping, + // e.g. a DDA-lile scaling. + // This is as fast as it gets. (Yeah, right!!! -- killough) + // + // killough 2/1/98: more performance tuning + // haleyjd 06/21/06: rewrote and specialized for screen patches { - width<<=1; - height<<=1; - src = source+SCREENWIDTH*4*srcy+srcx*2; - dest = dest_screen+SCREENWIDTH*4*desty+destx*2; + const byte *source = patchcol->source; - for ( ; height>0 ; height--) - { - memcpy (dest, src, width); - src += SCREENWIDTH*2; - dest += SCREENWIDTH*2; - } + while ((count -= 2) >= 0) + { + *dest = source[frac >> FRACBITS]; + dest += linesize; + frac += fracstep; + *dest = source[frac >> FRACBITS]; + dest += linesize; + frac += fracstep; + } + if (count & 1) + *dest = source[frac >> FRACBITS]; } - else - { - src = source+SCREENWIDTH*srcy+srcx; - dest = dest_screen+SCREENWIDTH*desty+destx; +} - for ( ; height>0 ; height--) - { - memcpy (dest, src, width); - src += SCREENWIDTH; - dest += SCREENWIDTH; - } +static void V_DrawPatchColumnTL(const patch_column_t *patchcol) +{ + int count; + byte *dest; // killough + fixed_t frac; // killough + fixed_t fracstep; + + count = patchcol->y2 - patchcol->y1 + 1; + + if (count <= 0) // Zero length, column does not exceed a pixel. + { + return; + } + +#ifdef RANGECHECK + if ((unsigned int)patchcol->x >= (unsigned int)video.width || + (unsigned int)patchcol->y1 >= (unsigned int)video.height) + { + I_Error("V_DrawPatchColumn: %i to %i at %i", patchcol->y1, patchcol->y2, + patchcol->x); + } +#endif + + dest = V_ADDRESS(dest_screen, patchcol->x, patchcol->y1); + + // Determine scaling, which is the only mapping to be done. + fracstep = patchcol->step; + frac = patchcol->frac + ((patchcol->y1 * fracstep) & 0xFFFF); + + // Inner loop that does the actual texture mapping, + // e.g. a DDA-lile scaling. + // This is as fast as it gets. (Yeah, right!!! -- killough) + // + // killough 2/1/98: more performance tuning + // haleyjd 06/21/06: rewrote and specialized for screen patches + { + const byte *source = patchcol->source; + const byte *translation = patchcol->translation; + + while ((count -= 2) >= 0) + { + *dest = translation[source[frac >> FRACBITS]]; + dest += linesize; + frac += fracstep; + *dest = translation[source[frac >> FRACBITS]]; + dest += linesize; + frac += fracstep; + } + if (count & 1) + { + *dest = translation[source[frac >> FRACBITS]]; + } + } +} + +static void V_DrawMaskedColumn(patch_column_t *patchcol, const int ytop, + column_t *column) +{ + for( ; column->topdelta != 0xff; column = (column_t *)((byte *)column + column->length + 4)) + { + // calculate unclipped screen coordinates for post + int columntop = ytop + column->topdelta; + + if (columntop >= 0) + { + // SoM: Make sure the lut is never referenced out of range + if (columntop >= video.unscaledh) + return; + + patchcol->y1 = y1lookup[columntop]; + patchcol->frac = 0; + } + else + { + patchcol->frac = (-columntop) << FRACBITS; + patchcol->y1 = 0; + } + + if (columntop + column->length - 1 < 0) + continue; + if (columntop + column->length - 1 < video.unscaledh) + patchcol->y2 = y2lookup[columntop + column->length - 1]; + else + patchcol->y2 = y2lookup[video.unscaledh - 1]; + + // SoM: The failsafes should be completely redundant now... + // haleyjd 05/13/08: fix clipping; y2lookup not clamped properly + if ((column->length > 0 && patchcol->y2 < patchcol->y1) || + patchcol->y2 >= video.height) + { + patchcol->y2 = video.height - 1; + } + + // killough 3/2/98, 3/27/98: Failsafe against overflow/crash: + if (patchcol->y1 <= patchcol->y2 && patchcol->y2 < video.height) + { + patchcol->source = (byte *)column + 3; + drawcolfunc(patchcol); + } + } +} + +void V_DrawPatchInt(int x, int y, patch_t *patch, boolean flipped, + byte *translation) +{ + int x1, x2, w; + fixed_t iscale, xiscale, startfrac = 0; + int maxw; + patch_column_t patchcol = {0}; + + w = patch->width; + + // calculate edges of the shape + if (flipped) + { + // If flipped, then offsets are flipped as well which means they + // technically offset from the right side of the patch (x2) + x2 = x + patch->leftoffset; + x1 = x2 - (w - 1); + } + else + { + x1 = x - patch->leftoffset; + x2 = x1 + w - 1; + } + + iscale = video.xstep; + patchcol.step = video.ystep; + maxw = video.unscaledw; + + // off the left or right side? + if (x2 < 0 || x1 >= maxw) + return; + + if (translation) + { + patchcol.translation = translation; + drawcolfunc = V_DrawPatchColumnTL; + } + else + { + drawcolfunc = V_DrawPatchColumn; + } + + xiscale = flipped ? -iscale : iscale; + + // haleyjd 10/10/08: must handle coordinates outside the screen buffer + // very carefully here. + if (x1 >= 0) + x1 = x1lookup[x1]; + else + x1 = -x2lookup[-x1 - 1]; + + if (x2 < video.unscaledw) + x2 = x2lookup[x2]; + else + x2 = x2lookup[video.unscaledw - 1]; + + patchcol.x = (x1 < 0) ? 0 : x1; + + // SoM: Any time clipping occurs on screen coords, the resulting clipped + // coords should be checked to make sure we are still on screen. + if (x2 < x1) + return; + + // SoM: Ok, so the startfrac should ALWAYS be the last post of the patch + // when the patch is flipped minus the fractional "bump" from the screen + // scaling, then the patchcol.x to x1 clipping will place the frac in the + // correct column no matter what. This also ensures that scaling will be + // uniform. If the resolution is 320x2X0 the iscale will be 65537 which + // will create some fractional bump down, so it is safe to assume this puts + // us just below patch->width << 16 + if (flipped) + startfrac = (w << FRACBITS) - ((x1 * iscale) & 0xffff) - 1; + else + startfrac = (x1 * iscale) & 0xffff; + + if (patchcol.x > x1) + startfrac += xiscale * (patchcol.x - x1); + + { + column_t *column; + int texturecolumn; + + const int ytop = y - patch->topoffset; + for( ; patchcol.x <= x2; patchcol.x++, startfrac += xiscale) + { + texturecolumn = startfrac >> FRACBITS; + + #ifdef RANGECHECK + if(texturecolumn < 0 || texturecolumn >= w) + { + I_Error("V_DrawPatchInt: bad texturecolumn %d\n", texturecolumn); + } + #endif + + column = (column_t *)((byte *)patch + patch->columnofs[texturecolumn]); + V_DrawMaskedColumn(&patchcol, ytop, column); + } } } @@ -366,402 +582,140 @@ void V_CopyRect(int srcx, int srcy, pixel_t *source, // killough 11/98: Consolidated V_DrawPatch and V_DrawPatchFlipped into one // -void V_DrawPatchGeneral(int x, int y, patch_t *patch, - boolean flipped) +void V_DrawPatchGeneral(int x, int y, patch_t *patch, boolean flipped) { - int w = SHORT(patch->width), col = w-1, colstop = -1, colstep = -1; - - if (!flipped) - col = 0, colstop = w, colstep = 1; - - y -= SHORT(patch->topoffset); - x -= SHORT(patch->leftoffset); - - x += WIDESCREENDELTA; // [crispy] horizontal widescreen offset - -#ifdef RANGECHECK_NOTHANKS - if (x<0 - ||x+SHORT(patch->width) >SCREENWIDTH - || y<0 - || y+SHORT(patch->height)>SCREENHEIGHT - || (unsigned)scrn>4) - return; // killough 1/19/98: commented out printfs -#endif - - if (hires) // killough 11/98: hires support (well, sorta :) - { - byte *desttop = dest_screen+y*SCREENWIDTH*4+x*2; - - for ( ; col != colstop ; col += colstep, desttop+=2, x++) - { - const column_t *column = - (const column_t *)((byte *)patch + LONG(patch->columnofs[col])); - - // [FG] prevent framebuffer overflows - { - // [FG] too far left - if (x < 0) - continue; - // [FG] too far right, too wide - if (x >= SCREENWIDTH) - break; - } - - // step through the posts in a column - while (column->topdelta != 0xff) - { - // killough 2/21/98: Unrolled and performance-tuned - - register const byte *source = (byte *) column + 3; - register byte *dest = desttop + column->topdelta*SCREENWIDTH*4; - register int count = column->length; - - // [FG] prevent framebuffer overflows - { - int topy = y + column->topdelta; - // [FG] too high - while (topy < 0 && count) - count--, source++, dest += SCREENWIDTH*4, topy++; - // [FG] too low, too tall - while (topy + count > SCREENHEIGHT && count) - count--; - } - - if ((count-=4)>=0) - do - { - register byte s0,s1; - s0 = source[0]; - s1 = source[1]; - dest[0] = s0; - dest[SCREENWIDTH*4] = s1; - dest[SCREENWIDTH*2] = s0; - dest[SCREENWIDTH*6] = s1; - dest[1] = s0; - dest[SCREENWIDTH*4+1] = s1; - dest[SCREENWIDTH*2+1] = s0; - dest[SCREENWIDTH*6+1] = s1; - dest += SCREENWIDTH*8; - s0 = source[2]; - s1 = source[3]; - source += 4; - dest[0] = s0; - dest[SCREENWIDTH*4] = s1; - dest[1] = s0; - dest[SCREENWIDTH*4+1] = s1; - dest[SCREENWIDTH*2] = s0; - dest[SCREENWIDTH*6] = s1; - dest[SCREENWIDTH*2+1] = s0; - dest[SCREENWIDTH*6+1] = s1; - dest += SCREENWIDTH*8; - } - while ((count-=4)>=0); - if (count+=4) - do - { - dest[0] = dest[SCREENWIDTH*2] = dest[1] = - dest[SCREENWIDTH*2+1] = *source++; - dest += SCREENWIDTH*4; - } - while (--count); -// column = (column_t *)(source+1); //killough 2/21/98 even faster - // [FG] back to Vanilla code, we may not run through the entire column - column = (column_t *)((byte *)column + column->length + 4); - } - } - } - else - { - byte *desttop = dest_screen+y*SCREENWIDTH+x; - - for ( ; col != colstop ; col += colstep, desttop++, x++) - { - const column_t *column = - (const column_t *)((byte *)patch + LONG(patch->columnofs[col])); - - // [FG] prevent framebuffer overflows - { - // [FG] too far left - if (x < 0) - continue; - // [FG] too far right, too wide - if (x >= SCREENWIDTH) - break; - } - - // step through the posts in a column - while (column->topdelta != 0xff) - { - // killough 2/21/98: Unrolled and performance-tuned - - register const byte *source = (byte *) column + 3; - register byte *dest = desttop + column->topdelta*SCREENWIDTH; - register int count = column->length; - - // [FG] prevent framebuffer overflows - { - int topy = y + column->topdelta; - // [FG] too high - while (topy < 0 && count) - count--, source++, dest += SCREENWIDTH, topy++; - // [FG] too low, too tall - while (topy + count > SCREENHEIGHT && count) - count--; - } - - if ((count-=4)>=0) - do - { - register byte s0,s1; - s0 = source[0]; - s1 = source[1]; - dest[0] = s0; - dest[SCREENWIDTH] = s1; - dest += SCREENWIDTH*2; - s0 = source[2]; - s1 = source[3]; - source += 4; - dest[0] = s0; - dest[SCREENWIDTH] = s1; - dest += SCREENWIDTH*2; - } - while ((count-=4)>=0); - if (count+=4) - do - { - *dest = *source++; - dest += SCREENWIDTH; - } - while (--count); -// column = (column_t *)(source+1); //killough 2/21/98 even faster - // [FG] back to Vanilla code, we may not run through the entire column - column = (column_t *)((byte *)column + column->length + 4); - } - } - } + x += video.deltaw; + V_DrawPatchInt(x, y, patch, flipped, NULL); } -// -// V_DrawPatchTranslated -// -// Masks a column based masked pic to the screen. -// Also translates colors from one palette range to another using -// the color translation lumps loaded in V_InitColorTranslation -// -// The patch is drawn at x,y in the screen buffer scrn. Color translation -// is performed thru the table pointed to by outr. -// -// jff 1/15/98 new routine to translate patch colors -// - void V_DrawPatchTranslated(int x, int y, patch_t *patch, char *outr) { - int col, w; - - //jff 2/18/98 if translation not needed, just use the old routine - if (outr == NULL) - { - V_DrawPatch(x, y, patch); - return; // killough 2/21/98: add return - } - - y -= SHORT(patch->topoffset); - x -= SHORT(patch->leftoffset); - - x += WIDESCREENDELTA; // [crispy] horizontal widescreen offset - -#ifdef RANGECHECK_NOTHANKS - if (x<0 - ||x+SHORT(patch->width) >SCREENWIDTH - || y<0 - || y+SHORT(patch->height)>SCREENHEIGHT - || (unsigned)scrn>4) - return; // killough 1/19/98: commented out printfs -#endif - - col = 0; - w = SHORT(patch->width); - - if (hires) // killough 11/98: hires support (well, sorta :) - { - byte *desttop = dest_screen+y*SCREENWIDTH*4+x*2; - - for ( ; colcolumnofs[col])); - - // [FG] prevent framebuffer overflows - { - // [FG] too far left - if (x < 0) - continue; - // [FG] too far right, too wide - if (x >= SCREENWIDTH) - break; - } - - // step through the posts in a column - while (column->topdelta != 0xff) - { - // killough 2/21/98: Unrolled and performance-tuned - - register const byte *source = (byte *) column + 3; - register byte *dest = desttop + column->topdelta*SCREENWIDTH*4; - register int count = column->length; - - // [FG] prevent framebuffer overflows - { - int topy = y + column->topdelta; - // [FG] too high - while (topy < 0 && count) - count--, source++, dest += SCREENWIDTH*4, topy++; - // [FG] too low, too tall - while (topy + count > SCREENHEIGHT && count) - count--; - } - - if ((count-=4)>=0) - do - { - register byte s0,s1; - s0 = source[0]; - s1 = source[1]; - s0 = outr[s0]; - s1 = outr[s1]; - dest[0] = s0; - dest[SCREENWIDTH*4] = s1; - dest[SCREENWIDTH*2] = s0; - dest[SCREENWIDTH*6] = s1; - dest[1] = s0; - dest[SCREENWIDTH*4+1] = s1; - dest[SCREENWIDTH*2+1] = s0; - dest[SCREENWIDTH*6+1] = s1; - dest += SCREENWIDTH*8; - s0 = source[2]; - s1 = source[3]; - s0 = outr[s0]; - s1 = outr[s1]; - source += 4; - dest[0] = s0; - dest[SCREENWIDTH*4] = s1; - dest[SCREENWIDTH*2] = s0; - dest[SCREENWIDTH*6] = s1; - dest[1] = s0; - dest[SCREENWIDTH*4+1] = s1; - dest[SCREENWIDTH*2+1] = s0; - dest[SCREENWIDTH*6+1] = s1; - dest += SCREENWIDTH*8; - } - while ((count-=4)>=0); - if (count+=4) - do - { - dest[0] = dest[SCREENWIDTH*2] = dest[1] = - dest[SCREENWIDTH*2+1] = outr[*source++]; - dest += SCREENWIDTH*4; - } - while (--count); -// column = (column_t *)(source+1); - // [FG] back to Vanilla code, we may not run through the entire column - column = (column_t *)((byte *)column + column->length + 4); - } - } - } - else - { - byte *desttop = dest_screen+y*SCREENWIDTH+x; - - for ( ; colcolumnofs[col])); - - // [FG] prevent framebuffer overflows - { - // [FG] too far left - if (x < 0) - continue; - // [FG] too far right, too wide - if (x >= SCREENWIDTH) - break; - } - - // step through the posts in a column - while (column->topdelta != 0xff) - { - // killough 2/21/98: Unrolled and performance-tuned - - register const byte *source = (byte *) column + 3; - register byte *dest = desttop + column->topdelta*SCREENWIDTH; - register int count = column->length; - - // [FG] prevent framebuffer overflows - { - int topy = y + column->topdelta; - // [FG] too high - while (topy < 0 && count) - count--, source++, dest += SCREENWIDTH, topy++; - // [FG] too low, too tall - while (topy + count > SCREENHEIGHT && count) - count--; - } - - if ((count-=4)>=0) - do - { - register byte s0,s1; - s0 = source[0]; - s1 = source[1]; - - //jff 2/18/98 apply red->range color translation - //2/18/98 don't brightness map for speed - - s0 = outr[s0]; - s1 = outr[s1]; - dest[0] = s0; - dest[SCREENWIDTH] = s1; - dest += SCREENWIDTH*2; - s0 = source[2]; - s1 = source[3]; - s0 = outr[s0]; - s1 = outr[s1]; - source += 4; - dest[0] = s0; - dest[SCREENWIDTH] = s1; - dest += SCREENWIDTH*2; - } - while ((count-=4)>=0); - if (count+=4) - do - { - *dest = outr[*source++]; - dest += SCREENWIDTH; - } - while (--count); -// column = (column_t *)(source+1); - // [FG] back to Vanilla code, we may not run through the entire column - column = (column_t *)((byte *)column + column->length + 4); - } - } - - } + x += video.deltaw; + V_DrawPatchInt(x, y, patch, false, (byte *)outr); } void V_DrawPatchFullScreen(patch_t *patch) { - int x = (SCREENWIDTH - SHORT(patch->width)) / 2 - WIDESCREENDELTA; + const int x = (video.unscaledw - SHORT(patch->width)) / 2; patch->leftoffset = 0; patch->topoffset = 0; // [crispy] fill pillarboxes in widescreen mode - if (SCREENWIDTH != NONWIDEWIDTH) + if (video.unscaledw != NONWIDEWIDTH) { - memset(dest_screen, v_darkest_color, (SCREENWIDTH<sx = x1lookup[rect->cx1]; + rect->sy = y1lookup[rect->cy1]; + rect->sw = x2lookup[rect->cx2] - rect->sx + 1; + rect->sh = y2lookup[rect->cy2] - rect->sy + 1; + +#ifdef RANGECHECK + // sanity check - out-of-bounds values should not come out of the scaling + // arrays so long as they are accessed within bounds. + if(rect->sx < 0 || rect->sx + rect->sw > video.width || + rect->sy < 0 || rect->sy + rect->sh > video.height) + { + I_Error("V_ScaleRect: internal error - invalid scaling lookups"); + } +#endif +} + +void V_ClipRect(vrect_t *rect) +{ + // clip to left and top edges + rect->cx1 = rect->x >= 0 ? rect->x : 0; + rect->cy1 = rect->y >= 0 ? rect->y : 0; + + // determine right and bottom edges + rect->cx2 = rect->x + rect->w - 1; + rect->cy2 = rect->y + rect->h - 1; + + // 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; + + // determine clipped width and height + rect->cw = rect->cx2 - rect->cx1 + 1; + rect->ch = rect->cy2 - rect->cy1 + 1; +} + +// +// V_CopyRect +// +// Copies a source rectangle in a screen buffer to a destination +// rectangle in another screen buffer. Source origin in srcx,srcy, +// destination origin in destx,desty, common size in width and height. +// + +void V_CopyRect(int srcx, int srcy, pixel_t *source, + int width, int height, + int destx, int desty) +{ + vrect_t srcrect, dstrect; + byte *src, *dest; + int usew, useh; + +#ifdef RANGECHECK + // rejection if source rect is off-screen + if (srcx + width < 0 || srcy + height < 0 || + srcx >= video.unscaledw || srcy >= video.unscaledh || + destx + width < 0 || desty + height < 0 || + destx >= video.unscaledw || desty >= video.unscaledh) + { + I_Error("Bad V_CopyRect"); + } +#endif + + // populate source rect + srcrect.x = srcx; + srcrect.y = srcy; + srcrect.w = width; + srcrect.h = height; + + V_ClipRect(&srcrect); + + // clipped away completely? + if (srcrect.cw <= 0 || srcrect.ch <= 0) + return; + + // populate dest rect + dstrect.x = destx; + dstrect.y = desty; + dstrect.w = width; + dstrect.h = height; + + V_ClipRect(&dstrect); + + // clipped away completely? + if (dstrect.cw <= 0 || dstrect.ch <= 0) + return; + + V_ScaleRect(&srcrect); + V_ScaleRect(&dstrect); + + // use the smaller of the two scaled rect widths / heights + usew = (srcrect.sw < dstrect.sw ? srcrect.sw : dstrect.sw); + useh = (srcrect.sh < dstrect.sh ? srcrect.sh : dstrect.sh); + + src = V_ADDRESS(source, srcrect.sx, srcrect.sy); + dest = V_ADDRESS(dest_screen, dstrect.sx, dstrect.sy); + + while (useh--) + { + memcpy(dest, src, usew); + src += linesize; + dest += linesize; + } } // @@ -772,46 +726,98 @@ void V_DrawPatchFullScreen(patch_t *patch) // The bytes at src are copied in linear order to the screen rectangle // at x,y in screenbuffer scrn, with size width by height. // -// The destination rectangle is marked dirty. -// -// No return value. -// void V_DrawBlock(int x, int y, int width, int height, pixel_t *src) { -#ifdef RANGECHECK - if (x<0 - ||x+width >SCREENWIDTH - || y<0 - || y+height>SCREENHEIGHT) - I_Error ("Bad V_DrawBlock"); -#endif + const byte *source; + byte *dest; + int dx, dy; + vrect_t dstrect; + + dstrect.x = x; + dstrect.y = y; + dstrect.w = width; + dstrect.h = height; + + V_ClipRect(&dstrect); + + // clipped away completely? + if (dstrect.cw <= 0 || dstrect.ch <= 0) + return; + + // change in origin due to clipping + dx = dstrect.cx1 - x; + dy = dstrect.cy1 - y; + + V_ScaleRect(&dstrect); + + source = src + dy * width + dx; + dest = V_ADDRESS(dest_screen, dstrect.sx, dstrect.sy); - if (hires) // killough 11/98: hires support { - byte *dest = dest_screen + y*SCREENWIDTH*4+x*2; + int w; + fixed_t xfrac, yfrac; + int xtex, ytex; + byte *row; - if (width) - while (height--) - { - byte *d = dest; - int t = width; - do - d[SCREENWIDTH*2] = d[SCREENWIDTH*2+1] = d[0] = d[1] = *src++; - while (d += 2, --t); - dest += SCREENWIDTH*4; - } + yfrac = 0; + + while (dstrect.sh--) + { + row = dest; + w = dstrect.sw; + xfrac = 0; + ytex = (yfrac >> FRACBITS) * width; + + while (w--) + { + xtex = (xfrac >> FRACBITS); + *row++ = source[ytex + xtex]; + xfrac += video.xstep; + } + + dest += linesize; + yfrac += video.ystep; + } } - else - { - byte *dest = dest_screen + y*SCREENWIDTH+x; +} - while (height--) - { - memcpy (dest, src, width); - src += width; - dest += SCREENWIDTH; - } +void V_TileBlock64(int line, int width, int height, const byte *src) +{ + byte *dest, *row; + fixed_t xfrac, yfrac; + int xtex, ytex, h; + vrect_t dstrect; + + dstrect.x = 0; + dstrect.y = line; + dstrect.w = width; + dstrect.h = height; + + V_ClipRect(&dstrect); + V_ScaleRect(&dstrect); + + h = dstrect.sh; + yfrac = dstrect.sy * video.ystep; + + dest = dest_screen; + + while (h--) + { + int w = dstrect.sw; + row = dest; + xfrac = 0; + ytex = ((yfrac >> FRACBITS) & 63) << 6; + + while (w--) + { + xtex = (xfrac >> FRACBITS) & 63; + *row++ = src[ytex + xtex]; + xfrac += video.xstep; + } + + dest += linesize; + yfrac += video.ystep; } } @@ -878,23 +884,9 @@ void V_PutBlock(int x, int y, int width, int height, byte *src) void V_DrawHorizLine(int x, int y, int width, byte color) { - byte *dest; - int height = 1; - - // [crispy] prevent framebuffer overflows - if (x + width > (unsigned)SCREENWIDTH) - width = SCREENWIDTH - x; - - if (hires) - y<<=2, x<<=1, width<<=1, height<<=1; - - dest = dest_screen + y * SCREENWIDTH + x; - - while (height--) - { - memset(dest, color, width); - dest += SCREENWIDTH << hires; - } + byte line[WIDE_SCREENWIDTH]; + memset(line, color, width); + V_DrawBlock(x, y, width, 1, line); } void V_ShadeScreen(void) @@ -911,7 +903,7 @@ void V_ShadeScreen(void) screenshade = 0; } - for (y = 0; y < (SCREENWIDTH << hires) * (SCREENHEIGHT << hires); y++) + for (y = 0; y < video.width * video.height; y++) { dest[y] = colormaps[0][screenshade * 256 + dest[y]]; } @@ -923,7 +915,7 @@ void V_ShadeScreen(void) if (screenshade > targshade) screenshade = targshade; } - + oldtic = gametic; } @@ -935,29 +927,9 @@ void V_ShadeScreen(void) void V_DrawBackground(const char *patchname) { - int x, y; - pixel_t *dest = dest_screen; - byte *src = W_CacheLumpNum(firstflat + R_FlatNumForName(patchname), PU_CACHE); + const byte *src = W_CacheLumpNum(firstflat + R_FlatNumForName(patchname), PU_CACHE); - if (hires) // killough 11/98: hires support - { - for (y = 0; y < SCREENHEIGHT<<1; y++) - for (x = 0; x < SCREENWIDTH<<1; x += 2) - { - const byte dot = src[(((y>>1)&63)<<6) + ((x>>1)&63)]; - - *dest++ = dot; - *dest++ = dot; - } - } - else - { - for (y = 0; y < SCREENHEIGHT; y++) - for (x = 0; x < SCREENWIDTH; x++) - { - *dest++ = src[((y&63)<<6) + (x&63)]; - } - } + V_TileBlock64(0, video.unscaledw, video.unscaledh, src); } // @@ -966,7 +938,42 @@ void V_DrawBackground(const char *patchname) void V_Init(void) { + int i; + fixed_t frac, lastfrac; + linesize = video.width; + + x1lookup[0] = 0; + lastfrac = frac = 0; + for(i = 0; i < video.width; i++) + { + if(frac >> FRACBITS > lastfrac >> FRACBITS) + { + x1lookup[frac >> FRACBITS] = i; + x2lookup[lastfrac >> FRACBITS] = i - 1; + lastfrac = frac; + } + + frac += video.xstep; + } + x2lookup[video.unscaledw - 1] = video.width - 1; + x1lookup[video.unscaledw] = x2lookup[video.unscaledw] = video.width; + + y1lookup[0] = 0; + lastfrac = frac = 0; + for(i = 0; i < video.height; i++) + { + if(frac >> FRACBITS > lastfrac >> FRACBITS) + { + y1lookup[frac >> FRACBITS] = i; + y2lookup[lastfrac >> FRACBITS] = i - 1; + lastfrac = frac; + } + + frac += video.ystep; + } + y2lookup[video.unscaledh - 1] = video.height - 1; + y1lookup[video.unscaledh] = y2lookup[video.unscaledh] = video.height; } // Set the buffer that the code draws to. diff --git a/src/v_video.h b/src/v_video.h index fd1db6aa..8be5694c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -90,6 +90,30 @@ extern byte gammatable[5][256]; //jff 4/24/98 loads color translation lumps void V_InitColorTranslation(void); +typedef struct +{ + int x; // original x coordinate for upper left corner + int y; // original y coordinate for upper left corner + int w; // original width + int h; // original height + + int cx1; // clipped x coordinate for left edge + int cx2; // clipped x coordinate for right edge + int cy1; // clipped y coordinate for upper edge + int cy2; // clipped y coordinate for lower edge + int cw; // clipped width + int ch; // clipped height + + int sx; // scaled x + int sy; // scaled y + int sw; // scaled width + int sh; // scaled height +} vrect_t; + +void V_ClipRect(vrect_t *rect); + +void V_ScaleRect(vrect_t *rect); + // Allocates buffer screens, call before R_Init. void V_Init (void); @@ -131,6 +155,8 @@ void V_DrawHorizLine(int x, int y, int width, byte color); void V_ShadeScreen(void); +void V_TileBlock64(int line, int width, int height, const byte *src); + void V_DrawBackground(const char *patchname); // [FG] colored blood and gibs diff --git a/src/wi_stuff.c b/src/wi_stuff.c index cf4b3ea4..60683a90 100644 --- a/src/wi_stuff.c +++ b/src/wi_stuff.c @@ -454,7 +454,7 @@ static void WI_drawLF(void) { patch_t* lpic = W_CacheLumpName(wbs->lastmapinfo->levelpic, PU_CACHE); - V_DrawPatch((ORIGWIDTH - SHORT(lpic->width))/2, + V_DrawPatch((SCREENWIDTH - SHORT(lpic->width))/2, y, lpic); y += (5 * SHORT(lpic->height)) / 4; @@ -464,14 +464,14 @@ static void WI_drawLF(void) if (wbs->last >= 0 && wbs->last < num_lnames && lnames[wbs->last] != NULL ) { // draw - V_DrawPatch((ORIGWIDTH - SHORT(lnames[wbs->last]->width))/2, + V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2, y, lnames[wbs->last]); // draw "Finished!" y += (5*SHORT(lnames[wbs->last]->height))/4; } - V_DrawPatch((ORIGWIDTH - SHORT(finished->width))/2, + V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2, y, finished); } @@ -487,7 +487,7 @@ static void WI_drawEL(void) int y = WI_TITLEY; // draw "Entering" - V_DrawPatch((ORIGWIDTH - SHORT(entering->width))/2, + V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2, y, entering); // The level defines a new name but no texture for the name @@ -510,7 +510,7 @@ static void WI_drawEL(void) y += (5 * SHORT(lpic->height)) / 4; - V_DrawPatch((ORIGWIDTH - SHORT(lpic->width))/2, + V_DrawPatch((SCREENWIDTH - SHORT(lpic->width))/2, y, lpic); } // [FG] prevent crashes for levels without name graphics @@ -518,10 +518,10 @@ static void WI_drawEL(void) { // draw level // haleyjd: corrected to use height of entering, not map name - if (SHORT(lnames[wbs->next]->height) < ORIGHEIGHT) + if (SHORT(lnames[wbs->next]->height) < SCREENHEIGHT) y += (5 * SHORT(entering->height)) / 4; - V_DrawPatch((ORIGWIDTH - SHORT(lnames[wbs->next]->width))/2, + V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2, y, lnames[wbs->next]); } } @@ -1817,16 +1817,16 @@ static void WI_drawStats(void) WI_drawLF(); V_DrawPatch(SP_STATSX, SP_STATSY, kills); - WI_drawPercent(ORIGWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]); + WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]); V_DrawPatch(SP_STATSX, SP_STATSY+lh, items); - WI_drawPercent(ORIGWIDTH - SP_STATSX, SP_STATSY+lh, cnt_items[0]); + WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+lh, cnt_items[0]); V_DrawPatch(SP_STATSX, SP_STATSY+2*lh, sp_secret); - WI_drawPercent(ORIGWIDTH - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]); + WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]); V_DrawPatch(SP_TIMEX, SP_TIMEY, witime); - WI_drawTime(ORIGWIDTH/2 - SP_TIMEX, SP_TIMEY, cnt_time, true); + WI_drawTime(SCREENWIDTH/2 - SP_TIMEX, SP_TIMEY, cnt_time, true); // Ty 04/11/98: redid logic: should skip only if with pwad but // without deh patch @@ -1836,17 +1836,17 @@ static void WI_drawStats(void) if (W_IsIWADLump(maplump) || deh_pars || um_pars) if (wbs->epsd < 3 || um_pars) { - V_DrawPatch(ORIGWIDTH/2 + SP_TIMEX, SP_TIMEY, par); - WI_drawTime(ORIGWIDTH - SP_TIMEX, SP_TIMEY, cnt_par, true); + V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, par); + WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par, true); } // [FG] draw total time alongside level time and par time { - const boolean wide = (wbs->totaltimes / TICRATE > 61*59) || (SP_TIMEX + SHORT(total->width) >= ORIGWIDTH/4); + const boolean wide = (wbs->totaltimes / TICRATE > 61*59) || (SP_TIMEX + SHORT(total->width) >= SCREENWIDTH/4); V_DrawPatch(SP_TIMEX, SP_TIMEY + 16, total); // [FG] choose x-position depending on width of time string - WI_drawTime((wide ? ORIGWIDTH : ORIGWIDTH/2) - SP_TIMEX, SP_TIMEY + 16, cnt_total_time, false); + WI_drawTime((wide ? SCREENWIDTH : SCREENWIDTH/2) - SP_TIMEX, SP_TIMEY + 16, cnt_total_time, false); } }