DEADSOFTWARE

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