diff --git a/.config example b/.config example index 62d1e22..4f3271a 100644 --- a/.config example +++ b/.config example @@ -1,9 +1,17 @@ +WORKDIR="/tmp/wacca" # VERSION VERSION="" # NETWORKING NET_KEYCHIP_ID="" NET_HOSTNAME="" +NET_COMPATIBILITY="3.0" # Which versions to enable networking for (3.0,2.5,1.0 e.t.c) # PORT BINDINGS PORT_CONSOLE_LEFT="" PORT_CONSOLE_RIGHT="" -PORT_AIME_READER="" \ No newline at end of file +PORT_AIME_READER="" +# APPLY BINARY PATCHES 3.07.01 ONLY +BINPATCH_DISABLE_LOCKOUT=0 # Fully disable lockout +BINPATCH_FORCE_ENGINE_LOCALE=0 # Force Engine locale (ignore router country language) +BINPATCH_ALLOW_CHN_REGION=0 # Allow using CHN region (don't change to HKG) +BINPATCH_FORCE_HIDDEN_LUIN_TITLE=1 # Force enable Hidden Luin title screen +ENABLE_EN_US_TRANSLATION=1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index f91ee75..c41b7ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ images/* +imagestore/* .config \ No newline at end of file diff --git a/bindinggen.sh b/bindinggen.sh new file mode 100644 index 0000000..52cf4e1 --- /dev/null +++ b/bindinggen.sh @@ -0,0 +1,3 @@ +IFS='_' read -r game version timestamp internalid subversion <<< "SDFE_2.50.00_20210129180947_1_2.00.00" +echo $component +mkdir imagestore/binding/$game/ \ No newline at end of file diff --git a/genbind.sh b/genbind.sh new file mode 100755 index 0000000..a8bead3 --- /dev/null +++ b/genbind.sh @@ -0,0 +1,123 @@ +#!/bin/bash +source .config + +workdir=${WORKDIR:-/tmp/wacca} +version=${VERSION:-3.07.01} + +check_prereqs () { + tools=("vhdimount" "umu-run" "fsdecrypt" "xdelta3" "aria2c") + echo "Checking for required tools..." + echo "==============================" + + all_installed=true + + for tool in "${tools[@]}"; do + if command -v "$tool" &> /dev/null; then + echo -e "\033[0;32m✓\033[0m $tool is installed" + else + echo -e "\033[0;31m✗\033[0m $tool is NOT installed" + all_installed=false + fi + done + + echo "==============================" + if [ "$all_installed" != true ]; then + echo "Some tools are missing :(" + if [ "$ignore_prereqs" = true ]; then + echo "Ignoring prerequisites" + else + exit 1 + fi + fi +} +# GET NEEDED APPS FROM $VERSION +get_required_app () { + apps="" + while IFS=',' read -r version url prettyname; do + apps+="$url," + if [[ "$version" == "$VERSION" ]]; then + break + fi + done < <(grep "$(echo "^$VERSION" | cut -c1-4)" imagestore/index.csv) +} + +extract_apps () { + mkdir -p imagestore/vhd + for url in ${apps//,/ }; do + file=$(basename "$url") + local vhd=$(basename "$url" | sed -E "s/.app/.vhd/") + if [ -f imagestore/app/$file ]; then + echo "Found $file" + if [ -f imagestore/vhd/$vhd ]; then + echo "Found $vhd" + else + echo "Decrypting $file" + fsdecrypt imagestore/app/$file + mv imagestore/app/$vhd imagestore/vhd/ + fi + else + if [ ! -f imagestore/vhd/$vhd ]; then + echo "Downloading $file" + aria2c -x 8 -j 8 -o imagestore/app/$file $url + + echo "Decrypting $file" + fsdecrypt imagestore/app/$file + mv imagestore/app/$vhd imagestore/vhd/ + fi + fi + done +} + +patchbin () { + # local targetvhd="$1" + # local tmp=$(mktemp -u) + # dd if=$targetvhd of=$tmp bs=1 count=576 + # dd if=TEST.vhd of=$tmp bs=1 skip=575 seek=576 count=80 + # dd if=$tmp of=$targetvhd bs=1 conv=notrunc + # echo -n $(basename $1) | iconv -f UTF-8 -t UTF-16BE | dd of=test + + for url in ${apps//,/ }; do + local file=$(basename $url) + IFS='_' read gameid version date vhdpos parentversion <<< "${file%.app}" + if [[ "$vhdpos" != "0" ]]; then + local vhd=$(basename "$url" | sed -E "s/.app/.vhd/") + input=$(vhdiinfo imagestore/vhd/$vhd) + + identifier=$(echo "$input" | grep -i "Identifier" | head -1 | awk '{print $NF}') + parent_identifier=$(echo "$input" | grep -i "Parent identifier" | awk '{print $NF}') + parent_filename=$(echo "$input" | grep -i "Parent filename" | awk -F': ' '{print $2}') + echo "Checking $vhd parent" + if [[ ! "$parent_filename" =~ ^\\SDFE ]]; then + echo "$vhd Parent filename incorrect" + new_parent_filename=$(grep "^$parentversion" imagestore/index.csv | cut -d',' -f2 | xargs basename | sed -E "s/.app/.vhd/") + new_parent_filename="\\$new_parent_filename" + local len=${#new_parent_filename} + result=$(((len * 2))) + echo "Writing parent filename $new_parent_filename to $vhd" + echo $new_parent_filename | iconv -f UTF-8 -t UTF-16BE | dd of=imagestore/vhd/$vhd seek=576 bs=1 conv=notrunc + echo $new_parent_filename | iconv -f UTF-8 -t UTF-16BE | dd of=imagestore/vhd/$vhd seek=4096 bs=1 conv=notrunc + if [ $result -lt 80 ]; then + remainder=$((80 - result)) + dd if=/dev/zero of=imagestore/vhd/$vhd seek=$((576 + result)) bs=1 count=$remainder conv=notrunc + dd if=/dev/zero of=imagestore/vhd/$vhd seek=$((4096 + result)) bs=1 count=$remainder conv=notrunc + fi # echo $parent_filename + fi + fi + done +} + +mount () { + vhdpath=$(grep "^$version" imagestore/index.csv | cut -d',' -f2 | xargs basename | sed -E "s/.app/.vhd/") + + mkdir -p $workdir/$version/{dev,lower,upper,game,work} + vhdimount imagestore/vhd/$vhdpath $workdir/$version/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 +} + +check_prereqs +get_required_app +extract_apps +patchbin +mount +# patchbin "images/vhd/SDFE_2.53.00_20210607052915_3_2.52.00.vhd.old" \ No newline at end of file diff --git a/patches/10-binpatch.sh b/patches/10-binpatch.sh new file mode 100644 index 0000000..e69de29 diff --git a/patches/10-segatools.sh b/patches/10-segatools.sh index d29e118..a9bfb7c 100755 --- a/patches/10-segatools.sh +++ b/patches/10-segatools.sh @@ -10,12 +10,12 @@ sed -i '/^\[vfs\]/,/^\[/ { /^appdata=/c\appdata=..\\\\..\\\\segatools\\\\appdata }' $dir/game/bin/segatools.ini -if [ -z ${PORT_AIME_READER+x} ]; then echo "\$Card reader binding not set, skipping."; else +if [ -z ${PORT_AIME_READER:-} ]; then echo "\$Card reader binding not set, skipping."; else echo "Card reader binding set, disabling card reader assembly emulation" sed -i '/^\[aime\]/,/^enable=1/ s/^enable=1/enable=0/' $dir/game/bin/segatools.ini fi -if [ -z ${PORT_CONSOLE_LEFT+x} ]; then echo "\$Left console binding not set, skipping."; else - if [ -z ${PORT_CONSOLE_RIGHT+x} ]; then echo "\$Right console binding not set, skipping."; else +if [ -z ${PORT_CONSOLE_LEFT:-} ]; then echo "\$Left console binding not set, skipping."; else + if [ -z ${PORT_CONSOLE_RIGHT:-} ]; then echo "\$Right console binding not set, skipping."; else echo "Console binding set, disabling mercuryio touch hooks" sed -i '/^\[touch\]/,/^enable=1/ s/^enable=1/enable=0/' $dir/game/bin/segatools.ini fi diff --git a/patches/11-networking.sh b/patches/11-networking.sh index 7d57b4a..6d66fb0 100644 --- a/patches/11-networking.sh +++ b/patches/11-networking.sh @@ -1,12 +1,12 @@ -if [ -z ${NET_HOSTNAME+x} ]; then - echo "Server hostname not set, skipping."; +if [ -z ${NET_KEYCHIP_ID:-} ]; then + echo "Keychip id not set, skipping."; sed -i '/^\[\/Script\/Mercury.MercuryNetworkSettings\]/,/^OfflineMode=false/ s/^OfflineMode=false/OfflineMode=true/' $dir/game/WindowsNoEditor/Mercury/Config/DefaultHardware.ini else - if [ -z ${NET_KEYCHIP_ID+x} ]; then - echo "Keychip id not set, skipping."; + sed -i "/^\[keychip\]/,/^id=A69E-01A88888888/ s/^id=A69E-01A88888888/id=$NET_KEYCHIP_ID/" $dir/game/bin/segatools.ini + if [ -z ${NET_HOSTNAME:-} ]; then + echo "Server hostname not set, skipping."; sed -i '/^\[\/Script\/Mercury.MercuryNetworkSettings\]/,/^OfflineMode=false/ s/^OfflineMode=false/OfflineMode=true/' $dir/game/WindowsNoEditor/Mercury/Config/DefaultHardware.ini else sed -i "/^\[dns\]/,/^default=127.0.0.1/ s/^default=127.0.0.1/default=$NET_HOSTNAME/" $dir/game/bin/segatools.ini - sed -i "/^\[keychip\]/,/^id=A69E-01A88888888/ s/^id=A69E-01A88888888/id=$NET_KEYCHIP_ID/" $dir/game/bin/segatools.ini fi fi \ No newline at end of file diff --git a/patches/15-wacca1-fixname.sh b/patches/15-wacca1-fixname.sh index 62b4562..9eaa17a 100644 --- a/patches/15-wacca1-fixname.sh +++ b/patches/15-wacca1-fixname.sh @@ -1,4 +1,5 @@ -if [[ "$version" == "1.00" || "$version" == "1.50" ]]; then + +if [[ "$version" =~ ^1\. ]]; 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." diff --git a/patches/binpatch/chn.xd3 b/patches/binpatch/chn.xd3 new file mode 100644 index 0000000..2833388 Binary files /dev/null and b/patches/binpatch/chn.xd3 differ diff --git a/patches/binpatch/enginelocale.xd3 b/patches/binpatch/enginelocale.xd3 new file mode 100644 index 0000000..500d97e Binary files /dev/null and b/patches/binpatch/enginelocale.xd3 differ diff --git a/patches/binpatch/hiddenscreen.xd3 b/patches/binpatch/hiddenscreen.xd3 new file mode 100644 index 0000000..6dfaa72 Binary files /dev/null and b/patches/binpatch/hiddenscreen.xd3 differ diff --git a/patches/binpatch/lockout.xd3 b/patches/binpatch/lockout.xd3 new file mode 100644 index 0000000..480cc65 Binary files /dev/null and b/patches/binpatch/lockout.xd3 differ diff --git a/patchvhdlebe.sh b/patchvhdlebe.sh deleted file mode 100644 index 985569a..0000000 --- a/patchvhdlebe.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -#Script that patches .vhd files to be correctly read vhditools by turning LE parent filenames into BE -if [ $# -eq 0 ]; then - echo "Usage: $0 <.vhd>" - exit 1 -fi - -str=$(strings -e l $1 | head -n 1) - -echo $str -read -p "Do you want to patch the listed string? (y/N): " -n 1 -r -echo # move to a new line -if [[ $REPLY =~ ^[Yy]$ ]] -then - be=$(echo -n $str | iconv -f UTF-8 -t UTF-16BE | xxd -p -c1 | tr -d '\n ' | sed 's/../\\x&/g') - le=$(echo -n $str | iconv -f UTF-8 -t UTF-16LE | xxd -p -c1 | tr -d '\n ' | sed 's/../\\x&/g') - mv $1 $1.old - bbe -e "s/$le/$be/" $1.old | pv -s $(stat --printf="%s" $1.old) > $1 -fi -rm $1.old diff --git a/profiles/waccalily/metadata b/profiles/waccalily/metadata index b39877a..0200bd4 100755 --- a/profiles/waccalily/metadata +++ b/profiles/waccalily/metadata @@ -1,4 +1,3 @@ prettyname="WACCA Lily" -version="2.00" -icf="https://archive.org/download/WACCA/EXP/2.00.00%20USB/SDFE_ACA.icf" -versionupdate="https://archive.org/download/WACCA/EXP/2.00.00%20USB/%5B%5B%5B%5B%5BVersionUpdate%5D%5D%5D%5D%5D" +version="2.0" +icf="https://archive.org/download/WACCA/EXP/2.00.00%20USB/SDFE_ACA.icf" \ No newline at end of file diff --git a/profiles/waccalilyr/metadata b/profiles/waccalilyr/metadata index 51822f3..394094c 100755 --- a/profiles/waccalilyr/metadata +++ b/profiles/waccalilyr/metadata @@ -1,4 +1,3 @@ prettyname="WACCA Lily R" -version="2.50" -icf="https://archive.org/download/WACCA/EXP/2.00.00%20USB/SDFE_ACA.icf" -versionupdate="https://archive.org/download/WACCA/EXP/2.00.00%20USB/%5B%5B%5B%5B%5BVersionUpdate%5D%5D%5D%5D%5D" +version="2.5" +icf="https://archive.org/download/WACCA/EXP/2.00.00%20USB/SDFE_ACA.icf" \ No newline at end of file diff --git a/profiles/waccareverse/metadata b/profiles/waccareverse/metadata index c3eeb20..52a5b9c 100755 --- a/profiles/waccareverse/metadata +++ b/profiles/waccareverse/metadata @@ -1,4 +1,3 @@ prettyname="WACCA Reverse" -version="3.00" -icf="https://archive.org/download/WACCA/EXP/3.00.00%20USB/SDFE_ACA.icf" -versionupdate="https://archive.org/download/WACCA/EXP/3.00.00%20USB/%5B%5B%5B%5B%5BVersionUpdate%5D%5D%5D%5D%5D" +version="3.0" +icf="https://archive.org/download/WACCA/EXP/3.00.00%20USB/SDFE_ACA.icf" \ No newline at end of file diff --git a/profiles/waccas/metadata b/profiles/waccas/metadata index 1649afe..1b8158b 100755 --- a/profiles/waccas/metadata +++ b/profiles/waccas/metadata @@ -1,4 +1,3 @@ prettyname="WACCA S" -version="1.50" -icf="https://archive.org/download/WACCA/EXP/1.50.00%20USB/SDFE_ACA.icf" -versionupdate="https://archive.org/download/WACCA/EXP/1.50.00%20USB/%5B%5B%5B%5B%5BVersionUpdate%5D%5D%5D%5D%5D" +version="1.5" +icf="https://archive.org/download/WACCA/EXP/1.50.00%20USB/SDFE_ACA.icf" \ No newline at end of file