Ports: Add Sonic Robo Blast 2

This commit adds Sonic Robo Blast 2, a Sonic fangame running with SDL2
to the list of SerenityOS game ports.
The game is working fine for the most part but there's some performance
issues and the mouse never resets to the center so it gets stuck in the
window's corners. It seems like the multiplayer / networking is also
not quite working but I think that this is very cool already.
This commit is contained in:
Refrag 2024-02-04 18:12:38 +01:00 committed by Tim Schumacher
parent a580118e53
commit 4fbc701721
8 changed files with 318 additions and 0 deletions

View file

@ -303,6 +303,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n
| [`sparsehash`](sparsehash/) | Google's C++ associative containers | 2.0.4 | https://github.com/sparsehash/sparsehash |
| [`speexdsp`](speexdsp/) | Speex audio processing library | 1.2.1 | https://www.speex.org/ |
| [`sqlite`](sqlite/) | SQLite | 3430000 | https://www.sqlite.org/ |
| [`SRB2`](SRB2/) | Sonic Robo Blast 2 | 2.2.13 | https://www.srb2.org/ |
| [`ssmtp`](ssmtp/) | sSMTP is a simple MTA | 2.64-11 | https://wiki.debian.org/sSMTP |
| [`stb`](stb/) | stb single-file public domain libraries for C/C++ | af1a5bc | https://github.com/nothings/stb |
| [`stockfish`](stockfish/) | Stockfish: A free and strong UCI chess engine | 16 | https://github.com/official-stockfish/Stockfish |

42
Ports/SRB2/package.sh Executable file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env -S bash ../.port_include.sh
port='SRB2'
useconfigure=true
version='2.2.13'
depends=(
'curl'
'libpng'
'SDL2'
'SDL2_mixer'
)
configopts=(
'-B./build'
"-DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt"
'-DSRB2_CONFIG_ENABLE_TESTS=OFF'
'-DSRB2_CONFIG_SYSTEM_LIBRARIES=ON'
'-DSRB2_SDL2_EXE_NAME=srb2'
)
files=(
"https://github.com/STJr/SRB2/archive/refs/tags/SRB2_release_${version}.tar.gz#0fc460dc93c056c21bfcc389ac0515588673ee692968d9a6711b19e63d283b3f"
"https://git.do.srb2.org/STJr/srb2assets-public/-/archive/SRB2_release_${version}/srb2assets-public-SRB2_release_${version}.tar.gz#edcc98a7ad0c0878013b39ca3941cdf8094f6cbab5129911abe3022170e96b8a"
)
workdir="SRB2-SRB2_release_${version}"
launcher_name='Sonic Robo Blast 2'
launcher_category='&Games'
launcher_command='/usr/local/games/SRB2/srb2'
icon_file='srb2.png'
install_dir='/usr/local/games/SRB2'
configure() {
run cmake "${configopts[@]}" .
}
build() {
run make -C build -j${MAKEJOBS}
}
install() {
run /usr/bin/install -d "${SERENITY_INSTALL_ROOT}${install_dir}/"
run /usr/bin/install ./build/bin/srb2 ./srb2.png "${SERENITY_INSTALL_ROOT}${install_dir}"
run cp -r "../srb2assets-public-SRB2_release_${version}/." "${SERENITY_INSTALL_ROOT}${install_dir}/"
}

View file

@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Refrag <R3FR4GYT@gmail.com>
Date: Sun, 4 Feb 2024 17:45:14 +0100
Subject: [PATCH] Add OpenMPT to build
The build system doesn't give us much choice on what library to build and what library to look for.
OpenMPT is not built by default but we need it to build so this goes and change that.
---
CMakeLists.txt | 1 -
thirdparty/CMakeLists.txt | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 80a3bdcd6..9bf42970b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -130,7 +130,6 @@ if("${SRB2_CONFIG_SYSTEM_LIBRARIES}")
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(CURL REQUIRED)
- find_package(OPENMPT REQUIRED)
# libgme defaults to "Nuked" YM2612 emulator, which is
# very SLOW. The system library probably uses the
diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
index f33b3bf3f..141114e70 100644
--- a/thirdparty/CMakeLists.txt
+++ b/thirdparty/CMakeLists.txt
@@ -15,7 +15,7 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
include("cpm-zlib.cmake")
include("cpm-png.cmake")
include("cpm-curl.cmake")
- include("cpm-openmpt.cmake")
endif()
+include("cpm-openmpt.cmake")
include("cpm-libgme.cmake")

View file

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Refrag <R3FR4GYT@gmail.com>
Date: Sun, 4 Feb 2024 17:45:15 +0100
Subject: [PATCH] Fix libgme include
One of the build targets is looking for the gme.h header.
It seems like it cannot automatically find it so we help it a little.
---
CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 80a3bdcd6..a01d32e1f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -168,6 +168,7 @@ set(SRB2_SDL2_EXE_NAME "" CACHE STRING "Override executable binary output name")
set(SRB2_SDL2_EXE_SUFFIX "" CACHE STRING "Optional executable suffix, separated by an underscore")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
+include_directories(${CMAKE_BINARY_DIR}/_deps/libgme-src)
add_subdirectory(src)
add_subdirectory(assets)

View file

@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Refrag <R3FR4GYT@gmail.com>
Date: Sun, 4 Feb 2024 17:45:16 +0100
Subject: [PATCH] Disable Console Variables value checker sad path
For some reason, the value checker for console variables seems to not behave properly even with the default console variables value.
Disabling the error path resolves this issue and the game still works fine without it.
---
src/command.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/command.c b/src/command.c
index e1a43522d..4336d19ac 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1522,8 +1522,6 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
override = true;
overrideval = v;
}
- if (v == INT32_MIN)
- goto badinput;
#undef MINVAL
#undef MAXVAL
}
@@ -1558,9 +1556,6 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
goto found;
}
}
-
- // ...or not.
- goto badinput;
found:
if (client && execversion_enabled)
{

View file

@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Refrag <R3FR4GYT@gmail.com>
Date: Sun, 4 Feb 2024 17:45:17 +0100
Subject: [PATCH] i_video.c: Mouse hacks
This patch works aroud the SDL relative mouse implementation as it is not implemented in the port.
SRB2 relies on it quite heavily to make the mouse work, not having this unfortunately means that the mouse doesn't reset back to the center and will get stuck at the window borders. Ultimately, we would want this relative mouse implementation to have a proper mouse support.
Removing the calls to the SDL relative mouse felt like the best option for now as otherwise the console gets spammed with this "No relative mode implementation available" messsage.
---
src/sdl/i_video.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c
index 590d7d142..18002f94c 100644
--- a/src/sdl/i_video.c
+++ b/src/sdl/i_video.c
@@ -402,8 +402,8 @@ static void SDLdoGrabMouse(void)
{
SDL_ShowCursor(SDL_DISABLE);
SDL_SetWindowGrab(window, SDL_TRUE);
- if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful
- wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore?
+ //if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful
+ wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore?
}
static void SDLdoUngrabMouse(void)
@@ -411,7 +411,7 @@ static void SDLdoUngrabMouse(void)
SDL_ShowCursor(SDL_ENABLE);
SDL_SetWindowGrab(window, SDL_FALSE);
wrapmouseok = SDL_FALSE;
- SDL_SetRelativeMouseMode(SDL_FALSE);
+ //SDL_SetRelativeMouseMode(SDL_FALSE);
}
void SDLforceUngrabMouse(void)
@@ -701,8 +701,8 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
// If using relative mouse mode, don't post an event_t just now,
// add on the offsets so we can make an overall event later.
- if (SDL_GetRelativeMouseMode())
- {
+ //if (SDL_GetRelativeMouseMode())
+ //{
if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window)
{
mousemovex += evt.xrel;
@@ -711,7 +711,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
}
firstmove = false;
return;
- }
+ //}
// If the event is from warping the pointer to middle
// of the screen then ignore it.

View file

@ -0,0 +1,88 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Refrag <R3FR4GYT@gmail.com>
Date: Sun, 4 Feb 2024 17:45:18 +0100
Subject: [PATCH] i_system.c hacks
This patch disables / removes some code to get the game to build without issues.
These don't seem to matter much anyway as the game still runs.
---
src/sdl/i_system.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c
index 902194f4f..e2306aa9c 100644
--- a/src/sdl/i_system.c
+++ b/src/sdl/i_system.c
@@ -83,14 +83,11 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <sys/vfs.h>
#else
#include <sys/param.h>
-#include <sys/mount.h>
/*For meminfo*/
#include <sys/types.h>
#ifdef FREEBSD
#include <kvm.h>
#endif
-#include <nlist.h>
-#include <sys/sysctl.h>
#endif
#endif
@@ -138,7 +135,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#endif
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
-#include <execinfo.h>
#include <time.h>
#define UNIXBACKTRACE
#endif
@@ -267,6 +263,7 @@ UINT8 keyboard_started = false;
static void write_backtrace(INT32 signal)
{
+#if 0
int fd = -1;
size_t size;
time_t rawtime;
@@ -316,6 +313,7 @@ static void write_backtrace(INT32 signal)
CRASHLOG_WRITE("\n"); // Write another newline to the log so it looks nice :)
close(fd);
+#endif
}
#undef STDERR_WRITE
#undef CRASHLOG_WRITE
@@ -2066,6 +2064,8 @@ void I_StartupMouse2(void)
else
rts = 1;
}
+
+ #if 0
if (dtr != -1 || rts != -1)
{
INT32 c;
@@ -2082,6 +2082,7 @@ void I_StartupMouse2(void)
c |= TIOCM_RTS;
ioctl(fdmouse2, TIOCMSET, &c);
}
+ #endif
}
mouse2_started = 1;
I_AddExitFunc(I_ShutdownMouse2);
@@ -2671,14 +2672,8 @@ void I_GetDiskFreeSpace(INT64 *freespace)
#if defined (SOLARIS) || defined (__HAIKU__)
*freespace = INT32_MAX;
return;
-#else // Both Linux and BSD have this, apparently.
- struct statfs stfs;
- if (statfs(srb2home, &stfs) == -1)
- {
- *freespace = INT32_MAX;
- return;
- }
- *freespace = stfs.f_bavail * stfs.f_bsize;
+#else
+ *freespace = 1024*1024*1024;
#endif
#elif defined (_WIN32)
static p_GetDiskFreeSpaceExA pfnGetDiskFreeSpaceEx = NULL;

View file

@ -0,0 +1,37 @@
# Patches for SRB2 on SerenityOS
## `0001-add-openmpt-to-build.patch`
Add OpenMPT to build
The build system doesn't give us much choice on what library to build and what library to look for.
OpenMPT is not built by default but we need it to build so this goes and change that.
## `0002-fix-libgme-include.patch`
Fix libgme include
One of the build targets is looking for the gme.h header.
It seems like it cannot automatically find it so we help it a little.
## `0003-disable-consolevar-value-checker-sad-path.patch`
Disable Console Variables value checker sad path
For some reason, the value checker for console variables seems to not behave properly even with the default console variables value.
Disabling the error path resolves this issue and the game still works fine without it.
## `0004-i_video.c-mouse-hacks.patch`
i_video.c: Mouse hacks
This patch works aroud the SDL relative mouse implementation as it is not implemented in the port.
SRB2 relies on it quite heavily to make the mouse work, not having this unfortunately means that the mouse doesn't reset back to the center and will get stuck at the window borders. Ultimately, we would want this relative mouse implementation to have a proper mouse support.
Removing the calls to the SDL relative mouse felt like the best option for now as otherwise the console gets spammed with this "No relative mode implementation available" messsage.
## `0005-i_system.c-hacks.patch`
i_system.c hacks
This patch disables / removes some code to get the game to build without issues.
These don't seem to matter much anyway as the game still runs.