Ports: Convert GLTron patches to new format

This commit is contained in:
Jelle Raaijmakers 2022-05-09 01:01:01 +02:00 committed by Linus Groh
parent 37bbfc1b38
commit fa77e6b289
14 changed files with 295 additions and 168 deletions

View file

@ -52,7 +52,6 @@ PORTS_MISSING_DESCRIPTIONS = {
'genemu',
'gettext',
'git',
'gltron',
'gmp',
'gnucobol',
'gnupg',

View file

@ -0,0 +1,25 @@
From 94e90c97566a73cb03c4837d53a4cddf452e42bf Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:29:43 +0200
Subject: [PATCH 1/6] Build: Allow `CFLAGS` env var to be set
---
configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure b/configure
index 226d00e..05ebf5d 100755
--- a/configure
+++ b/configure
@@ -2805,7 +2805,7 @@ else
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
--
2.34.1

View file

@ -0,0 +1,34 @@
From dd42cfe84e75619676a06b05f8ebe1c1c2e658c9 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:30:04 +0200
Subject: [PATCH 2/6] Build: Replace `-lGL` with `-lgl` to reference our LibGL
---
configure | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 05ebf5d..10f771f 100755
--- a/configure
+++ b/configure
@@ -3130,7 +3130,7 @@ if test "${ac_cv_lib_GL_main+set}" = set; then
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 @@ if test $ac_cv_lib_GL_main = yes; then
#define HAVE_LIBGL 1
EOF
- LIBS="-lGL $LIBS"
+ LIBS="-lgl $LIBS"
else
{ { echo "$as_me:3177: error: OpenGL is not installed" >&5
--
2.34.1

View file

@ -0,0 +1,39 @@
From b01d5c00dd0dbe9512857e32ffd0822bdfb8a9e3 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:30:54 +0200
Subject: [PATCH 3/6] Build: Remove `-ansi` build argument
---
lua/src/Makefile.in | 2 +-
lua/src/lib/Makefile.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lua/src/Makefile.in b/lua/src/Makefile.in
index 22ee463..fa110ef 100644
--- a/lua/src/Makefile.in
+++ b/lua/src/Makefile.in
@@ -84,7 +84,7 @@ noinst_LIBRARIES = liblua.a
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/lua/src/lib/Makefile.in b/lua/src/lib/Makefile.in
index e2f256f..d2f4040 100644
--- a/lua/src/lib/Makefile.in
+++ b/lua/src/lib/Makefile.in
@@ -82,7 +82,7 @@ noinst_LIBRARIES = liblualib.a
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
--
2.34.1

View file

@ -0,0 +1,31 @@
From 0ec20dfd57ae517d18f06c4c580d346fddd2f926 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:32:04 +0200
Subject: [PATCH 4/6] Build: Fix `char*` vs. `const char*` arguments
These arguments are of the wrong constness, which will trip our
compiler.
---
nebu/include/scripting/nebu_scripting.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/nebu/include/scripting/nebu_scripting.h b/nebu/include/scripting/nebu_scripting.h
index 867eada..f5d8084 100644
--- a/nebu/include/scripting/nebu_scripting.h
+++ b/nebu/include/scripting/nebu_scripting.h
@@ -18,9 +18,9 @@ extern int scripting_GetStringResult(char **s);
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));
--
2.34.1

View file

@ -1,6 +1,18 @@
--- 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 @@
From d2a56ba682814f2d2451fc0729ada79290de2939 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:36:08 +0200
Subject: [PATCH 5/6] Scripting: Fix default keybindings
These constants referred to the wrong keys.
---
scripts/config.lua | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/scripts/config.lua b/scripts/config.lua
index 3c9e6d2..4755678 100644
--- a/scripts/config.lua
+++ b/scripts/config.lua
@@ -90,18 +90,18 @@ settings.musicVolume = 0.5
settings.keys = {
{ -- player 1
@ -29,3 +41,6 @@
},
{ -- player 3
left = 276, -- cursor left
--
2.34.1

View file

@ -0,0 +1,113 @@
From bcaa941ae5b682862aacff18e44a8a33294ba716 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:53:48 +0200
Subject: [PATCH 6/6] SDL: Convert SDL1 to SDL2
---
nebu/input/input_system.c | 7 ++++---
nebu/video/video_system.c | 20 +++++++++++---------
src/game/init_sdl.c | 1 -
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/nebu/input/input_system.c b/nebu/input/input_system.c
index 5b934e2..802540a 100644
--- a/nebu/input/input_system.c
+++ b/nebu/input/input_system.c
@@ -6,18 +6,19 @@
#include "SDL.h"
#include <stdlib.h>
+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/nebu/video/video_system.c b/nebu/video/video_system.c
index fdfcc56..9c985f8 100644
--- a/nebu/video/video_system.c
+++ b/nebu/video/video_system.c
@@ -3,14 +3,15 @@
#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 SystemInitDisplayMode(int f, unsigned char full) {
}
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", "");
+ glcontext = SDL_GL_CreateContext(window);
+ SDL_SetWindowTitle(window, "GLtron");
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
- SDL_GL_SwapBuffers();
+ SDL_GL_SwapWindow(window);
return 1;
}
@@ -76,7 +78,7 @@ void SystemDestroyWindow(int id) {
/* 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/src/game/init_sdl.c b/src/game/init_sdl.c
index bb787e5..c35eeca 100644
--- a/src/game/init_sdl.c
+++ b/src/game/init_sdl.c
@@ -22,7 +22,6 @@ void videoInit(void) {
void inputInit(void) {
/* keyboard */
- SDL_EnableKeyRepeat(0, 0); /* turn keyrepeat off */
/* joystick */
if(SDL_Init(SDL_INIT_JOYSTICK) >= 0) {
--
2.34.1

View file

@ -0,0 +1,35 @@
# Patches for gltron on SerenityOS
## `0001-Build-Allow-CFLAGS-env-var-to-be-set.patch`
Build: Allow `CFLAGS` env var to be set
## `0002-Build-Replace-lGL-with-lgl-to-reference-our-LibGL.patch`
Build: Replace `-lGL` with `-lgl` to reference our LibGL
## `0003-Build-Remove-ansi-build-argument.patch`
Build: Remove `-ansi` build argument
## `0004-Build-Fix-char-vs.-const-char-arguments.patch`
Build: Fix `char*` vs. `const char*` arguments
These arguments are of the wrong constness, which will trip our
compiler.
## `0005-Scripting-Fix-default-keybindings.patch`
Scripting: Fix default keybindings
These constants referred to the wrong keys.
## `0006-SDL-Convert-SDL1-to-SDL2.patch`
SDL: Convert SDL1 to SDL2

View file

@ -1,29 +0,0 @@
--- 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

View file

@ -1,10 +0,0 @@
--- 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) {

View file

@ -1,22 +0,0 @@
--- 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

View file

@ -1,25 +0,0 @@
--- 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 <stdlib.h>
+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() {

View file

@ -1,15 +0,0 @@
--- 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));

View file

@ -1,63 +0,0 @@
--- 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-11 23:08:04.316789459 +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;
}