diff --git a/applypatches.sh b/applypatches.sh new file mode 100755 index 0000000..30c9da5 --- /dev/null +++ b/applypatches.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +profile="$1" + +source ./profiles/$profile/metadata +dir="/tmp/wacca/$profile" +PATCHES_DIR="./patches" + +[ ! -d "$PATCHES_DIR" ] && { echo "Error: $PATCHES_DIR not found"; exit 1; } + +# Change to patches directory and process files in numerical order +cd "$PATCHES_DIR" || exit 1 + +# Use ls with version sort to handle numbers correctly (1,2,3,10,50,etc.) +for script in $(ls -1v 2>/dev/null); do + [ -f "$script" ] && [ -r "$script" ] || continue + + echo -e "\033[0;34m=== Applying: $script ===\033[0m" + + # Use a temporary file to capture exit status and output + temp_file=$(mktemp) + + # Source the script and capture both stdout and stderr + if (source "$script") > "$temp_file" 2>&1; then + # Script succeeded - output with script name prefix + while IFS= read -r line; do + echo "[$script] $line" + done < "$temp_file" + echo -e "\033[0;32m=== Successfully applied: $script ======\033[0m" + else + exit_code=$? + # Script failed - output with script name prefix and error message + while IFS= read -r line; do + echo "[$script] $line" + done < "$temp_file" + echo -e "\033[0;31m=== Failed: $script (exit code: $exit_code) ===\033[0m" + fi + + rm -f "$temp_file" + echo +done + diff --git a/downloadsegatools.sh b/downloadsegatools.sh new file mode 100755 index 0000000..5173c7f --- /dev/null +++ b/downloadsegatools.sh @@ -0,0 +1,22 @@ +#!/bin/bash +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +profile="$1" +wget https://gitea.tendokyu.moe/TeamTofuShop/segatools/releases/download/latest/segatools.zip -O /tmp/segatools.zip +unzip -p /tmp/segatools.zip mercury.zip | bsdtar -xf- -C /tmp/wacca/$profile/game/bin +mkdir -p /tmp/wacca/$profile/segatools/{amfs,appdata,option} +source profiles/$profile/metadata +wget $icf -O /tmp/wacca/$profile/segatools/amfs/ICF1 + +# [vfs] +# ; Insert the path to the game AMFS directory here (contains ICF1 and ICF2) +# amfs=..\\..\\segatools\amfs +# ; Insert the path to the game Option directory here (unused in Mercury) +# option=..\\..\\segatools\option +# ; Create an empty directory somewhere and insert the path here. +# ; This directory may be shared between multiple SEGA games. +# ; NOTE: This has nothing to do with Windows %APPDATA%. +# appdata=..\\..\\segatools\appdata diff --git a/extractapps.sh b/extractapps.sh index 70bc938..3feb2d6 100755 --- a/extractapps.sh +++ b/extractapps.sh @@ -18,7 +18,8 @@ do else echo "Decrypting $file" fsdecrypt images/app/$file - mv images/app/*.vhd images/vhd + mkdir -p images/vhd + mv images/app/*.vhd images/vhd/ fi else if [ ! -f images/vhd/$vhd ]; then @@ -27,7 +28,8 @@ do echo "Decrypting $file" fsdecrypt images/app/$file + mkdir -p images/vhd mv images/app/*.vhd images/vhd fi fi -done < profiles/$profile/apps.csv \ No newline at end of file +done < profiles/$profile/apps.csv diff --git a/generatetree.sh b/generatetree.sh old mode 100644 new mode 100755 index f6c162d..31ec398 --- a/generatetree.sh +++ b/generatetree.sh @@ -5,6 +5,8 @@ if [ $# -eq 0 ]; then fi profile="$1" +rm -r images/tree/$profile +mkdir -p images/tree/$profile while IFS=, read -r vhd version identifier backingversion parent_identifier parent_filename do match=0 @@ -22,4 +24,4 @@ do echo "End of chain $vhd" ln -s $(pwd)/images/vhd/$vhd images/tree/$profile/"game.vhd" fi -done < images/lookup/phase1_$1.csv \ No newline at end of file +done < images/lookup/phase1_$1.csv diff --git a/mountprofile.sh b/mountprofile.sh new file mode 100755 index 0000000..d123f11 --- /dev/null +++ b/mountprofile.sh @@ -0,0 +1,15 @@ +#!/bin/bash +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +profile="$1" + +mkdir -p /tmp/wacca/$profile/{dev,lower,upper,game,work} +mkdir -p /tmp/wacca/$profile/lower +mkdir -p /tmp/wacca/$profile/upper +mkdir -p /tmp/wacca/$profile/game +sudo vhdimount images/tree/$profile/game.vhd /tmp/wacca/$profile/dev +sudo mount -t ntfs -o offset=$((2048*512)),uid=$(id -u),gid=$(id -g) $(sudo find /tmp/wacca/$profile/dev -maxdepth 1 -type f | sort -V | tail -1) /tmp/wacca/$profile/lower +sudo mount overlay -t overlay -o lowerdir=/tmp/wacca/$profile/lower,upperdir=/tmp/wacca/$profile/upper,workdir=/tmp/wacca/$profile/work /tmp/wacca/$profile/game \ No newline at end of file diff --git a/patches/10-offlinemode.sh b/patches/10-offlinemode.sh new file mode 100644 index 0000000..37a89c3 --- /dev/null +++ b/patches/10-offlinemode.sh @@ -0,0 +1,2 @@ +sed -i '/^\[\/Script\/Mercury.MercuryNetworkSettings\]/,/^OfflineMode=false/ s/^OfflineMode=false/OfflineMode=true/' $dir/game/WindowsNoEditor/Mercury/Config/DefaultHardware.ini + diff --git a/patches/10-segatools.sh b/patches/10-segatools.sh new file mode 100755 index 0000000..cc3a21f --- /dev/null +++ b/patches/10-segatools.sh @@ -0,0 +1,11 @@ +if [ -z ${dir+x} ]; then echo "\$dir not set, skipping."; exit 22; else + wget https://gitea.tendokyu.moe/TeamTofuShop/segatools/releases/download/latest/segatools.zip -O /tmp/segatools.zip + mkdir -p $dir/segatools/{amfs,appdata,option} + unzip -p /tmp/segatools.zip mercury.zip | bsdtar -xf- -C $dir/game/bin +fi + +sed -i '/^\[vfs\]/,/^\[/ { + /^amfs=/c\amfs=..\\\\..\\\\segatools\\\\amfs + /^option=/c\option=..\\\\..\\\\segatools\\\\option + /^appdata=/c\appdata=..\\\\..\\\\segatools\\\\appdata +}' $dir/game/bin/segatools.ini \ No newline at end of file diff --git a/patches/11-icf.sh b/patches/11-icf.sh new file mode 100644 index 0000000..99a7651 --- /dev/null +++ b/patches/11-icf.sh @@ -0,0 +1,5 @@ +if [ -z ${dir+x} ]; then echo "\$dir not set, skipping."; exit 22; else + if [ -z ${icf+x} ]; then echo "ICF url not set, skipping."; else + wget $icf -O $dir/segatools/amfs/ICF1 + fi +fi \ No newline at end of file diff --git a/patches/15-ledstub.sh b/patches/15-ledstub.sh new file mode 100755 index 0000000..2787c90 --- /dev/null +++ b/patches/15-ledstub.sh @@ -0,0 +1,3 @@ +sed -i '/^\[elisabeth\]/,/^enable=1/ s/^enable=1/enable=0/' $dir/game/bin/segatools.ini +cp ../wacca_led.dll $dir/game/WindowsNoEditor/Mercury/Plugins/ElizabethPlugin/Source/LEDDevice/Source/Runtime/Public/Externals/USBIntLED.DLL +rm $dir/game/WindowsNoEditor/Mercury/Plugins/ElizabethPlugin/Source/LEDDevice/Source/Runtime/Public/Externals/USBIntLED_.DLL \ No newline at end of file diff --git a/patches/15-openssl.sh b/patches/15-openssl.sh new file mode 100644 index 0000000..e16537e --- /dev/null +++ b/patches/15-openssl.sh @@ -0,0 +1,5 @@ +if [ -z ${dir+x} ]; then echo "\$dir not set, skipping."; exit 22; else + if grep -q "set OPENSSL_ia32cap=:~0x20000000" $dir/game/bin/launch.bat; then echo "Patch already present in file, skipping."; else + sed -i '/@echo off/Ia set OPENSSL_ia32cap=:~0x20000000' $dir/game/bin/launch.bat + fi +fi diff --git a/patches/15-wacca1-fixname.sh b/patches/15-wacca1-fixname.sh new file mode 100644 index 0000000..62b4562 --- /dev/null +++ b/patches/15-wacca1-fixname.sh @@ -0,0 +1,5 @@ +if [[ "$version" == "1.00" || "$version" == "1.50" ]]; then + sed -i 's/Mercury-Win64-Shipping.exe/Mercury.exe/g' $dir/game/bin/launch.bat +else + echo "Patch not applicable to specified version, skipping." +fi \ No newline at end of file diff --git a/patches/50-disablenetenv.sh b/patches/50-disablenetenv.sh new file mode 100755 index 0000000..35d11f0 --- /dev/null +++ b/patches/50-disablenetenv.sh @@ -0,0 +1,3 @@ +cp -r $dir/game/bin/segatools.ini $dir/game/bin/segatools-netenv.ini +sed -i '/^\[netenv\]/,/^enable=1/ s/^enable=1/enable=0/' $dir/game/bin/segatools-netenv.ini +sed -i '/inject -d -k mercuryhook.dll ..\/WindowsNoEditor\/Mercury\/Binaries\/Win64/i set SEGATOOLS_CONFIG_PATH=./segatools-netenv.ini' $dir/game/bin/launch.bat \ No newline at end of file diff --git a/unmountprofile.sh b/unmountprofile.sh new file mode 100755 index 0000000..33ee813 --- /dev/null +++ b/unmountprofile.sh @@ -0,0 +1,11 @@ +#!/bin/bash +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +profile="$1" + +sudo umount /tmp/wacca/$profile/game +sudo umount /tmp/wacca/$profile/lower +sudo fusermount -u /tmp/wacca/$profile/dev \ No newline at end of file diff --git a/versionselect.sh b/versionselect.sh old mode 100644 new mode 100755 diff --git a/wacca_led.dll b/wacca_led.dll new file mode 100644 index 0000000..02a1eeb Binary files /dev/null and b/wacca_led.dll differ