summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d5d4c90)
raw | patch | inline | side by side (parent: d5d4c90)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 17 Jun 2021 16:52:30 +0000 (19:52 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 07:47:42 +0000 (10:47 +0300) |
src/engine/e_input_sdl2.inc | patch | blob | history | |
src/engine/e_input_stub.inc | patch | blob | history | |
src/engine/e_log.pas | patch | blob | history | |
src/game/Doom2DF.lpr | patch | blob | history | |
src/game/g_console.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history | |
src/game/g_menu.pas | patch | blob | history | |
src/game/opengl/r_render.pas | [new file with mode: 0644] | patch | blob |
index 9e9c7d8aa60d12f4eabee89b8e83c06f11fa9114..effe559e475ec78ed53bc6dfe9858e5ea9e1f79b 100644 (file)
JOY2_DOWN = JOYH_BEG + 2*e_MaxJoyHats*4 + 0*4 + HAT_DOWN;
JOY3_DOWN = JOYH_BEG + 3*e_MaxJoyHats*4 + 0*4 + HAT_DOWN;
-function e_InitInput: Boolean;
-procedure e_ReleaseInput;
+procedure e_Input_Initialize;
+procedure e_Input_Finalize;
+
procedure e_UnpressAllKeys;
procedure e_KeyUpDown (key: Integer; down: Boolean);
result := i < e_MaxJoys
end;
-function e_InitInput: Boolean;
+procedure e_Input_Initialize;
var i: Integer;
begin
for i := 0 to e_MaxJoys - 1 do
e_JoystickAvailable[i] := False;
- GenerateKeyNames;
- result := True
+ GenerateKeyNames
end;
-procedure e_ReleaseInput;
+procedure e_Input_Finalize;
var i: Integer;
begin
for i := 0 to e_MaxJoys - 1 do
index 496dde54a1843de3ef482599dd7a49eff4e04363..4f10301a04bc3ac35a30234833121b4fd2f1fe71 100644 (file)
JOY2_DOWN = JOYH_BEG + 2*e_MaxJoyHats*4 + 0*4 + HAT_DOWN;
JOY3_DOWN = JOYH_BEG + 3*e_MaxJoyHats*4 + 0*4 + HAT_DOWN;
-function e_InitInput: Boolean;
-procedure e_ReleaseInput;
+procedure e_Input_Initialize;
+procedure e_Input_Finalize;
+
procedure e_UnpressAllKeys;
procedure e_KeyUpDown (key: Integer; down: Boolean);
result := i < e_MaxJoys
end;
-function e_InitInput: Boolean;
+procedure e_Input_Initialize;
var i: Integer;
begin
for i := 0 to e_MaxJoys - 1 do
e_JoystickAvailable[i] := False;
- GenerateKeyNames;
- result := True
+ GenerateKeyNames
end;
-procedure e_ReleaseInput;
+procedure e_Input_Finalize;
var i: Integer;
begin
for i := 0 to e_MaxJoys - 1 do
diff --git a/src/engine/e_log.pas b/src/engine/e_log.pas
index dbe7b5dc2773f5881427c776d1d66f57e2835e7d..629eed68cb8845a11bd954b4eb2d9002828ce7f4 100644 (file)
--- a/src/engine/e_log.pas
+++ b/src/engine/e_log.pas
interface
-uses
- SysUtils;
+ uses SysUtils;
-type
- TWriteMode = (WM_NEWFILE, WM_OLDFILE);
- TMsgType = (Fatal, Warning, Notify);
+ type
+ TWriteMode = (WM_NEWFILE, WM_OLDFILE);
+ TMsgType = (Fatal, Warning, Notify);
+ procedure e_Log_Initialize;
+ procedure e_Log_Finalize;
procedure e_InitLog (fFileName: String; fWriteMode: TWriteMode);
procedure e_DeinitLog ();
driverInited: Boolean = false;
+ procedure e_Log_Initialize;
+ begin
+ end;
+
+ procedure e_Log_Finalize;
+ begin
+ e_DeinitLog
+ end;
+
+
function DecodeIPV4 (ip: LongWord): string;
begin
{$IFDEF FPC_LITTLE_ENDIAN}
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index cfa26f5637b384ae0ff4a27387fcbcbecd275f74..d1fbc06443004070580798c0383ac96451e82199 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
r_texture in 'opengl/r_texture.pas',
r_weapons in 'opengl/r_weapons.pas',
r_window in 'opengl/r_window.pas',
+ r_render in 'opengl/r_render.pas',
{$IFDEF USE_FMOD}
fmod in '../lib/FMOD/fmod.pas',
{$R *.res}
{$ENDIF}
+ const
+ autoexecScript = 'autoexec.cfg';
+
var
noct: Boolean = False;
binPath: AnsiString = '';
Frame: Int64;
flag: Boolean = false;
+ NoSound: Boolean;
+
procedure Update ();
begin
// remember old mobj positions, prepare for update
if NetMode = NET_SERVER then g_Net_Flush();
end;
-procedure Init();
- {$IFDEF USE_SDLMIXER}
- var timiditycfg: AnsiString;
- var oldcwd, newcwd: RawByteString;
- {$ENDIF}
- var NoSound: Boolean;
-begin
- Randomize;
-
-{$IFDEF HEADLESS}
- {$IFDEF USE_SDLMIXER}
- NoSound := False; // hope env has set SDL_AUDIODRIVER to dummy
- {$ELSE}
- NoSound := True; // FMOD backend will sort it out
- {$ENDIF}
-{$ELSE}
- NoSound := False;
-{$ENDIF}
-
- g_Touch_Init;
-
-(*
- if (e_JoysticksAvailable > 0) then
- e_WriteLog('Input: Joysticks available.', TMsgType.Notify)
- else
- e_WriteLog('Input: No Joysticks.', TMsgType.Notify);
-*)
-
- 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);
- g_Game_Init();
-
-// FillChar(charbuff, sizeof(charbuff), ' ');
-end;
-
-procedure Release();
-begin
- e_WriteLog('Releasing engine', TMsgType.Notify);
- e_ReleaseEngine();
-
- e_WriteLog('Releasing input', TMsgType.Notify);
- e_ReleaseInput();
-
- if not gNoSound then
- begin
- e_WriteLog('Releasing sound', TMsgType.Notify);
- e_ReleaseSoundSystem();
- end;
-end;
-
function ProcessMessage (): Boolean;
var
i, t: Integer;
e_SoundUpdate();
end;
-
-function SDLMain (): Integer;
+procedure DebugOptions;
var
idx: Integer;
arg: AnsiString;
valres: Word;
{$ENDIF}
begin
-
idx := 1;
while (idx <= ParamCount) do
begin
end;
end;
end;
-
- r_Window_Initialize;
-
- Init;
- Time_Old := sys_GetTicks();
-
- g_Net_InitLowLevel();
-
- // game commad line
- if (ParamCount > 0) then g_Game_Process_Params();
-
-{$IFNDEF HEADLESS}
- if (not gGameOn) and gAskLanguage then g_Menu_AskLanguage();
-{$ENDIF}
-
- e_WriteLog('Entering the main loop', TMsgType.Notify);
-
- // main loop
- while not ProcessMessage() do begin end;
-
- g_Net_Slist_ShutdownAll();
-
- Release();
-
- g_Net_DeinitLowLevel();
- result := 0;
end;
function GetBinaryPath (): AnsiString;
AddDir(AllMapDirs, MegawadDirs[i]);
OptimizeDirs(AllMapDirs);
- if LogFileName = '' then
- begin
- rwdir := e_GetWriteableDir(LogDirs, false);
- if rwdir <> '' then
- begin
- {$IFDEF HEADLESS}
- LogFileName := e_CatPath(rwdir, 'Doom2DF_H.log');
- {$ELSE}
- LogFileName := e_CatPath(rwdir, 'Doom2DF.log');
- {$ENDIF}
- end
- end;
-
// HACK: ensure the screenshots folder also has a stats subfolder in it
rwdir := e_GetWriteableDir(ScreenshotDirs, false);
if rwdir <> '' then CreateDir(rwdir + '/stats');
end;
-procedure InitPrep;
- var i: Integer;
-begin
- {$IFDEF HEADLESS}
- conbufDumpToStdOut := true;
- {$ENDIF}
- for i := 1 to ParamCount do
+ procedure EntryParams;
+ var i: Integer;
begin
- case ParamStr(i) of
- '--con-stdout': conbufDumpToStdOut := true;
- '--no-fbo': glRenderToFBO := false;
+ i := 1;
+ while i <= ParamCount do
+ begin
+ case ParamStr(i) of
+ '--gdb': noct := true;
+ '--log', '--con-stdout': conbufDumpToStdOut := true;
+ '--safe-log': e_SetSafeSlowLog(true);
+ '--log-file':
+ if i + 1 <= ParamCount then
+ begin
+ Inc(i);
+ LogFileName := ParamStr(i)
+ end;
+ '--no-fbo': glRenderToFBO := false;
+ end;
+ Inc(i)
end
end;
- if LogFileName <> '' then
- e_InitLog(LogFileName, TWriteMode.WM_NEWFILE);
- e_InitWritelnDriver();
- e_WriteLog('Doom 2D: Forever version ' + GAME_VERSION + ' proto ' + IntToStr(NET_PROTOCOL_VER), TMsgType.Notify);
- e_WriteLog('Build arch: ' + g_GetBuildArch(), TMsgType.Notify);
- e_WriteLog('Build date: ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME, TMsgType.Notify);
- e_WriteLog('Build hash: ' + g_GetBuildHash(), TMsgType.Notify);
- e_WriteLog('Build by: ' + g_GetBuilderName(), TMsgType.Notify);
-
- e_LogWritefln('Force bin dir: %s', [forceBinDir], TMsgType.Notify);
- e_LogWritefln('BINARY PATH: [%s]', [binPath], TMsgType.Notify);
-
- PrintDirs('DataDirs', DataDirs);
- PrintDirs('ModelDirs', ModelDirs);
- PrintDirs('MegawadDirs', MegawadDirs);
- PrintDirs('MapDirs', MapDirs);
- PrintDirs('WadDirs', WadDirs);
-
- PrintDirs('LogDirs', LogDirs);
- PrintDirs('SaveDirs', SaveDirs);
- PrintDirs('CacheDirs', CacheDirs);
- PrintDirs('ConfigDirs', ConfigDirs);
- PrintDirs('ScreenshotDirs', ScreenshotDirs);
- PrintDirs('StatsDirs', StatsDirs);
- PrintDirs('MapDownloadDirs', MapDownloadDirs);
- PrintDirs('WadDownloadDirs', WadDownloadDirs);
-
- GameWAD := e_FindWad(DataDirs, GameWADName);
- if GameWad = '' then
+ procedure InitLog;
+ var rwdir: AnsiString;
begin
- e_WriteLog('WAD ' + GameWADName + ' not found in data directories.', TMsgType.Fatal);
- {$IF DEFINED(USE_SDL2) AND NOT DEFINED(HEADLESS)}
- if forceBinDir = false then
- SDL_ShowSimpleMessageBox(
- SDL_MESSAGEBOX_ERROR,
- 'Doom 2D Forever',
- PChar('WAD ' + GameWADName + ' not found in data directories.'),
- nil
- );
- {$ENDIF}
- e_DeinitLog;
- Halt(1);
+ if LogFileName = '' then
+ begin
+ rwdir := e_GetWriteableDir(LogDirs, false);
+ if rwdir <> '' then
+ begin
+ {$IFDEF HEADLESS}
+ LogFileName := e_CatPath(rwdir, 'Doom2DF_H.log');
+ {$ELSE}
+ LogFileName := e_CatPath(rwdir, 'Doom2DF.log');
+ {$ENDIF}
+ end
+ end;
+ if LogFileName <> '' then
+ e_InitLog(LogFileName, TWriteMode.WM_NEWFILE);
+ e_InitWritelnDriver
end;
-end;
-procedure Main;
-{$IFDEF ENABLE_HOLMES}
- var flexloaded: Boolean;
-{$ENDIF}
-begin
- {$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? *)
+ procedure InitPrep;
+ begin
+ e_WriteLog('Doom 2D: Forever version ' + GAME_VERSION + ' proto ' + IntToStr(NET_PROTOCOL_VER), TMsgType.Notify);
+ e_WriteLog('Build arch: ' + g_GetBuildArch(), TMsgType.Notify);
+ e_WriteLog('Build date: ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME, TMsgType.Notify);
+ e_WriteLog('Build hash: ' + g_GetBuildHash(), TMsgType.Notify);
+ e_WriteLog('Build by: ' + g_GetBuilderName(), TMsgType.Notify);
+
+ e_LogWritefln('Force bin dir: %s', [forceBinDir], TMsgType.Notify);
+ e_LogWritefln('BINARY PATH: [%s]', [binPath], TMsgType.Notify);
+
+ PrintDirs('DataDirs', DataDirs);
+ PrintDirs('ModelDirs', ModelDirs);
+ PrintDirs('MegawadDirs', MegawadDirs);
+ PrintDirs('MapDirs', MapDirs);
+ PrintDirs('WadDirs', WadDirs);
+
+ PrintDirs('LogDirs', LogDirs);
+ PrintDirs('SaveDirs', SaveDirs);
+ PrintDirs('CacheDirs', CacheDirs);
+ PrintDirs('ConfigDirs', ConfigDirs);
+ PrintDirs('ScreenshotDirs', ScreenshotDirs);
+ PrintDirs('StatsDirs', StatsDirs);
+ PrintDirs('MapDownloadDirs', MapDownloadDirs);
+ PrintDirs('WadDownloadDirs', WadDownloadDirs);
+
+ {$IFDEF HEADLESS}
+ {$IFDEF USE_SDLMIXER}
+ NoSound := False; // hope env has set SDL_AUDIODRIVER to dummy
+ {$ELSE}
+ NoSound := True; // FMOD backend will sort it out
+ {$ENDIF}
{$ELSE}
- UseNativeMusic := false;
+ NoSound := False;
{$ENDIF}
- {$ENDIF}
- InitPath;
- InitPrep;
- e_InitInput;
- sys_Init;
-
- sys_CharPress := @CharPress;
-
- g_Options_SetDefault;
- g_Options_SetDefaultVideo;
- g_Console_SysInit;
- if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then
- raise Exception.Create('Failed to set videomode on startup.');
-
- e_WriteLog(gLanguage, TMsgType.Notify);
- g_Language_Set(gLanguage);
+ GameWAD := e_FindWad(DataDirs, GameWADName);
+ if GameWad = '' then
+ begin
+ e_WriteLog('WAD ' + GameWADName + ' not found in data directories.', TMsgType.Fatal);
+ {$IF DEFINED(USE_SDL2) AND NOT DEFINED(HEADLESS)}
+ if forceBinDir = false then
+ SDL_ShowSimpleMessageBox(
+ SDL_MESSAGEBOX_ERROR,
+ 'Doom 2D Forever',
+ PChar('WAD ' + GameWADName + ' not found in data directories.'),
+ nil
+ );
+ {$ENDIF}
+ e_DeinitLog;
+ Halt(1);
+ end
+ end;
-{$IF not DEFINED(HEADLESS) and DEFINED(ENABLE_HOLMES)}
- flexloaded := true;
- if not fuiAddWad('flexui.wad') then
+{$IFDEF ENABLE_HOLMES}
+ procedure InitHolmes;
+ var flexloaded: Boolean;
begin
- if not fuiAddWad('./data/flexui.wad') then fuiAddWad('./flexui.wad');
- end;
- try
- fuiGfxLoadFont('win8', 'flexui/fonts/win8.fuifont');
- fuiGfxLoadFont('win14', 'flexui/fonts/win14.fuifont');
- fuiGfxLoadFont('win16', 'flexui/fonts/win16.fuifont');
- fuiGfxLoadFont('dos8', 'flexui/fonts/dos8.fuifont');
- fuiGfxLoadFont('msx6', 'flexui/fonts/msx6.fuifont');
- except on e: Exception do
- begin
- writeln('ERROR loading FlexUI fonts');
- flexloaded := false;
- //raise;
- end;
- else
+ flexloaded := true;
+ if not fuiAddWad('flexui.wad') then
begin
- flexloaded := false;
- //raise;
+ if not fuiAddWad('./data/flexui.wad') then fuiAddWad('./flexui.wad');
end;
- end;
- if (flexloaded) then
- begin
try
- e_LogWriteln('FlexUI: loading stylesheet...');
- uiLoadStyles('flexui/widgets.wgs');
- except on e: TParserException do
+ fuiGfxLoadFont('win8', 'flexui/fonts/win8.fuifont');
+ fuiGfxLoadFont('win14', 'flexui/fonts/win14.fuifont');
+ fuiGfxLoadFont('win16', 'flexui/fonts/win16.fuifont');
+ fuiGfxLoadFont('dos8', 'flexui/fonts/dos8.fuifont');
+ fuiGfxLoadFont('msx6', 'flexui/fonts/msx6.fuifont');
+ except on e: Exception do
begin
- writeln('ERROR at (', e.tokLine, ',', e.tokCol, '): ', e.message);
- //raise;
+ writeln('ERROR loading FlexUI fonts');
flexloaded := false;
+ //raise;
end;
else
begin
- //raise;
flexloaded := false;
+ //raise;
+ end;
+ end;
+ if flexloaded then
+ begin
+ try
+ e_LogWriteln('FlexUI: loading stylesheet...');
+ uiLoadStyles('flexui/widgets.wgs');
+ except on e: TParserException do
+ begin
+ writeln('ERROR at (', e.tokLine, ',', e.tokCol, '): ', e.message);
+ //raise;
+ flexloaded := false;
+ end;
+ else
+ begin
+ //raise;
+ flexloaded := false;
+ end;
end;
end;
+ g_holmes_imfunctional := not flexloaded;
+ if not g_holmes_imfunctional then
+ begin
+ uiInitialize();
+ uiContext.font := 'win14';
+ end;
+ if assigned(oglInitCB) then oglInitCB;
end;
- g_holmes_imfunctional := not flexloaded;
- if (not g_holmes_imfunctional) then
+ procedure FreeHolmes;
begin
- uiInitialize();
- uiContext.font := 'win14';
+ if assigned(oglDeinitCB) then
+ oglDeinitCB
end;
-
- if assigned(oglInitCB) then oglInitCB;
{$ENDIF}
- //g_Res_CreateDatabases(true); // it will be done before connecting to the server for the first time
-
- e_WriteLog('Entering SDLMain', TMsgType.Notify);
-
- {$WARNINGS OFF}
- SDLMain();
- {$WARNINGS ON}
-
- {$IFDEF ENABLE_HOLMES}
- if assigned(oglDeinitCB) then oglDeinitCB;
- {$ENDIF}
-
- g_Console_WriteGameConfig;
- sys_Final;
-end;
-
-
-procedure EntryParams;
- var f: Integer;
-begin
- f := 1;
- while f <= ParamCount do
+ procedure InitSound;
+ {$IFDEF USE_SDLMIXER}
+ var timiditycfg: AnsiString;
+ var oldcwd, newcwd: RawByteString;
+ {$ENDIF}
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
+ if NoSound = 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;
- Inc(f)
- end
-end;
+ end;
-procedure EntryPoint;
-begin
- SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
- EntryParams;
- if noct then
- Main
- else
- try
- Main;
+ procedure Startup;
+ begin
+ Randomize;
+ InitPath;
+ InitLog;
+ InitPrep;
+ e_Input_Initialize;
+ InitSound;
+ sys_Init;
+ sys_CharPress := @CharPress; (* install hook *)
+ g_Options_SetDefault;
+ g_Options_SetDefaultVideo;
+ g_Console_Initialize;
+ // TODO move load configs here
+ g_Language_Set(gLanguage);
+ r_Render_Initialize;
+ g_Touch_Init;
+ DebugOptions;
+ g_Net_InitLowLevel;
+ // TODO init serverlist
+ {$IFDEF ENABLE_HOLMES}
+ InitHolmes;
+ {$ENDIF}
+ g_Game_Init;
+ {$IFNDEF HEADLESS}
+ g_Menu_Init;
+ g_GUI_Init;
+ {$ENDIF}
+ g_Game_Process_Params;
+ // TODO reload GAME textures
+ g_Console_Init; // welcome message
+ {$IFNDEF HEADLESS}
+ if (not gGameOn) and gAskLanguage then
+ g_Menu_AskLanguage;
+ {$ENDIF}
+ Time_Old := sys_GetTicks();
+ while not ProcessMessage() do begin end;
+ g_Console_WriteGameConfig;
+ {$IFNDEF HEADLESS}
+ g_GUI_Destroy;
+ g_Menu_Free;
+ {$ENDIF}
+ {$IFDEF ENABLE_HOLMES}
+ FreeHolmes;
+ {$ENDIF}
+ g_Net_Slist_ShutdownAll;
+ g_Net_DeinitLowLevel;
+ (* g_Touch_Finalize; *)
+ r_Render_Finalize;
+ sys_Final;
+ g_Console_Finalize;
+ e_ReleaseSoundSystem;
+ e_Input_Finalize;
e_WriteLog('Shutdown with no errors.', TMsgType.Notify)
- except on e: Exception do
- e_WriteStackTrace(e.message)
- else
- e_WriteStackTrace('FATAL ERROR')
end;
- e_DeinitLog;
-end;
+ procedure InitCVars;
+ begin
+ {$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;
+
+ procedure EntryPoint;
+ begin
+ SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
+ InitCVars;
+ EntryParams;
+ e_Log_Initialize;
+ {$IFDEF HEADLESS}
+ conbufDumpToStdOut := true;
+ {$ENDIF}
+ if noct then
+ Startup
+ else
+ try
+ Startup
+ except on e: Exception do
+ e_WriteStackTrace(e.message)
+ else
+ e_WriteStackTrace('FATAL ERROR')
+ end;
+ e_Log_Finalize
+ end;
{$IFDEF ANDROID}
function SDL_main (argc: CInt; argv: PPChar): CInt; cdecl;
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 5b9e95199bea42ab4f9f31c769c17cd885b66a33..fee51960c149868ffe4c969c24c04e7c1513af66 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
end;
procedure g_Console_Init;
-procedure g_Console_SysInit;
+procedure g_Console_Initialize;
+procedure g_Console_Finalize;
procedure g_Console_Update;
procedure g_Console_Char (C: AnsiChar);
procedure g_Console_Control (K: Word);
Keyboard;
const
- autoexecScript = 'autoexec.cfg';
configComment = 'generated by doom2d, do not modify';
type
end;
end;
-procedure g_Console_SysInit;
+procedure g_Console_Initialize;
var a: Integer;
begin
gConsoleShow := False;
g_Console_ResetBinds;
g_Console_ReadConfig(gConfigScript);
- g_Console_ReadConfig(autoexecScript);
+// g_Console_ReadConfig(autoexecScript);
+ g_Console_ReadConfig('autoexec.cfg');
+
gParsingBinds := False;
end;
+procedure g_Console_Finalize;
+begin
+
+end;
+
procedure g_Console_Init;
begin
g_Console_Add(Format(_lc[I_CONSOLE_WELCOME], [GAME_VERSION]));
procedure g_Console_BindKey (key: Integer; down: AnsiString; up: AnsiString = ''; rep: Boolean = False);
begin
- //e_LogWritefln('bind "%s" "%s" <%s>', [LowerCase(e_KeyNames[key]), cmd, key]);
+ // e_LogWritefln('bind "%s" "%s" "%s" <%s>', [LowerCase(e_KeyNames[key]), down, up, key]);
ASSERT(key >= 0);
ASSERT(key < e_MaxInputKeys);
if key > 0 then
end;
begin
+ // e_LogWritefln('g_Console_WriteConfig: %s', [filename]);
AssignFile(f, filename);
Rewrite(f);
WriteLn(f, '// ' + configComment);
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index b5139c37a19e1cf2d591309fdd62afb14340fe85..664377ccad70d23e9a067e6e8dba179848495e6f 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION]), 0, False);
g_Game_SetLoadingText('', 0, False);
- g_Game_SetLoadingText(_lc[I_LOAD_CONSOLE], 0, False);
- r_Console_Init;
- g_Console_Init();
-
g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False);
- r_PlayerModel_Initialize;
-
// load models from all possible wad types, in all known directories
// this does a loosy job (linear search, ooph!), but meh
for wext in wadExtensions do
g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD+':MUSIC\ROUNDMUS', True, True);
g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD+':MUSIC\ENDMUS', True);
-{$IFNDEF HEADLESS}
- g_Game_SetLoadingText(_lc[I_LOAD_MENUS], 0, False);
- g_Menu_Init();
-{$ENDIF}
-
gMusic := TMusic.Create();
gMusic.SetByName('MUSIC_MENU');
gMusic.Play();
g_Game_StopAllSounds(True);
gMusic.Free();
g_Game_FreeData();
- r_PlayerModel_Finalize;
g_PlayerModel_FreeData();
g_Texture_DeleteAll();
g_Frames_DeleteAll();
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index cc6f6862bbd5a0400dfb1d2cd94aee15a034765b..19a9a1dd6cfa86817ebef5a42487a83b73197876 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
procedure g_Menu_Init();
begin
MenuLoadData();
- g_GUI_Init();
CreateAllMenus();
end;
procedure g_Menu_Free();
begin
- g_GUI_Destroy();
-
- e_WriteLog('Releasing menu data...', TMsgType.Notify);
-
MenuFreeData();
end;
diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas
--- /dev/null
@@ -0,0 +1,43 @@
+(* Copyright (C) Doom 2D: Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE ../../shared/a_modes.inc}
+unit r_render;
+
+interface
+
+ procedure r_Render_Initialize;
+ procedure r_Render_Finalize;
+
+implementation
+
+ uses SysUtils, Classes, g_system, g_game, g_options, r_window, r_graphics, r_console, r_playermodel;
+
+ procedure r_Render_Initialize;
+ begin
+ if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then
+ raise Exception.Create('Failed to set videomode on startup.');
+
+ r_Window_Initialize;
+ r_Console_Init;
+ r_PlayerModel_Initialize;
+ end;
+
+ procedure r_Render_Finalize;
+ begin
+ r_PlayerModel_Finalize;
+ e_ReleaseEngine
+ end;
+
+end.