DEADSOFTWARE

Now android version can contain game resources in APK
[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 {$IFDEF USE_SDLMIXER}
26 {$IFDEF USE_FMOD}
27 {$ERROR define only one of USE_SDLMIXER or USE_FMOD}
28 {$ENDIF}
29 {$ELSE}
30 {$UNDEF USE_SDLMIXER}
31 {$DEFINE USE_FMOD}
32 {$ENDIF}
34 uses
35 {$IFDEF ANDROID}
36 ctypes,
37 {$ENDIF}
38 {$IFDEF UNIX}
39 cthreads,
40 {$ENDIF}
41 mempool in '../shared/mempool.pas',
42 conbuf in '../shared/conbuf.pas',
43 geom in '../shared/geom.pas',
44 math,
45 {$IFDEF USE_NANOGL}
46 nanoGL in '../lib/nanogl/nanoGL.pas',
47 {$ELSE}
48 GL,
49 GLExt,
50 {$ENDIF}
51 {$IFDEF USE_MINIUPNPC}
52 miniupnpc in '../lib/miniupnpc/miniupnpc.pas',
53 {$ENDIF}
54 SDL2 in '../lib/sdl2/sdl2.pas',
55 {$IFDEF USE_SDLMIXER}
56 SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas',
57 {$ENDIF}
58 ENet in '../lib/enet/enet.pp',
59 e_graphics in '../engine/e_graphics.pas',
60 e_input in '../engine/e_input.pas',
61 e_log in '../engine/e_log.pas',
62 e_sound in '../engine/e_sound.pas',
63 e_texture in '../engine/e_texture.pas',
64 e_msg in '../engine/e_msg.pas',
65 utils in '../shared/utils.pas',
66 xstreams in '../shared/xstreams.pas',
67 sfs in '../sfs/sfs.pas',
68 sfsPlainFS in '../sfs/sfsPlainFS.pas',
69 sfsZipFS in '../sfs/sfsZipFS.pas',
70 wadreader in '../shared/wadreader.pas',
71 MAPDEF in '../shared/MAPDEF.pas',
72 CONFIG in '../shared/CONFIG.pas',
73 g_basic in 'g_basic.pas',
74 g_console in 'g_console.pas',
75 g_net in 'g_net.pas',
76 g_netmsg in 'g_netmsg.pas',
77 g_nethandler in 'g_nethandler.pas',
78 g_netmaster in 'g_netmaster.pas',
79 g_res_downloader in 'g_res_downloader.pas',
80 g_grid in 'g_grid.pas',
81 g_game in 'g_game.pas',
82 g_gfx in 'g_gfx.pas',
83 g_gui in 'g_gui.pas',
84 g_items in 'g_items.pas',
85 g_main in 'g_main.pas',
86 g_map in 'g_map.pas',
87 g_menu in 'g_menu.pas',
88 g_monsters in 'g_monsters.pas',
89 g_options in 'g_options.pas',
90 g_phys in 'g_phys.pas',
91 g_player in 'g_player.pas',
92 g_playermodel in 'g_playermodel.pas',
93 g_saveload in 'g_saveload.pas',
94 g_sound in 'g_sound.pas',
95 g_textures in 'g_textures.pas',
96 g_triggers in 'g_triggers.pas',
97 g_weapons in 'g_weapons.pas',
98 g_window in 'g_window.pas',
99 g_holmes in 'g_holmes.pas',
100 SysUtils,
101 {$IFDEF USE_FMOD}
102 fmod in '../lib/FMOD/fmod.pas',
103 fmoderrors in '../lib/FMOD/fmoderrors.pas',
104 fmodpresets in '../lib/FMOD/fmodpresets.pas',
105 fmodtypes in '../lib/FMOD/fmodtypes.pas',
106 {$ENDIF}
107 xprofiler in '../shared/xprofiler.pas',
108 binheap in '../shared/binheap.pas',
109 hashtable in '../shared/hashtable.pas',
110 idpool in '../shared/idpool.pas',
111 xparser in '../shared/xparser.pas',
112 xdynrec in '../shared/xdynrec.pas',
113 exoma in '../shared/exoma.pas',
114 envvars in '../shared/envvars.pas',
115 g_panel in 'g_panel.pas',
116 g_language in 'g_language.pas',
118 sdlcarcass in '../flexui/sdlcarcass.pas',
119 //sdlstandalone in '../flexui/sdlstandalone.pas',
121 fui_wadread in '../flexui/fui_wadread.pas',
122 fui_common in '../flexui/fui_common.pas',
123 fui_gfx_gl in '../flexui/fui_gfx_gl.pas',
124 fui_events in '../flexui/fui_events.pas',
125 fui_style in '../flexui/fui_style.pas',
126 fui_flexlay in '../flexui/fui_flexlay.pas',
127 fui_ctls in '../flexui/fui_ctls.pas',
129 ImagingTypes,
130 Imaging,
131 ImagingUtility;
133 {$IFDEF WINDOWS}
134 {$R *.res}
135 {$ENDIF}
137 {$IFDEF ANDROID}
138 function SDL_main(argc: CInt; argv: PPChar): CInt; cdecl;
139 {$ENDIF ANDROID}
141 var
142 f: Integer;
143 noct: Boolean = false;
144 //tfo: Text;
145 begin
146 SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
148 {$IFDEF ANDROID}
149 {$I-}
150 e_SetSafeSlowLog(true);
151 Chdir(SDL_AndroidGetExternalStoragePath());
152 if IOresult <> 0 then
153 begin
154 Chdir(SDL_AndroidGetInternalStoragePath());
155 if IOresult <> 0 then
156 begin
157 e_WriteLog('Fuck! Cant chdir to any game directory :(', TMsgType.Fatal);
158 result := 1;
159 exit;
160 end;
161 end;
162 {$ENDIF ANDROID}
164 for f := 1 to ParamCount do
165 begin
166 if ParamStr(f) = '--gdb' then noct := true
167 else if ParamStr(f) = '--log' then conbufDumpToStdOut := true
168 else if ParamStr(f) = '--safe-log' then e_SetSafeSlowLog(true);
169 end;
170 if noct then
171 begin
172 Main()
173 end
174 else
175 begin
176 try
177 Main();
178 e_WriteLog('Shutdown with no errors.', TMsgType.Notify);
179 except
180 on e: Exception do
181 begin
182 e_WriteStackTrace(e.message);
183 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_MSG], [E.Message]), MSG_FATALERROR);
184 (*
185 AssignFile(tfo, GameDir+'/trace.log');
186 {$I-}
187 Append(tfo);
188 if (IOResult <> 0) then Rewrite(tfo);
189 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
190 *)
191 end
192 else
193 begin
194 //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [NativeUInt(ExceptAddr())]), MSG_FATALERROR);
195 e_WriteStackTrace('FATAL ERROR');
196 end;
197 end;
198 end;
199 e_DeinitLog();
201 {$IFDEF ANDROID}
202 result := 0;
203 end; // SDL_main
204 exports SDL_main;
205 {$ENDIF ANDROID}
206 end.