update DRS parameters

This commit is contained in:
Roman Fomin 2023-12-20 14:09:01 +07:00
parent 3584cb67bb
commit fea6833ea0
4 changed files with 34 additions and 34 deletions

View File

@ -210,7 +210,6 @@ void D_ProcessEvents (void)
gamestate_t wipegamestate = GS_DEMOSCREEN; gamestate_t wipegamestate = GS_DEMOSCREEN;
boolean screen_melt = true; boolean screen_melt = true;
extern int showMessages; extern int showMessages;
boolean enable_drs;
void D_Display (void) void D_Display (void)
{ {
@ -246,10 +245,14 @@ void D_Display (void)
} }
} }
enable_drs = true;
redrawsbar = false; redrawsbar = false;
// save the current screen if about to wipe
if ((wipe = gamestate != wipegamestate) && NOTSTRICTMODE(screen_melt))
wipe_StartScreen(0, 0, video.unscaledw, SCREENHEIGHT);
else
I_DynamicResolution();
if (setsizeneeded) // change the view size if needed if (setsizeneeded) // change the view size if needed
{ {
R_ExecuteSetViewSize(); R_ExecuteSetViewSize();
@ -257,13 +260,6 @@ void D_Display (void)
borderdrawcount = 3; borderdrawcount = 3;
} }
// save the current screen if about to wipe
if ((wipe = gamestate != wipegamestate) && NOTSTRICTMODE(screen_melt))
{
enable_drs = false;
wipe_StartScreen(0, 0, video.unscaledw, SCREENHEIGHT);
}
if (gamestate == GS_LEVEL && gametic) if (gamestate == GS_LEVEL && gametic)
HU_Erase(); HU_Erase();

View File

@ -368,8 +368,6 @@ extern boolean precache;
// to force a wipe on the next draw // to force a wipe on the next draw
extern gamestate_t wipegamestate; extern gamestate_t wipegamestate;
extern boolean enable_drs;
extern int mouseSensitivity_horiz; // killough extern int mouseSensitivity_horiz; // killough
extern int mouseSensitivity_vert; extern int mouseSensitivity_vert;
extern int mouseSensitivity_horiz_strafe; // [FG] strafe extern int mouseSensitivity_horiz_strafe; // [FG] strafe

View File

@ -479,7 +479,7 @@ static int targetrefresh;
static void ResetResolution(int height); static void ResetResolution(int height);
static void ResetLogicalSize(void); static void ResetLogicalSize(void);
static void DynamicResolution(void) void I_DynamicResolution(void)
{ {
if (resolution_mode != RES_DRS || frametime_withoutpresent == 0 || if (resolution_mode != RES_DRS || frametime_withoutpresent == 0 ||
frametime_withoutpresent > 1000000 / 15) frametime_withoutpresent > 1000000 / 15)
@ -494,9 +494,10 @@ static void DynamicResolution(void)
double actualpercent = actual / target; double actualpercent = actual / target;
#define DRS_MIN_HEIGHT 400 #define DRS_MIN_HEIGHT 400
#define DRS_DELTA 0.5 #define DRS_DELTA 0.01
#define DRS_GREATER (1 + DRS_DELTA) #define DRS_GREATER (1 + DRS_DELTA)
#define DRS_LESS (1 - DRS_DELTA) #define DRS_LESS (1 - DRS_DELTA)
#define DRS_STEP (SCREENHEIGHT / 2)
int newheight = 0; int newheight = 0;
int oldheight = video.height; int oldheight = video.height;
@ -516,6 +517,15 @@ static void DynamicResolution(void)
return; return;
} }
int mul = (newheight + (DRS_STEP - 1)) / DRS_STEP; // integer round
newheight = mul * DRS_STEP;
if (newheight > native_height_adjusted)
{
newheight -= DRS_STEP;
}
if (newheight == oldheight) if (newheight == oldheight)
{ {
return; return;
@ -563,8 +573,8 @@ void I_FinishUpdate(void)
time = frametime_start - last_time; time = frametime_start - last_time;
// Update FPS counter every second // Update FPS counter every 10th of second
if (time >= 1000000) if (time >= 100000)
{ {
fps = (frame_counter * 1000000) / time; fps = (frame_counter * 1000000) / time;
frame_counter = 0; frame_counter = 0;
@ -590,11 +600,6 @@ void I_FinishUpdate(void)
I_ResetScreen(); I_ResetScreen();
need_reset = false; need_reset = false;
} }
else if (enable_drs)
{
DynamicResolution();
enable_drs = false;
}
if (need_resize) if (need_resize)
{ {
@ -966,14 +971,16 @@ static void ResetResolution(int height)
{ {
int w, h; int w, h;
int unscaled_ah = use_aspect ? ACTUALHEIGHT : SCREENHEIGHT;
actualheight = use_aspect ? (int)(height * 1.2) : height; actualheight = use_aspect ? (int)(height * 1.2) : height;
video.height = height; video.height = height;
switch (widescreen) switch (widescreen)
{ {
case RATIO_ORIG: case RATIO_ORIG:
w = 4; w = SCREENWIDTH;
h = 3; h = unscaled_ah;
break; break;
case RATIO_MATCH_SCREEN: case RATIO_MATCH_SCREEN:
w = native_width; w = native_width;
@ -1004,14 +1011,11 @@ static void ResetResolution(int height)
aspect_ratio = 2.4; aspect_ratio = 2.4;
} }
video.unscaledw = (int)(ACTUALHEIGHT * aspect_ratio); video.unscaledw = (int)(unscaled_ah * aspect_ratio);
video.width = (int)(actualheight * aspect_ratio);
// width and height shoud be even double vertscale = (double)actualheight / (double)unscaled_ah;
video.unscaledw = (video.unscaledw + 1) & ~1; video.width = (int)(video.unscaledw * vertscale);
video.width = (video.width + 1) & ~1; video.width = (video.width + 1) & ~1;
video.height = (video.height + 1) & ~1;
actualheight = (actualheight + 1) & ~1;
video.deltaw = (video.unscaledw - NONWIDEWIDTH) / 2; video.deltaw = (video.unscaledw - NONWIDEWIDTH) / 2;

View File

@ -51,20 +51,22 @@ typedef enum
// determines the hardware configuration // determines the hardware configuration
// and sets up the video mode // and sets up the video mode
void I_InitGraphics (void); void I_InitGraphics(void);
void I_ShutdownGraphics(void); void I_ShutdownGraphics(void);
// Takes full 8 bit values. // Takes full 8 bit values.
void I_SetPalette (byte* palette); void I_SetPalette(byte* palette);
void I_FinishUpdate (void); void I_FinishUpdate(void);
void I_ReadScreen (byte* scr); void I_ReadScreen(byte* dst);
void I_ResetScreen(void); // killough 10/98 void I_ResetScreen(void); // killough 10/98
void I_ResetTargetRefresh(void); void I_ResetTargetRefresh(void);
void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle
void I_DynamicResolution(void);
extern boolean use_vsync; // killough 2/8/98: controls whether vsync is called extern boolean use_vsync; // killough 2/8/98: controls whether vsync is called
extern boolean disk_icon; // killough 10/98 extern boolean disk_icon; // killough 10/98
extern resolution_mode_t resolution_mode, default_resolution_mode; extern resolution_mode_t resolution_mode, default_resolution_mode;