forked from RetroPie/RetroPie-Setup
/
scummvm.sh
145 lines (123 loc) · 4.85 KB
/
scummvm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env bash
# This file is part of The RetroPie Project
#
# The RetroPie Project is the legal property of its developers, whose names are
# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source.
#
# See the LICENSE.md file at the top-level directory of this distribution and
# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md
#
rp_module_id="scummvm"
rp_module_desc="ScummVM"
rp_module_help="Copy your ScummVM games to $romdir/scummvm.\nSee https://retropie.org.uk/docs/ScummVM/#example\nfor expected folders and files."
rp_module_licence="GPL2 https://raw.githubusercontent.com/scummvm/scummvm/master/COPYING"
rp_module_repo="git https://github.com/scummvm/scummvm.git v2.5.0"
rp_module_section="opt"
rp_module_flags="sdl2"
function depends_scummvm() {
local depends=(
libmpeg2-4-dev libogg-dev libvorbis-dev libflac-dev libmad0-dev libpng-dev
libtheora-dev libfaad-dev libfluidsynth-dev libfreetype6-dev zlib1g-dev
libjpeg-dev libasound2-dev libcurl4-openssl-dev
)
if isPlatform "vero4k"; then
depends+=(vero3-userland-dev-osmc)
fi
if [[ "$md_id" == "scummvm-sdl1" ]]; then
depends+=(libsdl1.2-dev)
else
depends+=(libsdl2-dev)
fi
getDepends "${depends[@]}"
}
function sources_scummvm() {
gitPullOrClone
}
function build_scummvm() {
local params=(
--enable-release --enable-vkeybd
--disable-debug --disable-eventrecorder --prefix="$md_inst"
)
isPlatform "rpi" && isPlatform "32bit" && params+=(--host=raspberrypi)
isPlatform "gles" && params+=(--opengl-mode=gles2)
# stop scummvm using arm-linux-gnueabihf-g++ which is v4.6 on
# wheezy and doesn't like rpi2 cpu flags
if isPlatform "rpi"; then
CC="gcc" CXX="g++" ./configure "${params[@]}"
else
./configure "${params[@]}"
fi
make clean
make
strip "$md_build/scummvm"
md_ret_require="$md_build/scummvm"
}
function install_scummvm() {
make install
mkdir -p "$md_inst/extra"
cp -v backends/vkeybd/packs/vkeybd_*.zip "$md_inst/extra"
}
function configure_scummvm() {
mkRomDir "scummvm"
local dir
for dir in .config .local/share; do
moveConfigDir "$home/$dir/scummvm" "$md_conf_root/scummvm"
done
# copy python helper
cp "$rootdir/supplementary/scummvm/scummvm_helper.py" "$romdir/scummvm/"
# Create startup script
rm -f "$romdir/scummvm/+Launch GUI.sh"
local name="ScummVM"
[[ "$md_id" == "scummvm-sdl1" ]] && name="ScummVM-SDL1"
cat > "$romdir/scummvm/+Start $name.sh" << _EOF_
#! /bin/bash
base_name="\$1"
# <base_name>.svm and <base_name>/ folder expected to be siblings on filesystem
emu_home="$md_inst"
scummvm_bin="\$emu_home/bin/scummvm"
rom_home="$romdir/scummvm"
scummvm_ini="\$HOME/.config/scummvm/scummvm.ini"
pushd "\$rom_home" >/dev/null
params=(
--fullscreen
--joystick=0
--extrapath="\$emu_home/extra"
)
# enable for verbose log
#params+=(--debuglevel=3)
if [[ ! -z "\$base_name" ]] ; then
# <game_heading> maps to section [<game_heading>] in scummvm.ini
game_heading=\$(cat "\$rom_home/\$base_name.svm" | xargs)
# check if game heading/section is present (maybe absent on first start)
if [[ -z "\$game_heading" ]] ; then
# create an entry in ~/.config/scummvm/scummvm.ini for customisation
"\$scummvm_bin" --add --path="\$base_name" >/dev/null 2>&1
# lookup detected game in scummvm.ini and pick first matching [<game_heading>]
game_heading=\$("\$rom_home/scummvm_helper.py" findsection "\$base_name" | cut -f 1 -d ';')
# if game_heading is empty at this point, then detection was not successful
if [[ -z "\$game_heading" ]] ; then
echo "FATAL: Detecting game in base_name '\$base_name' failed. Game will not start." >> /dev/shm/runcommand.log
echo " Maybe a required game file is missing? Check https://wiki.scummvm.org for this game." >> /dev/shm/runcommand.log
echo " Try running" >> /dev/shm/runcommand.log
echo " \"\$scummvm_bin\" --detect --path=\"\$rom_home/\$base_name\" --debuglevel=3" >> /dev/shm/runcommand.log
echo " interactively to examine." >> /dev/shm/runcommand.log
exit 1
else
echo "\$game_heading" > "\$rom_home/\$base_name.svm"
fi
fi
else
# directly detour into GUI, most likely initial start (to add game / mass add in GUI)
game_heading=""
fi
"\$scummvm_bin" "\${params[@]}" "\$game_heading"
if [[ -z "\$game_heading" ]] ; then
"\$rom_home/scummvm_helper.py" createsvm >> /dev/shm/runcommand.log
fi
popd >/dev/null
_EOF_
chown $user:$user "$romdir/scummvm/+Start $name.sh"
chmod u+x "$romdir/scummvm/+Start $name.sh"
addEmulator 1 "$md_id" "scummvm" "bash $romdir/scummvm/+Start\ $name.sh %BASENAME%"
addSystem "scummvm"
}