Skip to content

Commit f15c58e

Browse files
committed
initial version of HOM test
1 parent 81ebfef commit f15c58e

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

src/d_main.c

+19
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ char **wadfiles;
133133

134134
boolean devparm; // started game with -devparm
135135

136+
boolean run_test;
137+
136138
// jff 1/24/98 add new versions of these variables to remember command line
137139
boolean clnomonsters; // checkparm of -nomonsters
138140
boolean clrespawnparm; // checkparm of -respawn
@@ -2931,6 +2933,11 @@ void D_DoomMain(void)
29312933
I_AtExitPrio(D_EndDoom, false, "D_EndDoom", exit_priority_last);
29322934
}
29332935

2936+
if (M_ParmExists("-test"))
2937+
{
2938+
run_test = true;
2939+
}
2940+
29342941
TryRunTics();
29352942

29362943
D_StartGameLoop();
@@ -2940,6 +2947,18 @@ void D_DoomMain(void)
29402947
// frame syncronous IO operations
29412948
I_StartFrame ();
29422949

2950+
if (run_test)
2951+
{
2952+
static int oldgametic = 3;
2953+
2954+
if (gametic >= oldgametic)
2955+
{
2956+
oldgametic = gametic + 3;
2957+
if (!I_ChangeRes())
2958+
I_SafeExit(0);
2959+
}
2960+
}
2961+
29432962
TryRunTics (); // will run at least one tic
29442963

29452964
// Update display, next frame, with current state.

src/d_main.h

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ void D_PageDrawer(void);
5959
void D_AdvanceDemo(void);
6060
void D_StartTitle(void);
6161

62+
extern boolean run_test;
63+
6264
#endif
6365

6466
//----------------------------------------------------------------------------

src/i_video.c

+58
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,64 @@ void I_InitGraphics(void)
16981698
ResetLogicalSize();
16991699
}
17001700

1701+
static struct {
1702+
int w, h;
1703+
} native_res[] = {
1704+
//{ 320, 240 },
1705+
{ 640, 480 },
1706+
{ 800, 600 },
1707+
{ 1024, 768 },
1708+
//{ 1280, 1024 },
1709+
{ 1280, 720 },
1710+
{ 1280, 800 },
1711+
{ 1366, 768 },
1712+
{ 1440, 900 },
1713+
{ 1440, 1080 },
1714+
{ 1680, 1050 },
1715+
{ 1920, 1080 },
1716+
{ 1920, 1200 },
1717+
{ 2048, 1152 },
1718+
{ 2560, 1080 },
1719+
{ 2304, 1440 },
1720+
{ 2560, 1600 },
1721+
{ 3200, 2400 },
1722+
{ 3840, 2160 },
1723+
{ 5120, 2160 }
1724+
};
1725+
1726+
static int index;
1727+
1728+
boolean I_ChangeRes(void)
1729+
{
1730+
native_width = native_res[index].w;
1731+
native_height = native_res[index].h;
1732+
1733+
native_height_adjusted = (int)(native_height / 1.2);
1734+
1735+
ResetResolution(native_height_adjusted, true);
1736+
CreateSurfaces(video.pitch, video.height);
1737+
ResetLogicalSize();
1738+
1739+
index++;
1740+
1741+
if (index == arrlen(native_res))
1742+
return false;
1743+
1744+
return true;
1745+
}
1746+
1747+
void I_CheckHOM(void)
1748+
{
1749+
for (int i = 0; i < video.height; ++i)
1750+
{
1751+
if (I_VideoBuffer[video.width - 1] == v_lightest_color)
1752+
{
1753+
printf("HOM %dx%d\n", native_res[index].w, native_res[index].h);
1754+
break;
1755+
}
1756+
}
1757+
}
1758+
17011759
//----------------------------------------------------------------------------
17021760
//
17031761
// $Log: i_video.c,v $

src/i_video.h

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ void I_InitWindowIcon(void);
107107
void I_ShowMouseCursor(boolean on);
108108
void I_ResetRelativeMouseState(void);
109109

110+
boolean I_ChangeRes(void);
111+
void I_CheckHOM(void);
112+
110113
#endif
111114

112115
//----------------------------------------------------------------------------

src/r_main.c

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <string.h>
2727

2828
#include "d_loop.h"
29+
#include "d_main.h"
2930
#include "d_player.h"
3031
#include "doomdata.h"
3132
#include "doomdef.h"
@@ -853,6 +854,12 @@ void R_RenderPlayerView (player_t* player)
853854
R_ClearSprites ();
854855
VX_ClearVoxels ();
855856

857+
if (run_test)
858+
{
859+
V_FillRect(scaledviewx, scaledviewy, scaledviewwidth, scaledviewheight,
860+
v_lightest_color);
861+
}
862+
856863
if (autodetect_hom)
857864
{ // killough 2/10/98: add flashing red HOM indicators
858865
pixel_t c[47*47];
@@ -948,6 +955,8 @@ void R_RenderPlayerView (player_t* player)
948955
R_SetFuzzPosDraw();
949956
R_DrawMasked ();
950957

958+
I_CheckHOM();
959+
951960
// Check for new console commands.
952961
NetUpdate ();
953962
}

0 commit comments

Comments
 (0)