DEADSOFTWARE

758c4f9eb4fa2abc003b363db081ee87fa2f2fa1
[d2df-sdl.git] / src / game / Doom2DF.lpr
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 {$IFDEF ANDROID}library{$ELSE}program{$ENDIF} Doom2DF;
17 {$IFNDEF HEADLESS}
18 {$IFDEF WINDOWS}
19 {$APPTYPE GUI}
20 {$ENDIF}
21 {$ENDIF}
22 {$HINTS OFF}
24 {$IF DEFINED(USE_SYSSTUB)}
25 {$IF DEFINED(USE_SDL) OR DEFINED(USE_SDL2)}
26 {$ERROR Only one system driver must be selected!}
27 {$ENDIF}
28 {$ELSEIF DEFINED(USE_SDL)}
29 {$IF DEFINED(USE_SYSSTUB) OR DEFINED(USE_SDL2)}
30 {$ERROR Only one system driver must be selected!}
31 {$ENDIF}
32 {$ELSEIF DEFINED(USE_SDL2)}
33 {$IF DEFINED(USE_SYSSTUB) OR DEFINED(USE_SDL)}
34 {$ERROR Only one system driver must be selected!}
35 {$ENDIF}
36 {$ELSE}
37 {$ERROR System driver not selected. Use -dUSE_SYSSTUB or -dUSE_SDL or -dUSE_SDL2}
38 {$ENDIF}
40 {$IF DEFINED(USE_SOUNDSTUB)}
41 {$IF DEFINED(USE_SDLMIXER) OR DEFINED(USE_FMOD) OR DEFINED(USE_OPENAL)}
42 {$ERROR Only one sound driver must be selected!}
43 {$ENDIF}
44 {$ELSEIF DEFINED(USE_SDLMIXER)}
45 {$IF DEFINED(USE_SOUNDSTUB) OR DEFINED(USE_FMOD) OR DEFINED(USE_OPENAL)}
46 {$ERROR Only one sound driver must be selected!}
47 {$ENDIF}
48 {$ELSEIF DEFINED(USE_FMOD)}
49 {$IF DEFINED(USE_SOUNDSTUB) OR DEFINED(USE_SDLMIXER) OR DEFINED(USE_OPENAL)}
50 {$ERROR Only one sound driver must be selected!}
51 {$ENDIF}
52 {$ELSEIF DEFINED(USE_OPENAL)}
53 {$IF DEFINED(USE_SOUNDSTUB) OR DEFINED(USE_SDLMIXER) OR DEFINED(USE_FMOD)}
54 {$ERROR Only one sound driver must be selected!}
55 {$ENDIF}
56 {$ELSE}
57 {$ERROR Sound driver not selected. Use -dUSE_SOUNDSTUB or -dUSE_SDLMIXER or -dUSE_FMOD or -dUSE_OPENAL}
58 {$ENDIF}
60 {$IFDEF HEADLESS}
61 {$IFNDEF USE_SYSSTUB}
62 {$ERROR Using system driver has no sense for headless build. Use -dUSE_SYSSTUB instead}
63 {$ENDIF}
64 {$ENDIF}
66 {$IFDEF ENABLE_HOLMES}
67 {$IFDEF HEADLESS}
68 {$ERROR Holmes in HEADLESS mode has no sense}
69 {$ENDIF}
70 {$IFNDEF USE_SDL2}
71 {$ERROR Holmes supported only with SDL2}
72 {$ENDIF}
73 {$IFDEF USE_GLES1}
74 {$ERROR Holmes not supported with GLES}
75 {$ENDIF}
76 {$ENDIF}
78 uses
79 {$IFDEF ANDROID}
80 ctypes,
81 {$ENDIF}
82 {$IFDEF UNIX}
83 cthreads,
84 {$ENDIF}
85 mempool in '../shared/mempool.pas',
86 conbuf in '../shared/conbuf.pas',
87 geom in '../shared/geom.pas',
88 math,
90 {$INCLUDE ../nogl/noGLuses.inc}
92 {$IFDEF USE_MINIUPNPC}
93 miniupnpc in '../lib/miniupnpc/miniupnpc.pas',
94 {$ENDIF}
96 {$IFDEF USE_SDL}
97 SDL,
98 {$ENDIF}
99 {$IFDEF USE_SDL2}
100 SDL2 in '../lib/sdl2/sdl2.pas',
101 {$IFDEF USE_SDLMIXER}
102 SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas',
103 {$ENDIF}
104 {$ENDIF}
106 {$IFDEF USE_OPENAL}
107 AL in '../lib/openal/al.pas',
108 e_soundfile in '../engine/e_soundfile.pas',
109 {$IF DEFINED(USE_SDL) OR DEFINED(USE_SDL2)}
110 e_soundfile_wav in '../engine/e_soundfile_wav.pas',
111 {$ENDIF}
112 {$IFDEF USE_VORBIS}
113 vorbis in '../lib/vorbis/vorbis.pas',
114 e_soundfile_vorbis in '../engine/e_soundfile_vorbis.pas',
115 {$ENDIF}
116 {$IFDEF USE_FLUIDSYNTH}
117 fluidsynth in '../lib/fluidsynth/fluidsynth.pas',
118 e_soundfile_fluid in '../engine/e_soundfile_fluid.pas',
119 {$ENDIF}
120 {$IFDEF USE_MODPLUG}
121 modplug in '../lib/modplug/modplug.pas',
122 e_soundfile_modplug in '../engine/e_soundfile_modplug.pas',
123 {$ENDIF}
124 {$IFDEF USE_XMP}
125 xmp in '../lib/xmp/xmp.pas',
126 e_soundfile_xmp in '../engine/e_soundfile_xmp.pas',
127 {$ENDIF}
128 {$IFDEF USE_MPG123}
129 mpg123 in '../lib/mpg123/mpg123.pas',
130 e_soundfile_mp3 in '../engine/e_soundfile_mp3.pas',
131 {$ENDIF}
132 {$IFDEF USE_OPUS}
133 opus in '../lib/opus/opus.pas',
134 e_soundfile_opus in '../engine/e_soundfile_opus.pas',
135 {$ENDIF}
136 {$IF DEFINED(USE_VORBIS) OR DEFINED(USE_OPUS)}
137 ogg in '../lib/vorbis/ogg.pas', // this has to come last because link order
138 {$ENDIF}
139 {$ENDIF}
141 ENet in '../lib/enet/enet.pp',
142 e_graphics in '../engine/e_graphics.pas',
143 e_input in '../engine/e_input.pas',
144 e_log in '../engine/e_log.pas',
145 e_sound in '../engine/e_sound.pas',
146 e_texture in '../engine/e_texture.pas',
147 e_msg in '../engine/e_msg.pas',
148 utils in '../shared/utils.pas',
149 xstreams in '../shared/xstreams.pas',
150 sfs in '../sfs/sfs.pas',
151 sfsPlainFS in '../sfs/sfsPlainFS.pas',
152 sfsZipFS in '../sfs/sfsZipFS.pas',
153 wadreader in '../shared/wadreader.pas',
154 MAPDEF in '../shared/MAPDEF.pas',
155 CONFIG in '../shared/CONFIG.pas',
156 g_basic in 'g_basic.pas',
157 g_console in 'g_console.pas',
158 g_net in 'g_net.pas',
159 g_netmsg in 'g_netmsg.pas',
160 g_nethandler in 'g_nethandler.pas',
161 g_netmaster in 'g_netmaster.pas',
162 g_res_downloader in 'g_res_downloader.pas',
163 g_grid in 'g_grid.pas',
164 g_game in 'g_game.pas',
165 g_gfx in 'g_gfx.pas',
166 g_gui in 'g_gui.pas',
167 g_items in 'g_items.pas',
168 g_main in 'g_main.pas',
169 g_map in 'g_map.pas',
170 g_menu in 'g_menu.pas',
171 g_monsters in 'g_monsters.pas',
172 g_options in 'g_options.pas',
173 g_phys in 'g_phys.pas',
174 g_player in 'g_player.pas',
175 g_playermodel in 'g_playermodel.pas',
176 g_saveload in 'g_saveload.pas',
177 g_sound in 'g_sound.pas',
178 g_textures in 'g_textures.pas',
179 g_triggers in 'g_triggers.pas',
180 g_weapons in 'g_weapons.pas',
181 g_window in 'g_window.pas',
182 {$IFDEF USE_SYSSTUB}
183 g_system in 'stub/g_system.pas',
184 g_touch in 'stub/g_touch.pas',
185 {$ENDIF}
186 {$IFDEF USE_SDL}
187 g_system in 'sdl/g_system.pas',
188 g_touch in 'sdl/g_touch.pas',
189 {$ENDIF}
190 {$IFDEF USE_SDL2}
191 g_system in 'sdl2/g_system.pas',
192 g_touch in 'sdl2/g_touch.pas',
193 {$ENDIF}
195 SysUtils,
196 {$IFDEF USE_FMOD}
197 fmod in '../lib/FMOD/fmod.pas',
198 fmoderrors in '../lib/FMOD/fmoderrors.pas',
199 fmodpresets in '../lib/FMOD/fmodpresets.pas',
200 fmodtypes in '../lib/FMOD/fmodtypes.pas',
201 {$ENDIF}
202 xprofiler in '../shared/xprofiler.pas',
203 binheap in '../shared/binheap.pas',
204 hashtable in '../shared/hashtable.pas',
205 fhashdb in '../shared/fhashdb.pas',
206 idpool in '../shared/idpool.pas',
207 xparser in '../shared/xparser.pas',
208 xdynrec in '../shared/xdynrec.pas',
209 exoma in '../shared/exoma.pas',
210 envvars in '../shared/envvars.pas',
211 g_panel in 'g_panel.pas',
212 g_language in 'g_language.pas',
214 {$IFDEF ENABLE_HOLMES}
215 g_holmes in 'g_holmes.pas',
217 sdlcarcass in '../flexui/sdlcarcass.pas',
218 //sdlstandalone in '../flexui/sdlstandalone.pas',
220 fui_wadread in '../flexui/fui_wadread.pas',
221 fui_common in '../flexui/fui_common.pas',
222 fui_gfx_gl in '../flexui/fui_gfx_gl.pas',
223 fui_events in '../flexui/fui_events.pas',
224 fui_style in '../flexui/fui_style.pas',
225 fui_flexlay in '../flexui/fui_flexlay.pas',
226 fui_ctls in '../flexui/fui_ctls.pas',
227 {$ENDIF}
229 ImagingTypes,
230 Imaging,
231 ImagingUtility;
233 {$IFDEF WINDOWS}
234 {$R *.res}
235 {$ENDIF}
237 {$IFDEF ANDROID}
238 function SDL_main(argc: CInt; argv: PPChar): CInt; cdecl;
239 {$ENDIF ANDROID}
241 var
242 f: Integer;
243 noct: Boolean = false;
244 {$IFDEF ANDROID}
245 storage: String;
246 {$ENDIF}
247 //tfo: Text;
248 begin
249 SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
251 {$IFDEF ANDROID}
252 {$I-}
253 e_SetSafeSlowLog(true);
254 if SDL_AndroidGetExternalStorageState() <> 0 then
255 begin
256 storage := SDL_AndroidGetExternalStoragePath();
257 Chdir(storage);
258 e_WriteLog('Use external storage: ' + storage, TMsgType.Notify)
259 end
260 else
261 begin
262 storage := SDL_AndroidGetInternalStoragePath();
263 Chdir(storage);
264 e_WriteLog('Use internal storage: ' + storage, TMsgType.Notify)
265 end;
266 if IOresult <> 0 then
267 begin
268 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, PChar('Invalid path'), PChar('Can''t chdir to ' + storage), nil);
269 result := 1;
270 exit
271 end;
272 SetEnvVar('TIMIDITY_CFG', 'timidity.cfg');
273 {$ENDIF ANDROID}
275 f := 1;
276 while f <= ParamCount do
277 begin
278 case ParamStr(f) of
279 '--gdb': noct := true;
280 '--log': conbufDumpToStdOut := true;
281 '--safe-log': e_SetSafeSlowLog(true);
282 '--log-file':
283 if f + 1 <= ParamCount then
284 begin
285 Inc(f);
286 LogFileName := ParamStr(f)
287 end;
288 end;
289 Inc(f)
290 end;
292 if LogFileName = '' then
293 begin
294 {$IFDEF HEADLESS}
295 LogFileName := 'Doom2DF_H.log';
296 {$ELSE}
297 LogFileName := 'Doom2DF.log';
298 {$ENDIF}
299 end;
301 if noct then
302 begin
303 Main()
304 end
305 else
306 begin
307 try
308 Main();
309 e_WriteLog('Shutdown with no errors.', TMsgType.Notify);
310 except
311 on e: Exception do
312 begin
313 e_WriteStackTrace(e.message);
314 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_MSG], [E.Message]), MSG_FATALERROR);
315 (*
316 AssignFile(tfo, GameDir+'/trace.log');
317 {$I-}
318 Append(tfo);
319 if (IOResult <> 0) then Rewrite(tfo);
320 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
321 *)
322 end
323 else
324 begin
325 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [NativeUInt(ExceptAddr())]), MSG_FATALERROR);
326 e_WriteStackTrace('FATAL ERROR');
327 end;
328 end;
329 end;
330 e_DeinitLog();
332 {$IFDEF ANDROID}
333 result := 0;
334 end; // SDL_main
335 exports SDL_main;
336 {$ENDIF ANDROID}
337 end.