DEADSOFTWARE

Sound: Initial OpenAL driver impl
[d2df-sdl.git] / src / game / Doom2DF.lpr
index c86d7441e795240e6d4ec170060d2f34cc45f406..546cabf9f423cee29481327d8b4f4fca3b5a6190 100644 (file)
@@ -51,6 +51,11 @@ uses
   SDL2 in '../lib/sdl2/sdl2.pas',
 {$IFDEF USE_SDLMIXER}
   SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas',
+{$ENDIF}
+{$IFDEF USE_OPENAL}
+  AL in '../lib/openal/al.pas',
+  e_soundfile in '../engine/e_soundfile.pas',
+  e_soundfile_wav in '../engine/e_soundfile_wav.pas',
 {$ENDIF}
   ENet in '../lib/enet/enet.pp',
   e_graphics in '../engine/e_graphics.pas',
@@ -141,6 +146,9 @@ function SDL_main(argc: CInt; argv: PPChar): CInt; cdecl;
 var
   f: Integer;
   noct: Boolean = false;
+{$IFDEF ANDROID}
+  storage: String;
+{$ENDIF}
   //tfo: Text;
 begin
   SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
@@ -148,26 +156,53 @@ begin
 {$IFDEF ANDROID}
 {$I-}
   e_SetSafeSlowLog(true);
-  Chdir(SDL_AndroidGetExternalStoragePath());
+  if SDL_AndroidGetExternalStorageState() <> 0 then
+  begin
+    storage := SDL_AndroidGetExternalStoragePath();
+    Chdir(storage);
+    e_WriteLog('Use external storage: ' + storage, TMsgType.Notify)
+  end
+  else
+  begin
+    storage := SDL_AndroidGetInternalStoragePath();
+    Chdir(storage);
+    e_WriteLog('Use internal storage: ' + storage, TMsgType.Notify)
+  end;
   if IOresult <> 0 then
   begin
-    Chdir(SDL_AndroidGetInternalStoragePath());
-    if IOresult <> 0 then
-    begin
-      e_WriteLog('Fuck! Cant chdir to any game directory :(', TMsgType.Fatal);
-      result := 1;
-      exit;
-    end;
+    SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, PChar('Invalid path'), PChar('Can''t chdir to ' + storage), nil);
+    result := 1;
+    exit
   end;
   SetEnvVar('TIMIDITY_CFG', 'timidity.cfg');
 {$ENDIF ANDROID}
 
-  for f := 1 to ParamCount do
+  f := 1;
+  while f <= ParamCount do
+  begin
+    case ParamStr(f) of
+    '--gdb': noct := true;
+    '--log': conbufDumpToStdOut := true;
+    '--safe-log': e_SetSafeSlowLog(true);
+    '--log-file':
+      if f + 1 <= ParamCount then
+      begin
+        Inc(f);
+        LogFileName := ParamStr(f)
+      end;
+    end;
+    Inc(f)
+  end;
+
+  if LogFileName = '' then
   begin
-         if ParamStr(f) = '--gdb' then noct := true
-    else if ParamStr(f) = '--log' then conbufDumpToStdOut := true
-    else if ParamStr(f) = '--safe-log' then e_SetSafeSlowLog(true);
+{$IFDEF HEADLESS}
+    LogFileName := 'Doom2DF_H.log';
+{$ELSE}
+    LogFileName := 'Doom2DF.log';
+{$ENDIF}
   end;
+
   if noct then
   begin
     Main()