DEADSOFTWARE

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