From b5a2dd3333fa8c71ff5d3c78a06a3f7165dccbe8 Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Wed, 21 Feb 2024 16:41:29 +0700 Subject: [PATCH] initial version of HOM test --- src/d_main.c | 19 +++++++++++++++++ src/d_main.h | 2 ++ src/i_video.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/i_video.h | 3 +++ src/r_main.c | 9 ++++++++ 5 files changed, 92 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 9ff1fd085..d49ac9c4b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -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 @@ -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(); @@ -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. diff --git a/src/d_main.h b/src/d_main.h index 5ede94695..5afbdc264 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -59,6 +59,8 @@ void D_PageDrawer(void); void D_AdvanceDemo(void); void D_StartTitle(void); +extern boolean run_test; + #endif //---------------------------------------------------------------------------- diff --git a/src/i_video.c b/src/i_video.c index b02e48bc5..171db1b66 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -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 $ diff --git a/src/i_video.h b/src/i_video.h index c79e5ec4a..0874d88d7 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -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 //---------------------------------------------------------------------------- diff --git a/src/r_main.c b/src/r_main.c index cfdea6236..a6dc1af92 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -26,6 +26,7 @@ #include #include "d_loop.h" +#include "d_main.h" #include "d_player.h" #include "doomdata.h" #include "doomdef.h" @@ -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]; @@ -948,6 +955,8 @@ void R_RenderPlayerView (player_t* player) R_SetFuzzPosDraw(); R_DrawMasked (); + I_CheckHOM(); + // Check for new console commands. NetUpdate (); }