Skip to content

Commit 00ed1de

Browse files
authored
Merge pull request #4057 from protocultor/yquake2
Yamagi Quake 2 version 8.50 overhaul
2 parents 1c7a16a + 9d7c807 commit 00ed1de

File tree

4 files changed

+231
-29
lines changed

4 files changed

+231
-29
lines changed

scriptmodules/ports/yquake2.sh

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
rp_module_id="yquake2"
1313
rp_module_desc="yquake2 - The Yamagi Quake II client"
1414
rp_module_licence="GPL2 https://raw.githubusercontent.com/yquake2/yquake2/master/LICENSE"
15-
rp_module_repo="git https://github.com/yquake2/yquake2.git QUAKE2_8_41"
15+
rp_module_repo="git https://github.com/yquake2/yquake2.git QUAKE2_8_50"
1616
rp_module_section="exp"
17-
rp_module_flags=""
17+
rp_module_flags="sdl2"
1818

1919
function depends_yquake2() {
2020
local depends=(libgl1-mesa-dev libglu1-mesa-dev libogg-dev libopenal-dev libsdl2-dev libvorbis-dev zlib1g-dev libcurl4-openssl-dev)
@@ -25,15 +25,27 @@ function depends_yquake2() {
2525
function sources_yquake2() {
2626
gitPullOrClone
2727
# get the add-ons sources
28-
gitPullOrClone "$md_build/xatrix" "https://github.com/yquake2/xatrix" "XATRIX_2_13"
29-
gitPullOrClone "$md_build/rogue" "https://github.com/yquake2/rogue" "ROGUE_2_12"
28+
gitPullOrClone "$md_build/xatrix" "https://github.com/yquake2/xatrix" "XATRIX_2_14"
29+
gitPullOrClone "$md_build/rogue" "https://github.com/yquake2/rogue" "ROGUE_2_13"
30+
31+
# 1st enables Guide+Start to quit. 2nd restores buttons to SDL2 style (from SDL3).
32+
applyPatch "$md_data/hotkey_exit.diff"
33+
applyPatch "$md_data/sdl2_joylabels.diff"
3034
}
3135

3236
function build_yquake2() {
37+
local params=(config client game ref_soft)
38+
local repo
39+
40+
isPlatform "gl" || isPlatform "mesa" && params+=(ref_gl1)
41+
isPlatform "gl3" && params+=(ref_gl3)
42+
isPlatform "gles" && [[ "$__os_debian_ver" -lt 12 ]] && params+=(ref_gles1)
43+
isPlatform "gles3" && params+=(ref_gles3)
44+
3345
make clean
34-
make
46+
make ${params[@]}
47+
3548
# build the add-ons source
36-
local repo
3749
for repo in 'xatrix' 'rogue'; do
3850
make -C "$repo" clean
3951
make -C "$repo"
@@ -46,32 +58,32 @@ function build_yquake2() {
4658
function install_yquake2() {
4759
md_ret_files=(
4860
'release/baseq2'
49-
'release/q2ded'
5061
'release/quake2'
51-
'release/ref_gl1.so'
52-
'release/ref_gl3.so'
5362
'release/ref_soft.so'
5463
'LICENSE'
5564
'README.md'
5665
'xatrix/xatrix'
5766
'rogue/rogue'
5867
)
68+
69+
isPlatform "gl" || isPlatform "mesa" && md_ret_files+=('release/ref_gl1.so')
70+
isPlatform "gl3" && md_ret_files+=('release/ref_gl3.so')
71+
isPlatform "gles" && [[ "$__os_debian_ver" -lt 12 ]] && md_ret_files+=('release/ref_gles1.so')
72+
isPlatform "gles3" && md_ret_files+=('release/ref_gles3.so')
5973
}
6074

6175
function add_games_yquake2() {
6276
local cmd="$1"
6377
declare -A games=(
64-
['baseq2/pak0']="Quake II"
65-
['rogue/pak0']="Quake II - Ground Zero"
66-
['xatrix/pak0']="Quake II - The Reckoning"
78+
['baseq2']="Quake II"
79+
['xatrix']="Quake II XP1 - The Reckoning"
80+
['rogue']="Quake II XP2 - Ground Zero"
6781
)
6882

6983
local game
70-
local pak
7184
for game in "${!games[@]}"; do
72-
pak="$romdir/ports/quake2/$game.pak"
73-
if [[ -f "$pak" ]]; then
74-
addPort "$md_id" "quake2" "${games[$game]}" "$cmd" "${game%%/*}"
85+
if [[ -f "$romdir/ports/quake2/$game/pak0.pak" ]]; then
86+
addPort "$md_id" "quake2" "${games[$game]}" "$cmd" "$game"
7587
fi
7688
done
7789
}
@@ -92,24 +104,30 @@ function game_data_yquake2() {
92104

93105

94106
function configure_yquake2() {
95-
local params=()
107+
local config="$md_conf_root/quake2/yquake2/baseq2/yq2.cfg"
108+
local renderer="soft"
109+
110+
mkRomDir "ports/quake2"
111+
112+
moveConfigDir "$home/.yq2" "$md_conf_root/quake2/yquake2"
113+
mkUserDir "$md_conf_root/quake2/yquake2/baseq2"
114+
115+
copyDefaultConfig "$md_data/yq2.cfg" "$config"
116+
iniConfig " " '"' "$config"
96117

97118
if isPlatform "gl3"; then
98-
params+=("+set vid_renderer gl3")
119+
renderer="gl3"
120+
elif isPlatform "gles3"; then
121+
renderer="gles3"
122+
elif isPlatform "gles" && [[ "$__os_debian_ver" -lt 11 ]]; then
123+
renderer="gles1"
124+
iniSet "set gl1_pointparameters" "1"
99125
elif isPlatform "gl" || isPlatform "mesa"; then
100-
params+=("+set vid_renderer gl1")
101-
else
102-
params+=("+set vid_renderer soft")
103-
fi
104-
105-
if isPlatform "kms"; then
106-
params+=("+set r_mode -1" "+set r_customwidth %XRES%" "+set r_customheight %YRES%" "+set r_vsync 1")
126+
renderer="gl1"
107127
fi
108128

109-
mkRomDir "ports/quake2"
110-
111-
moveConfigDir "$home/.yq2" "$md_conf_root/quake2/yquake2"
129+
iniSet "set vid_renderer" "$renderer"
112130

113131
[[ "$md_mode" == "install" ]] && game_data_yquake2
114-
add_games_yquake2 "$md_inst/quake2 -datadir $romdir/ports/quake2 ${params[*]} +set game %ROM%"
132+
add_games_yquake2 "$md_inst/quake2 -datadir $romdir/ports/quake2 +set game %ROM%"
115133
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
diff --git a/src/client/input/sdl2.c b/src/client/input/sdl2.c
2+
index 7ea263a4..4e16892e 100644
3+
--- a/src/client/input/sdl2.c
4+
+++ b/src/client/input/sdl2.c
5+
@@ -79,11 +79,12 @@ typedef enum
6+
// IN_Update() called at the beginning of a frame to the
7+
// actual movement functions called at a later time.
8+
static float mouse_x, mouse_y;
9+
-static unsigned char joy_escbutton = SDL_CONTROLLER_BUTTON_START;
10+
static int joystick_left_x, joystick_left_y, joystick_right_x, joystick_right_y;
11+
static float gyro_yaw, gyro_pitch;
12+
static qboolean mlooking;
13+
14+
+static qboolean hotkey_back = false; // RetroPie Hotkey is Back instead of Guide
15+
+
16+
// The last time input events were processed.
17+
// Used throughout the client.
18+
int sys_frame_time;
19+
@@ -652,6 +653,7 @@ IN_Update(void)
20+
static qboolean left_trigger = false;
21+
static qboolean right_trigger = false;
22+
static qboolean left_stick[4] = {false, false, false, false}; // left, right, up, down virtual keys
23+
+ static qboolean hotkey_pressed = false; // is Hotkey in RetroPie pressed
24+
25+
static int consoleKeyCode = 0;
26+
27+
@@ -852,9 +854,22 @@ IN_Update(void)
28+
qboolean down = (event.type == SDL_CONTROLLERBUTTONDOWN);
29+
unsigned char btn = event.cbutton.button;
30+
31+
- // Handle Esc button first, to override its original key
32+
- Key_Event( (btn == joy_escbutton)? K_ESCAPE : K_JOY_FIRST_BTN + btn,
33+
- down, true );
34+
+ switch (btn)
35+
+ {
36+
+ case SDL_CONTROLLER_BUTTON_START:
37+
+ if (hotkey_pressed && down)
38+
+ Cbuf_AddText("quit");
39+
+ else
40+
+ Key_Event( K_ESCAPE, down, true );
41+
+ break;
42+
+
43+
+ case SDL_CONTROLLER_BUTTON_BACK:
44+
+ if (hotkey_back)
45+
+ case SDL_CONTROLLER_BUTTON_GUIDE:
46+
+ hotkey_pressed = down;
47+
+ default:
48+
+ Key_Event( K_JOY_FIRST_BTN + btn, down, true );
49+
+ }
50+
break;
51+
}
52+
53+
@@ -2204,22 +2219,6 @@ IN_Controller_Init(qboolean notify_user)
54+
SDL_Joystick *joystick = NULL;
55+
SDL_bool is_controller = SDL_FALSE;
56+
57+
- cvar = Cvar_Get("joy_escbutton", "0", CVAR_ARCHIVE);
58+
- if (cvar)
59+
- {
60+
- switch ((int)cvar->value)
61+
- {
62+
- case 1:
63+
- joy_escbutton = SDL_CONTROLLER_BUTTON_BACK;
64+
- break;
65+
- case 2:
66+
- joy_escbutton = SDL_CONTROLLER_BUTTON_GUIDE;
67+
- break;
68+
- default:
69+
- joy_escbutton = SDL_CONTROLLER_BUTTON_START;
70+
- }
71+
- }
72+
-
73+
cvar = Cvar_Get("in_initjoy", "1", CVAR_NOSET);
74+
if (!cvar->value)
75+
{
76+
@@ -2365,6 +2364,7 @@ IN_Controller_Init(qboolean notify_user)
77+
78+
show_gamepad = true;
79+
Com_Printf("Enabled as Game Controller, settings:\n%s\n", SDL_GameControllerMapping(controller));
80+
+ hotkey_back = ( !strstr(SDL_GameControllerMapping(controller), "guide:") );
81+
82+
#ifndef NO_SDL_GYRO
83+
84+
@@ -2540,6 +2540,7 @@ IN_Controller_Shutdown(qboolean notify_user)
85+
show_gamepad = show_gyro = show_haptic = false;
86+
joystick_left_x = joystick_left_y = joystick_right_x = joystick_right_y = 0;
87+
gyro_yaw = gyro_pitch = 0;
88+
+ hotkey_back = false;
89+
90+
#ifdef NO_SDL_GYRO
91+
if (imu_joystick)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
diff --git a/src/client/cl_keyboard.c b/src/client/cl_keyboard.c
2+
index 20ba3fcc..c9b24c41 100644
3+
--- a/src/client/cl_keyboard.c
4+
+++ b/src/client/cl_keyboard.c
5+
@@ -216,10 +216,10 @@ static char *gamepadbtns[] =
6+
// It is imperative that this list of buttons follow EXACTLY the order they
7+
// appear in QKEYS enum in keyboard.h, which in turn is the same order as
8+
// they appear in SDL_GamepadButton / SDL_GameControllerButton enum.
9+
- "BTN_SOUTH",
10+
- "BTN_EAST",
11+
- "BTN_WEST",
12+
- "BTN_NORTH",
13+
+ "BTN_A",
14+
+ "BTN_B",
15+
+ "BTN_X",
16+
+ "BTN_Y",
17+
"BTN_BACK",
18+
"BTN_GUIDE",
19+
"BTN_START",
20+
@@ -245,10 +245,10 @@ static char *gamepadbtns[] =
21+
"TRIG_LEFT",
22+
"TRIG_RIGHT",
23+
// Same with _ALT buttons ( button + 'alt modifier' pressed )
24+
- "BTN_SOUTH_ALT",
25+
- "BTN_EAST_ALT",
26+
- "BTN_WEST_ALT",
27+
- "BTN_NORTH_ALT",
28+
+ "BTN_A_ALT",
29+
+ "BTN_B_ALT",
30+
+ "BTN_X_ALT",
31+
+ "BTN_Y_ALT",
32+
"BTN_BACK_ALT",
33+
"BTN_GUIDE_ALT",
34+
"BTN_START_ALT",
35+
diff --git a/src/client/input/sdl2.c b/src/client/input/sdl2.c
36+
index a4fa5e25..8a4fa52f 100644
37+
--- a/src/client/input/sdl2.c
38+
+++ b/src/client/input/sdl2.c
39+
@@ -2467,8 +2467,8 @@ IN_Init(void)
40+
joy_forwardsensitivity = Cvar_Get("joy_forwardsensitivity", "1.0", CVAR_ARCHIVE);
41+
joy_sidesensitivity = Cvar_Get("joy_sidesensitivity", "1.0", CVAR_ARCHIVE);
42+
43+
- joy_labels = Cvar_Get("joy_labels", "-1", CVAR_ARCHIVE);
44+
- joy_confirm = Cvar_Get("joy_confirm", "-1", CVAR_ARCHIVE);
45+
+ joy_labels = Cvar_Get("joy_labels", "0", CVAR_ARCHIVE);
46+
+ joy_confirm = Cvar_Get("joy_confirm", "0", CVAR_ARCHIVE);
47+
joy_layout = Cvar_Get("joy_layout", "0", CVAR_ARCHIVE);
48+
joy_left_expo = Cvar_Get("joy_left_expo", "2.0", CVAR_ARCHIVE);
49+
joy_left_snapaxis = Cvar_Get("joy_left_snapaxis", "0.15", CVAR_ARCHIVE);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Default gamepad controls
2+
bind SHOULDR_LEFT "+movedown"
3+
bind TRIG_LEFT "+moveup"
4+
bind SHOULDR_RIGHT "+joyaltselector"
5+
bind TRIG_RIGHT "+attack"
6+
7+
bind BTN_A "+movedown"
8+
bind BTN_B "+moveup"
9+
bind BTN_X "weapprev"
10+
bind BTN_Y "weapnext"
11+
bind BTN_BACK "cmd help"
12+
bind BTN_GUIDE "+joyaltselector"
13+
bind STICK_LEFT "+gyroaction"
14+
bind STICK_RIGHT "centerview"
15+
bind DP_UP "cycleweap weapon_plasmabeam weapon_boomer weapon_chaingun weapon_etf_rifle weapon_machinegun weapon_blaster"
16+
bind DP_DOWN "cycleweap weapon_supershotgun weapon_shotgun weapon_chainfist"
17+
bind DP_LEFT "cycleweap weapon_phalanx weapon_rocketlauncher weapon_proxlauncher weapon_grenadelauncher ammo_grenades"
18+
bind DP_RIGHT "cycleweap weapon_bfg weapon_disintegrator weapon_railgun weapon_hyperblaster ammo_tesla ammo_trap"
19+
20+
bind BTN_X_ALT "invdrop"
21+
bind BTN_Y_ALT "invuse"
22+
bind BTN_BACK_ALT "inven"
23+
bind DP_UP_ALT "invprev"
24+
bind DP_DOWN_ALT "invnext"
25+
bind DP_LEFT_ALT "invprev"
26+
bind DP_RIGHT_ALT "invnext"
27+
28+
// Gameplay options, check YQ2 documentation
29+
set cl_run "1"
30+
set aimfix "1"
31+
set g_machinegun_norecoil "1"
32+
set g_quick_weap "1"
33+
set g_swap_speed "2"
34+
35+
// Audio options
36+
set s_openal "0"
37+
set ogg_ignoretrack0 "1"
38+
39+
// Video options
40+
set vid_renderer "soft"
41+
set gl1_discardfb "1"
42+
set gl1_lightmapcopies "1"
43+
set gl1_pointparameters "0"
44+
set r_mode "-2"

0 commit comments

Comments
 (0)