Co-Authored-By: Sally Coolatta <tehrealsalt@gmail.com> Co-Authored-By: James R <justsomejames2@gmail.com> Co-Authored-By: Monster Iestyn <iestynjealous@ntlworld.com> Co-Authored-By: katsy <katmint@live.com> Place Frame Interpolation in "Experimental" video options header This seems like an appropriate way to describe the feature for now. Add smooth level platter under interpolation, `renderdeltatics` `renderdeltatics` can be used as a standard delta time in any place, allowing for smooth menus. It will always be equal to `realtics` when frame interpolation is turned off, producing consistent framerate behavior everywhere it is used. Add smooth rendering to save select screen Add smooth rendering to Record/NiGHTS Attack, F_SkyScroll Ensure viewsector is accurate to viewx/viewy This fixes a potential crash in OpenGL when changing between levels. Ensure + commands get executed before map start Always have precise_t defined Fix misc dropshadow issues Reset view interpolation on level load Remove unnecessary precipmobj thinker hack Add reset interpolation state functions Reset precip interpolation on snap to ceil Reset mobj interp state on TeleportMove Only swap view interp state if a tick is run Run anti-lag chasecam at tic frequency Fixes jittery and unstable chasecam in high latency netgames Homogenize mobj interpolations Add sector plane level interpolations Add SectorScroll interpolator Add SideScroll interpolator Add Polyobj interpolator Intialize interpolator list at a better time Delete interpolators associated with thinkers Interpolate mobj angles and player drawangle Interpolate HWR_DrawModel Add functions to handle interpolation Much less code duplication P_InitAngle, to fix angle interpolation on spawning objects Fully fix drop shadows It used the thing's floorz / ceilingz directly -- that wouldn't account for interpolated coordinates. Do not speed up underwater/heatwave effect in OpenGL Closer OpenGL underwater/heatwave effect to Software Interpolate from time of previous tic Previously interpolated from last 35th of a second, which may be offset from game time due to connection lag. Consider this the proper fix to 54148a0dd0 too. Calculate FPS stuff even if frame is skipped I decided ultimately to actually keep the frame skip optimization disabled, because I think it is actually a little bit helpful that you can still get accurate rendering perfstats while paused, however if we decide otherwise then we can have this optimization back without making the game act like it's lagging. Keep rect in memory Feel better about this than creating one all da time Lots of FPS stuff - Disabled VSync, due to the numerous problems it has. - Instead, added an FPS cap. - Frame interpolation is now tied to fpscap != 35. - By default, the FPS cap is set to the monitor's refresh rate. - Rewrote the FPS counter. (This also consolidates several more commits ahead of this fixing various issues. -eid) Misc changes after Kart cherry-picks Fix renderdeltatics with new timing data Update mobj oldstates before all thinkers Allow FPS cap values Adjust how FPS cap is checked to improve FPS stability Fix precip crash from missing vars Improve the framerate limiter's timing for extreme stable FPS Handle the sleep at the end of D_SRB2Loop instead of the start Simplifies logic in the other parts of the loop, and fixes problems with it frequently waiting too long. Reset mobj interp state on add Add mobj interpolator on load netgame Move mobj interpolators to r_fps Dynamic slope interpolators I_GetFrameTime to try and improve frame pace (It doesn't feel that much better though.) Move I_FinishUpdate to D_SRB2Loop to sync screen updates with FPS cap, use timestamps in I_FrameCapSleep to simplify the code Fix plane interpolation light level flickering Fix flickering plane interpolation for OpenGL in the exact same way Funny OpenGL renderer being at least 50% copy-pasted Software code :) P_SetOrigin & P_MoveOrigin to replace P_TeleportMove Convert P_TeleportMove use to origin funcs Revert "P_InitAngle, to fix angle interpolation on spawning objects" This reverts commit a80c98bd164a2748cbbfad9027b34601185d93f5. Waypoint polyobjects interpolate z & children Add interpolation to more moving plane types Adds interpolation to the following: - Crumbling platforms - Mario blocks - Floatbob platforms (this one works really strangely due to two thinkers, maybe double-check this one?) Reset overlays interp states each TryRunTics Interpolate model interpolation (lol) Use interp tracer pos for GL linkdraw Papersprite angle interpolation Makes the ending signpost smooth Move intermission emerald bounce to ticker Bring back shadows on polyobjects Also optimizes the method used so rings can show their shadows too. Using just the subsector is a tad bit imprecise admittedly but any more precise methods get really laggy. Fix a bunch of ticking in hu_ drawing functions Revert "Reset overlays interp states each TryRunTics" This reverts commit a71a216faa20e8751b3bd0157354e8d748940c92. Move intro ticking out of the drawer Adjust 1up monitor icon z offsets Fixes interpolation issues with 1up monitors. Delta time choose player menu animations Add drawerlib deltaTime function Interpolate afterimages further back Use old sleep in dedicated mode Clamp cechotimer to 0 Fixes issues with cechos staying on-screen and glitching out (NiGHTS items for example). Revert "Remove unnecessary precipmobj thinker hack" This reverts commit 0e38208620d19ec2ab690740438ac2fc7862a49e. Fix frame pacing when game lags behind The frame timestamp should've been made at the start of the frame, not the end. Fix I_FrameCapSleep not respecting cpusleep Jonathan Joestar bruh Allow dedicated to use precise sleep timing again Instead of only using one old sleep, just enforce framerate cap to match TICRATE. Make Lua TeleportMove call MoveOrigin Reset Metal fume interp state on appear Add interpdebug Put interpdebug stuff in perfstats instead Add timescale cvar Slow the game down to debug animations / interpolation problems! Speed it up if you need to get somewhere quickly while mapping! Enable timescale outside of DEVELOP builds It has NETVAR, so it should be fine -- put an end to useful debugging features excluded in multiplayer! Force interpolation when timescale != 1.0 Reset old_z in MT_LOCKON think Fixes interpolation artifacting due to spawn pos. Fix cutscenes in interp Fix boss1 laser in interp Interpolate mobj scale Precalculate refresh rate Slower PCs can have issue querying mode over and over. This might kinda suck for windowed mode if you have different refresh rate displays but oh well Fix interp scaling crashing software Reset interp scale when Lua sets .scale Disable angle interp on fresh mobjs Fix interp scale crash for hires sprites Interp shadow scales Copy interp state in P_SpawnMobjFromMobj Fix multiplayer character select Don't interpolate mobj state if frac = 1.0 Fix Mario block item placement Interpolate spritescale/offset x/y Fix offset copies for SpawnMobjFromMobj THANKS SAL Add Lua HUD drawlists Buffers draw calls between tics to ensure hooks run at the originally intended rate. Rename drawerlib deltaTime to getDeltaTime Make renderisnewtic is false between tics I know what I'm doing! I swear Completely refactor timing system Time is now tracked internally in the game using I_GetPreciseTime and I_UpdateTime. I_Time now pulls from this internal timer. The system code no longer needs to keep track of time itself. This significantly improves frame and tic timing in interp mode, resulting in a much smoother image with essentially no judder at any framerate. Ensure mobj interpolators reset on level load Ensure view is not interpolated on first frame Disable sprite offset interpolation (for now) Refactor timing code even more System layer is greatly simplified and framecap logic has been moved internally. I_Sleep now takes a sleep duration and I_SleepDuration generically implements a precise sleep with spin loop.
507 lines
15 KiB
C
507 lines
15 KiB
C
// SONIC ROBO BLAST 2
|
|
//-----------------------------------------------------------------------------
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
|
// Copyright (C) 1999-2018 by Sonic Team Junior.
|
|
//
|
|
// This program is free software distributed under the
|
|
// terms of the GNU General Public License, version 2.
|
|
// See the 'LICENSE' file for more details.
|
|
//-----------------------------------------------------------------------------
|
|
/// \file screen.c
|
|
/// \brief Handles multiple resolutions, 8bpp/16bpp(highcolor) modes
|
|
|
|
#include "doomdef.h"
|
|
#include "doomstat.h"
|
|
#include "screen.h"
|
|
#include "console.h"
|
|
#include "am_map.h"
|
|
#include "i_time.h"
|
|
#include "i_system.h"
|
|
#include "i_video.h"
|
|
#include "r_local.h"
|
|
#include "r_sky.h"
|
|
#include "m_argv.h"
|
|
#include "m_misc.h"
|
|
#include "v_video.h"
|
|
#include "st_stuff.h"
|
|
#include "hu_stuff.h"
|
|
#include "z_zone.h"
|
|
#include "d_main.h"
|
|
#include "d_clisrv.h"
|
|
#include "f_finale.h"
|
|
|
|
// SRB2Kart
|
|
#include "r_fps.h" // R_GetFramerateCap
|
|
|
|
#if defined (USEASM) && !defined (NORUSEASM)//&& (!defined (_MSC_VER) || (_MSC_VER <= 1200))
|
|
#define RUSEASM //MSC.NET can't patch itself
|
|
#endif
|
|
|
|
// --------------------------------------------
|
|
// assembly or c drawer routines for 8bpp/16bpp
|
|
// --------------------------------------------
|
|
void (*wallcolfunc)(void); // new wall column drawer to draw posts >128 high
|
|
void (*colfunc)(void); // standard column, up to 128 high posts
|
|
|
|
void (*basecolfunc)(void);
|
|
void (*fuzzcolfunc)(void); // standard fuzzy effect column drawer
|
|
void (*transcolfunc)(void); // translation column drawer
|
|
void (*shadecolfunc)(void); // smokie test..
|
|
void (*spanfunc)(void); // span drawer, use a 64x64 tile
|
|
void (*splatfunc)(void); // span drawer w/ transparency
|
|
void (*basespanfunc)(void); // default span func for color mode
|
|
void (*transtransfunc)(void); // translucent translated column drawer
|
|
void (*twosmultipatchfunc)(void); // for cols with transparent pixels
|
|
void (*twosmultipatchtransfunc)(void); // for cols with transparent pixels AND translucency
|
|
|
|
// ------------------
|
|
// global video state
|
|
// ------------------
|
|
viddef_t vid;
|
|
INT32 setmodeneeded; //video mode change needed if > 0 (the mode number to set + 1)
|
|
|
|
static CV_PossibleValue_t scr_depth_cons_t[] = {{8, "8 bits"}, {16, "16 bits"}, {24, "24 bits"}, {32, "32 bits"}, {0, NULL}};
|
|
|
|
static CV_PossibleValue_t shittyscreen_cons_t[] = {{0, "Okay"}, {1, "Shitty"}, {2, "Extra Shitty"}, {0, NULL}};
|
|
|
|
//added : 03-02-98: default screen mode, as loaded/saved in config
|
|
#ifdef WII
|
|
consvar_t cv_scr_width = {"scr_width", "640", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
consvar_t cv_scr_height = {"scr_height", "480", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
#else
|
|
consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
#endif
|
|
consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
consvar_t cv_vhseffect = {"vhspause", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittyscreen_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
static void SCR_ChangeFullscreen (void);
|
|
|
|
consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
// =========================================================================
|
|
// SCREEN VARIABLES
|
|
// =========================================================================
|
|
|
|
INT32 scr_bpp; // current video mode bytes per pixel
|
|
UINT8 *scr_borderpatch; // flat used to fill the reduced view borders set at ST_Init()
|
|
|
|
// =========================================================================
|
|
|
|
// Short and Tall sky drawer, for the current color mode
|
|
void (*walldrawerfunc)(void);
|
|
|
|
boolean R_ASM = true;
|
|
boolean R_486 = false;
|
|
boolean R_586 = false;
|
|
boolean R_MMX = false;
|
|
boolean R_SSE = false;
|
|
boolean R_3DNow = false;
|
|
boolean R_MMXExt = false;
|
|
boolean R_SSE2 = false;
|
|
|
|
|
|
void SCR_SetMode(void)
|
|
{
|
|
if (dedicated)
|
|
return;
|
|
|
|
if (!setmodeneeded || WipeInAction)
|
|
return; // should never happen and don't change it during a wipe, BAD!
|
|
|
|
VID_SetMode(--setmodeneeded);
|
|
|
|
V_SetPalette(0);
|
|
|
|
//
|
|
// setup the right draw routines for either 8bpp or 16bpp
|
|
//
|
|
if (true)//vid.bpp == 1) //Always run in 8bpp. todo: remove all 16bpp code?
|
|
{
|
|
spanfunc = basespanfunc = R_DrawSpan_8;
|
|
splatfunc = R_DrawSplat_8;
|
|
transcolfunc = R_DrawTranslatedColumn_8;
|
|
transtransfunc = R_DrawTranslatedTranslucentColumn_8;
|
|
|
|
colfunc = basecolfunc = R_DrawColumn_8;
|
|
shadecolfunc = R_DrawShadeColumn_8;
|
|
fuzzcolfunc = R_DrawTranslucentColumn_8;
|
|
walldrawerfunc = R_DrawWallColumn_8;
|
|
twosmultipatchfunc = R_Draw2sMultiPatchColumn_8;
|
|
twosmultipatchtransfunc = R_Draw2sMultiPatchTranslucentColumn_8;
|
|
#ifdef RUSEASM
|
|
if (R_ASM)
|
|
{
|
|
if (R_MMX)
|
|
{
|
|
colfunc = basecolfunc = R_DrawColumn_8_MMX;
|
|
//shadecolfunc = R_DrawShadeColumn_8_ASM;
|
|
//fuzzcolfunc = R_DrawTranslucentColumn_8_ASM;
|
|
walldrawerfunc = R_DrawWallColumn_8_MMX;
|
|
twosmultipatchfunc = R_Draw2sMultiPatchColumn_8_MMX;
|
|
spanfunc = basespanfunc = R_DrawSpan_8_MMX;
|
|
}
|
|
else
|
|
{
|
|
colfunc = basecolfunc = R_DrawColumn_8_ASM;
|
|
//shadecolfunc = R_DrawShadeColumn_8_ASM;
|
|
//fuzzcolfunc = R_DrawTranslucentColumn_8_ASM;
|
|
walldrawerfunc = R_DrawWallColumn_8_ASM;
|
|
twosmultipatchfunc = R_Draw2sMultiPatchColumn_8_ASM;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
/* else if (vid.bpp > 1)
|
|
{
|
|
I_OutputMsg("using highcolor mode\n");
|
|
spanfunc = basespanfunc = R_DrawSpan_16;
|
|
transcolfunc = R_DrawTranslatedColumn_16;
|
|
transtransfunc = R_DrawTranslucentColumn_16; // No 16bit operation for this function
|
|
|
|
colfunc = basecolfunc = R_DrawColumn_16;
|
|
shadecolfunc = NULL; // detect error if used somewhere..
|
|
fuzzcolfunc = R_DrawTranslucentColumn_16;
|
|
walldrawerfunc = R_DrawWallColumn_16;
|
|
}*/
|
|
else
|
|
I_Error("unknown bytes per pixel mode %d\n", vid.bpp);
|
|
/*#if !defined (DC) && !defined (WII)
|
|
if (SCR_IsAspectCorrect(vid.width, vid.height))
|
|
CONS_Alert(CONS_WARNING, M_GetText("Resolution is not aspect-correct!\nUse a multiple of %dx%d\n"), BASEVIDWIDTH, BASEVIDHEIGHT);
|
|
#endif*/
|
|
// set the apprpriate drawer for the sky (tall or INT16)
|
|
setmodeneeded = 0;
|
|
}
|
|
|
|
// do some initial settings for the game loading screen
|
|
//
|
|
void SCR_Startup(void)
|
|
{
|
|
const CPUInfoFlags *RCpuInfo = I_CPUInfo();
|
|
if (!M_CheckParm("-NOCPUID") && RCpuInfo)
|
|
{
|
|
#if defined (__i386__) || defined (_M_IX86) || defined (__WATCOMC__)
|
|
R_486 = true;
|
|
#endif
|
|
if (RCpuInfo->RDTSC)
|
|
R_586 = true;
|
|
if (RCpuInfo->MMX)
|
|
R_MMX = true;
|
|
if (RCpuInfo->AMD3DNow)
|
|
R_3DNow = true;
|
|
if (RCpuInfo->MMXExt)
|
|
R_MMXExt = true;
|
|
if (RCpuInfo->SSE)
|
|
R_SSE = true;
|
|
if (RCpuInfo->SSE2)
|
|
R_SSE2 = true;
|
|
CONS_Printf("CPU Info: 486: %i, 586: %i, MMX: %i, 3DNow: %i, MMXExt: %i, SSE2: %i\n", R_486, R_586, R_MMX, R_3DNow, R_MMXExt, R_SSE2);
|
|
}
|
|
|
|
if (M_CheckParm("-noASM"))
|
|
R_ASM = false;
|
|
if (M_CheckParm("-486"))
|
|
R_486 = true;
|
|
if (M_CheckParm("-586"))
|
|
R_586 = true;
|
|
if (M_CheckParm("-MMX"))
|
|
R_MMX = true;
|
|
if (M_CheckParm("-3DNow"))
|
|
R_3DNow = true;
|
|
if (M_CheckParm("-MMXExt"))
|
|
R_MMXExt = true;
|
|
|
|
if (M_CheckParm("-SSE"))
|
|
R_SSE = true;
|
|
if (M_CheckParm("-noSSE"))
|
|
R_SSE = false;
|
|
|
|
if (M_CheckParm("-SSE2"))
|
|
R_SSE2 = true;
|
|
|
|
M_SetupMemcpy();
|
|
|
|
if (dedicated)
|
|
{
|
|
V_Init();
|
|
V_SetPalette(0);
|
|
return;
|
|
}
|
|
|
|
vid.modenum = 0;
|
|
|
|
vid.dupx = vid.width / BASEVIDWIDTH;
|
|
vid.dupy = vid.height / BASEVIDHEIGHT;
|
|
vid.dupx = vid.dupy = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy);
|
|
vid.fdupx = FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT);
|
|
vid.fdupy = FixedDiv(vid.height*FRACUNIT, BASEVIDHEIGHT*FRACUNIT);
|
|
|
|
#ifdef HWRENDER
|
|
if (rendermode != render_opengl && rendermode != render_none) // This was just placing it incorrectly at non aspect correct resolutions in opengl
|
|
#endif
|
|
vid.fdupx = vid.fdupy = (vid.fdupx < vid.fdupy ? vid.fdupx : vid.fdupy);
|
|
|
|
vid.meddupx = (UINT8)(vid.dupx >> 1) + 1;
|
|
vid.meddupy = (UINT8)(vid.dupy >> 1) + 1;
|
|
#ifdef HWRENDER
|
|
vid.fmeddupx = vid.meddupx*FRACUNIT;
|
|
vid.fmeddupy = vid.meddupy*FRACUNIT;
|
|
#endif
|
|
|
|
vid.smalldupx = (UINT8)(vid.dupx / 3) + 1;
|
|
vid.smalldupy = (UINT8)(vid.dupy / 3) + 1;
|
|
#ifdef HWRENDER
|
|
vid.fsmalldupx = vid.smalldupx*FRACUNIT;
|
|
vid.fsmalldupy = vid.smalldupy*FRACUNIT;
|
|
#endif
|
|
|
|
vid.baseratio = FRACUNIT;
|
|
|
|
V_Init();
|
|
CV_RegisterVar(&cv_ticrate);
|
|
CV_RegisterVar(&cv_constextsize);
|
|
|
|
V_SetPalette(0);
|
|
}
|
|
|
|
// Called at new frame, if the video mode has changed
|
|
//
|
|
void SCR_Recalc(void)
|
|
{
|
|
if (dedicated)
|
|
return;
|
|
|
|
// bytes per pixel quick access
|
|
scr_bpp = vid.bpp;
|
|
|
|
// scale 1,2,3 times in x and y the patches for the menus and overlays...
|
|
// calculated once and for all, used by routines in v_video.c
|
|
vid.dupx = vid.width / BASEVIDWIDTH;
|
|
vid.dupy = vid.height / BASEVIDHEIGHT;
|
|
vid.dupx = vid.dupy = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy);
|
|
vid.fdupx = FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT);
|
|
vid.fdupy = FixedDiv(vid.height*FRACUNIT, BASEVIDHEIGHT*FRACUNIT);
|
|
|
|
#ifdef HWRENDER
|
|
//if (rendermode != render_opengl && rendermode != render_none) // This was just placing it incorrectly at non aspect correct resolutions in opengl
|
|
// 13/11/18:
|
|
// The above is no longer necessary, since we want OpenGL to be just like software now
|
|
// -- Monster Iestyn
|
|
#endif
|
|
vid.fdupx = vid.fdupy = (vid.fdupx < vid.fdupy ? vid.fdupx : vid.fdupy);
|
|
|
|
//vid.baseratio = FixedDiv(vid.height << FRACBITS, BASEVIDHEIGHT << FRACBITS);
|
|
vid.baseratio = FRACUNIT;
|
|
|
|
vid.meddupx = (UINT8)(vid.dupx >> 1) + 1;
|
|
vid.meddupy = (UINT8)(vid.dupy >> 1) + 1;
|
|
#ifdef HWRENDER
|
|
vid.fmeddupx = vid.meddupx*FRACUNIT;
|
|
vid.fmeddupy = vid.meddupy*FRACUNIT;
|
|
#endif
|
|
|
|
vid.smalldupx = (UINT8)(vid.dupx / 3) + 1;
|
|
vid.smalldupy = (UINT8)(vid.dupy / 3) + 1;
|
|
#ifdef HWRENDER
|
|
vid.fsmalldupx = vid.smalldupx*FRACUNIT;
|
|
vid.fsmalldupy = vid.smalldupy*FRACUNIT;
|
|
#endif
|
|
|
|
// toggle off automap because some screensize-dependent values will
|
|
// be calculated next time the automap is activated.
|
|
if (automapactive)
|
|
AM_Stop();
|
|
|
|
// set the screen[x] ptrs on the new vidbuffers
|
|
V_Init();
|
|
|
|
// scr_viewsize doesn't change, neither detailLevel, but the pixels
|
|
// per screenblock is different now, since we've changed resolution.
|
|
R_SetViewSize(); //just set setsizeneeded true now ..
|
|
|
|
// vid.recalc lasts only for the next refresh...
|
|
con_recalc = true;
|
|
am_recalc = true;
|
|
}
|
|
|
|
// Check for screen cmd-line parms: to force a resolution.
|
|
//
|
|
// Set the video mode to set at the 1st display loop (setmodeneeded)
|
|
//
|
|
|
|
void SCR_CheckDefaultMode(void)
|
|
{
|
|
INT32 scr_forcex, scr_forcey; // resolution asked from the cmd-line
|
|
|
|
if (dedicated)
|
|
return;
|
|
|
|
// 0 means not set at the cmd-line
|
|
scr_forcex = scr_forcey = 0;
|
|
|
|
if (M_CheckParm("-width") && M_IsNextParm())
|
|
scr_forcex = atoi(M_GetNextParm());
|
|
|
|
if (M_CheckParm("-height") && M_IsNextParm())
|
|
scr_forcey = atoi(M_GetNextParm());
|
|
|
|
if (scr_forcex && scr_forcey)
|
|
{
|
|
CONS_Printf(M_GetText("Using resolution: %d x %d\n"), scr_forcex, scr_forcey);
|
|
// returns -1 if not found, thus will be 0 (no mode change) if not found
|
|
setmodeneeded = VID_GetModeForSize(scr_forcex, scr_forcey) + 1;
|
|
}
|
|
else
|
|
{
|
|
CONS_Printf(M_GetText("Default resolution: %d x %d (%d bits)\n"), cv_scr_width.value,
|
|
cv_scr_height.value, cv_scr_depth.value);
|
|
// see note above
|
|
setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1;
|
|
}
|
|
}
|
|
|
|
// sets the modenum as the new default video mode to be saved in the config file
|
|
void SCR_SetDefaultMode(void)
|
|
{
|
|
// remember the default screen size
|
|
CV_SetValue(&cv_scr_width, vid.width);
|
|
CV_SetValue(&cv_scr_height, vid.height);
|
|
CV_SetValue(&cv_scr_depth, vid.bpp*8);
|
|
}
|
|
|
|
// Change fullscreen on/off according to cv_fullscreen
|
|
void SCR_ChangeFullscreen(void)
|
|
{
|
|
#ifdef DIRECTFULLSCREEN
|
|
// allow_fullscreen is set by VID_PrepareModeList
|
|
// it is used to prevent switching to fullscreen during startup
|
|
if (!allow_fullscreen)
|
|
return;
|
|
|
|
if (graphics_started)
|
|
{
|
|
VID_PrepareModeList();
|
|
setmodeneeded = VID_GetModeForSize(vid.width, vid.height) + 1;
|
|
}
|
|
return;
|
|
#endif
|
|
}
|
|
|
|
boolean SCR_IsAspectCorrect(INT32 width, INT32 height)
|
|
{
|
|
return
|
|
( width % BASEVIDWIDTH == 0
|
|
&& height % BASEVIDHEIGHT == 0
|
|
&& width / BASEVIDWIDTH == height / BASEVIDHEIGHT
|
|
);
|
|
}
|
|
|
|
double averageFPS = 0.0f;
|
|
|
|
#define FPS_SAMPLE_RATE (50000) // How often to update FPS samples, in microseconds
|
|
#define NUM_FPS_SAMPLES 16 // Number of samples to store
|
|
|
|
static double fps_samples[NUM_FPS_SAMPLES];
|
|
|
|
void SCR_CalculateFPS(void)
|
|
{
|
|
static boolean init = false;
|
|
|
|
static precise_t startTime = 0;
|
|
precise_t endTime = 0;
|
|
|
|
static precise_t updateTime = 0;
|
|
int updateElapsed = 0;
|
|
int i;
|
|
|
|
endTime = I_GetPreciseTime();
|
|
|
|
if (init == false)
|
|
{
|
|
startTime = updateTime = endTime;
|
|
init = true;
|
|
return;
|
|
}
|
|
|
|
updateElapsed = (endTime - updateTime) / (I_GetPrecisePrecision() / 1000000);
|
|
|
|
if (updateElapsed >= FPS_SAMPLE_RATE)
|
|
{
|
|
static int sampleIndex = 0;
|
|
int frameElapsed = (endTime - startTime) / (I_GetPrecisePrecision() / 1000000);
|
|
|
|
fps_samples[sampleIndex] = frameElapsed / 1000.0f;
|
|
|
|
sampleIndex++;
|
|
if (sampleIndex >= NUM_FPS_SAMPLES)
|
|
sampleIndex = 0;
|
|
|
|
averageFPS = 0.0f;
|
|
for (i = 0; i < NUM_FPS_SAMPLES; i++)
|
|
{
|
|
averageFPS += fps_samples[i];
|
|
}
|
|
averageFPS = 1000.0f / (averageFPS / NUM_FPS_SAMPLES);
|
|
|
|
updateTime = endTime;
|
|
}
|
|
|
|
startTime = endTime;
|
|
}
|
|
|
|
void SCR_DisplayTicRate(void)
|
|
{
|
|
const UINT8 *ticcntcolor = NULL;
|
|
UINT32 cap = R_GetFramerateCap();
|
|
UINT32 benchmark = (cap == 0) ? I_GetRefreshRate() : cap;
|
|
INT32 x = 318;
|
|
double fps = ceil(averageFPS);
|
|
|
|
// draw "FPS"
|
|
V_DrawFixedPatch(306<<FRACBITS, 183<<FRACBITS, FRACUNIT, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, framecounter, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_YELLOW, GTC_CACHE));
|
|
|
|
if (fps > (benchmark - 5))
|
|
ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE);
|
|
else if (fps < 20)
|
|
ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE);
|
|
|
|
if (cap != 0)
|
|
{
|
|
UINT32 digits = 1;
|
|
UINT32 c2 = cap;
|
|
|
|
while (c2 > 0)
|
|
{
|
|
c2 = c2 / 10;
|
|
digits++;
|
|
}
|
|
|
|
// draw total frame:
|
|
V_DrawPingNum(x, 190, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, cap, ticcntcolor);
|
|
x -= digits * 4;
|
|
|
|
// draw "/"
|
|
V_DrawFixedPatch(x<<FRACBITS, 190<<FRACBITS, FRACUNIT, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, frameslash, ticcntcolor);
|
|
}
|
|
|
|
// draw our actual framerate
|
|
V_DrawPingNum(x, 190, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, fps, ticcntcolor);
|
|
}
|
|
|
|
// SCR_DisplayLocalPing
|
|
// Used to draw the user's local ping next to the framerate for a quick check without having to hold TAB for instance. By default, it only shows up if your ping is too high and risks getting you kicked.
|
|
|
|
void SCR_DisplayLocalPing(void)
|
|
{
|
|
UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P
|
|
if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level
|
|
{
|
|
INT32 dispy = cv_ticrate.value ? 160 : 181;
|
|
HU_drawPing(307, dispy, ping, V_SNAPTORIGHT | V_SNAPTOBOTTOM);
|
|
}
|
|
}
|