From 35f9a0ca016af5ef3dac8dc6ba97dcbf659f6176 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 29 Jan 2022 21:44:13 +0300 Subject: [PATCH] system: add option -dDISABLE_SYSTEM --- src/game/Doom2DF.lpr | 41 ++++++++++++++++++++---------------- src/game/g_game.pas | 4 ++-- src/game/g_netmaster.pas | 10 ++++----- src/game/g_window.pas | 8 +++---- src/game/opengl/r_game.pas | 8 +++++-- src/game/opengl/r_render.pas | 23 +++++++++++++------- src/game/opengl/r_window.pas | 9 ++++++-- src/shared/a_modes.inc | 28 ++++++++++++++++++++++++ 8 files changed, 90 insertions(+), 41 deletions(-) diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 44d23d1..4aecd40 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -148,17 +148,18 @@ uses g_triggers in 'g_triggers.pas', g_weapons in 'g_weapons.pas', g_window in 'g_window.pas', -{$IFNDEF HEADLESS} - {$IFDEF USE_SYSSTUB} - g_system in 'stub/g_system.pas', - {$ENDIF} - {$IFDEF USE_SDL} - g_system in 'sdl/g_system.pas', - {$ENDIF} - {$IFDEF USE_SDL2} - g_system in 'sdl2/g_system.pas', + + {$IFDEF ENABLE_SYSTEM} + {$IFDEF USE_SYSSTUB} + g_system in 'stub/g_system.pas', + {$ENDIF} + {$IFDEF USE_SDL} + g_system in 'sdl/g_system.pas', + {$ENDIF} + {$IFDEF USE_SDL2} + g_system in 'sdl2/g_system.pas', + {$ENDIF} {$ENDIF} -{$ENDIF} {$IFDEF ENABLE_RENDER} {$I ../shared/vampimg.inc} @@ -266,10 +267,10 @@ var Time, Time_Delta: Int64; Frame: Int64; begin - {$IFDEF HEADLESS} - Result := False; - {$ELSE} + {$IFDEF ENABLE_SYSTEM} Result := sys_HandleInput(); + {$ELSE} + Result := False; {$ENDIF} Time := GetTickCount64(); @@ -318,10 +319,12 @@ begin gLerpFactor := 1.0 else gLerpFactor := nmin(1.0, (Time - Time_Old) / 28.0); -{$IFDEF ENABLE_RENDER} - r_Render_Draw; - sys_Repaint; -{$ENDIF} + {$IFDEF ENABLE_RENDER} + r_Render_Draw; + {$ENDIF} + {$IFDEF ENABLE_SYSTEM} + sys_Repaint; + {$ENDIF} Frame := Time end else @@ -1004,7 +1007,7 @@ end; InitPrep; e_Input_Initialize; InitSound; - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_SYSTEM} sys_Init; sys_CharPress := @CharPress; (* install hook *) sys_ScreenResize := @ScreenResize; (* install hook *) @@ -1059,6 +1062,8 @@ end; (* g_Touch_Finalize; *) {$IFDEF ENABLE_RENDER} r_Render_Finalize; + {$ENDIF} + {$IFDEF ENABLE_SYSTEM} sys_Final; {$ENDIF} g_Console_Finalize; diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 602fa42..9fdc66e 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -472,7 +472,7 @@ uses {$IFDEF ENABLE_RENDER} r_render, {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_SYSTEM} g_system, {$ENDIF} e_res, g_window, @@ -2598,7 +2598,7 @@ begin gExit := EXIT_QUIT; - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_SYSTEM} sys_RequestQuit; {$ENDIF} end; diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index 29e60e7..2774b44 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -182,7 +182,7 @@ uses {$IFDEF ENABLE_RENDER} r_render, {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_SYSTEM} g_system, {$ENDIF} e_input, e_log, g_net, g_console, @@ -1752,10 +1752,10 @@ begin if gConsoleShow or gChatShow then Exit; - {$IFDEF HEADLESS} - qm := True; - {$ELSE} + {$IFDEF ENABLE_SYSTEM} qm := sys_HandleInput(); // this updates kbd + {$ELSE} + qm := True; {$ENDIF} if qm or e_KeyPressed(IK_ESCAPE) or e_KeyPressed(VK_ESCAPE) or @@ -1793,7 +1793,7 @@ begin {$IFDEF ENABLE_RENDER} r_Render_Draw; {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_SYSTEM} sys_Repaint; {$ENDIF} diff --git a/src/game/g_window.pas b/src/game/g_window.pas index ab211a9..2b20517 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -25,7 +25,7 @@ implementation {$IFDEF ENABLE_RENDER} r_render, {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_SYSTEM} g_system, {$ENDIF} e_sound, g_net @@ -34,10 +34,10 @@ implementation procedure ProcessLoading (forceUpdate: Boolean = False); var update: Boolean; begin - {$IFDEF HEADLESS} - update := True; - {$ELSE} + {$IFDEF ENABLE_SYSTEM} update := sys_HandleInput() = False; + {$ELSE} + update := True; {$ENDIF} if update then begin diff --git a/src/game/opengl/r_game.pas b/src/game/opengl/r_game.pas index 9387ca4..672ceb4 100644 --- a/src/game/opengl/r_game.pas +++ b/src/game/opengl/r_game.pas @@ -50,9 +50,11 @@ implementation {$IFDEF ENABLE_CORPSES} g_corpses, {$ENDIF} + {$IFDEF ENABLE_SYSTEM} + g_system, + {$ENDIF} SysUtils, Classes, Math, g_base, g_basic, r_graphics, - g_system, MAPDEF, xprofiler, utils, wadreader, CONFIG, e_input, e_sound, g_language, g_console, g_triggers, g_player, g_options, g_monsters, g_map, g_panel, @@ -575,7 +577,9 @@ var begin e_TextureFontGetSize(gStdFont, ww2, hh2); - sys_HandleInput; + {$IFDEF ENABLE_SYSTEM} + sys_HandleInput; + {$ENDIF} if g_Console_Action(ACTION_SCORES) then begin diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas index 6c3729f..ffb1c4d 100644 --- a/src/game/opengl/r_render.pas +++ b/src/game/opengl/r_render.pas @@ -61,8 +61,11 @@ implementation {$IFDEF ENABLE_GFX} r_gfx, {$ENDIF} + {$IFDEF ENABLE_SYSTEM} + g_system, + {$ENDIF} SysUtils, Classes, Math, - e_log, g_system, utils, + e_log, utils, g_game, g_options, g_console, r_window, r_graphics, r_console, r_playermodel, r_textures, r_animations, r_weapons, r_items, r_monsters, r_map, r_player, r_game @@ -237,8 +240,10 @@ implementation procedure r_Render_Initialize; begin - if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then - raise Exception.Create('Failed to set videomode on startup.'); + {$IFDEF ENABLE_SYSTEM} + if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then + raise Exception.Create('Failed to set videomode on startup.'); + {$ENDIF} LoadGL; r_Window_Initialize; r_Console_Init; @@ -301,11 +306,13 @@ implementation procedure r_Render_Apply; begin - if sys_SetDisplayMode(Max(1, gRC_Width), Max(1, gRC_Height), Max(1, gBPP), gRC_FullScreen, gRC_Maximized) then - e_LogWriteln('resolution changed') - else - e_LogWriteln('resolution not changed'); - sys_EnableVSync(gVSync) + {$IFDEF ENABLE_SYSTEM} + if sys_SetDisplayMode(Max(1, gRC_Width), Max(1, gRC_Height), Max(1, gBPP), gRC_FullScreen, gRC_Maximized) then + e_LogWriteln('resolution changed') + else + e_LogWriteln('resolution not changed'); + sys_EnableVSync(gVSync) + {$ENDIF} end; function r_Render_WriteScreenShot (filename: String): Boolean; diff --git a/src/game/opengl/r_window.pas b/src/game/opengl/r_window.pas index 9b7100f..3e4075f 100644 --- a/src/game/opengl/r_window.pas +++ b/src/game/opengl/r_window.pas @@ -23,9 +23,12 @@ implementation uses {$INCLUDE ../nogl/noGLuses.inc} + {$IFDEF ENABLE_SYSTEM} + g_system, + {$ENDIF} SysUtils, Classes, e_log, utils, - r_graphics, r_game, r_console, g_system, + r_graphics, r_game, r_console, g_options, g_game, g_console, xprofiler ; @@ -61,7 +64,9 @@ implementation e_SetViewPort(0, 0, gWinSizeX, gWinSizeY); e_BlitFramebuffer(gWinSizeX, gWinSizeY); - sys_Repaint; + {$IFDEF ENABLE_SYSTEM} + sys_Repaint; + {$ENDIF} prevLoadingUpdateTime := getTimeMilli(); end; end; diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc index 9596f5b..c500a34 100644 --- a/src/shared/a_modes.inc +++ b/src/shared/a_modes.inc @@ -140,6 +140,11 @@ {$UNDEF ENABLE_RENDER} {$DEFINE DISABLE_RENDER} {$ENDIF} + {$IFDEF ENABLE_SYSTEM} + {$WARNING System in headless mode has no sense. Disabled.} + {$UNDEF ENABLE_SYSTEM} + {$DEFINE DISABLE_SYSTEM} + {$ENDIF} {$ENDIF} {$IF DEFINED(ENABLE_MENU) AND DEFINED(DISABLE_MENU)} @@ -219,6 +224,17 @@ {$ENDIF} {$ENDIF} +{$IF DEFINED(ENABLE_SYSTEM) AND DEFINED(DISABLE_SYSTEM)} + {$ERROR Select ENABLE_SYSTEM or DISABLE_SYSTEM} +{$ELSEIF NOT DEFINED(ENABLE_SYSTEM) AND NOT DEFINED(DISABLE_SYSTEM)} + // default ENABLE/DISABLE system driver + {$IFDEF HEADLESS} + {$DEFINE DISABLE_SYSTEM} + {$ELSE} + {$DEFINE ENABLE_SYSTEM} + {$ENDIF} +{$ENDIF} + {$IF DEFINED(USE_SYSSTUB)} {$IF DEFINED(USE_SDL) OR DEFINED(USE_SDL2)} {$ERROR Only one system driver must be selected!} @@ -285,3 +301,15 @@ {$ERROR Holmes supported only with desktop OpenGL} {$ENDIF} {$ENDIF} + +{$IFDEF ENABLE_MENU} + {$IFDEF DISABLE_RENDER} + {$FATAL Render driver required for current menu implementation} + {$ENDIF} +{$ENDIF} + +{$IFDEF ENABLE_TOUCH} + {$IFDEF DISABLE_SYSTEM} + {$FATAL System driver required for current touch implementation} + {$ENDIF} +{$ENDIF} -- 2.29.2