DEADSOFTWARE

Sound: OpenAL: Add MIDI support via FluidSynth
[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_FLUIDSYNTH}
67 fluidsynth in '../lib/fluidsynth/fluidsynth.pas',
68 e_soundfile_fluid in '../engine/e_soundfile_fluid.pas',
69 {$ENDIF}
70 {$IFDEF USE_MODPLUG}
71 modplug in '../lib/modplug/modplug.pas',
72 e_soundfile_modplug in '../engine/e_soundfile_modplug.pas',
73 {$ENDIF}
74 {$IFDEF USE_XMP}
75 xmp in '../lib/xmp/xmp.pas',
76 e_soundfile_xmp in '../engine/e_soundfile_xmp.pas',
77 {$ENDIF}
78 {$IFDEF USE_MPG123}
79 mpg123 in '../lib/mpg123/mpg123.pas',
80 e_soundfile_mp3 in '../engine/e_soundfile_mp3.pas',
81 {$ENDIF}
82 {$ENDIF}
83 ENet in '../lib/enet/enet.pp',
84 e_graphics in '../engine/e_graphics.pas',
85 e_input in '../engine/e_input.pas',
86 e_log in '../engine/e_log.pas',
87 e_sound in '../engine/e_sound.pas',
88 e_texture in '../engine/e_texture.pas',
89 e_msg in '../engine/e_msg.pas',
90 utils in '../shared/utils.pas',
91 xstreams in '../shared/xstreams.pas',
92 sfs in '../sfs/sfs.pas',
93 sfsPlainFS in '../sfs/sfsPlainFS.pas',
94 sfsZipFS in '../sfs/sfsZipFS.pas',
95 wadreader in '../shared/wadreader.pas',
96 MAPDEF in '../shared/MAPDEF.pas',
97 CONFIG in '../shared/CONFIG.pas',
98 g_basic in 'g_basic.pas',
99 g_console in 'g_console.pas',
100 g_net in 'g_net.pas',
101 g_netmsg in 'g_netmsg.pas',
102 g_nethandler in 'g_nethandler.pas',
103 g_netmaster in 'g_netmaster.pas',
104 g_res_downloader in 'g_res_downloader.pas',
105 g_grid in 'g_grid.pas',
106 g_game in 'g_game.pas',
107 g_gfx in 'g_gfx.pas',
108 g_gui in 'g_gui.pas',
109 g_items in 'g_items.pas',
110 g_main in 'g_main.pas',
111 g_map in 'g_map.pas',
112 g_menu in 'g_menu.pas',
113 g_monsters in 'g_monsters.pas',
114 g_options in 'g_options.pas',
115 g_phys in 'g_phys.pas',
116 g_player in 'g_player.pas',
117 g_playermodel in 'g_playermodel.pas',
118 g_saveload in 'g_saveload.pas',
119 g_sound in 'g_sound.pas',
120 g_textures in 'g_textures.pas',
121 g_triggers in 'g_triggers.pas',
122 g_weapons in 'g_weapons.pas',
123 g_window in 'g_window.pas',
124 SysUtils,
125 {$IFDEF USE_FMOD}
126 fmod in '../lib/FMOD/fmod.pas',
127 fmoderrors in '../lib/FMOD/fmoderrors.pas',
128 fmodpresets in '../lib/FMOD/fmodpresets.pas',
129 fmodtypes in '../lib/FMOD/fmodtypes.pas',
130 {$ENDIF}
131 xprofiler in '../shared/xprofiler.pas',
132 binheap in '../shared/binheap.pas',
133 hashtable in '../shared/hashtable.pas',
134 idpool in '../shared/idpool.pas',
135 xparser in '../shared/xparser.pas',
136 xdynrec in '../shared/xdynrec.pas',
137 exoma in '../shared/exoma.pas',
138 envvars in '../shared/envvars.pas',
139 g_panel in 'g_panel.pas',
140 g_language in 'g_language.pas',
142 {$IFDEF ENABLE_HOLMES}
143 g_holmes in 'g_holmes.pas',
145 sdlcarcass in '../flexui/sdlcarcass.pas',
146 //sdlstandalone in '../flexui/sdlstandalone.pas',
148 fui_wadread in '../flexui/fui_wadread.pas',
149 fui_common in '../flexui/fui_common.pas',
150 fui_gfx_gl in '../flexui/fui_gfx_gl.pas',
151 fui_events in '../flexui/fui_events.pas',
152 fui_style in '../flexui/fui_style.pas',
153 fui_flexlay in '../flexui/fui_flexlay.pas',
154 fui_ctls in '../flexui/fui_ctls.pas',
155 {$ENDIF}
157 ImagingTypes,
158 Imaging,
159 ImagingUtility;
161 {$IFDEF WINDOWS}
162 {$R *.res}
163 {$ENDIF}
165 {$IFDEF ANDROID}
166 function SDL_main(argc: CInt; argv: PPChar): CInt; cdecl;
167 {$ENDIF ANDROID}
169 var
170 f: Integer;
171 noct: Boolean = false;
172 {$IFDEF ANDROID}
173 storage: String;
174 {$ENDIF}
175 //tfo: Text;
176 begin
177 SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
179 {$IFDEF ANDROID}
180 {$I-}
181 e_SetSafeSlowLog(true);
182 if SDL_AndroidGetExternalStorageState() <> 0 then
183 begin
184 storage := SDL_AndroidGetExternalStoragePath();
185 Chdir(storage);
186 e_WriteLog('Use external storage: ' + storage, TMsgType.Notify)
187 end
188 else
189 begin
190 storage := SDL_AndroidGetInternalStoragePath();
191 Chdir(storage);
192 e_WriteLog('Use internal storage: ' + storage, TMsgType.Notify)
193 end;
194 if IOresult <> 0 then
195 begin
196 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, PChar('Invalid path'), PChar('Can''t chdir to ' + storage), nil);
197 result := 1;
198 exit
199 end;
200 SetEnvVar('TIMIDITY_CFG', 'timidity.cfg');
201 {$ENDIF ANDROID}
203 f := 1;
204 while f <= ParamCount do
205 begin
206 case ParamStr(f) of
207 '--gdb': noct := true;
208 '--log': conbufDumpToStdOut := true;
209 '--safe-log': e_SetSafeSlowLog(true);
210 '--log-file':
211 if f + 1 <= ParamCount then
212 begin
213 Inc(f);
214 LogFileName := ParamStr(f)
215 end;
216 end;
217 Inc(f)
218 end;
220 if LogFileName = '' then
221 begin
222 {$IFDEF HEADLESS}
223 LogFileName := 'Doom2DF_H.log';
224 {$ELSE}
225 LogFileName := 'Doom2DF.log';
226 {$ENDIF}
227 end;
229 if noct then
230 begin
231 Main()
232 end
233 else
234 begin
235 try
236 Main();
237 e_WriteLog('Shutdown with no errors.', TMsgType.Notify);
238 except
239 on e: Exception do
240 begin
241 e_WriteStackTrace(e.message);
242 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_MSG], [E.Message]), MSG_FATALERROR);
243 (*
244 AssignFile(tfo, GameDir+'/trace.log');
245 {$I-}
246 Append(tfo);
247 if (IOResult <> 0) then Rewrite(tfo);
248 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
249 *)
250 end
251 else
252 begin
253 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [NativeUInt(ExceptAddr())]), MSG_FATALERROR);
254 e_WriteStackTrace('FATAL ERROR');
255 end;
256 end;
257 end;
258 e_DeinitLog();
260 {$IFDEF ANDROID}
261 result := 0;
262 end; // SDL_main
263 exports SDL_main;
264 {$ENDIF ANDROID}
265 end.