Skip to content

Commit 3a041c4

Browse files
authored
Merge pull request #198 from retropieuser/patch-2
Majora's Mask Source Port Added
2 parents d15be3f + a4ae4f8 commit 3a041c4

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

scriptmodules/ports/2s2h.sh

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/usr/bin/env bash
2+
3+
# This file is part of RetroPie-Extra, a supplement to RetroPie.
4+
# For more information, please visit:
5+
#
6+
# https://github.com/RetroPie/RetroPie-Setup
7+
# https://github.com/Exarkuniv/RetroPie-Extra
8+
#
9+
# See the LICENSE file distributed with this source and at
10+
# https://raw.githubusercontent.com/Exarkuniv/RetroPie-Extra/master/LICENSE
11+
#
12+
13+
rp_module_id="2s2h"
14+
rp_module_desc="2s2h - 2ship2harkinian is an advanced source port for The Legend of Zelda - Majora's Mask"
15+
rp_module_help="Save your valid USA .z64 copy of Majora's Mask to $romdir/n64"
16+
rp_module_repo="git https://github.com/HarbourMasters/2ship2harkinian.git 1.0.1"
17+
rp_module_section="exp"
18+
rp_module_flags="all"
19+
20+
function depends_2s2h() {
21+
getDepends gcc g++ git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev jq
22+
}
23+
24+
function sources_2s2h() {
25+
gitPullOrClone
26+
}
27+
28+
function increase_swap() {
29+
original_swap=$(grep SwapTotal /proc/meminfo | awk '{print $2}')
30+
sudo dphys-swapfile swapoff
31+
sudo sed -i 's/^CONF_SWAPSIZE=.*/CONF_SWAPSIZE=4096/' /etc/dphys-swapfile
32+
sudo dphys-swapfile setup
33+
sudo dphys-swapfile swapon
34+
}
35+
36+
function restore_swap() {
37+
sudo dphys-swapfile swapoff
38+
sudo sed -i "s/^CONF_SWAPSIZE=.*/CONF_SWAPSIZE=$((original_swap / 1024))/" /etc/dphys-swapfile
39+
sudo dphys-swapfile setup
40+
sudo dphys-swapfile swapon
41+
}
42+
43+
function copy_rom_2s2h() {
44+
local romdir="$home/RetroPie/roms/n64"
45+
local destdir="$md_build/OTRExporter"
46+
47+
mkdir -p "$destdir"
48+
49+
# Define the hashes to check against
50+
local hash1="d6133ace5afaa0882cf214cf88daba39e266c078"
51+
local hash2="9743aa026e9269b339eb0e3044cd5830a440c1fd"
52+
53+
# Iterate through the files in the ROM directory
54+
for file in "$romdir"/*; do
55+
if [[ -f "$file" ]]; then
56+
local sha1=$(sha1sum "$file" | awk '{print $1}')
57+
# Check if the calculated SHA1 matches either of the specified hashes
58+
if [[ "$sha1" == "$hash1" || "$sha1" == "$hash2" ]]; then
59+
cp "$file" "$destdir"
60+
echo "Copied $file to $destdir"
61+
return 0
62+
fi
63+
fi
64+
done
65+
66+
echo "No matching ROM file found in $romdir"
67+
return 1
68+
}
69+
70+
function build_2s2h() {
71+
copy_rom_2s2h
72+
if [[ $? -ne 0 ]]; then
73+
echo "Build cannot proceed without a valid ROM file."
74+
return 1
75+
fi
76+
77+
increase_swap
78+
cmake -H. -Bbuild-cmake -GNinja
79+
cmake --build build-cmake --target ExtractAssets
80+
cmake --build build-cmake
81+
md_ret_require="$md_build/build-cmake/mm"
82+
restore_swap
83+
}
84+
85+
function install_2s2h() {
86+
md_ret_files=(
87+
'build-cmake/mm/2s2h.elf'
88+
'build-cmake/mm/2ship.o2r'
89+
'build-cmake/mm/mm.o2r'
90+
)
91+
}
92+
93+
function configure_2s2h() {
94+
95+
# Create the boot .sh file
96+
cat > "$md_inst/2s2h.sh" << _EOF_
97+
#!/bin/bash
98+
99+
# Change directory
100+
cd "$md_inst" || exit
101+
102+
# Run the 2s2h.elf file
103+
./2s2h.elf
104+
_EOF_
105+
chmod +x "$md_inst/2s2h.sh"
106+
107+
# Create the config file to default to fullscreen
108+
cat > "$md_inst/2ship2harkinian.json" << _EOF_
109+
{
110+
"Window": {
111+
"AudioBackend": "sdl",
112+
"Backend": {
113+
"Id": 3,
114+
"Name": "OpenGL"
115+
},
116+
"Fullscreen": {
117+
"Enabled": true,
118+
"Height": 1080,
119+
"Width": 1920
120+
},
121+
"Height": 1080,
122+
"PositionX": 0,
123+
"PositionY": 0,
124+
"Width": 1920
125+
}
126+
}
127+
_EOF_
128+
chmod +x "$md_inst/2ship2harkinian.json"
129+
130+
addPort "$md_id" "2s2h" "2ship2harkinian - Majora's Mask" "$md_inst/2s2h.sh"
131+
132+
chown -R $user:$user "$md_inst"
133+
}

0 commit comments

Comments
 (0)