Skip to content

Commit

Permalink
Merge pull request #653 from cdeletre/fallenleaf
Browse files Browse the repository at this point in the history
Add new port Fallen Leaf
  • Loading branch information
JanTrueno authored Sep 14, 2024
2 parents f19ad49 + c409fc9 commit c4a0958
Show file tree
Hide file tree
Showing 26 changed files with 899 additions and 0 deletions.
142 changes: 142 additions & 0 deletions ports/fallenleaf/Fallen Leaf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/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

source $controlfolder/control.txt
source $controlfolder/device_info.txt
export PORT_32BIT="Y"


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

get_controls

$ESUDO chmod 666 /dev/tty0

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

printf "\033c" > $CUR_TTY

GAMEDIR="/$directory/ports/fallenleaf"
TOOLDIR="$GAMEDIR/tools"
TMPDIR="$GAMEDIR/tmp"
BITRATE=128

$ESUDO chmod 777 "$TOOLDIR/splash"
$ESUDO chmod 777 "$TOOLDIR/gmKtool.py"
$ESUDO chmod 777 "$TOOLDIR/swapabxy.py"
$ESUDO chmod 777 "$GAMEDIR/gmloader"

export LD_LIBRARY_PATH="/usr/lib32:$GAMEDIR/libs:$TOOLDIR/libs:$LD_LIBRARY_PATH"
export PATH="$TOOLDIR:$PATH"
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"
export GMLOADER_DEPTH_DISABLE=1
export GMLOADER_SAVEDIR="$GAMEDIR/gamedata/"
export GMLOADER_PLATFORM="os_linux"

cd $GAMEDIR

# We log the execution of the script into log.txt
> "$GAMEDIR/log.txt" && exec > >(tee "$GAMEDIR/log.txt") 2>&1

# Functions
install() {

# Rename data.win
[ -f "./gamedata/data.win" ] && mv gamedata/data.win gamedata/game.droid
[ -f "./gamedata/game.win" ] && mv gamedata/game.win gamedata/game.droid
[ -f "./gamedata/game.unx" ] && mv gamedata/game.unx gamedata/game.droid

if [ -f "$GAMEDIR/compress.txt" ]; then
# Compress audio
compress_audio
fi
}

compress_audio() {
echo "Compressing audio. The process will take 5-10 minutes" > $CUR_TTY
mkdir -p "$TMPDIR"
gmKtool.py -v -b $BITRATE -d "$TMPDIR" "$GAMEDIR/gamedata/game.droid"

if [ $? -eq 0 ]; then
mv $TMPDIR/* "$GAMEDIR/gamedata"
rm "$GAMEDIR/compress.txt"
rmdir "$TMPDIR"
echo "Audio compression applied successfully." > $CUR_TTY
return 0
else
echo "Audio compression failed." > $CUR_TTY
rm -rf "$TMPDIR"
return 1
fi
}

random_splash() {
# Randomize the splash screen
n=$((1 + $RANDOM % 3))
mkdir -p "$GAMEDIR/assets"
cp "splash-$n.png" "$GAMEDIR/assets/splash.png"
zip -u -r -0 "game.apk" "assets"
rm "$GAMEDIR/assets/splash.png"
rmdir "$GAMEDIR/assets"
}

swapabxy() {
# Update SDL_GAMECONTROLLERCONFIG to swap a/b and x/y button

if [ "$CFW_NAME" == "knulli" ] && [ -f "$SDL_GAMECONTROLLERCONFIG_FILE" ];then
# Knulli seems to use SDL_GAMECONTROLLERCONFIG_FILE (on rg40xxh at least)
cat "$SDL_GAMECONTROLLERCONFIG_FILE" | swapabxy.py > "$GAMEDIR/gamecontrollerdb_swapped.txt"
export SDL_GAMECONTROLLERCONFIG_FILE="$GAMEDIR/gamecontrollerdb_swapped.txt"
else
# Other CFW use SDL_GAMECONTROLLERCONFIG
export SDL_GAMECONTROLLERCONFIG="`echo "$SDL_GAMECONTROLLERCONFIG" | swapabxy.py`"
fi
}

# Run install if needed
if [ ! -f "$GAMEDIR/gamedata/game.droid" ]; then
[ "$CFW_NAME" == "muOS" ] && splash "splash-install.png" 1 # workaround for muOS
splash "splash-install.png" 600000 & # 10 minutes
SPLASH_PID=$!
install
res=$?
$ESUDO kill -9 $SPLASH_PID
if [ ! $res -eq 0 ]; then
exit 1
fi
fi

# Swap a/b and x/y button if needed
if [ -f "$GAMEDIR/swapabxy.txt" ]; then
swapabxy
fi

random_splash

# Make sure uinput is accessible so we can make use of the gptokeyb controls
$ESUDO chmod 666 /dev/uinput

$GPTOKEYB "gmloader" &

./gmloader game.apk

$ESUDO kill -9 $(pidof gptokeyb)
$ESUDO systemctl restart oga_events &
printf "\033c" > $CUR_TTY
32 changes: 32 additions & 0 deletions ports/fallenleaf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Notes

* The game is available on [Steam](https://store.steampowered.com/app/1459010/Fallen_Leaf/)
* The first run will need 5 to 10 min to compress the audio data so that the game can run on 1GB memory devices
* The splashscreen on game loading is currently not displayed on rocknix devices, it shows a black screen
* You can skip a cutscene with a long press on start
* This game uses X360 gamepad layout for A/B/X/Y buttons, which means :
- A button is South
- X button is West
- B button is East
* In the game menu and during the gameplay you'll see indications/hints for which button you have to press. It uses North/South/West/East button indications. If the indications don't match your gamepad layout, for example you need to press East when it says to press South for jumping, you can try to remove the `swapabxy.txt` file in the `fallenleaf` folder and restart the game. You can always put back a `swapabxy.txt` file in the `fallenleaf` to re-enable the swapping of A/B and X/Y buttons.
* If you don't want to compress the audio data you can remove the `compress.txt` file in the `fallenleaf` folder **before** you start the game for the first time. However be aware that the loading time will be longer and the game won't work if your device only have 1GB memory.

## Controls

| Button | Action |
|--|--|
|Dpad / Left Stick|Movement|
|A|Jump / Select|
|X|Shoot / Cancel|
|B|Magic|
|L2 / R2|Prev. / Next Char|
|L1 / R2|Prev. / Next Magic|
|Start|Pause|

## Acknowledgments

A special thank you to the wonderful devs over at [Delta Shore Games](https://www.deltashoregames.com/home) for making this magnificent game.

We cannot forget to thanks warmly our fellow testers from the PortMaster Discord <3

And finaly a big thanks to our Lucky Luke cover maker, aka Jeod, for making this beautiful cover for the port in the blink of an eye *~pew~ ~pew~*
Binary file added ports/fallenleaf/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ports/fallenleaf/fallenleaf/compress.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This file will be automaticaly removed after the installation process has been done.
Do not remove it unless you don't want to compress the audio.
Note: 1GB memory device only work with compressed audio
Binary file added ports/fallenleaf/fallenleaf/game.apk
Binary file not shown.
Empty file.
Binary file added ports/fallenleaf/fallenleaf/gmloader
Binary file not shown.
Binary file added ports/fallenleaf/fallenleaf/libc++_shared.so
Binary file not shown.
Binary file added ports/fallenleaf/fallenleaf/libs/libcrypto.so.1.1
Binary file not shown.
Binary file added ports/fallenleaf/fallenleaf/libs/libzip.so.5
Binary file not shown.
Binary file added ports/fallenleaf/fallenleaf/splash-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ports/fallenleaf/fallenleaf/splash-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ports/fallenleaf/fallenleaf/splash-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ports/fallenleaf/fallenleaf/splash-install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ports/fallenleaf/fallenleaf/swapabxy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove this file if you don't need to swap A/B and X/Y button so that the hints on the screen match your gamepad layout
Loading

0 comments on commit c4a0958

Please sign in to comment.