DEADSOFTWARE

0e7d21877ce2ee6ffa2867fdc7b1d8da3bda1807
[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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 {$IFDEF ANDROID}library{$ELSE}program{$ENDIF} Doom2DF;
18 {$IFNDEF HEADLESS}
19 {$IFDEF WINDOWS}
20 {$APPTYPE GUI}
21 {$ENDIF}
22 {$ENDIF}
23 {$HINTS OFF}
25 {$IF DEFINED(USE_SDLMIXER)}
26 {$IF DEFINED(USE_FMOD) OR DEFINED(USE_OPENAL)}
27 {$ERROR Only one sound driver must be selected!}
28 {$ENDIF}
29 {$ELSEIF DEFINED(USE_FMOD)}
30 {$IF DEFINED(USE_SDLMIXER) OR DEFINED(USE_OPENAL)}
31 {$ERROR Only one sound driver must be selected!}
32 {$ENDIF}
33 {$ELSEIF DEFINED(USE_OPENAL)}
34 {$IF DEFINED(USE_SDLMIXER) OR DEFINED(USE_FMOD)}
35 {$ERROR Only one sound driver must be selected!}
36 {$ENDIF}
37 {$ELSE}
38 {$ERROR Sound driver not selected. Use -DUSE_SDLMIXER or -DUSE_FMOD or -DUSE_OPENAL}
39 {$ENDIF}
41 uses
42 {$IFDEF ANDROID}
43 ctypes,
44 {$ENDIF}
45 {$IFDEF UNIX}
46 cthreads,
47 {$ENDIF}
48 mempool in '../shared/mempool.pas',
49 conbuf in '../shared/conbuf.pas',
50 geom in '../shared/geom.pas',
51 math,
53 {$INCLUDE ../nogl/noGLuses.inc}
55 {$IFDEF USE_MINIUPNPC}
56 miniupnpc in '../lib/miniupnpc/miniupnpc.pas',
57 {$ENDIF}
58 SDL2 in '../lib/sdl2/sdl2.pas',
59 {$IFDEF USE_SDLMIXER}
60 SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas',
61 {$ENDIF}
62 {$IFDEF USE_OPENAL}
63 AL in '../lib/openal/al.pas',
64 e_soundfile in '../engine/e_soundfile.pas',
65 e_soundfile_wav in '../engine/e_soundfile_wav.pas',
66 {$IFDEF USE_VORBIS}
67 vorbis in '../lib/vorbis/vorbis.pas',
68 ogg in '../lib/vorbis/ogg.pas',
69 e_soundfile_ogg in '../engine/e_soundfile_ogg.pas',
70 {$ENDIF}
71 {$IFDEF USE_FLUIDSYNTH}
72 fluidsynth in '../lib/fluidsynth/fluidsynth.pas',
73 e_soundfile_fluid in '../engine/e_soundfile_fluid.pas',
74 {$ENDIF}
75 {$IFDEF USE_MODPLUG}
76 modplug in '../lib/modplug/modplug.pas',
77 e_soundfile_modplug in '../engine/e_soundfile_modplug.pas',
78 {$ENDIF}
79 {$IFDEF USE_XMP}
80 xmp in '../lib/xmp/xmp.pas',
81 e_soundfile_xmp in '../engine/e_soundfile_xmp.pas',
82 {$ENDIF}
83 {$IFDEF USE_MPG123}
84 mpg123 in '../lib/mpg123/mpg123.pas',
85 e_soundfile_mp3 in '../engine/e_soundfile_mp3.pas',
86 {$ENDIF}
87 {$ENDIF}
88 ENet in '../lib/enet/enet.pp',
89 e_graphics in '../engine/e_graphics.pas',
90 e_input in '../engine/e_input.pas',
91 e_log in '../engine/e_log.pas',
92 e_sound in '../engine/e_sound.pas',
93 e_texture in '../engine/e_texture.pas',
94 e_msg in '../engine/e_msg.pas',
95 utils in '../shared/utils.pas',
96 xstreams in '../shared/xstreams.pas',
97 sfs in '../sfs/sfs.pas',
98 sfsPlainFS in '../sfs/sfsPlainFS.pas',
99 sfsZipFS in '../sfs/sfsZipFS.pas',
100 wadreader in '../shared/wadreader.pas',
101 MAPDEF in '../shared/MAPDEF.pas',
102 CONFIG in '../shared/CONFIG.pas',
103 g_basic in 'g_basic.pas',
104 g_console in 'g_console.pas',
105 g_net in 'g_net.pas',
106 g_netmsg in 'g_netmsg.pas',
107 g_nethandler in 'g_nethandler.pas',
108 g_netmaster in 'g_netmaster.pas',
109 g_res_downloader in 'g_res_downloader.pas',
110 g_grid in 'g_grid.pas',
111 g_game in 'g_game.pas',
112 g_gfx in 'g_gfx.pas',
113 g_gui in 'g_gui.pas',
114 g_items in 'g_items.pas',
115 g_main in 'g_main.pas',
116 g_map in 'g_map.pas',
117 g_menu in 'g_menu.pas',
118 g_monsters in 'g_monsters.pas',
119 g_options in 'g_options.pas',
120 g_phys in 'g_phys.pas',
121 g_player in 'g_player.pas',
122 g_playermodel in 'g_playermodel.pas',
123 g_saveload in 'g_saveload.pas',
124 g_sound in 'g_sound.pas',
125 g_textures in 'g_textures.pas',
126 g_triggers in 'g_triggers.pas',
127 g_weapons in 'g_weapons.pas',
128 g_window in 'g_window.pas',
129 SysUtils,
130 {$IFDEF USE_FMOD}
131 fmod in '../lib/FMOD/fmod.pas',
132 fmoderrors in '../lib/FMOD/fmoderrors.pas',
133 fmodpresets in '../lib/FMOD/fmodpresets.pas',
134 fmodtypes in '../lib/FMOD/fmodtypes.pas',
135 {$ENDIF}
136 xprofiler in '../shared/xprofiler.pas',
137 binheap in '../shared/binheap.pas',
138 hashtable in '../shared/hashtable.pas',
139 idpool in '../shared/idpool.pas',
140 xparser in '../shared/xparser.pas',
141 xdynrec in '../shared/xdynrec.pas',
142 exoma in '../shared/exoma.pas',
143 envvars in '../shared/envvars.pas',
144 g_panel in 'g_panel.pas',
145 g_language in 'g_language.pas',
147 {$IFDEF ENABLE_HOLMES}
148 g_holmes in 'g_holmes.pas',
150 sdlcarcass in '../flexui/sdlcarcass.pas',
151 //sdlstandalone in '../flexui/sdlstandalone.pas',
153 fui_wadread in '../flexui/fui_wadread.pas',
154 fui_common in '../flexui/fui_common.pas',
155 fui_gfx_gl in '../flexui/fui_gfx_gl.pas',
156 fui_events in '../flexui/fui_events.pas',
157 fui_style in '../flexui/fui_style.pas',
158 fui_flexlay in '../flexui/fui_flexlay.pas',
159 fui_ctls in '../flexui/fui_ctls.pas',
160 {$ENDIF}
162 ImagingTypes,
163 Imaging,
164 ImagingUtility;
166 {$IFDEF WINDOWS}
167 {$R *.res}
168 {$ENDIF}
170 {$IFDEF ANDROID}
171 function SDL_main(argc: CInt; argv: PPChar): CInt; cdecl;
172 {$ENDIF ANDROID}
174 var
175 f: Integer;
176 noct: Boolean = false;
177 {$IFDEF ANDROID}
178 storage: String;
179 {$ENDIF}
180 //tfo: Text;
181 begin
182 SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
184 {$IFDEF ANDROID}
185 {$I-}
186 e_SetSafeSlowLog(true);
187 if SDL_AndroidGetExternalStorageState() <> 0 then
188 begin
189 storage := SDL_AndroidGetExternalStoragePath();
190 Chdir(storage);
191 e_WriteLog('Use external storage: ' + storage, TMsgType.Notify)
192 end
193 else
194 begin
195 storage := SDL_AndroidGetInternalStoragePath();
196 Chdir(storage);
197 e_WriteLog('Use internal storage: ' + storage, TMsgType.Notify)
198 end;
199 if IOresult <> 0 then
200 begin
201 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, PChar('Invalid path'), PChar('Can''t chdir to ' + storage), nil);
202 result := 1;
203 exit
204 end;
205 SetEnvVar('TIMIDITY_CFG', 'timidity.cfg');
206 {$ENDIF ANDROID}
208 f := 1;
209 while f <= ParamCount do
210 begin
211 case ParamStr(f) of
212 '--gdb': noct := true;
213 '--log': conbufDumpToStdOut := true;
214 '--safe-log': e_SetSafeSlowLog(true);
215 '--log-file':
216 if f + 1 <= ParamCount then
217 begin
218 Inc(f);
219 LogFileName := ParamStr(f)
220 end;
221 end;
222 Inc(f)
223 end;
225 if LogFileName = '' then
226 begin
227 {$IFDEF HEADLESS}
228 LogFileName := 'Doom2DF_H.log';
229 {$ELSE}
230 LogFileName := 'Doom2DF.log';
231 {$ENDIF}
232 end;
234 if noct then
235 begin
236 Main()
237 end
238 else
239 begin
240 try
241 Main();
242 e_WriteLog('Shutdown with no errors.', TMsgType.Notify);
243 except
244 on e: Exception do
245 begin
246 e_WriteStackTrace(e.message);
247 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_MSG], [E.Message]), MSG_FATALERROR);
248 (*
249 AssignFile(tfo, GameDir+'/trace.log');
250 {$I-}
251 Append(tfo);
252 if (IOResult <> 0) then Rewrite(tfo);
253 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
254 *)
255 end
256 else
257 begin
258 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [NativeUInt(ExceptAddr())]), MSG_FATALERROR);
259 e_WriteStackTrace('FATAL ERROR');
260 end;
261 end;
262 end;
263 e_DeinitLog();
265 {$IFDEF ANDROID}
266 result := 0;
267 end; // SDL_main
268 exports SDL_main;
269 {$ENDIF ANDROID}
270 end.