Skip to content

Commit

Permalink
Merge pull request #925 from JeodC/utyellow-refactor
Browse files Browse the repository at this point in the history
Refactor port Undertale Yellow
  • Loading branch information
Cebion authored Nov 13, 2024
2 parents 674a2a2 + 39c80b4 commit 3245b78
Show file tree
Hide file tree
Showing 23 changed files with 858 additions and 72 deletions.
2 changes: 1 addition & 1 deletion ports/sonic3air/port.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"inst": "Copy a rom of Sonic 3 & Knuckles to ports/sonic3air and rename it to `Sonic_Knuckles_wSonic3.bin`.",
"inst_md": null,
"genres": [
"platform"
"platformer"
],
"image": null,
"rtr": false,
Expand Down
3 changes: 2 additions & 1 deletion ports/utyellow/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Installation
Download the [Windows](https://gamejolt.com/games/UndertaleYellow/136925) or [Android](https://gamejolt.com/games/utyandroidp-yftxzc/866335) game from gamejolt and add the contents to `ports/utyellow/assets` (if windows) or directly to `ports/utyellow` (if android).
Download [Undertale Yellow for Windows](https://gamejolt.com/games/UndertaleYellow/136925) game from gamejolt and add the assets (mus, snd folders, data.win etc) to `ports/utyellow/assets`.
Game is ready to play after a brief first-time setup.

## Default Gameplay Controls
Expand All @@ -15,4 +15,5 @@ Game is ready to play after a brief first-time setup.
## Thanks
TeamUndertaleYellow -- The game
JohnnyOnFlame -- GMLoaderNext
Cyril aka kotzebuedog -- GMTools audio patcher
Testers and Devs from the PortMaster Discord
101 changes: 31 additions & 70 deletions ports/utyellow/Undertale Yellow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,90 +13,51 @@ else
fi

source $controlfolder/control.txt
source $controlfolder/device_info.txt
[ -f "${controlfolder}/mod_${CFW_NAME}.txt" ] && source "${controlfolder}/mod_${CFW_NAME}.txt"
get_controls

# Setup permissions
$ESUDO chmod 666 /dev/tty1
$ESUDO chmod 666 /dev/uinput
echo "Loading, please wait... (might take a while!)" > /dev/tty0

# Variables
GAMEDIR="/$directory/ports/utyellow"
CUR_TTY="/dev/tty0"

# Set current virtual screen
if [ "$CFW_NAME" == "muOS" ]; then
/opt/muos/extra/muxlog & CUR_TTY="/tmp/muxlog_info"
else
CUR_TTY="/dev/tty0"
fi

# CD and set permissions
cd $GAMEDIR
> "$GAMEDIR/log.txt" && exec > >(tee "$GAMEDIR/log.txt") 2>&1

$ESUDO chmod 777 "$GAMEDIR/gmloadernext"
$ESUDO chmod +x -R $GAMEDIR/*

# Exports
export LD_LIBRARY_PATH="$GAMEDIR/libs:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/usr/lib:$GAMEDIR/lib:$GAMEDIR/libs:$LD_LIBRARY_PATH"
export PATCHER_FILE="$GAMEDIR/tools/patchscript"
export PATCHER_GAME="$(basename "${0%.*}")" # This gets the current script filename without the extension
export PATCHER_TIME="2 to 5 minutes"
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"

# Run the installer file if it hasn't been run yet
install-apk() {
if [ ! -f "$GAMEDIR/installed" ]; then
echo "Performing first-run setup..." > $CUR_TTY
PATCHFILE="patch-droid.xdelta"
# Extract the APK, replace game.droid, and repack
mkdir -p "$GAMEDIR/assets"
./utils/unzip "yellow.apk" -d "$GAMEDIR/assets/"
mv "$GAMEDIR/assets/assets/game.droid" "$GAMEDIR/game.droid"
apply_patch
mv "$GAMEDIR/game.droid" "$GAMEDIR/assets/assets/game.droid"
./utils/zip -r -0 "yellow.apk" "assets"
rm -rf "$GAMEDIR/assets"
rm -rf game.apk
mv yellow.apk game.apk
touch "$GAMEDIR/installed"
# dos2unix in case we need it
dos2unix "$GAMEDIR/tools/gmKtool.py"
dos2unix "$GAMEDIR/tools/Klib/GMblob.py"
dos2unix "$GAMEDIR/tools/patchscript"

# Check if patchlog.txt to skip patching
if [ ! -f patchlog.txt ]; then
if [ -f "$controlfolder/utils/patcher.txt" ]; then
source "$controlfolder/utils/patcher.txt"
$ESUDO kill -9 $(pidof gptokeyb)
else
echo "This port requires the latest version of PortMaster." > $CUR_TTY
fi
}
install-win() {
if [ ! -f "$GAMEDIR/installed" ]; then
echo "Performing first-run setup..." > $CUR_TTY
PATCHFILE="patch-win.xdelta"
# Purge unneeded files
rm -rf assets/*.ini assets/*.exe
# Rename data.win
echo "Moving the game file..." > $CUR_TTY
mv "./assets/data.win" "./game.droid"
# Create a new zip file game.apk from specified directories
echo "Zipping assets into apk..." > $CUR_TTY
./utils/zip -r -0 "game.apk" "assets"
rm -rf "$GAMEDIR/assets"
apply_patch
fi
}
apply_patch() {
if [ -f "$PATCHFILE" ]; then
echo "Applying patch..." > $CUR_TTY
$controlfolder/xdelta3 -d -s "$GAMEDIR/game.droid" "$GAMEDIR/$PATCHFILE" "$GAMEDIR/game2.droid"
rm -rf game.droid
rm -rf *.xdelta
mv game2.droid game.droid
fi
}

if [ -f "$GAMEDIR/yellow.apk" ]; then
install-apk
else
install-win
echo "Patching process already completed. Skipping."
fi

# Display loading splash
if [ -f "$GAMEDIR/patchlog.txt" ]; then
$ESUDO ./libs/splash "splash.png" 1
$ESUDO ./libs/splash "splash.png" 3000
fi

# Assign gptokeyb and load the game
$GPTOKEYB "gmloadernext" -c "control.gptk" &
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"
./gmloadernext game.apk
$GPTOKEYB "gmloadernext.aarch64" -c "yellow.gptk" &
pm_platform_helper "gmloadernext.aarch64"
./gmloadernext.aarch64 -c gmloader.json

# Kill processes
$ESUDO kill -9 $(pidof gptokeyb)
$ESUDO systemctl restart oga_events &
printf "\033c" > /dev/tty0
# Cleanup
pm_finish
7 changes: 7 additions & 0 deletions ports/utyellow/utyellow/gmloader.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"save_dir" : "saves",
"apk_path" : "utyellow.port",
"show_cursor" : false,
"disable_controller" : false,
"force_platform" : "os_windows"
}
Binary file removed ports/utyellow/utyellow/gmloadernext
Binary file not shown.
Binary file added ports/utyellow/utyellow/gmloadernext.aarch64
Binary file not shown.
Binary file added ports/utyellow/utyellow/libs/splash
Binary file not shown.
Binary file removed ports/utyellow/utyellow/patch-droid.xdelta
Binary file not shown.
Binary file removed ports/utyellow/utyellow/patch-win.xdelta
Binary file not shown.
Loading

0 comments on commit 3245b78

Please sign in to comment.