Advertisement
Guest User

tmnt.sh

a guest
Aug 3rd, 2023
1,095
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.04 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ -d "/opt/system/Tools/PortMaster/" ]; then
  4.   controlfolder="/opt/system/Tools/PortMaster"
  5. elif [ -d "/opt/tools/PortMaster/" ]; then
  6.   controlfolder="/opt/tools/PortMaster"
  7. elif [ -d "/roms/ports" ]; then
  8.   controlfolder="/roms/ports/PortMaster"
  9.  elif [ -d "/roms2/ports" ]; then
  10.   controlfolder="/roms2/ports/PortMaster"
  11. else
  12.   controlfolder="/storage/roms/ports/PortMaster"
  13. fi
  14.  
  15. source $controlfolder/control.txt
  16. source $controlfolder/tasksetter
  17.  
  18. get_controls
  19.  
  20. gameassembly="TMNT.exe"
  21. gamedir="/$directory/ports/tmntsr"
  22. cd "$gamedir/gamedata"
  23.  
  24. # Grab text output...
  25. $ESUDO chmod 666 /dev/tty0
  26. printf "\033c" > /dev/tty0
  27. echo "Loading... Please Wait." > /dev/tty0
  28.  
  29. # # # export path for local libSDL
  30. export LD_PRELOAD=$gamedir/libs/libSDL2-2.0.so.0
  31.  
  32.  
  33. # Setup mono
  34. monodir="$HOME/mono"
  35. monofile="$controlfolder/libs/mono-6.12.0.122-aarch64.squashfs"
  36. $ESUDO mkdir -p "$monodir"
  37. $ESUDO umount "$monofile" || true
  38. $ESUDO mount "$monofile" "$monodir"
  39.  
  40.  
  41. # # # Rotate screen
  42. SDL=$(readlink -f /usr/lib32/SDL2-rotated/libSDL2.so 2>/dev/null)  
  43. export LD_PRELOAD="${SDL}"
  44.  
  45. # Setup savedir
  46. $ESUDO rm -rf ~/.local/share/Tribute\ Games/TMNT
  47. mkdir -p ~/.local/share/Tribute\ Games/
  48. ln -sfv "$gamedir/savedata" ~/.local/share/Tribute\ Games/TMNT
  49.  
  50. # Remove all the dependencies in favour of system libs - e.g. the included
  51. rm -f System*.dll mscorlib.dll FNA.dll Mono.*.dll
  52.  
  53. # Setup path and other environment variables
  54. # export FNA_PATCH="$gamedir/dlls/PanzerPaladinPatches.dll"
  55. export XDG_DATA_HOME=$HOME/.local/share
  56. export MONO_PATH="$gamedir/dlls":"$gamedir/gamedata":"$gamedir/monomod"
  57. export LD_LIBRARY_PATH="$gamedir/libs":"$monodir/lib":"$LD_LIBRARY_PATH"
  58. export PATH="$monodir/bin":"$PATH"
  59.  
  60.  
  61. # Configure the renderpath
  62. export FNA3D_FORCE_DRIVER=OpenGL
  63. export FNA3D_OPENGL_FORCE_ES3=1
  64. export FNA3D_OPENGL_FORCE_VBO_DISCARD=1
  65. export FNA_SDL2_FORCE_BASE_PATH=0
  66. regen_checksum=no
  67.  
  68. sha1sum -sc "${gamedir}/gamedata/.ver_checksum"
  69. if [ $? -ne 0 ]; then
  70.     echo "Checksum fail or unpatched binary found, patching game..." > /dev/tty0 2>&1
  71.     rm -f "${gamedir}/gamedata/.astc_done"
  72.     rm -f "${gamedir}/gamedata/.patch_done"
  73. fi
  74.  
  75. # Textures not converted? let's perform first time setup
  76. if [[ ! -f "${gamedir}/gamedata/.astc_done" ]]; then
  77.     echo "Performing first time setup..." > /dev/tty0 2>&1
  78.     echo "This may take upwards of 15 minutes (RK3326), go grab a pizza slice or two." > /dev/tty0 2>&1
  79.  
  80.     # Re-encode a few common textures as ASTC 4x4 due to RAM constraints.
  81.     mono "${gamedir}/FNARepacker.exe" "${gamedir}/gamedata/Content/" > >(tee ${gamedir}/astc_log.txt) 2>&1
  82.    
  83.     # Mark step as done
  84.     touch "${gamedir}/gamedata/.astc_done"
  85.     regen_checksum=yes
  86. fi
  87.  
  88. # MONOMODDED files not found, let's perform patching
  89. if [[ ! -f "${gamedir}/gamedata/.patch_done" ]]; then
  90.     echo "Performing game patching..." > /dev/tty0 2>&1
  91.  
  92.     # Configure MonoMod settings
  93.     export MONOMOD_MODS="$gamedir/patches"
  94.     export MONOMOD_DEPDIRS="${MONO_PATH}":"${gamedir}/monomod"
  95.  
  96.     # Patch the ParisEngine/gameassembly files
  97.     mono "${gamedir}/monomod/MonoMod.exe" "${gamedir}/gamedata/ParisEngine.dll" > >(tee ${gamedir}/monomod_log.txt) 2>&1
  98.     mono "${gamedir}/monomod/MonoMod.exe" "${gamedir}/gamedata/${gameassembly}" > >(tee -a ${gamedir}/monomod_log.txt) 2>&1
  99.     if [ $? -ne 0 ]; then
  100.         echo "Failure performing first time setup, report this." > /dev/tty0 2>&1
  101.         sleep 5
  102.         exit -1
  103.     fi
  104.  
  105.     # Mark step as done
  106.     touch "${gamedir}/gamedata/.patch_done"
  107.     regen_checksum=yes
  108. fi
  109.  
  110. # Regenerate sha1sum checks
  111. if [[ x${regen_checksum} -eq xyes ]]; then
  112.     sha1sum "${gamedir}/gamedata/"{ParisEngine.dll,TMNT.exe} > "${gamedir}/gamedata/.ver_checksum"
  113.     sha1sum "${gamedir}/patches/"*.dll >> "${gamedir}/gamedata/.ver_checksum"
  114. fi
  115.  
  116. printf "\033c" > /dev/tty0
  117. echo "Loading... Please Wait." > /dev/tty0
  118.  
  119. $GPTOKEYB "mono" &
  120. $TASKSET mono ../MMLoader.exe MONOMODDED_${gameassembly} > >(tee ${gamedir}/log.txt) 2>&1
  121. $ESUDO kill -9 $(pidof gptokeyb)
  122. $ESUDO systemctl restart oga_events &
  123. $ESUDO umount "$monodir"
  124.  
  125. # Disable console
  126. printf "\033c" >> /dev/tty1
  127.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement