forked from RetroPie/RetroPie-Setup
-
Notifications
You must be signed in to change notification settings - Fork 14
/
mupen64plus.sh
235 lines (211 loc) · 9.3 KB
/
mupen64plus.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/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="mupen64plus"
rp_module_desc="N64 emulator MUPEN64Plus"
rp_module_help="ROM Extensions: .z64 .n64 .v64\n\nCopy your N64 roms to $romdir/n64"
rp_module_licence="GPL2 https://raw.githubusercontent.com/mupen64plus/mupen64plus-core/master/LICENSES"
rp_module_section="main"
rp_module_flags="!mali !kms"
function depends_mupen64plus() {
local depends=(cmake libsamplerate0-dev libspeexdsp-dev libsdl2-dev libpng12-dev)
isPlatform "x11" && depends+=(libglew-dev libglu1-mesa-dev libboost-filesystem-dev)
isPlatform "x86" && depends+=(nasm)
getDepends "${depends[@]}"
}
function sources_mupen64plus() {
local repos=(
'mupen64plus core'
'mupen64plus ui-console'
'mupen64plus audio-sdl'
'mupen64plus input-sdl'
'mupen64plus rsp-hle'
)
if isPlatform "rpi"; then
repos+=(
'gizmo98 audio-omx'
'ricrpi video-gles2rice pandora-backport'
'ricrpi video-gles2n64'
)
else
repos+=(
'mupen64plus video-glide64mk2'
'mupen64plus rsp-cxd4'
'mupen64plus rsp-z64'
)
fi
local repo
local dir
for repo in "${repos[@]}"; do
repo=($repo)
dir="$md_build/mupen64plus-${repo[1]}"
gitPullOrClone "$dir" https://github.com/${repo[0]}/mupen64plus-${repo[1]} ${repo[2]}
done
gitPullOrClone "$md_build/GLideN64" https://github.com/gonetz/GLideN64.git
# temporary workaround for https://github.com/gonetz/GLideN64/issues/1665
isPlatform "rpi" && applyPatch "$md_data/rpi-yuv.diff"
local config_version=$(grep -oP '(?<=CONFIG_VERSION_CURRENT ).+?(?=U)' GLideN64/src/Config.h)
echo "$config_version" > "$md_build/GLideN64_config_version.ini"
}
function build_mupen64plus() {
rpSwap on 750
local dir
local params=()
for dir in *; do
if [[ -f "$dir/projects/unix/Makefile" ]]; then
make -C "$dir/projects/unix" clean
params=()
isPlatform "rpi1" && params+=("VFP=1" "VFP_HARD=1" "HOST_CPU=armv6")
isPlatform "rpi" && params+=("VC=1")
isPlatform "neon" && params+=("NEON=1")
isPlatform "x11" && params+=("OSD=1" "PIE=1")
isPlatform "x86" && params+=("SSE=SSE2")
[[ "$dir" == "mupen64plus-ui-console" ]] && params+=("COREDIR=$md_inst/lib/" "PLUGINDIR=$md_inst/lib/mupen64plus/")
# MAKEFLAGS replace removes any distcc from path, as it segfaults with cross compiler and lto
MAKEFLAGS="${MAKEFLAGS/\/usr\/lib\/distcc:/}" make -C "$dir/projects/unix" all "${params[@]}" OPTFLAGS="$CFLAGS -O3 -flto"
fi
done
# build GLideN64
"$md_build/GLideN64/src/getRevision.sh"
pushd "$md_build/GLideN64/projects/cmake"
params=("-DMUPENPLUSAPI=On" "-DVEC4_OPT=On")
isPlatform "neon" && params+=("-DNEON_OPT=On")
isPlatform "rpi" && params+=("-DUSE_SYSTEM_LIBS=On")
if isPlatform "rpi3"; then
params+=("-DCRC_ARMV8=On")
else
params+=("-DCRC_OPT=On")
fi
cmake "${params[@]}" ../../src/
make
popd
rpSwap off
md_ret_require=(
'mupen64plus-ui-console/projects/unix/mupen64plus'
'mupen64plus-core/projects/unix/libmupen64plus.so.2.0.0'
'mupen64plus-audio-sdl/projects/unix/mupen64plus-audio-sdl.so'
'mupen64plus-input-sdl/projects/unix/mupen64plus-input-sdl.so'
'mupen64plus-rsp-hle/projects/unix/mupen64plus-rsp-hle.so'
'GLideN64/projects/cmake/plugin/release/mupen64plus-video-GLideN64.so'
)
if isPlatform "rpi"; then
md_ret_require+=(
'mupen64plus-video-gles2rice/projects/unix/mupen64plus-video-rice.so'
'mupen64plus-video-gles2n64/projects/unix/mupen64plus-video-n64.so'
'mupen64plus-audio-omx/projects/unix/mupen64plus-audio-omx.so'
)
else
md_ret_require+=(
'mupen64plus-video-glide64mk2/projects/unix/mupen64plus-video-glide64mk2.so'
'mupen64plus-rsp-z64/projects/unix/mupen64plus-rsp-z64.so'
)
if isPlatform "x86"; then
md_ret_require+=('mupen64plus-rsp-cxd4/projects/unix/mupen64plus-rsp-cxd4-sse2.so')
else
md_ret_require+=('mupen64plus-rsp-cxd4/projects/unix/mupen64plus-rsp-cxd4.so')
fi
fi
}
function install_mupen64plus() {
for source in *; do
if [[ -f "$source/projects/unix/Makefile" ]]; then
# optflags is needed due to the fact the core seems to rebuild 2 files and relink during install stage most likely due to a buggy makefile
local params=()
isPlatform "armv6" && params+=("VFP=1" "HOST_CPU=armv6")
isPlatform "rpi" && params+=("VC=1")
isPlatform "neon" && params+=("NEON=1")
isPlatform "x86" && params+=("SSE=SSE2")
make -C "$source/projects/unix" PREFIX="$md_inst" OPTFLAGS="$CFLAGS -O3 -flto" "${params[@]}" install
fi
done
cp "$md_build/GLideN64/ini/GLideN64.custom.ini" "$md_inst/share/mupen64plus/"
cp "$md_build/GLideN64/projects/cmake/plugin/release/mupen64plus-video-GLideN64.so" "$md_inst/lib/mupen64plus/"
cp "$md_build/GLideN64_config_version.ini" "$md_inst/share/mupen64plus/"
# remove default InputAutoConfig.ini. inputconfigscript writes a clean file
rm -f "$md_inst/share/mupen64plus/InputAutoCfg.ini"
}
function configure_mupen64plus() {
if isPlatform "rpi"; then
local res
for res in "320x240" "640x480"; do
local name=""
[[ "$res" == "640x480" ]] && name="-highres"
addEmulator 0 "${md_id}-GLideN64$name" "n64" "$md_inst/bin/mupen64plus.sh mupen64plus-video-GLideN64 %ROM% $res"
addEmulator 0 "${md_id}-gles2rice$name" "n64" "$md_inst/bin/mupen64plus.sh mupen64plus-video-rice %ROM% $res"
done
addEmulator 0 "${md_id}-gles2n64" "n64" "$md_inst/bin/mupen64plus.sh mupen64plus-video-n64 %ROM%"
addEmulator 1 "${md_id}-auto" "n64" "$md_inst/bin/mupen64plus.sh AUTO %ROM%"
else
addEmulator 0 "${md_id}-GLideN64" "n64" "$md_inst/bin/mupen64plus.sh mupen64plus-video-GLideN64 %ROM%"
addEmulator 1 "${md_id}-glide64" "n64" "$md_inst/bin/mupen64plus.sh mupen64plus-video-glide64mk2 %ROM%"
if isPlatform "x86"; then
addEmulator 0 "${md_id}-GLideN64-LLE" "n64" "$md_inst/bin/mupen64plus.sh mupen64plus-video-GLideN64 %ROM% 640x480 mupen64plus-rsp-cxd4-sse2"
fi
fi
addSystem "n64"
mkRomDir "n64"
[[ "$md_mode" == "remove" ]] && return
# copy hotkey remapping start script
cp "$md_data/mupen64plus.sh" "$md_inst/bin/"
chmod +x "$md_inst/bin/mupen64plus.sh"
mkUserDir "$md_conf_root/n64/"
# Copy config files
cp -v "$md_inst/share/mupen64plus/"{*.ini,font.ttf} "$md_conf_root/n64/"
isPlatform "rpi" && cp -v "$md_inst/share/mupen64plus/"*.conf "$md_conf_root/n64/"
local config="$md_conf_root/n64/mupen64plus.cfg"
local cmd="$md_inst/bin/mupen64plus --configdir $md_conf_root/n64 --datadir $md_conf_root/n64"
# if the user has an existing mupen64plus config we back it up, generate a new configuration
# copy that to rp-dist and put the original config back again. We then make any ini changes
# on the rp-dist file. This preserves any user configs from modification and allows us to have
# a default config for reference
if [[ -f "$config" ]]; then
mv "$config" "$config.user"
su "$user" -c "$cmd"
mv "$config" "$config.rp-dist"
mv "$config.user" "$config"
config+=".rp-dist"
else
su "$user" -c "$cmd"
fi
# RPI GLideN64 settings
if isPlatform "rpi"; then
iniConfig " = " "" "$config"
# Create GlideN64 section in .cfg
if ! grep -q "\[Video-GLideN64\]" "$config"; then
echo "[Video-GLideN64]" >> "$config"
fi
# Settings version. Don't touch it.
iniSet "configVersion" "17"
# Bilinear filtering mode (0=N64 3point, 1=standard)
iniSet "bilinearMode" "1"
# Size of texture cache in megabytes. Good value is VRAM*3/4
iniSet "CacheSize" "50"
# Disable FB emulation until visual issues are sorted out
iniSet "EnableFBEmulation" "True"
# Use native res
iniSet "UseNativeResolutionFactor" "1"
# Enable legacy blending
iniSet "EnableLegacyBlending" "True"
# Enable FPS Counter. Fixes zelda depth issue
iniSet "ShowFPS " "True"
iniSet "fontSize" "14"
iniSet "fontColor" "1F1F1F"
# Disable gles2n64 autores feature and use dispmanx upscaling
iniConfig " = " "" "$md_conf_root/n64/gles2n64.conf"
iniSet "auto resolution" "0"
addAutoConf mupen64plus_audio 1
addAutoConf mupen64plus_compatibility_check 1
else
addAutoConf mupen64plus_audio 0
addAutoConf mupen64plus_compatibility_check 0
fi
addAutoConf mupen64plus_hotkeys 1
addAutoConf mupen64plus_texture_packs 1
chown -R $user:$user "$md_conf_root/n64"
}