From fb8592aa898a8da05a47bfe50ff8272de4fdc995 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Tue, 2 Jan 2018 23:52:02 +0000 Subject: [PATCH] Add Haiku OS support --- src/flexui/sdlcarcass.pas | 6 ++++-- src/game/g_game.pas | 2 +- src/game/g_main.pas | 3 ++- src/lib/sdl2/sdl2.pas | 14 +++++++++----- src/lib/sdl2/sdlsyswm.inc | 4 +++- src/shared/xprofiler.pas | 7 +++++-- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/flexui/sdlcarcass.pas b/src/flexui/sdlcarcass.pas index a9e254b..59e43fd 100644 --- a/src/flexui/sdlcarcass.pas +++ b/src/flexui/sdlcarcass.pas @@ -74,6 +74,8 @@ uses unixtype, linux {$ELSEIF DEFINED(WINDOWS)} Windows + {$ELSEIF DEFINED(HAIKU)} + unixtype {$ELSE} {$WARNING You suck!} {$ENDIF} @@ -111,7 +113,7 @@ begin if not mHasHPTimer then raise Exception.Create('profiler error: hires timer is not available'); mFrequency := 1; // just a flag if (r.tv_nsec <> 0) then mFrequency := 1000000000000000000 div r.tv_nsec; -{$ELSE} +{$ELSEIF DEFINED(WINDOWS)} mHasHPTimer := QueryPerformanceFrequency(r); if not mHasHPTimer then raise Exception.Create('profiler error: hires timer is not available'); mFrequency := r; @@ -128,7 +130,7 @@ begin {$IF DEFINED(LINUX)} clock_gettime(CLOCK_MONOTONIC, @r); result := UInt64(r.tv_sec)*1000000+UInt64(r.tv_nsec) div 1000; // microseconds - {$ELSE} + {$ELSEIF DEFINED(WINDOWS)} QueryPerformanceCounter(r); result := UInt64(r)*1000000 div mFrequency; {$ENDIF} diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 9553cbe..8444232 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -344,7 +344,7 @@ uses e_input, e_log, g_console, g_items, g_map, g_panel, g_playermodel, g_gfx, g_options, g_weapons, Math, g_triggers, g_monsters, e_sound, CONFIG, - g_language, g_net, SDL, + g_language, g_net, ENet, e_msg, g_netmsg, g_netmaster, GL, GLExt, sfs, wadreader, g_holmes; diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 12f33c6..ac24954 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -91,7 +91,8 @@ begin {$ENDIF} {$ELSE} {$IFDEF USE_SDLMIXER} - sdlflags := SDL_INIT_EVERYTHING; + {*sdlflags := SDL_INIT_EVERYTHING;*} + sdlflags := SDL_INIT_JOYSTICK or SDL_INIT_TIMER or SDL_INIT_VIDEO; {$ELSE} sdlflags := SDL_INIT_JOYSTICK or SDL_INIT_TIMER or SDL_INIT_VIDEO; {$ENDIF} diff --git a/src/lib/sdl2/sdl2.pas b/src/lib/sdl2/sdl2.pas index 168742e..745985a 100644 --- a/src/lib/sdl2/sdl2.pas +++ b/src/lib/sdl2/sdl2.pas @@ -137,10 +137,12 @@ interface Windows; {$ENDIF} - {$IFDEF UNIX} - uses - X, - XLib; + {$IF DEFINED(UNIX)} + {$IF NOT DEFINED(HAIKU)} + uses + X, + XLib; + {$ENDIF} {$ENDIF} {$IFDEF DARWIN} @@ -156,7 +158,9 @@ const SDL_LibName = 'SDL2.dll'; {$ENDIF} - {$IFDEF UNIX} + {$IF DEFINED(HAIKU)} + SDL_LibName = 'libSDL2.so.0'; + {$ELSEIF DEFINED(UNIX)} {$IFDEF DARWIN} SDL_LibName = 'libSDL2.dylib'; {$ELSE} diff --git a/src/lib/sdl2/sdlsyswm.inc b/src/lib/sdl2/sdlsyswm.inc index 0b2b7c6..f89df21 100644 --- a/src/lib/sdl2/sdlsyswm.inc +++ b/src/lib/sdl2/sdlsyswm.inc @@ -5,7 +5,9 @@ {$ENDIF} {$IF DEFINED (LINUX) OR DEFINED(UNIX)} - {$DEFINE SDL_VIDEO_DRIVER_X11} + {$IF NOT DEFINED(HAIKU)} + {$DEFINE SDL_VIDEO_DRIVER_X11} + {$ENDIF} {$IFEND} {$IFDEF DARWIN} diff --git a/src/shared/xprofiler.pas b/src/shared/xprofiler.pas index b4e2fc4..9584fe6 100644 --- a/src/shared/xprofiler.pas +++ b/src/shared/xprofiler.pas @@ -28,6 +28,9 @@ uses {$ELSEIF DEFINED(WINDOWS)} {$DEFINE STOPWATCH_IS_HERE} Windows + {$ELSEIF DEFINED(HAIKU)} + {$DEFINE STOPWATCH_IS_HERE} + unixtype {$ELSE} {$IFDEF STOPWATCH_IS_HERE} {$UNDEF STOPWATCH_IS_HERE} @@ -173,7 +176,7 @@ begin if not mHasHPTimer then raise Exception.Create('profiler error: hires timer is not available'); mFrequency := 1; // just a flag if (r.tv_nsec <> 0) then mFrequency := 1000000000000000000 div r.tv_nsec; -{$ELSE} +{$ELSEIF DEFINED(WINDOWS)} mHasHPTimer := QueryPerformanceFrequency(r); if not mHasHPTimer then raise Exception.Create('profiler error: hires timer is not available'); mFrequency := r; @@ -190,7 +193,7 @@ begin {$IF DEFINED(LINUX)} clock_gettime(CLOCK_MONOTONIC, @r); result := UInt64(r.tv_sec)*1000000+UInt64(r.tv_nsec) div 1000; // microseconds - {$ELSE} + {$ELSEIF DEFINED(WINDOWS)} QueryPerformanceCounter(r); result := UInt64(r)*1000000 div mFrequency; {$ENDIF} -- 2.29.2