Skip to content

Commit

Permalink
initial version of HOM test
Browse files Browse the repository at this point in the history
  • Loading branch information
rfomin committed Feb 21, 2024
1 parent 81ebfef commit b5a2dd3
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ char **wadfiles;

boolean devparm; // started game with -devparm

boolean run_test;

// jff 1/24/98 add new versions of these variables to remember command line
boolean clnomonsters; // checkparm of -nomonsters
boolean clrespawnparm; // checkparm of -respawn
Expand Down Expand Up @@ -2931,6 +2933,11 @@ void D_DoomMain(void)
I_AtExitPrio(D_EndDoom, false, "D_EndDoom", exit_priority_last);
}

if (M_ParmExists("-test"))
{
run_test = true;
}

TryRunTics();

D_StartGameLoop();
Expand All @@ -2940,6 +2947,18 @@ void D_DoomMain(void)
// frame syncronous IO operations
I_StartFrame ();

if (run_test)
{
static int oldgametic = 3;

if (gametic >= oldgametic)
{
oldgametic = gametic + 3;
if (!I_ChangeRes())
I_SafeExit(0);
}
}

TryRunTics (); // will run at least one tic

// Update display, next frame, with current state.
Expand Down
2 changes: 2 additions & 0 deletions src/d_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void D_PageDrawer(void);
void D_AdvanceDemo(void);
void D_StartTitle(void);

extern boolean run_test;

#endif

//----------------------------------------------------------------------------
Expand Down
59 changes: 59 additions & 0 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,65 @@ void I_InitGraphics(void)
ResetLogicalSize();
}

static struct {
int w, h;
} native_res[] = {
//{ 320, 240 },
{ 640, 480 },
{ 800, 600 },
{ 1024, 768 },
//{ 1280, 1024 },
{ 1280, 720 },
{ 1280, 800 },
{ 1366, 768 },
{ 1440, 900 },
{ 1440, 1080 },
{ 1680, 1050 },
{ 1920, 1080 },
{ 1920, 1200 },
{ 2048, 1152 },
{ 2560, 1080 },
{ 2304, 1440 },
{ 2560, 1600 },
{ 3200, 2400 },
{ 3840, 2160 },
{ 5120, 2160 }
};

static int curr_test_res;

boolean I_ChangeRes(void)
{
native_width = native_res[curr_test_res].w;
native_height = native_res[curr_test_res].h;

native_height_adjusted = (int)(native_height / 1.2);

ResetResolution(native_height_adjusted, true);
CreateSurfaces(video.pitch, video.height);
ResetLogicalSize();

curr_test_res++;

if (curr_test_res == arrlen(native_res))
return false;

return true;
}

void I_CheckHOM(void)
{
for (int i = 0; i < video.height; ++i)
{
if (I_VideoBuffer[video.width - 1] == v_lightest_color)
{
printf("HOM %dx%d\n",
native_res[curr_test_res].w, native_res[curr_test_res].h);
break;
}
}
}

//----------------------------------------------------------------------------
//
// $Log: i_video.c,v $
Expand Down
3 changes: 3 additions & 0 deletions src/i_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ void I_InitWindowIcon(void);
void I_ShowMouseCursor(boolean on);
void I_ResetRelativeMouseState(void);

boolean I_ChangeRes(void);
void I_CheckHOM(void);

#endif

//----------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions src/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <string.h>

#include "d_loop.h"
#include "d_main.h"
#include "d_player.h"
#include "doomdata.h"
#include "doomdef.h"
Expand Down Expand Up @@ -853,6 +854,12 @@ void R_RenderPlayerView (player_t* player)
R_ClearSprites ();
VX_ClearVoxels ();

if (run_test)
{
V_FillRect(scaledviewx, scaledviewy, scaledviewwidth, scaledviewheight,
v_lightest_color);
}

if (autodetect_hom)
{ // killough 2/10/98: add flashing red HOM indicators
pixel_t c[47*47];
Expand Down Expand Up @@ -948,6 +955,8 @@ void R_RenderPlayerView (player_t* player)
R_SetFuzzPosDraw();
R_DrawMasked ();

I_CheckHOM();

// Check for new console commands.
NetUpdate ();
}
Expand Down

0 comments on commit b5a2dd3

Please sign in to comment.