649 changes: 649 additions & 0 deletions games-fps/quakespasm/additional-files/QuakeSpasm.rdef.in

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions games-fps/quakespasm/additional-files/haiku_readme.txt
@@ -0,0 +1,18 @@

Installing game data files for QuakeSpasm on Haiku
===============================================================

QuakeSpasm for Haiku searches for game data at the system directory specified
by the symbolic constant `B_USER_NONPACKAGED_DATA_DIRECTORY` + `/QuakeSpasm/`.

On a normal system install, this would be located at:
`/boot/home/config/non-packaged/data/QuakeSpasm/`

Screenshots and configuration files are also saved here.

To install the shareware or registered versions of Quake, place the files
pak0.pak and pak1.pak into the following directory:
`/boot/home/config/non-packaged/data/QuakeSpasm/id1/`

Any mods for Quake should be installed accordingly, with the folder name "id1"
being replaced with the name of the mod (no spaces).
145 changes: 145 additions & 0 deletions games-fps/quakespasm/additional-files/qgrad-plain.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
190 changes: 190 additions & 0 deletions games-fps/quakespasm/patches/quakespasm-0.96.0~git.patchset
@@ -0,0 +1,190 @@
From 77b165e3088b42842a0119cb919908e86ab6127f Mon Sep 17 00:00:00 2001
From: Jaycie Ewald <jaycie.ewald@outlook.com>
Date: Sat, 3 Jun 2023 10:43:28 -0500
Subject: Haiku support.

Changes already submitted upstream.
---
Quake/Makefile | 23 +++++++++++++++--------
Quake/build_cross_haiku32-sdl2.sh | 2 +-
Quake/build_cross_haiku64-sdl2.sh | 2 +-
Quake/common.c | 23 +++++++++++++++++++++++
Quake/sys_sdl_unix.c | 21 +++++++++++++++++++++
5 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/Quake/Makefile b/Quake/Makefile
index beea5e1..91141a0 100644
--- a/Quake/Makefile
+++ b/Quake/Makefile
@@ -10,9 +10,6 @@ DO_USERDIRS=0
### Enable/Disable SDL2
USE_SDL2=0

-### Do we need to link the math library?
-LINK_M=1
-
### Enable/Disable codecs for streaming music support
USE_CODEC_WAVE=1
USE_CODEC_FLAC=0
@@ -38,7 +35,7 @@ check_gcc = $(shell if echo | $(CC) $(1) -Werror -S -o /dev/null -xc - > /dev/nu

# ---------------------------

-HOST_OS := $(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]')
+HOST_OS ?= $(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]')

DEBUG ?= 0

@@ -112,7 +109,7 @@ SDL_LIBS := $(shell $(SDL_CONFIG) --libs)

ifeq ($(HOST_OS),sunos)
NET_LIBS :=-lsocket -lnsl -lresolv
-else ifdef HAIKU_OS
+else ifeq ($(HOST_OS),haiku)
NET_LIBS :=-lnetwork
else
NET_LIBS :=
@@ -185,10 +182,10 @@ ifeq ($(USE_CODEC_UMX),1)
CFLAGS+= -DUSE_CODEC_UMX
endif

+ifeq ($(HOST_OS),haiku)
COMMON_LIBS:= -lGL
-
-ifeq ($(LINK_M),1)
-COMMON_LIBS += -lm
+else
+COMMON_LIBS:= -lGL -lm
endif

LIBS := $(COMMON_LIBS) $(NET_LIBS) $(CODECLIBS)
@@ -305,7 +302,17 @@ debug:
clean:
$(RM) *.o *.d $(DEFAULT_TARGET)

+ifeq ($(HOST_OS),haiku)
+QS_DATA_DIR=$(shell finddir B_USER_NONPACKAGED_DATA_DIRECTORY)/QuakeSpasm/
+QS_APP_DIR=$(shell finddir B_APPS_DIRECTORY)/QuakeSpasm/
+install: quakespasm
+ mkdir -p $(QS_APP_DIR)
+ mkdir -p $(QS_DATA_DIR)
+ cp quakespasm $(QS_APP_DIR)
+ cp quakespasm.pak $(QS_DATA_DIR)
+else
install: quakespasm
cp quakespasm /usr/local/games/quake
+endif

sinclude $(OBJS:.o=.d)
diff --git a/Quake/build_cross_haiku32-sdl2.sh b/Quake/build_cross_haiku32-sdl2.sh
index b180335..d6c5e55 100755
--- a/Quake/build_cross_haiku32-sdl2.sh
+++ b/Quake/build_cross_haiku32-sdl2.sh
@@ -14,4 +14,4 @@ STRIP="$TARGET-strip"
LDFLAGS=-L/usr/lib32 # hack
export CC AS AR RANLIB STRIP LDFLAGS

-exec $MAKE_CMD HAIKU_OS=1 LINK_M=0 USE_SDL2=1 LDFLAGS=$LDFLAGS CC=$CC AS=$AS RANLIB=$RANLIB AR=$AR STRIP=$STRIP -f Makefile $*
+exec $MAKE_CMD HOST_OS=haiku USE_SDL2=1 LDFLAGS=$LDFLAGS CC=$CC AS=$AS RANLIB=$RANLIB AR=$AR STRIP=$STRIP -f Makefile $*
diff --git a/Quake/build_cross_haiku64-sdl2.sh b/Quake/build_cross_haiku64-sdl2.sh
index 0b43404..8090528 100755
--- a/Quake/build_cross_haiku64-sdl2.sh
+++ b/Quake/build_cross_haiku64-sdl2.sh
@@ -13,4 +13,4 @@ AR="$TARGET-ar"
STRIP="$TARGET-strip"
export CC AS AR RANLIB STRIP

-exec $MAKE_CMD HAIKU_OS=1 LINK_M=0 USE_SDL2=1 CC=$CC AS=$AS RANLIB=$RANLIB AR=$AR STRIP=$STRIP -f Makefile $*
+exec $MAKE_CMD HOST_OS=haiku USE_SDL2=1 CC=$CC AS=$AS RANLIB=$RANLIB AR=$AR STRIP=$STRIP -f Makefile $*
diff --git a/Quake/common.c b/Quake/common.c
index c604a0a..931f971 100644
--- a/Quake/common.c
+++ b/Quake/common.c
@@ -28,6 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "miniz.h"

+#include "arch_def.h"
+#ifdef PLATFORM_HAIKU
+#include <FindDirectory.h>
+#include <fs_info.h>
+#endif
+
static char *largv[MAX_NUM_ARGVS + 1];
static char argvdummy[] = " ";

@@ -2052,11 +2058,28 @@ _add_path:
if (i != 0 || path_id != 1 || fitzmode)
qspak = NULL;
else {
+ #ifdef PLATFORM_HAIKU
+ qboolean old = com_modified;
+ dev_t volume = dev_for_path("/boot");
+ char buffer[B_PATH_NAME_LENGTH];
+ status_t result;
+
+ result = find_directory(B_SYSTEM_DATA_DIRECTORY, volume, false, buffer, sizeof(buffer));
+ if (result != B_OK)
+ Sys_Error ("Couldn't determine userspace directory");
+
+ q_snprintf (pakfile, sizeof(pakfile), "%s/QuakeSpasm/quakespasm.pak", buffer);
+
+ qspak = COM_LoadPackFile (pakfile);
+
+ com_modified = old;
+ #else
qboolean old = com_modified;
if (been_here) base = host_parms->userdir;
q_snprintf (pakfile, sizeof(pakfile), "%s/quakespasm.pak", base);
qspak = COM_LoadPackFile (pakfile);
com_modified = old;
+ #endif
}
if (pak) {
search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t));
diff --git a/Quake/sys_sdl_unix.c b/Quake/sys_sdl_unix.c
index 71c8595..ab683ca 100644
--- a/Quake/sys_sdl_unix.c
+++ b/Quake/sys_sdl_unix.c
@@ -244,10 +244,30 @@ static char cwd[MAX_OSPATH];
static char userdir[MAX_OSPATH];
#ifdef PLATFORM_OSX
#define SYS_USERDIR "Library/Application Support/QuakeSpasm"
+#elif defined(PLATFORM_HAIKU)
+#define SYS_USERDIR "QuakeSpasm"
#else
#define SYS_USERDIR ".quakespasm"
#endif

+#ifdef PLATFORM_HAIKU
+
+#include <FindDirectory.h>
+#include <fs_info.h>
+
+static void Sys_GetUserdir (char *dst, size_t dstsize)
+{
+ dev_t volume = dev_for_path("/boot");
+ char buffer[B_PATH_NAME_LENGTH];
+ status_t result;
+
+ result = find_directory(B_USER_NONPACKAGED_DATA_DIRECTORY, volume, false, buffer, sizeof(buffer));
+ if (result != B_OK)
+ Sys_Error ("Couldn't determine userspace directory");
+
+ q_snprintf (dst, dstsize, "%s/%s", buffer, SYS_USERDIR);
+}
+#else
static void Sys_GetUserdir (char *dst, size_t dstsize)
{
size_t n;
@@ -274,6 +294,7 @@ static void Sys_GetUserdir (char *dst, size_t dstsize)

q_snprintf (dst, dstsize, "%s/%s", home_dir, SYS_USERDIR);
}
+#endif /* PLATFORM_HAIKU */
#endif /* DO_USERDIRS */

#ifdef PLATFORM_OSX
--
2.41.0

102 changes: 102 additions & 0 deletions games-fps/quakespasm/quakespasm-0.96.0~git.recipe
@@ -0,0 +1,102 @@
SUMMARY="An engine for id software's Quake"
DESCRIPTION="QuakeSpasm is a Haiku friendly Quake Engine based on the SDL port of the popular \
FitzQuake.
It includes some new features, important fixes, and aims for portability and 64 bit correctness.
Installation:
To install the game data under Haiku, copy the "id1" folder from a normal Quake installation \
to the following directory: ~/config/non-packaged/data/QuakeSpasm/. Mods should be installed \
to the same directory.
Features:
- Supports Windows, Mac OS X, Haiku, Linux, and other unices.
- Well tested on both 32 bit and 64 bit platforms. Well tested on both little endian and big \
endian platforms.
- OpenGL improvements. In-game resolution changing.
- Widescreen FOV (field of view) support and automatic Hor+ FOV scaling.
- Improved sound support. Support for OGG, MP3, Opus and WAV external music files.
- Improved game controller support using SDL2.
- Countless bug fixes, security fixes and other improvements.
- Support for playing the 'Quake 2021 re-release' content."
HOMEPAGE="https://quakespasm.sourceforge.net/"
COPYRIGHT="1996-2001 Id Software, Inc.
2002-2009 John Fitzgibbons and others
2010-2014 QuakeSpasm developers"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="70df2b661e9c632d04825b259e63ad58c29c01ac"
SOURCE_URI="https://github.com/sezero/quakespasm/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="b89ba914d061376945b1fbe2cd0631e162f4f0d835e004eba87a0a9cce107ad4"
SOURCE_DIR="quakespasm-$srcGitRev"
ADDITIONAL_FILES="QuakeSpasm.rdef.in
haiku_readme.txt"
PATCHES="quakespasm-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
quakespasm$secondaryArchSuffix = $portVersion
app:QuakeSpasm
"
REQUIRES="
haiku$secondaryArchSuffix
lib:libGL$secondaryArchSuffix
lib:libogg$secondaryArchSuffix
lib:libmad$secondaryArchSuffix
lib:libSDL2_2.0$secondaryArchSuffix
lib:libvorbis$secondaryArchSuffix
"

BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
devel:libGL$secondaryArchSuffix
devel:libogg$secondaryArchSuffix
devel:libmad$secondaryArchSuffix
devel:libSDL2_2.0$secondaryArchSuffix
devel:libvorbis$secondaryArchSuffix
"
BUILD_PREREQUIRES="
cmd:gcc$secondaryArchSuffix
cmd:ld$secondaryArchSuffix
cmd:make
"

BUILD()
{
cd $sourceDir/Quake
make $jobArgs DO_USERDIRS=1 USE_SDL2=1 -f Makefile
}

INSTALL()
{
local APP_SIGNATURE="application/x-vnd.QuakeSpasm"
local MAJOR="`echo "$portVersion" | cut -d. -f1`"
local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
local MINOR="`echo "${portVersion//~git}" | cut -d. -f3`"
local LONG_INFO="$SUMMARY"
sed \
-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
-e "s|@MAJOR@|$MAJOR|" \
-e "s|@MIDDLE@|$MIDDLE|" \
-e "s|@MINOR@|$MINOR|" \
-e "s|@LONG_INFO@|$LONG_INFO|" \
$portDir/additional-files/QuakeSpasm.rdef.in > QuakeSpasm.rdef

addResourcesToBinaries QuakeSpasm.rdef $sourceDir/Quake/quakespasm
mimeset -f $sourceDir/Quake/quakespasm

mkdir -p $appsDir
cp -a $sourceDir/Quake/quakespasm $appsDir/QuakeSpasm

mkdir -p $docDir
cp $sourceDir/Quakespasm.html $docDir/Quakespasm.html
cp $portDir/additional-files/haiku_readme.txt $docDir/haiku_readme.txt

mkdir -p $dataDir/QuakeSpasm
cp $sourceDir/Quake/quakespasm.pak $dataDir/QuakeSpasm/quakespasm.pak

addAppDeskbarSymlink $appsDir/QuakeSpasm
}