DEADSOFTWARE

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