Skip to content

Commit ecf5043

Browse files
authored
Merge pull request #161 from Gemba/fix_gmloader_scriptmodule
Fixes for current droidports/gmloader
2 parents 24b6867 + fac0b52 commit ecf5043

File tree

4 files changed

+78
-32
lines changed

4 files changed

+78
-32
lines changed

scriptmodules/ports/gmloader.sh

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,82 @@
1212

1313
rp_module_id="gmloader"
1414
rp_module_desc="GMLoader - play GameMaker Studio games for Android on non-Android operating systems"
15-
rp_module_help="ROM Extensions: .apk .APK\n\nIncludes free games Maldita Castilla and Spelunky Classic HD. Use launch scripts as template for additional games."
16-
rp_module_repo="git https://github.com/JohnnyonFlame/droidports.git master faf3970"
15+
rp_module_help="ROM Extensions: .apk .APK\n\nIncludes free games Maldita Castilla and Spelunky Classic HD. Use a launch script (e.g. 'Spelunky Classic HD.sh') as template for additional games."
16+
rp_module_repo="git https://github.com/JohnnyonFlame/droidports.git master"
1717
rp_module_licence="GPL3 https://raw.githubusercontent.com/JohnnyonFlame/droidports/master/LICENSE.md"
1818
rp_module_section="exp"
19-
rp_module_flags="!all rpi4"
19+
rp_module_flags="!all rpi4 rpi3"
2020

2121
function depends_gmloader() {
2222
getDepends libopenal-dev libfreetype6-dev zlib1g-dev libbz2-dev libpng-dev libzip-dev libsdl2-image-dev cmake
2323
}
2424

2525
function sources_gmloader() {
2626
gitPullOrClone
27-
# group config dirs in parent gmloader dir
28-
applyPatch "$md_data/01_config_dir.patch"
27+
applyPatch "$md_data/01_sdl_retropie_exit_emu.patch"
28+
applyPatch "$md_data/02_sdl_disable_mouse_cursor.patch"
2929
}
3030

3131
function build_gmloader() {
32-
mkdir build && cd build
32+
mkdir build
33+
cd build
3334
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=linux -DPORT=gmloader ..
3435
make
3536
md_ret_require="$md_build/build/gmloader"
3637
}
3738

3839
function install_gmloader() {
39-
md_ret_files=('build/gmloader')
40+
md_ret_files=(
41+
'build/gmloader'
42+
'LICENSE.md'
43+
'README.md'
44+
)
4045
}
4146

4247
function configure_gmloader() {
43-
local apkdir="$romdir/ports/droidports"
48+
local apk_dir="$romdir/ports/droidports"
4449
local maldita_url="https://locomalito.com/juegos/Maldita_Castilla_ouya.apk"
45-
local spelunky_url="https://github.com/yancharkin/SpelunkyClassicHD/releases/download/1.1.7/spelunky_classic_hd-android.apk"
46-
local maldita_file="$apkdir/$(basename ${maldita_url})"
47-
local spelunky_file="$apkdir/$(basename ${spelunky_url})"
48-
local am2r_file="$apkdir/am2r_155.apk"
50+
local spelunky_url="https://github.com/yancharkin/SpelunkyClassicHD/releases/download/1.1.7-optimized/spelunky_classic_hd-android-armv7.apk"
4951

5052
if [[ "$md_mode" == "install" ]]; then
51-
mkUserDir "$apkdir"
52-
[[ ! -f "$maldita_file" ]] && download "$maldita_url" "$apkdir"
53-
[[ ! -f "$spelunky_file" ]] && download "$spelunky_url" "$apkdir"
53+
mkUserDir "$apk_dir"
54+
local dl_url
55+
for dl_url in "$maldita_url" "$spelunky_url"; do
56+
local apk_file="$apk_dir/$(basename ${dl_url})"
57+
if [[ ! -f "$apk_file" ]]; then
58+
download "$dl_url" "$apk_dir"
59+
chown $user:$user "$apk_file"
60+
fi
61+
done
62+
63+
local libcpp_eabi="libc++_shared.so"
64+
if [[ ! -f "$md_inst/$libcpp_eabi" ]]; then
65+
downloadAndExtract "https://chromium.googlesource.com/android_ndk.git/+archive/refs/heads/main/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a.tar.gz" "$md_inst" "$libcpp_eabi"
66+
strip -s "$md_inst/$libcpp_eabi"
67+
fi
68+
69+
# Launcher: Change to install folder as failsafe to load libc++_shared.so
70+
# sibling to gmloader binary for APKs which do not bundle the lib
71+
cat >"$md_inst/gmlauncher.sh" << _EOF_
72+
#! /usr/bin/env bash
73+
cd "$md_inst"
74+
ROM="\$1"
75+
fn="\${ROM##*/}"
76+
BASENAME="\${fn%.*}"
77+
GMLOADER_SAVEDIR="$home/.config/gmloader/\$BASENAME/" ./gmloader "\$ROM"
78+
_EOF_
79+
chmod a+x "$md_inst/gmlauncher.sh"
5480
fi
5581

56-
addPort "$md_id" "droidports" "Maldita Castilla" "$md_inst/gmloader %ROM%" "$maldita_file"
57-
addPort "$md_id" "droidports" "Spelunky Classic HD" "$md_inst/gmloader %ROM%" "$spelunky_file"
82+
local maldita_file="$apk_dir/$(basename ${maldita_url})"
83+
local spelunky_file="$apk_dir/$(basename ${spelunky_url})"
84+
addPort "$md_id" "droidports" "Maldita Castilla" "$md_inst/gmlauncher.sh %ROM%" "$maldita_file"
85+
addPort "$md_id" "droidports" "Spelunky Classic HD" "$md_inst/gmlauncher.sh %ROM%" "$spelunky_file"
5886

87+
local am2r_file="$apk_dir/am2r_155.apk"
5988
if [[ -f "$am2r_file" || "$md_mode" == "remove" ]]; then
60-
addPort "$md_id" "droidports" "AM2R - Another Metroid 2 Remake" "$md_inst/gmloader %ROM%" "$am2r_file"
89+
addPort "$md_id" "droidports" "AM2R - Another Metroid 2 Remake" "$md_inst/gmlauncher.sh %ROM%" "$am2r_file"
6190
fi
6291

6392
moveConfigDir "$home/.config/gmloader" "$md_conf_root/droidports"
64-
}
93+
}

scriptmodules/ports/gmloader/01_config_dir.patch

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/ports/gmloader/sdl2_media.c b/ports/gmloader/sdl2_media.c
2+
index c5533b1..8be9dc4 100644
3+
--- a/ports/gmloader/sdl2_media.c
4+
+++ b/ports/gmloader/sdl2_media.c
5+
@@ -371,6 +372,13 @@ int update_input()
6+
if (slot < 0 || slot >= ARRAY_SIZE(yoyo_gamepads))
7+
continue;
8+
9+
+ if (SDL_GameControllerGetButton(controller->controller, SDL_CONTROLLER_BUTTON_START)
10+
+ && (SDL_GameControllerGetButton(controller->controller, SDL_CONTROLLER_BUTTON_BACK)
11+
+ || SDL_GameControllerGetButton(controller->controller, SDL_CONTROLLER_BUTTON_GUIDE))) {
12+
+ // Mimic RetroPie 'Start+Select' or 'Start+Hotkey' behaviour: Quit Emulator
13+
+ return 0;
14+
+ }
15+
+
16+
uint8_t new_states[16] = {};
17+
int k = 0;
18+
new_states[k++] = SDL_GameControllerGetButton(controller->controller, SDL_CONTROLLER_BUTTON_A);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/ports/gmloader/sdl2_media.c b/ports/gmloader/sdl2_media.c
2+
index c5533b1..91361b0 100644
3+
--- a/ports/gmloader/sdl2_media.c
4+
+++ b/ports/gmloader/sdl2_media.c
5+
@@ -63,6 +63,7 @@ int init_display(int w, int h)
6+
return 0;
7+
}
8+
9+
+ SDL_ShowCursor(SDL_DISABLE);
10+
SDL_GL_MakeCurrent(sdl_win, sdl_ctx);
11+
SDL_GL_SetSwapInterval(1); //Forced vsync, booo
12+
SDL_GL_SwapWindow(sdl_win); //Workaround for missing first frame

0 commit comments

Comments
 (0)