Skip to content

Commit

Permalink
Merge pull request #868 from JeodC/ufo50-update
Browse files Browse the repository at this point in the history
UFO50: Update for v1.4.0
  • Loading branch information
Cebion authored Oct 28, 2024
2 parents 88cbe5c + d9c4e2f commit 41927dc
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 9 deletions.
2 changes: 2 additions & 0 deletions ports/ufo50/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Installation
Purchase the game on Steam and copy all the data to `ports/ufo50/gamedata`. On first run the game will be patched.

If you are updating a prepatched game, simply delete the `ufo50/gamedata/game.droid` file and the `patchlog.txt` file, and add your new `data.win` file to `gamedata`.

## Performance Notes
This port features audio compression and texture repacking in an attempt to reduce memory usage. This is necessary in order for the port to run on the linux arm handhelds targeted. These handhelds are equipped with low-end rockchip or allwinner processors
and usually 1-2GB of memory, alongside Mali blob drivers. Low processing power, low memory, and low VRAM are all major things to watch for when running ports on these devices. The following are known issues that are, again, **conditionally existent due to hardware and gmloader-next constraints**.
Expand Down
Binary file not shown.
25 changes: 20 additions & 5 deletions ports/ufo50/ufo50/tools/gmKtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@ def main():


parser = argparse.ArgumentParser(description='GameMaker K-dog tool: compress wav to ogg, recompress ogg, in Gamemaker data files')
parser.add_argument('-v','--verbose', action='count', default=0, help='Verbose level (cumulative option)')
parser.add_argument('-m','--minsize', default=MIN_SIZE, type=int, help='Minimum WAV/OGG size in bytes to target (default 1MB)')
parser.add_argument('-a','--audiogroup', nargs='?',action='append',type=int, help='Audiogroup ID to process (option can repeat). By default any.')
parser.add_argument('-b','--bitrate', default=0, help='nominal bitrate (in kbps) to encode at (oggenc -b option). 0 for auto (default)')
parser.add_argument('-v', '--verbose', action='count', default=0, help='Verbose level (cumulative option)')
parser.add_argument('-m', '--minsize', default=MIN_SIZE, type=int, help='Minimum WAV/OGG size in bytes to target (default 1MB)')
parser.add_argument('-a', '--audiogroup', nargs='?',action='append',type=int, help='Audiogroup ID to process (option can repeat). By default any.')
parser.add_argument('-N', '--no-write', nargs="?",action='append', type=int, help='Don\'t write the updated file for this audiogroup number (option can repeat). By default none.')
parser.add_argument('-O', '--only-write', nargs="?",action='append', type=int, help='Only write the updated file for this audiogroup number (option can repeat). By default write all.')
parser.add_argument('-b', '--bitrate', default=0, help='nominal bitrate (in kbps) to encode at (oggenc -b option). 0 for auto (default)')
parser.add_argument('-B', '--buffered', default=False, action='store_true', help='Don\'t flush stdout after each line (incompatible with the patcher screen)')
parser.add_argument('-r', '--recompress', default=False, action='store_true', help='Allow ogg recompression')
parser.add_argument('-y', '--yes', default=False, action='store_true', help='Overwrite the files if already present without asking (DANGEROUS, use with caution)')
parser.add_argument('-d','--destdirpath', default="./Ktool.out",help='Destination directory path (default ./Ktool.out)')
parser.add_argument('-d', '--destdirpath', default="./Ktool.out",help='Destination directory path (default ./Ktool.out)')

parser.add_argument('infilepath', help='Input file path (eg: data.win)')

args = parser.parse_args()

if args.no_write != None and args.only_write != None:
print("-N and -O are incompatible together, use only one")
exit(1)

if args.audiogroup:
audiogroup_filter = args.audiogroup
else:
Expand All @@ -56,6 +63,14 @@ def main():
OUT_DIR.mkdir()

myiffdata = GMdata(INFILE_PATH, args.verbose, args.bitrate, audiogroup_filter)

if args.no_write != None:
myiffdata.no_write(args.no_write)
elif args.only_write != None:
myiffdata.only_write(args.only_write)

myiffdata.set_buffered(args.buffered)

myiffdata.audio_enable_compress(args.minsize,args.recompress)
myiffdata.write_changes(OUT_DIR)

Expand Down
Binary file modified ports/ufo50/ufo50/tools/patches/ufo50.xdelta
Binary file not shown.
32 changes: 28 additions & 4 deletions ports/ufo50/ufo50/tools/patchscript
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ chmod 777 "$TOOLDIR/oggenc"

cd "$GAMEDIR"

unzip_audiogroups() {
# Unzip audiogroups from game.apk into $DATADIR
echo "Unzipping audiogroups..."
unzip -j -o "$GAMEDIR/game.apk" "assets/*" -d "$DATADIR"
if [ $? -eq 0 ]; then
echo "Audiogroups unzipped successfully to $DATADIR."
else
echo "Failed to unzip audiogroups."
exit 1
fi
}

apply_xdelta() {
# Check if the data.win file exists and apply xdelta
if [ -f "$DATADIR/data.win" ]; then
Expand All @@ -47,13 +59,20 @@ compress_audio() {

# Run the compression tool
PYTHON=$(which python3)
$PYTHON ./tools/gmKtool.py -vvv -m 1000 -r -b 64 -d "$TMPDIR" "$DATADIR/game.droid"
DATAONLY=1
if [ "$PREPATCH" != 1 ]; then
echo "Running GMTools on data and audiogroups."
$PYTHON ./tools/gmKtool.py -vvv -m 1000 -r -b 64 -d "$TMPDIR" "$DATADIR/game.droid"
else
echo "Running GMTools on data file only."
$PYTHON ./tools/gmKtool.py -v -O 0 -m 1000 -b 64 -r -d "$TMPDIR" "$DATADIR/game.droid"
fi

if [ $? -eq 0 ]; then
echo "Compression completed successfully."
mv "$TMPDIR/"* "$DATADIR"
echo "Moved compressed files to $DATADIR."
rmdir "$TMPDIR"
rm -rf "$TMPDIR"
echo "Temporary directory $TMPDIR removed."
echo "Audio compression applied successfully."
else
Expand All @@ -66,8 +85,13 @@ compress_audio() {
process_game() {
# Delete unnecessary files
rm -rf $DATADIR/*.exe $DATADIR/*.dll $DATADIR/.gitkeep
echo "Removed unecessary files"

echo "Removed unnecessary files"
# Check if we're using a prepatched game
if unzip -l "$GAMEDIR/game.apk" "assets/*" | grep -q "assets/.*\.dat"; then
echo "Prepatched game detected." && sleep 1
PREPATCH=1
unzip_audiogroups
fi
apply_xdelta
compress_audio
sleep 3
Expand Down

0 comments on commit 41927dc

Please sign in to comment.