Skip to content

Commit

Permalink
Merge pull request #741 from JanTrueno/MAGO
Browse files Browse the repository at this point in the history
New Port: Mago
  • Loading branch information
Cebion authored Oct 6, 2024
2 parents b82085e + b0e0b4f commit 7e71b19
Show file tree
Hide file tree
Showing 30 changed files with 842 additions and 0 deletions.
57 changes: 57 additions & 0 deletions ports/mago/Mago.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}

if [ -d "/opt/system/Tools/PortMaster/" ]; then
controlfolder="/opt/system/Tools/PortMaster"
elif [ -d "/opt/tools/PortMaster/" ]; then
controlfolder="/opt/tools/PortMaster"
elif [ -d "$XDG_DATA_HOME/PortMaster/" ]; then
controlfolder="$XDG_DATA_HOME/PortMaster"
else
controlfolder="/roms/ports/PortMaster"
fi

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

GAMEDIR=/$directory/ports/mago

# Enable logging
> "$GAMEDIR/log.txt" && exec > >(tee "$GAMEDIR/log.txt") 2>&1

# Exports
export LD_LIBRARY_PATH="/usr/lib:$GAMEDIR/lib:$GAMEDIR/tools/libs:$LD_LIBRARY_PATH"
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"

export PATCHER_FILE="$GAMEDIR/patch/patchscript"
export PATCHER_GAME="MAGO"
export PATCHER_TIME="2 to 4 minutes"
export PATCHDIR=$GAMEDIR

# Permissions
$ESUDO chmod +x "$GAMEDIR/gmloadernext"
$ESUDO chmod +x "$GAMEDIR/patch/patchscript"
$ESUDO chmod +x "$GAMEDIR/tools/xdelta3"
$ESUDO chmod +x "$GAMEDIR/tools/splash"

cd "$GAMEDIR"

# Check if patchlog.txt exists to skip patching
if [ ! -f patchlog.txt ]; then
source "$controlfolder/utils/patcher.txt"
fi

# Splash
$ESUDO ./tools/splash "splash.png" 5000 &

# GPTK Setup and run gmloader
$GPTOKEYB "gmloadernext" &
pm_platform_helper $GAMEDIR/gmloadernext
./gmloadernext game.apk

# Cleanup
pm_finish
printf "\033c" > /dev/tty0
17 changes: 17 additions & 0 deletions ports/mago/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Notes

Huge thanks to the developers of MAGO, [Dream Potion Games ](https://dreampotiongames.com/). You can buy the game on [Steam](https://store.steampowered.com/app/1098280/Mago/).

Note that this game always stretches to fullscreen. The game is natively 16:9, this game will not look great on devices like the RGB30.

## Controls

| Button | Action |
|--|--|
|D-pad|Move|
|A|Jump|
|X|Magic|
|L1+R1|Next/Previous Page|
|Option|Pause|


Binary file added ports/mago/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions ports/mago/gameinfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<gameList>
<game>
<path>./Mago.sh</path>
<name>Mago</name>
<desc>A classic magical adventure with beautiful pixel art and intuitive controls. Travel a vast world with many levels, mini-games, and secret locations!</desc>
<releasedate>20220621T000000</releasedate>
<developer>Dream Potion Games</developer>
<genre>Platformer</genre>
<image>./mago/cover.png</image>
</game>
</gameList>
Empty file added ports/mago/mago/compress.txt
Empty file.
Binary file added ports/mago/mago/game.apk
Binary file not shown.
Empty file.
Binary file added ports/mago/mago/gmloadernext
Binary file not shown.
17 changes: 17 additions & 0 deletions ports/mago/mago/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# What are those?

Those are native Android libraries meant to be loaded into the guest environment,
and the come from a [prebuilt AOSP image provided by google](https://ci.android.com/builds/branches/aosp-main/grid).

# What are these files for then?

They provide a similar-to-android implementation to all of the supported libraries,
allowing us to make less guesswork, and provide more accurate renditions of a lot
of those functionalities, specially for libc++ where a lot of guesswork was done
in the past.

OpenAL, OpenGL and libc.so are provided from the host (via thunking where needed) or
via reimplementations.

You still need a suitable GameMaker Android title/runner. You can source those from
either [freeware Android APKs](https://itch.io) or finding a [suitable runner](https://gamemaker.io/account/runtimes) for hacking.
Binary file added ports/mago/mago/lib/arm64-v8a/libc++_shared.so
Binary file not shown.
Binary file added ports/mago/mago/lib/arm64-v8a/libcompiler_rt.so
Binary file not shown.
Binary file added ports/mago/mago/lib/arm64-v8a/libm.so
Binary file not shown.
Binary file added ports/mago/mago/lib/armeabi-v7a/libc++_shared.so
Binary file not shown.
Binary file added ports/mago/mago/lib/armeabi-v7a/libcompiler_rt.so
Binary file not shown.
Binary file added ports/mago/mago/lib/armeabi-v7a/libm.so
Binary file not shown.
Binary file added ports/mago/mago/lib/libcrypto.so.1.1
Binary file not shown.
Binary file added ports/mago/mago/lib/libopenal.so.1
Binary file not shown.
Binary file added ports/mago/mago/lib/libzip.so.5
Binary file not shown.
Binary file added ports/mago/mago/patch/mago.xdelta
Binary file not shown.
105 changes: 105 additions & 0 deletions ports/mago/mago/patch/patchscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

# Set the log file
LOGFILE="$PATCHDIR/patchlog.txt"

# Redirect output and error to the log file
exec > >(tee -a "$LOGFILE") 2>&1

echo "PATCHDIR is set to: $PATCHDIR"

# Exports
export LD_LIBRARY_PATH="/usr/lib:$GAMEDIR/lib:$GAMEDIR/tools/libs:$LD_LIBRARY_PATH"
export TOOLDIR="$PATCHDIR/tools"
export TMPDIR="$PATCHDIR/tmp"
export PATH=$PATH:$PATCHDIR/tools


# Permissions
chmod 666 /dev/uinput
chmod 777 "$TOOLDIR/gmKtool.py"
chmod 777 "$TOOLDIR/oggenc"

cd "$PATCHDIR"

process_game() {
# Move assets from gamedata folder
if [ -d "gamedata" ]; then
mv gamedata/* .
echo "Moved assets from gamedata to PATCHDIR."
rm -rf gamedata
echo "Removed gamedata directory."
else
echo "gamedata directory not found. Skipping asset move."
fi

# Define files to delete
files_to_delete="Steamworks_x64.dll steam_appid.txt steam_api64.dll MAGO.exe"

# Delete unnecessary files
for file in $files_to_delete; do
if [ -f "$file" ]; then
rm "$file"
echo "Deleted $file"
else
echo "$file not found"
fi
done

# Check if the data.win file exists and its checksum
if [ -f "data.win" ]; then
checksum=$(md5sum "data.win" | awk '{print $1}')
if [ "$checksum" = "7948b946e26ad8a95a7d2f86c800d1b9" ]; then
# Apply the patch
tools/xdelta3 -d -s "data.win" -f "./patch/mago.xdelta" "game.droid" && rm "data.win"
fi
fi

# Compress audio
if [ -f "compress.txt" ]; then
echo "Compressing audio. The process will take 5-10 minutes."

mkdir -p "$TMPDIR"

# Run the compression tool
echo "Running gmKtool.py with parameters..."
./tools/gmKtool.py -vvv -m 262144 -b 64 -d "$TMPDIR" "$PATCHDIR/game.droid"

if [ $? -eq 0 ]; then
echo "Compression completed successfully."
mv "$TMPDIR/"* "$PATCHDIR"
echo "Moved compressed files to $PATCHDIR."
rm "$PATCHDIR/compress.txt"
echo "Removed compress.txt from $PATCHDIR."
rmdir "$TMPDIR"
echo "Temporary directory $TMPDIR removed."
echo "Audio compression applied successfully."
else
echo "Audio compression failed."
echo "Cleaning up temporary directory $TMPDIR."
rm -rf "$TMPDIR"
fi
else
echo "compress.txt not found. Skipping audio compression."
fi

sleep 3

# Check for .dat files and move to APK
if [ -n "$(ls ./*.dat 2>/dev/null)" ]; then
mkdir -p ./assets
mv ./*.dat ./assets/
echo "Moved .dat files to ./assets/"

zip -r -0 ./game.apk ./assets/
echo "Zipped contents to ./game.apk"

rm -rf ./assets
echo "Deleted assets directory"
else
echo "No .dat files found"
fi
}

# Call the function
process_game
Loading

0 comments on commit 7e71b19

Please sign in to comment.