1 /*
2  * Portions of this file are copyright Rebirth contributors and licensed as
3  * described in COPYING.txt.
4  * Portions of this file are copyright Parallax Software and licensed
5  * according to the Parallax license below.
6  * See COPYING.txt for license details.
7 
8 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
9 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
10 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
11 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
12 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
13 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
14 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
15 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
16 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
17 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
18 */
19 
20 /*
21  *
22  * Prototypes for accessing arguments.
23  *
24  */
25 
26 #pragma once
27 
28 #include <type_traits>
29 #include "dxxsconf.h"
30 #include <cstdint>
31 
32 #if DXX_USE_OGL
33 // GL Sync methods
34 enum SyncGLMethod : uint8_t {
35 	SYNC_GL_NONE=0,
36 	SYNC_GL_FENCE,
37 	SYNC_GL_FENCE_SLEEP,
38 	SYNC_GL_FINISH_AFTER_SWAP,
39 	SYNC_GL_FINISH_BEFORE_SWAP,
40 	SYNC_GL_AUTO
41 };
42 
43 #define OGL_SYNC_METHOD_DEFAULT		SYNC_GL_AUTO
44 #define OGL_SYNC_WAIT_DEFAULT		2		/* milliseconds */
45 
46 #endif
47 
48 // Struct that keeps all variables used by FindArg
49 // Prefixes are:
50 //   Sys - System Options
51 //   Ctl - Control Options
52 //   Snd - Sound Options
53 //   Gfx - Graphics Options
54 //   Ogl - OpenGL Options
55 //   Mpl - Multiplayer Options
56 //   Edi - Editor Options
57 //   Dbg - Debugging/Undocumented Options
58 #include <string>
59 #include "dxxsconf.h"
60 #include "dsx-ns.h"
61 #include "pack.h"
62 
63 namespace dcx {
64 struct CArg : prohibit_void_ptr<CArg>
65 {
66 	bool CtlNoCursor;
67 	bool CtlNoMouse;
68 	bool CtlNoStickyKeys;
69 	bool DbgForbidConsoleGrab;
70 	bool DbgShowMemInfo;
71 	bool DbgSafelog;
72 	bool SysShowCmdHelp;
73 	bool SysLowMem;
74 	int8_t SysUsePlayersDir;
75 	bool SysAutoRecordDemo;
76 	bool SysWindow;
77 	bool SysAutoDemo;
78 	bool GfxSkipHiresFNT;
79 	bool SndNoSound;
80 	bool SndNoMusic;
81 	bool SysNoBorders;
82 	bool SysNoTitles;
83 #if DXX_USE_SDLMIXER
84 	bool SndDisableSdlMixer;
85 #else
86 	static constexpr std::true_type SndDisableSdlMixer{};
87 #endif
88 #if DXX_MAX_JOYSTICKS
89 	bool CtlNoJoystick;
90 #else
91 	static constexpr std::true_type CtlNoJoystick{};
92 #endif
93 #if DXX_USE_OGL
94 	bool OglFixedFont;
95 	SyncGLMethod OglSyncMethod;
96 	bool OglDarkEdges;
97 	bool DbgUseOldTextureMerge;
98 	bool DbgGlIntensity4Ok;
99 	bool DbgGlReadPixelsOk;
100 	bool DbgGlGetTexLevelParamOk;
101 	bool DbgGlLuminance4Alpha4Ok;
102 	bool DbgGlRGBA2Ok;
103 	bool OglStereo;
104 	uint8_t OglStereoView;
105 	unsigned OglSyncWait;
106 #else
107 	bool DbgSdlHWSurface;
108 	bool DbgSdlASyncBlit;
109 #endif
110 	bool DbgNoRun;
111 	bool DbgNoDoubleBuffer;
112 	bool DbgNoCompressPigBitmap;
113 	bool DbgRenderStats;
114 	uint8_t DbgBpp;
115 	int8_t DbgVerbose;
116 	bool SysNoNiceFPS;
117 	int SysMaxFPS;
118 	uint16_t MplUdpHostPort;
119 	uint16_t MplUdpMyPort;
120 #if DXX_USE_TRACKER
121 	uint16_t MplTrackerPort;
122 	std::string MplTrackerAddr;
123 #endif
124 	std::string SysMissionDir;
125 	std::string SysHogDir;
126 	std::string SysPilot;
127 	std::string SysRecordDemoNameTemplate;
128 	std::string MplUdpHostAddr;
129 	std::string DbgAltTex;
130 #if !DXX_USE_OGL
131 	std::string DbgTexMap;
132 #endif
133 };
134 extern CArg CGameArg;
135 }
136 
137 #ifdef dsx
138 namespace dsx {
139 struct Arg : prohibit_void_ptr<Arg>
140 {
141 #if DXX_USE_SHAREPATH
142 	bool SysNoHogDir;
143 #endif
144 #ifdef DXX_BUILD_DESCENT_I
145 	bool EdiNoBm;
146 #endif
147 #ifdef DXX_BUILD_DESCENT_II
148 	bool SysNoMovies;
149 	bool GfxSkipHiresMovie;
150 	bool GfxSkipHiresGFX;
151 	int SndDigiSampleRate;
152 	std::string EdiAutoLoad;
153 	bool EdiSaveHoardData;
154 	bool EdiMacData; // also used for some read routines in non-editor build
155 #endif
156 };
157 
158 extern struct Arg GameArg;
159 
160 bool InitArgs(int argc, char **argv);
161 }
162 
163 namespace dcx {
164 #define PLAYER_DIRECTORY_TEXT	"Players/"
165 
166 __attribute_format_arg(1)
167 static inline const char *PLAYER_DIRECTORY_STRING(const char *s);
PLAYER_DIRECTORY_STRING(const char * s)168 static inline const char *PLAYER_DIRECTORY_STRING(const char *s)
169 {
170 	return &s[CGameArg.SysUsePlayersDir + sizeof(PLAYER_DIRECTORY_TEXT) - 1];
171 }
172 #define PLAYER_DIRECTORY_STRING(S)	((PLAYER_DIRECTORY_STRING)(PLAYER_DIRECTORY_TEXT S))
173 }
174 #endif
175