From 1e43b976bfe67d3e27398889d7fb7685bdc52bc5 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 e7999c5..5a06f52 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} @@ -263,10 +264,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(); @@ -315,10 +316,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 @@ -967,7 +970,7 @@ end; InitPrep; e_Input_Initialize; e_InitSoundSystem(NoSound); - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_SYSTEM} sys_Init; sys_CharPress := @CharPress; (* install hook *) sys_ScreenResize := @ScreenResize; (* install hook *) @@ -1022,6 +1025,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 69c1240..de56a17 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -463,7 +463,7 @@ uses {$IFDEF ENABLE_RENDER} r_render, {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_SYSTEM} g_system, {$ENDIF} e_res, g_window, @@ -2554,7 +2554,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 e708c13..120fcde 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, @@ -1751,10 +1751,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 @@ -1792,7 +1792,7 @@ begin {$IFDEF ENABLE_RENDER} r_Render_Draw; {$ENDIF} - {$IFNDEF HEALESS} + {$IFDEF ENABLE_SYSTEM} sys_Repaint; {$ENDIF} diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 027f409..a6edeae 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 286ce25..314c7e7 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 253ff7d..2a4c3e7 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 d018fa0..13ee251 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!} @@ -288,3 +304,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