summaryrefslogtreecommitdiff
path: root/Ports
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2021-12-24 15:24:16 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-27 11:58:43 +0100
commitb3672236bd48d03c8ee110bfdd7e147dea3f8b57 (patch)
treeb3e8ccc39e8a07366e54d1e3fd9ec7f1496cada6 /Ports
parent02647fd4858f52053073458338835624e65a3604 (diff)
downloadserenity-b3672236bd48d03c8ee110bfdd7e147dea3f8b57.zip
Ports: Add Tux Racer
The patches take care of a port from SDL1 to SDL2 and replace the keyboard mapping logic, which will otherwise take a whopping 16 GiB of memory to run.
Diffstat (limited to 'Ports')
-rw-r--r--Ports/AvailablePorts.md1
-rwxr-xr-xPorts/tuxracer/package.sh36
-rw-r--r--Ports/tuxracer/patches/configure.patch29
-rw-r--r--Ports/tuxracer/patches/source.patch372
4 files changed, 438 insertions, 0 deletions
diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md
index 7bb54abd80..3ea1ba0ea9 100644
--- a/Ports/AvailablePorts.md
+++ b/Ports/AvailablePorts.md
@@ -170,6 +170,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^
| [`stpuzzles`](stpuzzles/) | Simon Tatham's Portable Puzzle Collection | | https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ |
| [`stress-ng`](stress-ng/) | stress-ng | 0.11.23 | https://github.com/ColinIanKing/stress-ng |
| [`Super-Mario`](Super-Mario/) | Super-Mario Clone | | https://github.com/Bennyhwanggggg/Super-Mario-Clone-Cpp |
+| [`tuxracer`](tuxracer/) | Tux Racer | 0.61 | http://tuxracer.sourceforge.net/ |
| [`tcl`](tcl/) | Tcl | 8.6.11 | https://www.tcl-lang.org/ |
| [`termcap`](termcap/) | GNU termcap | 1.3.1 | https://www.gnu.org/software/termutils/ |
| [`tinycc`](tinycc/) | Tiny C Compiler (TinyCC) | dev | https://github.com/TinyCC/tinycc |
diff --git a/Ports/tuxracer/package.sh b/Ports/tuxracer/package.sh
new file mode 100755
index 0000000000..c08a539607
--- /dev/null
+++ b/Ports/tuxracer/package.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env -S bash ../.port_include.sh
+port=tuxracer
+useconfigure="true"
+version="0.61"
+files="http://ftp.e.kth.se/pub/mpkg/distfiles/tuxracer/${version}/tuxracer-${version}.tar.gz tuxracer-${version}.tar.gz a311d09080598fe556134d4b9faed7dc0c2ed956ebb10d062e5d4df022f91eff
+http://ftp.e.kth.se/pub/mpkg/distfiles/tuxracer/${version}/tuxracer-data-${version}.tar.gz tuxracer-data-${version}.tar.gz 3783d204b7bb1ed16aa5e5a1d5944de10fbee05bc7cebb8f616fce84301f3651"
+auth_type=sha256
+depends=("glu" "SDL2" "SDL2_mixer" "tcl")
+configopts=(
+ "--with-gl-inc=${SERENITY_INSTALL_ROOT}/usr/include/LibGL"
+ "--with-gl-lib-name=gl"
+ "--with-sdl-prefix=${SERENITY_INSTALL_ROOT}/usr/local"
+ "--with-tcl-lib-name=tcl8.6"
+ "--without-x"
+)
+launcher_name="Tux Racer"
+launcher_category="Games"
+launcher_command="/usr/local/bin/tuxracer"
+
+pre_configure() {
+ export CFLAGS="-I${SERENITY_INSTALL_ROOT}/usr/local/include/SDL2"
+ export CXXFLAGS="-I${SERENITY_INSTALL_ROOT}/usr/local/include/SDL2"
+ export LIBS="-lmodplug -lSDL2"
+}
+
+post_configure() {
+ unset LIBS
+ unset CXXFLAGS
+ unset CFLAGS
+}
+
+post_install() {
+ resourcePath="${SERENITY_INSTALL_ROOT}/usr/local/share/tuxracer"
+ mkdir -p "${resourcePath}"
+ cp -r tuxracer-data-${version}/* "${resourcePath}/"
+}
diff --git a/Ports/tuxracer/patches/configure.patch b/Ports/tuxracer/patches/configure.patch
new file mode 100644
index 0000000000..d6e803788d
--- /dev/null
+++ b/Ports/tuxracer/patches/configure.patch
@@ -0,0 +1,29 @@
+--- tuxracer-0.61-original/configure 2021-12-23 14:26:17.978567580 +0000
++++ tuxracer-0.61/configure 2021-12-24 12:12:08.718881004 +0000
+@@ -1674,7 +1674,7 @@
+
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if [ "$ac_func" = "isnan" ]; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+ else
+@@ -3415,7 +3415,7 @@
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ ac_save_LIBS="$LIBS"
+-LIBS="-lSDL_mixer $LIBS"
++LIBS="-lSDL2_mixer $LIBS"
+ cat > conftest.$ac_ext <<EOF
+ #line 3423 "configure"
+ #include "confdefs.h"
+@@ -3452,7 +3452,7 @@
+
+ if test "x$have_SDL_mixer" = "xyes" ; then
+ TR_CPPFLAGS="$TR_CPPFLAGS -DHAVE_SDL_MIXER=1"
+- TR_LIBS="$TR_LIBS -lSDL_mixer"
++ TR_LIBS="$TR_LIBS -lSDL2_mixer"
+ else
+ echo "*** SDL_mixer not found. Configuring without audio support."
+ fi
diff --git a/Ports/tuxracer/patches/source.patch b/Ports/tuxracer/patches/source.patch
new file mode 100644
index 0000000000..ff5948a924
--- /dev/null
+++ b/Ports/tuxracer/patches/source.patch
@@ -0,0 +1,372 @@
+diff -ur tuxracer-0.61-original/src/game_config.c tuxracer-0.61/src/game_config.c
+--- tuxracer-0.61-original/src/game_config.c 2001-01-30 20:04:43.000000000 +0000
++++ tuxracer-0.61/src/game_config.c 2021-12-26 13:41:33.341076372 +0000
+@@ -114,26 +114,26 @@
+ */
+
+ #define INIT_PARAM( nam, val, typename, commnt ) \
+- Params. ## nam ## .loaded = False; \
+- Params. ## nam ## .name = #nam; \
+- Params. ## nam ## .deflt. ## typename ## _val = val; \
+- Params. ## nam ## .comment = commnt;
++ Params.nam.loaded = False; \
++ Params.nam.name = #nam; \
++ Params.nam.deflt.typename ## _val = val; \
++ Params.nam.comment = commnt;
+
+ #define INIT_PARAM_STRING( nam, val, commnt ) \
+ INIT_PARAM( nam, val, string, commnt ); \
+- Params. ## nam ## .type = PARAM_STRING;
++ Params.nam.type = PARAM_STRING;
+
+ #define INIT_PARAM_CHAR( nam, val, commnt ) \
+ INIT_PARAM( nam, val, char, commnt ); \
+- Params. ## nam ## .type = PARAM_CHAR;
++ Params.nam.type = PARAM_CHAR;
+
+ #define INIT_PARAM_INT( nam, val, commnt ) \
+ INIT_PARAM( nam, val, int, commnt ); \
+- Params. ## nam ## .type = PARAM_INT;
++ Params.nam.type = PARAM_INT;
+
+ #define INIT_PARAM_BOOL( nam, val, commnt ) \
+ INIT_PARAM( nam, val, bool, commnt ); \
+- Params. ## nam ## .type = PARAM_BOOL;
++ Params.nam.type = PARAM_BOOL;
+
+
+ /*
+@@ -310,13 +310,13 @@
+ */
+ #define FN_PARAM( name, typename, type ) \
+ type getparam_ ## name() { \
+- if ( !Params. ## name ## .loaded ) { \
+- fetch_param_ ## typename( &( Params. ## name ) ); \
++ if ( !Params.name.loaded ) { \
++ fetch_param_ ## typename( &( Params.name ) ); \
+ } \
+- return Params. ## name ## .val. ## typename ## _val; \
++ return Params.name.val.typename ## _val; \
+ } \
+ void setparam_ ## name( type val) { \
+- set_param_ ## typename( &( Params. ## name ), val ); }
++ set_param_ ## typename( &( Params.name ), val ); }
+
+ #define FN_PARAM_STRING( name ) \
+ FN_PARAM( name, string, char* )
+@@ -505,7 +505,7 @@
+ "# decreasing this number, at the cost of lower image quality." );
+
+ INIT_PARAM_BOOL(
+- fullscreen, True,
++ fullscreen, False,
+ "# If true then the game will run in full-screen mode." );
+
+ INIT_PARAM_INT(
+diff -ur tuxracer-0.61-original/src/keyboard.c tuxracer-0.61/src/keyboard.c
+--- tuxracer-0.61-original/src/keyboard.c 2001-01-13 22:09:51.000000000 +0000
++++ tuxracer-0.61/src/keyboard.c 2021-12-26 13:41:33.341076372 +0000
+@@ -23,11 +23,17 @@
+ #include "loop.h"
+
+ #define KEYMAP_SIZE 1000
+-#define KEYTABLE_SIZE WSK_LAST
+-#define SPECIAL_KEYTABLE_SIZE WSK_LAST
++#define KEYTABLE_SIZE 100
+
+-static key_cb_t keytable[KEYTABLE_SIZE];
+-static key_cb_t special_keytable[SPECIAL_KEYTABLE_SIZE];
++static key_cb_t keytable_callback[KEYTABLE_SIZE];
++static int keytable_key[KEYTABLE_SIZE];
++static int num_keytable_entries = 0;
++
++static key_cb_t special_keytable_callback[KEYTABLE_SIZE];
++static int special_keytable_key[KEYTABLE_SIZE];
++static int num_special_keytable_entries = 0;
++
++static key_cb_t default_keytable_callback = NULL;
+
+ static keymap_t keymap[KEYMAP_SIZE];
+ static int num_keymap_entries = 0;
+@@ -50,19 +56,6 @@
+ return 0; /* success */
+ }
+
+-static void fill_keytable( key_cb_t value )
+-{
+- int i;
+-
+- for (i=0; i<KEYTABLE_SIZE; i++) {
+- keytable[i] = value;
+- }
+-
+- for (i=0; i<SPECIAL_KEYTABLE_SIZE; i++) {
+- special_keytable[i] = value;
+- }
+-}
+-
+ static int insert_keytable_entries( char *keys, key_cb_t callback )
+ {
+ key_desc_t *key_list;
+@@ -74,9 +67,13 @@
+ if ( num_keys > 0 ) {
+ for ( i=0; i<num_keys; i++ ) {
+ if ( key_list[i].special ) {
+- special_keytable[ key_list[i].key ] = callback;
++ special_keytable_callback[num_special_keytable_entries] = callback;
++ special_keytable_key[num_special_keytable_entries] = key_list[i].key;
++ ++num_special_keytable_entries;
+ } else {
+- keytable[ key_list[i].key ] = callback;
++ keytable_callback[num_keytable_entries] = callback;
++ keytable_key[num_keytable_entries] = key_list[i].key;
++ ++num_keytable_entries;
+ }
+ }
+
+@@ -92,15 +89,14 @@
+ {
+ int i;
+ char *keys;
+- fill_keytable( NULL );
+
+ /* Handle default callbacks first */
+ for (i=0; i<num_keymap_entries; i++) {
+ if ( ( keymap[i].mode == mode || keymap[i].mode == ALL_MODES ) &&
+ keymap[i].keymap_class == DEFAULT_CALLBACK )
+ {
+- fill_keytable( keymap[i].key_cb );
+- }
++ default_keytable_callback = keymap[i].key_cb;
++ }
+ }
+
+ /* Handle other classes */
+@@ -155,7 +151,9 @@
+ bool_t release, int x, int y )
+ {
+ static game_mode_t last_mode = NO_MODE;
+- key_cb_t *table;
++ int* table_key;
++ key_cb_t* table_callback;
++ int num_entries;
+
+ if ( is_mode_change_pending() ) {
+ /* Don't process keyboard events until the mode change happens */
+@@ -168,18 +166,28 @@
+ }
+
+ if ( special ) {
+- table = special_keytable;
++ table_callback = special_keytable_callback;
++ table_key = special_keytable_key;
++ num_entries = num_special_keytable_entries;
+ } else {
+- table = keytable;
++ table_callback = keytable_callback;
++ table_key = keytable_key;
++ num_entries = num_keytable_entries;
+ }
+
+ if ( isalpha( key ) ) {
+- key = tolower( key );
++ key = tolower( key );
+ }
+
+- if ( table[key] != NULL ) {
+- (table[key])( key, special, release, x, y );
+- }
++ // Find index
++ int callback_index = 0;
++ for (; callback_index < num_entries; ++callback_index) {
++ if (table_key[callback_index] == key)
++ break;
++ }
++ if (callback_index < num_entries) {
++ (table_callback[callback_index])(key, special, release, x, y);
++ }
+ }
+
+ void init_keyboard()
+diff -ur tuxracer-0.61-original/src/winsys.c tuxracer-0.61/src/winsys.c
+--- tuxracer-0.61-original/src/winsys.c 2001-01-13 22:09:51.000000000 +0000
++++ tuxracer-0.61/src/winsys.c 2021-12-26 13:48:57.590964343 +0000
+@@ -36,7 +36,8 @@
+ /*---------------------------------------------------------------------------*/
+ /*---------------------------------------------------------------------------*/
+
+-static SDL_Surface *screen = NULL;
++static SDL_Window *screen = NULL;
++static SDL_GLContext context = NULL;
+
+ static winsys_display_func_t display_func = NULL;
+ static winsys_idle_func_t idle_func = NULL;
+@@ -164,7 +165,7 @@
+ */
+ void winsys_swap_buffers()
+ {
+- SDL_GL_SwapBuffers();
++ SDL_GL_SwapWindow(screen);
+ }
+
+
+@@ -177,7 +178,7 @@
+ */
+ void winsys_warp_pointer( int x, int y )
+ {
+- SDL_WarpMouse( x, y );
++ SDL_WarpMouseInWindow( screen, x, y );
+ }
+
+
+@@ -190,14 +191,14 @@
+ */
+ static void setup_sdl_video_mode()
+ {
+- Uint32 video_flags = SDL_OPENGL;
++ Uint32 video_flags = SDL_WINDOW_OPENGL;
+ int bpp = 0;
+ int width, height;
+
+ if ( getparam_fullscreen() ) {
+- video_flags |= SDL_FULLSCREEN;
++ video_flags |= SDL_WINDOW_FULLSCREEN;
+ } else {
+- video_flags |= SDL_RESIZABLE;
++ video_flags |= SDL_WINDOW_RESIZABLE;
+ }
+
+ switch ( getparam_bpp_mode() ) {
+@@ -224,12 +225,16 @@
+ width = getparam_x_resolution();
+ height = getparam_y_resolution();
+
+- if ( ( screen = SDL_SetVideoMode( width, height, bpp, video_flags ) ) ==
++ if ( ( screen = SDL_CreateWindow("Tuxracer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, video_flags ) ) ==
+ NULL )
+ {
+ handle_system_error( 1, "Couldn't initialize video: %s",
+ SDL_GetError() );
+ }
++
++ context = SDL_GL_CreateContext(screen);
++ if (context == NULL)
++ handle_system_error( 1, "Couldn't initialize video: %s", SDL_GetError() );
+ }
+
+
+@@ -266,8 +271,7 @@
+
+ setup_sdl_video_mode();
+
+- SDL_WM_SetCaption( window_title, icon_title );
+-
++ SDL_SetWindowTitle(screen, window_title);
+ }
+
+
+@@ -280,6 +284,7 @@
+ */
+ void winsys_shutdown()
+ {
++ SDL_GL_DeleteContext(context);
+ SDL_Quit();
+ }
+
+@@ -293,12 +298,6 @@
+ */
+ void winsys_enable_key_repeat( bool_t enabled )
+ {
+- if ( enabled ) {
+- SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY,
+- SDL_DEFAULT_REPEAT_INTERVAL );
+- } else {
+- SDL_EnableKeyRepeat( 0, 0 );
+- }
+ }
+
+
+@@ -330,9 +329,6 @@
+
+ while (True) {
+
+- SDL_LockAudio();
+- SDL_UnlockAudio();
+-
+ while ( SDL_PollEvent( &event ) ) {
+
+ switch ( event.type ) {
+@@ -384,18 +380,15 @@
+ }
+ break;
+
+- case SDL_VIDEORESIZE:
++ case SDL_WINDOWEVENT_RESIZED:
+ setup_sdl_video_mode();
+ if ( reshape_func ) {
+- (*reshape_func)( event.resize.w,
+- event.resize.h );
++ (*reshape_func)( event.window.data1,
++ event.window.data2 );
+ }
+
+ break;
+ }
+-
+- SDL_LockAudio();
+- SDL_UnlockAudio();
+ }
+
+ if ( redisplay && display_func ) {
+diff -ur tuxracer-0.61-original/src/winsys.h tuxracer-0.61/src/winsys.h
+--- tuxracer-0.61-original/src/winsys.h 2001-01-13 22:09:51.000000000 +0000
++++ tuxracer-0.61/src/winsys.h 2021-12-26 13:41:33.341076372 +0000
+@@ -48,16 +48,16 @@
+ WSK_NOT_AVAIL = SDLK_UNKNOWN,
+
+ /* Numeric keypad */
+- WSK_KP0 = SDLK_KP0,
+- WSK_KP1 = SDLK_KP1,
+- WSK_KP2 = SDLK_KP2,
+- WSK_KP3 = SDLK_KP3,
+- WSK_KP4 = SDLK_KP4,
+- WSK_KP5 = SDLK_KP5,
+- WSK_KP6 = SDLK_KP6,
+- WSK_KP7 = SDLK_KP7,
+- WSK_KP8 = SDLK_KP8,
+- WSK_KP9 = SDLK_KP9,
++ WSK_KP0 = SDLK_KP_0,
++ WSK_KP1 = SDLK_KP_1,
++ WSK_KP2 = SDLK_KP_2,
++ WSK_KP3 = SDLK_KP_3,
++ WSK_KP4 = SDLK_KP_4,
++ WSK_KP5 = SDLK_KP_5,
++ WSK_KP6 = SDLK_KP_6,
++ WSK_KP7 = SDLK_KP_7,
++ WSK_KP8 = SDLK_KP_8,
++ WSK_KP9 = SDLK_KP_9,
+ WSK_KP_PERIOD = SDLK_KP_PERIOD,
+ WSK_KP_DIVIDE = SDLK_KP_DIVIDE,
+ WSK_KP_MULTIPLY = SDLK_KP_MULTIPLY,
+@@ -95,17 +95,17 @@
+ WSK_F15 = SDLK_F15,
+
+ /* Key state modifier keys */
+- WSK_NUMLOCK = SDLK_NUMLOCK,
++ WSK_NUMLOCK = SDLK_NUMLOCKCLEAR,
+ WSK_CAPSLOCK = SDLK_CAPSLOCK,
+- WSK_SCROLLOCK = SDLK_SCROLLOCK,
++ WSK_SCROLLOCK = SDLK_SCROLLLOCK,
+ WSK_RSHIFT = SDLK_RSHIFT,
+ WSK_LSHIFT = SDLK_LSHIFT,
+ WSK_RCTRL = SDLK_RCTRL,
+ WSK_LCTRL = SDLK_LCTRL,
+ WSK_RALT = SDLK_RALT,
+ WSK_LALT = SDLK_LALT,
+- WSK_RMETA = SDLK_RMETA,
+- WSK_LMETA = SDLK_LMETA,
++ WSK_RMETA = SDLK_RALT,
++ WSK_LMETA = SDLK_LALT,
+
+ WSK_LAST
+