DEADSOFTWARE

18f1f21ac854c050c2d928da10d4ebf4e874f437
[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_SDLMIXER)}
41 {$IF DEFINED(USE_FMOD) OR DEFINED(USE_OPENAL)}
42 {$ERROR Only one sound driver must be selected!}
43 {$ENDIF}
44 {$ELSEIF DEFINED(USE_FMOD)}
45 {$IF DEFINED(USE_SDLMIXER) OR DEFINED(USE_OPENAL)}
46 {$ERROR Only one sound driver must be selected!}
47 {$ENDIF}
48 {$ELSEIF DEFINED(USE_OPENAL)}
49 {$IF DEFINED(USE_SDLMIXER) OR DEFINED(USE_FMOD)}
50 {$ERROR Only one sound driver must be selected!}
51 {$ENDIF}
52 {$ELSE}
53 {$ERROR Sound driver not selected. Use -dUSE_SDLMIXER or -dUSE_FMOD or -dUSE_OPENAL}
54 {$ENDIF}
56 uses
57 {$IFDEF ANDROID}
58 ctypes,
59 {$ENDIF}
60 {$IFDEF UNIX}
61 cthreads,
62 {$ENDIF}
63 mempool in '../shared/mempool.pas',
64 conbuf in '../shared/conbuf.pas',
65 geom in '../shared/geom.pas',
66 math,
68 {$INCLUDE ../nogl/noGLuses.inc}
70 {$IFDEF USE_MINIUPNPC}
71 miniupnpc in '../lib/miniupnpc/miniupnpc.pas',
72 {$ENDIF}
74 {$IFDEF USE_SDL}
75 SDL,
76 {$ENDIF}
77 {$IFDEF USE_SDL2}
78 SDL2 in '../lib/sdl2/sdl2.pas',
79 {$IFDEF USE_SDLMIXER}
80 SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas',
81 {$ENDIF}
82 {$ENDIF}
84 {$IFDEF USE_OPENAL}
85 AL in '../lib/openal/al.pas',
86 e_soundfile in '../engine/e_soundfile.pas',
87 {$IF DEFINED(USE_SDL) OR DEFINED(USE_SDL2)}
88 e_soundfile_wav in '../engine/e_soundfile_wav.pas',
89 {$ENDIF}
90 {$IFDEF USE_VORBIS}
91 vorbis in '../lib/vorbis/vorbis.pas',
92 e_soundfile_vorbis in '../engine/e_soundfile_vorbis.pas',
93 {$ENDIF}
94 {$IFDEF USE_FLUIDSYNTH}
95 fluidsynth in '../lib/fluidsynth/fluidsynth.pas',
96 e_soundfile_fluid in '../engine/e_soundfile_fluid.pas',
97 {$ENDIF}
98 {$IFDEF USE_MODPLUG}
99 modplug in '../lib/modplug/modplug.pas',
100 e_soundfile_modplug in '../engine/e_soundfile_modplug.pas',
101 {$ENDIF}
102 {$IFDEF USE_XMP}
103 xmp in '../lib/xmp/xmp.pas',
104 e_soundfile_xmp in '../engine/e_soundfile_xmp.pas',
105 {$ENDIF}
106 {$IFDEF USE_MPG123}
107 mpg123 in '../lib/mpg123/mpg123.pas',
108 e_soundfile_mp3 in '../engine/e_soundfile_mp3.pas',
109 {$ENDIF}
110 {$IFDEF USE_OPUS}
111 opus in '../lib/opus/opus.pas',
112 e_soundfile_opus in '../engine/e_soundfile_opus.pas',
113 {$ENDIF}
114 {$IF DEFINED(USE_VORBIS) OR DEFINED(USE_OPUS)}
115 ogg in '../lib/vorbis/ogg.pas', // this has to come last because link order
116 {$ENDIF}
117 {$ENDIF}
119 ENet in '../lib/enet/enet.pp',
120 e_graphics in '../engine/e_graphics.pas',
121 e_input in '../engine/e_input.pas',
122 e_log in '../engine/e_log.pas',
123 e_sound in '../engine/e_sound.pas',
124 e_texture in '../engine/e_texture.pas',
125 e_msg in '../engine/e_msg.pas',
126 utils in '../shared/utils.pas',
127 xstreams in '../shared/xstreams.pas',
128 sfs in '../sfs/sfs.pas',
129 sfsPlainFS in '../sfs/sfsPlainFS.pas',
130 sfsZipFS in '../sfs/sfsZipFS.pas',
131 wadreader in '../shared/wadreader.pas',
132 MAPDEF in '../shared/MAPDEF.pas',
133 CONFIG in '../shared/CONFIG.pas',
134 g_basic in 'g_basic.pas',
135 g_console in 'g_console.pas',
136 g_net in 'g_net.pas',
137 g_netmsg in 'g_netmsg.pas',
138 g_nethandler in 'g_nethandler.pas',
139 g_netmaster in 'g_netmaster.pas',
140 g_res_downloader in 'g_res_downloader.pas',
141 g_grid in 'g_grid.pas',
142 g_game in 'g_game.pas',
143 g_gfx in 'g_gfx.pas',
144 g_gui in 'g_gui.pas',
145 g_items in 'g_items.pas',
146 g_main in 'g_main.pas',
147 g_map in 'g_map.pas',
148 g_menu in 'g_menu.pas',
149 g_monsters in 'g_monsters.pas',
150 g_options in 'g_options.pas',
151 g_phys in 'g_phys.pas',
152 g_player in 'g_player.pas',
153 g_playermodel in 'g_playermodel.pas',
154 g_saveload in 'g_saveload.pas',
155 g_sound in 'g_sound.pas',
156 g_textures in 'g_textures.pas',
157 g_triggers in 'g_triggers.pas',
158 g_weapons in 'g_weapons.pas',
159 g_window in 'g_window.pas',
160 {$IFDEF USE_SYSSTUB}
161 g_system in 'stub/g_system.pas',
162 g_touch in 'stub/g_touch.pas',
163 {$ENDIF}
164 {$IFDEF USE_SDL}
165 g_system in 'sdl/g_system.pas',
166 g_touch in 'sdl/g_touch.pas',
167 {$ENDIF}
168 {$IFDEF USE_SDL2}
169 g_system in 'sdl2/g_system.pas',
170 g_touch in 'sdl2/g_touch.pas',
171 {$ENDIF}
173 SysUtils,
174 {$IFDEF USE_FMOD}
175 fmod in '../lib/FMOD/fmod.pas',
176 fmoderrors in '../lib/FMOD/fmoderrors.pas',
177 fmodpresets in '../lib/FMOD/fmodpresets.pas',
178 fmodtypes in '../lib/FMOD/fmodtypes.pas',
179 {$ENDIF}
180 xprofiler in '../shared/xprofiler.pas',
181 binheap in '../shared/binheap.pas',
182 hashtable in '../shared/hashtable.pas',
183 fhashdb in '../shared/fhashdb.pas',
184 idpool in '../shared/idpool.pas',
185 xparser in '../shared/xparser.pas',
186 xdynrec in '../shared/xdynrec.pas',
187 exoma in '../shared/exoma.pas',
188 envvars in '../shared/envvars.pas',
189 g_panel in 'g_panel.pas',
190 g_language in 'g_language.pas',
192 {$IFDEF ENABLE_HOLMES}
193 g_holmes in 'g_holmes.pas',
195 sdlcarcass in '../flexui/sdlcarcass.pas',
196 //sdlstandalone in '../flexui/sdlstandalone.pas',
198 fui_wadread in '../flexui/fui_wadread.pas',
199 fui_common in '../flexui/fui_common.pas',
200 fui_gfx_gl in '../flexui/fui_gfx_gl.pas',
201 fui_events in '../flexui/fui_events.pas',
202 fui_style in '../flexui/fui_style.pas',
203 fui_flexlay in '../flexui/fui_flexlay.pas',
204 fui_ctls in '../flexui/fui_ctls.pas',
205 {$ENDIF}
207 ImagingTypes,
208 Imaging,
209 ImagingUtility;
211 {$IFDEF WINDOWS}
212 {$R *.res}
213 {$ENDIF}
215 {$IFDEF ANDROID}
216 function SDL_main(argc: CInt; argv: PPChar): CInt; cdecl;
217 {$ENDIF ANDROID}
219 var
220 f: Integer;
221 noct: Boolean = false;
222 {$IFDEF ANDROID}
223 storage: String;
224 {$ENDIF}
225 //tfo: Text;
226 begin
227 SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
229 {$IFDEF ANDROID}
230 {$I-}
231 e_SetSafeSlowLog(true);
232 if SDL_AndroidGetExternalStorageState() <> 0 then
233 begin
234 storage := SDL_AndroidGetExternalStoragePath();
235 Chdir(storage);
236 e_WriteLog('Use external storage: ' + storage, TMsgType.Notify)
237 end
238 else
239 begin
240 storage := SDL_AndroidGetInternalStoragePath();
241 Chdir(storage);
242 e_WriteLog('Use internal storage: ' + storage, TMsgType.Notify)
243 end;
244 if IOresult <> 0 then
245 begin
246 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, PChar('Invalid path'), PChar('Can''t chdir to ' + storage), nil);
247 result := 1;
248 exit
249 end;
250 SetEnvVar('TIMIDITY_CFG', 'timidity.cfg');
251 {$ENDIF ANDROID}
253 f := 1;
254 while f <= ParamCount do
255 begin
256 case ParamStr(f) of
257 '--gdb': noct := true;
258 '--log': conbufDumpToStdOut := true;
259 '--safe-log': e_SetSafeSlowLog(true);
260 '--log-file':
261 if f + 1 <= ParamCount then
262 begin
263 Inc(f);
264 LogFileName := ParamStr(f)
265 end;
266 end;
267 Inc(f)
268 end;
270 if LogFileName = '' then
271 begin
272 {$IFDEF HEADLESS}
273 LogFileName := 'Doom2DF_H.log';
274 {$ELSE}
275 LogFileName := 'Doom2DF.log';
276 {$ENDIF}
277 end;
279 if noct then
280 begin
281 Main()
282 end
283 else
284 begin
285 try
286 Main();
287 e_WriteLog('Shutdown with no errors.', TMsgType.Notify);
288 except
289 on e: Exception do
290 begin
291 e_WriteStackTrace(e.message);
292 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_MSG], [E.Message]), MSG_FATALERROR);
293 (*
294 AssignFile(tfo, GameDir+'/trace.log');
295 {$I-}
296 Append(tfo);
297 if (IOResult <> 0) then Rewrite(tfo);
298 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
299 *)
300 end
301 else
302 begin
303 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [NativeUInt(ExceptAddr())]), MSG_FATALERROR);
304 e_WriteStackTrace('FATAL ERROR');
305 end;
306 end;
307 end;
308 e_DeinitLog();
310 {$IFDEF ANDROID}
311 result := 0;
312 end; // SDL_main
313 exports SDL_main;
314 {$ENDIF ANDROID}
315 end.