From c7e021c1f19b1b7572e3bcc46c9230c8b7660262 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Tue, 11 Jan 2022 02:09:10 +0100 Subject: [PATCH] Ports: Add GLTron The patches mainly convert this SDL1 game to SDL2. It has some graphical artifacts, but it's playable! --- Ports/AvailablePorts.md | 1 + Ports/gltron/package.sh | 27 ++++++++ Ports/gltron/patches/config.sub.patch | 11 ++++ Ports/gltron/patches/configure.patch | 29 +++++++++ Ports/gltron/patches/game_init_sdl_c.patch | 10 +++ Ports/gltron/patches/lua_makefile_in.patch | 22 +++++++ .../gltron/patches/nebu_input_system_c.patch | 25 ++++++++ Ports/gltron/patches/nebu_scripting_h.patch | 15 +++++ .../gltron/patches/nebu_video_system_c.patch | 63 +++++++++++++++++++ Ports/gltron/patches/scripts_config_lua.patch | 31 +++++++++ 10 files changed, 234 insertions(+) create mode 100755 Ports/gltron/package.sh create mode 100644 Ports/gltron/patches/config.sub.patch create mode 100644 Ports/gltron/patches/configure.patch create mode 100644 Ports/gltron/patches/game_init_sdl_c.patch create mode 100644 Ports/gltron/patches/lua_makefile_in.patch create mode 100644 Ports/gltron/patches/nebu_input_system_c.patch create mode 100644 Ports/gltron/patches/nebu_scripting_h.patch create mode 100644 Ports/gltron/patches/nebu_video_system_c.patch create mode 100644 Ports/gltron/patches/scripts_config_lua.patch diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index a65510846a..fb1d1c7a88 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -55,6 +55,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^ | [`git`](git/) | Git | 2.33.0 | https://git-scm.com/ | | [`glib`](glib/) | GLib | 2.70.0 | https://wiki.gnome.org/Projects/GLib | | [`glm`](glm/) | OpenGL Mathematics (GLM) | 0.9.9.8 | https://github.com/g-truc/glm | +| [`gltron`](gltron/) | GLTron | 0.70 | http://gltron.org | | [`glu`](glu/) | Mesa GLU | 9.0.2 | https://gitlab.freedesktop.org/mesa/glu | | [`gmp`](gmp/) | GNU Multiple Precision Arithmetic Library (GMP) | 6.2.1 | https://gmplib.org/ | | [`gnucobol`](gnucobol/) | GnuCOBOL | 3.1.2 | https://gnucobol.sourceforge.io/ | diff --git a/Ports/gltron/package.sh b/Ports/gltron/package.sh new file mode 100755 index 0000000000..fd357737b8 --- /dev/null +++ b/Ports/gltron/package.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port=gltron +useconfigure="true" +version="0.70" +files="http://mirror.sobukus.de/files/grimoire/games-arcade-2d/gltron-${version}-source.tar.gz gltron-${version}-source.tar.gz e0c8ebb41a18a1f8d7302a9c2cb466f5b1dd63e9a9966c769075e6b6bdad8bb0" +auth_type=sha256 +depends=("SDL_sound" "SDL2") +configopts=( + "--disable-warn" +) + +launcher_name="GLTron" +launcher_category="Games" +launcher_command="/usr/local/bin/gltron" +icon_file="art/default/gltron.png" + +pre_configure() { + export CPPFLAGS="-I${SERENITY_INSTALL_ROOT}/usr/include/LibGL -I${SERENITY_INSTALL_ROOT}/usr/local/include/SDL2" + export LIBS="-lSDL2_sound" + export SDL_CONFIG="${SERENITY_INSTALL_ROOT}/usr/local/bin/sdl2-config" +} + +post_configure() { + unset CPPFLAGS + unset LIBS + unset SDL_CONFIG +} diff --git a/Ports/gltron/patches/config.sub.patch b/Ports/gltron/patches/config.sub.patch new file mode 100644 index 0000000000..8cdc25e866 --- /dev/null +++ b/Ports/gltron/patches/config.sub.patch @@ -0,0 +1,11 @@ +--- gltron-0.70/config.sub 2002-03-23 17:40:17.000000000 +0000 ++++ gltron-0.70-patched/config.sub 2022-01-09 23:05:14.342418312 +0000 +@@ -1070,7 +1070,7 @@ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ +- | -os2* | -vos*) ++ | -os2* | -vos* | -serenity*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) diff --git a/Ports/gltron/patches/configure.patch b/Ports/gltron/patches/configure.patch new file mode 100644 index 0000000000..90a47c5616 --- /dev/null +++ b/Ports/gltron/patches/configure.patch @@ -0,0 +1,29 @@ +--- gltron-0.70/configure 2003-12-14 09:00:19.000000000 +0000 ++++ gltron-0.70-patched/configure 2022-01-10 00:11:14.467260522 +0000 +@@ -2805,7 +2805,7 @@ + RANLIB="$ac_cv_prog_RANLIB" + fi + +-CFLAGS="-DSEPARATOR=\"'/'\"" ++CFLAGS="$CFLAGS -DSEPARATOR=\"'/'\"" + + # Check whether --enable-warn or --disable-warn was given. + if test "${enable_warn+set}" = set; then +@@ -3130,7 +3130,7 @@ + echo $ECHO_N "(cached) $ECHO_C" >&6 + else + ac_check_lib_save_LIBS=$LIBS +-LIBS="-lGL $LIBS" ++LIBS="-lgl $LIBS" + cat >conftest.$ac_ext <<_ACEOF + #line 3135 "configure" + #include "confdefs.h" +@@ -3171,7 +3171,7 @@ + #define HAVE_LIBGL 1 + EOF + +- LIBS="-lGL $LIBS" ++ LIBS="-lgl $LIBS" + + else + { { echo "$as_me:3177: error: OpenGL is not installed" >&5 diff --git a/Ports/gltron/patches/game_init_sdl_c.patch b/Ports/gltron/patches/game_init_sdl_c.patch new file mode 100644 index 0000000000..10d416a1f0 --- /dev/null +++ b/Ports/gltron/patches/game_init_sdl_c.patch @@ -0,0 +1,10 @@ +--- gltron-0.70/src/game/init_sdl.c 2003-07-13 13:47:58.000000000 +0000 ++++ gltron-0.70-patched/src/game/init_sdl.c 2022-01-10 00:57:00.255732917 +0000 +@@ -22,7 +22,6 @@ + + void inputInit(void) { + /* keyboard */ +- SDL_EnableKeyRepeat(0, 0); /* turn keyrepeat off */ + + /* joystick */ + if(SDL_Init(SDL_INIT_JOYSTICK) >= 0) { diff --git a/Ports/gltron/patches/lua_makefile_in.patch b/Ports/gltron/patches/lua_makefile_in.patch new file mode 100644 index 0000000000..a2e1a1fdd4 --- /dev/null +++ b/Ports/gltron/patches/lua_makefile_in.patch @@ -0,0 +1,22 @@ +--- gltron-0.70/lua/src/lib/Makefile.in 2003-12-14 09:00:20.000000000 +0000 ++++ gltron-0.70-patched/lua/src/lib/Makefile.in 2022-01-10 00:05:42.499282291 +0000 +@@ -82,7 +82,7 @@ + + DEFS = + CPPFLAGS = +-CFLAGS = -ansi -pedantic -Wall -I$(srcdir)/.. -I$(top_srcdir)/lua/include ++CFLAGS = -pedantic -Wall -I$(srcdir)/.. -I$(top_srcdir)/lua/include + LDFLAGS = + LIBS = -lm + +--- gltron-0.70/lua/src/Makefile.in 2003-12-14 09:00:20.000000000 +0000 ++++ gltron-0.70-patched/lua/src/Makefile.in 2022-01-10 00:05:33.643271402 +0000 +@@ -84,7 +84,7 @@ + + DEFS = + AM_CPPFLAGS = +-AM_CFLAGS = -ansi -pedantic -Wall -I$(srcdir) -I$(top_srcdir)/lua/include ++AM_CFLAGS = -pedantic -Wall -I$(srcdir) -I$(top_srcdir)/lua/include + LDFLAGS = + LIBS = -lm + diff --git a/Ports/gltron/patches/nebu_input_system_c.patch b/Ports/gltron/patches/nebu_input_system_c.patch new file mode 100644 index 0000000000..f7d38ead18 --- /dev/null +++ b/Ports/gltron/patches/nebu_input_system_c.patch @@ -0,0 +1,25 @@ +--- gltron-0.70/nebu/input/input_system.c 2003-07-16 20:23:38.000000000 +0000 ++++ gltron-0.70-patched/nebu/input/input_system.c 2022-01-10 00:40:05.362550537 +0000 +@@ -6,18 +6,19 @@ + #include "SDL.h" + #include + ++extern SDL_Window* window; + static float joystick_threshold = 0; + + void SystemGrabInput() { +- SDL_WM_GrabInput(SDL_GRAB_ON); ++ SDL_SetWindowGrab(window, SDL_TRUE); + } + + void SystemUngrabInput() { +- SDL_WM_GrabInput(SDL_GRAB_OFF); ++ SDL_SetWindowGrab(window, SDL_FALSE); + } + + void SystemWarpPointer(int x, int y) { +- SDL_WarpMouse(x, y); ++ SDL_WarpMouseInWindow(window, x, y); + } + + void SystemHidePointer() { diff --git a/Ports/gltron/patches/nebu_scripting_h.patch b/Ports/gltron/patches/nebu_scripting_h.patch new file mode 100644 index 0000000000..7a631f2e07 --- /dev/null +++ b/Ports/gltron/patches/nebu_scripting_h.patch @@ -0,0 +1,15 @@ +--- gltron-0.70/nebu/include/scripting/nebu_scripting.h 2003-12-12 09:01:13.000000000 +0000 ++++ gltron-0.70-patched/nebu/include/scripting/nebu_scripting.h 2022-01-10 00:21:06.346024766 +0000 +@@ -18,9 +18,9 @@ + extern int scripting_CopyStringResult(char *s, int len); + + +-extern void scripting_RunFile(const char *name); +-extern void scripting_Run(const char *command); +-extern void scripting_RunFormat(const char *format, ...); ++extern void scripting_RunFile(char *name); ++extern void scripting_Run(char *command); ++extern void scripting_RunFormat(char *format, ...); + extern void scripting_RunGC(); + extern void scripting_Register(const char *name, int(*func) (lua_State *L)); + diff --git a/Ports/gltron/patches/nebu_video_system_c.patch b/Ports/gltron/patches/nebu_video_system_c.patch new file mode 100644 index 0000000000..48ef399d4d --- /dev/null +++ b/Ports/gltron/patches/nebu_video_system_c.patch @@ -0,0 +1,63 @@ +--- gltron-0.70/nebu/video/video_system.c 2003-07-21 08:18:57.000000000 +0000 ++++ gltron-0.70-patched/nebu/video/video_system.c 2022-01-10 00:39:53.078575380 +0000 +@@ -1,16 +1,17 @@ + #include "Nebu_video.h" + +-#include "SDL.h" ++#include "SDL.h" + #include "SDL_opengl.h" + +-static SDL_Surface *screen; ++SDL_Window* window; ++static SDL_GLContext glcontext; + static int width, height; + static int flags; + static int fullscreen; + extern int video_initialized; + + void SystemSwapBuffers() { +- SDL_GL_SwapBuffers(); ++ SDL_GL_SwapWindow(window); + } + + void SystemInitWindow(int x, int y, int w, int h) { +@@ -50,21 +51,22 @@ + } + + void SystemSetGamma(float red, float green, float blue) { +- SDL_SetGamma(red, green, blue); ++ SDL_SetWindowBrightness(window, (red + green + blue) / 3); + } + + int SystemCreateWindow(char *name) { +- int f = SDL_OPENGL; ++ int f = SDL_WINDOW_OPENGL; + if(fullscreen & SYSTEM_FULLSCREEN) +- f |= SDL_FULLSCREEN; +- if( (screen = SDL_SetVideoMode( width, height, 0, f )) == NULL ) { ++ f |= SDL_WINDOW_FULLSCREEN; ++ if( (window = SDL_CreateWindow("GLTron", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, f )) == NULL ) { + fprintf(stderr, "[system] Couldn't set GL mode: %s\n", SDL_GetError()); + exit(1); /* OK: critical, no visual */ + } +- SDL_WM_SetCaption("GLtron", ""); +- glClearColor(0,0,0,0); +- glClear(GL_COLOR_BUFFER_BIT); +- SDL_GL_SwapBuffers(); ++ glcontext = SDL_GL_CreateContext(window); ++ SDL_SetWindowTitle(window, "GLtron"); ++ glClearColor(0,0,0,0); ++ glClear(GL_COLOR_BUFFER_BIT); ++ SDL_GL_SwapWindow(window); + return 1; + } + +@@ -76,7 +78,7 @@ + /* there used to be some problems (memory leaks, unprober driver unloading) + * caused by this, but I can't remember what they where + */ +- ++ SDL_GL_DeleteContext(glcontext); + SDL_QuitSubSystem(SDL_INIT_VIDEO); + video_initialized = 0; + } diff --git a/Ports/gltron/patches/scripts_config_lua.patch b/Ports/gltron/patches/scripts_config_lua.patch new file mode 100644 index 0000000000..93dac2d217 --- /dev/null +++ b/Ports/gltron/patches/scripts_config_lua.patch @@ -0,0 +1,31 @@ +--- gltron-0.70/scripts/config.lua 2003-12-12 09:01:14.000000000 +0000 ++++ gltron-0.70-patched/scripts/config.lua 2022-01-11 01:05:39.007703324 +0000 +@@ -90,18 +90,18 @@ + + settings.keys = { + { -- player 1 +- left = 97, -- lower case 'a' +- right = 115, -- lower case 's' +- glance_left = 113, -- lower case 'q' +- glance_right = 119, -- lower case 'w' +- boost = 101, -- lower case 'd' ++ left = 65, -- lower case 'a' ++ right = 83, -- lower case 's' ++ glance_left = 81, -- lower case 'q' ++ glance_right = 87, -- lower case 'w' ++ boost = 68, -- lower case 'd' + }, + { -- player 2 +- left = 106, -- lower case 'j' +- right = 107, -- lower case 'k' +- glance_left = 117, -- lower case 'u' +- glance_right = 105, -- lower case 'i' +- boost = 108, -- lower case 'l' ++ left = 74, -- lower case 'j' ++ right = 75, -- lower case 'k' ++ glance_left = 85, -- lower case 'u' ++ glance_right = 73, -- lower case 'i' ++ boost = 76, -- lower case 'l' + }, + { -- player 3 + left = 276, -- cursor left