diff --git a/ports/ufo50/README.md b/ports/ufo50/README.md index 7354a132b9..0038db0272 100644 --- a/ports/ufo50/README.md +++ b/ports/ufo50/README.md @@ -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**. diff --git a/ports/ufo50/ufo50/tools/Klib/__pycache__/GMblob.cpython-311.pyc b/ports/ufo50/ufo50/tools/Klib/__pycache__/GMblob.cpython-311.pyc new file mode 100644 index 0000000000..77b92d53d2 Binary files /dev/null and b/ports/ufo50/ufo50/tools/Klib/__pycache__/GMblob.cpython-311.pyc differ diff --git a/ports/ufo50/ufo50/tools/gmKtool.py b/ports/ufo50/ufo50/tools/gmKtool.py index d168bb9c92..4c5f796bf8 100644 --- a/ports/ufo50/ufo50/tools/gmKtool.py +++ b/ports/ufo50/ufo50/tools/gmKtool.py @@ -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: @@ -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) diff --git a/ports/ufo50/ufo50/tools/patches/ufo50.xdelta b/ports/ufo50/ufo50/tools/patches/ufo50.xdelta index e76f164536..6352edf2e9 100644 Binary files a/ports/ufo50/ufo50/tools/patches/ufo50.xdelta and b/ports/ufo50/ufo50/tools/patches/ufo50.xdelta differ diff --git a/ports/ufo50/ufo50/tools/patchscript b/ports/ufo50/ufo50/tools/patchscript index c8648ab978..b1853d7806 100644 --- a/ports/ufo50/ufo50/tools/patchscript +++ b/ports/ufo50/ufo50/tools/patchscript @@ -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 @@ -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 @@ -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