DEADSOFTWARE

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