summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 11e475e)
raw | patch | inline | side by side (parent: 11e475e)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 14 Jul 2022 01:30:35 +0000 (04:30 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 14 Jul 2022 01:30:35 +0000 (04:30 +0300) |
src/engine/e_sound_sdl.inc | patch | blob | history | |
src/game/g_main.pas | patch | blob | history |
index d8a1312669a7f7364b1807ae054fa9a9c7ef801f..f71805ef50324de7d8d9b171871d7a783605753a 100644 (file)
var
e_SoundsArray: array of TSoundRec = nil;
+ e_TimidityDecoder: Boolean; (* sdl_mixer special *)
+
implementation
uses
begin
e_WriteLog(Format('SDL: chunk decoder %s is avalable', [Mix_GetChunkDecoder(i)]), TMsgType.Notify);
end;
+
+ e_TimidityDecoder := false;
for i := 0 to Mix_GetNumMusicDecoders()-1 do
begin
+ case AnsiString(Mix_GetMusicDecoder(i)) of
+ 'TIMIDITY': e_TimidityDecoder := true;
+ end;
e_WriteLog(Format('SDL: music decoder %s is avalable', [Mix_GetMusicDecoder(i)]), TMsgType.Notify);
end;
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index af95f90039433fabd4834b40f6b977878b65234c..5c458d5159025a8f4b376bb425802b8986f1a877 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
charbuff: packed array [0..15] of AnsiChar;
binPath: AnsiString = '';
forceBinDir: Boolean;
+ {$IFDEF USE_SDLMIXER}
+ UseNativeMusic: Boolean;
+ {$ENDIF}
function GetBinaryPath (): AnsiString;
{$IFDEF LINUX}
end;
procedure InitPrep;
- {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)}
- var timiditycfg: AnsiString;
- {$ENDIF}
var i: Integer;
begin
{$IFDEF HEADLESS}
e_DeinitLog;
Halt(1);
end;
-
- {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)}
- timiditycfg := 'timidity.cfg';
- if e_FindResource(ConfigDirs, timiditycfg) = true then
- begin
- timiditycfg := ExpandFileName(timiditycfg);
- SetEnvVar('TIMIDITY_CFG', timiditycfg);
- e_LogWritefln('Set TIMIDITY_CFG = "%s"', [timiditycfg]);
- end;
- {$ENDIF}
end;
procedure Main();
end;
procedure Init();
-var
- NoSound: Boolean;
+ {$IFDEF USE_SDLMIXER}
+ var timiditycfg: AnsiString;
+ var oldcwd, newcwd: RawByteString;
+ {$ENDIF}
+ var NoSound: Boolean;
begin
Randomize;
e_WriteLog('Input: No Joysticks.', TMsgType.Notify);
*)
- if (not gNoSound) then
+ if gNoSound = false then
begin
e_WriteLog('Initializing sound system', TMsgType.Notify);
+ {$IFDEF USE_SDLMIXER}
+ newcwd := '';
+ if UseNativeMusic then
+ SetEnvVar('SDL_NATIVE_MUSIC', '1');
+ timiditycfg := GetEnvironmentVariable('TIMIDITY_CFG');
+ if timiditycfg = '' then
+ begin
+ timiditycfg := 'timidity.cfg';
+ if e_FindResource(ConfigDirs, timiditycfg) OR e_FindResource(DataDirs, timiditycfg) then
+ begin
+ timiditycfg := ExpandFileName(timiditycfg);
+ newcwd := ExtractFileDir(timiditycfg);
+ SetEnvVar('TIMIDITY_CFG', timiditycfg);
+ end
+ else
+ timiditycfg := '';
+ end;
+ e_LogWritefln('TIMIDITY_CFG = "%s"', [timiditycfg]);
+ e_LogWritefln('SDL_NATIVE_MUSIC = "%s"', [GetEnvironmentVariable('SDL_NATIVE_MUSIC')]);
+ {$ENDIF}
e_InitSoundSystem(NoSound);
+ {$IFDEF USE_SDLMIXER}
+ if e_TimidityDecoder and (newcwd <> '') then
+ begin
+ (* HACK: Set CWD to load GUS patches relatively to cfg file. *)
+ (* CWD not restored after sound init because timidity *)
+ (* store relative pathes internally and load patches *)
+ (* later. I hope game never relies on CWD. *)
+ oldcwd := '';
+ GetDir(0, oldcwd);
+ ChDir(newcwd);
+ e_logwritefln('WARNING: USED TIMIDITY CONFIG HACK, CWD SWITCHED "%s" -> "%s"', [oldcwd, newcwd]);
+ end;
+ {$ENDIF}
end;
e_WriteLog('Init game', TMsgType.Notify);
end;
end;
+initialization
+{$IFDEF USE_SDLMIXER}
+ conRegVar('sdl_native_music', @UseNativeMusic, 'use native midi music output when possible', 'use native midi');
+ {$IFDEF DARWIN}
+ UseNativeMusic := true; (* OSX have a good midi support, so why not? *)
+ {$ELSE}
+ UseNativeMusic := false;
+ {$ENDIF}
+{$ENDIF}
end.