Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Descent launchscripts #1185

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 19 additions & 46 deletions ports/descent/Descent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fi

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

get_controls

# Variables
Expand All @@ -33,61 +32,35 @@ $ESUDO chmod +x -R $GAMEDIR/*
# Set config dir
bind_directories ~/.$GAME $GAMEDIR/config

# Exports
export LD_LIBRARY_PATH="$GAMEDIR/libs:$LD_LIBRARY_PATH"
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"
export SDL_FORCE_SOUNDFONTS=1
export SDL_SOUNDFONTS="$GAMEDIR/soundfont.sf2"

# Add some cheats
if [ ! -f "./cheats.txt" ]; then
echo "Error: Cheats file not found. No cheats will be used." > $CUR_TTY
pm_message "Error: Cheats file not found. No cheats will be used."
else
CHEATS=$(sed -n -E '/^[^#]*=[[:space:]]*1([^0-9#]|$)/s/(=[[:space:]]*1[^0-9#]*)//p' ./cheats.txt | tr -d '\n')
fi

# Exports
export LD_LIBRARY_PATH="$GAMEDIR/libs:$LD_LIBRARY_PATH"
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"
export SDL_FORCE_SOUNDFONTS=1
export SDL_SOUNDFONTS="$GAMEDIR/soundfont.sf2"
export TEXTINPUTPRESET=$CHEATS

# Edit .cfg file with updated resolution and aspect ratio
sed -i "s/^ResolutionX=640/ResolutionX=$DISPLAY_WIDTH/g" $GAMEDIR/config/descent.cfg
sed -i "s/^ResolutionY=480/ResolutionY=$DISPLAY_HEIGHT/g" $GAMEDIR/config/descent.cfg
sed -i "s/^AspectX=.*/AspectX=$ASPECT_Y/g" $GAMEDIR/config/descent.cfg
sed -i "s/^AspectY=.*/AspectY=$ASPECT_X/g" $GAMEDIR/config/descent.cfg

# List of compatibility firmwares
CFW_NAMES="ArkOS:ArkOS wuMMLe:ArkOS AeUX:knulli:TrimUI"

# Check if the current CFW name is in the list
contains() {
local value="$CFW_NAME"
local item
local tmp=$IFS
IFS=":" # Use : as the delimiter
echo "Checking if CFW_NAME '$value' is in the list..."
for item in $CFW_NAMES; do
echo "Comparing '$item' with '$value'..."
if [ "$item" = "$value" ]; then
echo "Match found: '$item'"
IFS=$tmp
return 0
fi
done
echo "No match found for '$value'."
IFS=$tmp
return 1
}

# If it's in the list use the compatibility binary
if contains; then
$GPTOKEYB "$GAME.compat" -c "config/joy.gptk" &
pm_platform_helper "$GAMEDIR/$GAME.compat"
./$GAME.compat -hogdir data
else
$GPTOKEYB "$GAME.$DEVICE_ARCH" -c "config/joy.gptk" &
pm_platform_helper "$GAMEDIR/$GAME.$DEVICE_ARCH"
./$GAME.$DEVICE_ARCH -hogdir data
sed -i "s/^ResolutionX=[0-9]\{1,4\}/ResolutionX=$DISPLAY_WIDTH/g" "$GAMEDIR/config/descent.cfg"
sed -i "s/^ResolutionY=[0-9]\{1,4\}/ResolutionY=$DISPLAY_HEIGHT/g" "$GAMEDIR/config/descent.cfg"
sed -i "s/^AspectX=[0-9]\{1,2\}/AspectX=$ASPECT_Y/g" "$GAMEDIR/config/descent.cfg"
sed -i "s/^AspectY=[0-9]\{1,2\}/AspectY=$ASPECT_X/g" "$GAMEDIR/config/descent.cfg"

# Use compatibility binary if low glibc
if [ $CFW_GLIBC -lt 234 ]; then
GAME="$GAME.compat"
fi

# Run game
$GPTOKEYB "$GAME" -c "config/joy.gptk" &
pm_platform_helper "$GAMEDIR/$GAME"
./$GAME -hogdir data

# Cleanup
pm_finish

65 changes: 19 additions & 46 deletions ports/descent2/Descent 2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fi

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

get_controls

# Variables
Expand All @@ -33,61 +32,35 @@ $ESUDO chmod +x -R $GAMEDIR/*
# Set config dir
bind_directories ~/.$GAME $GAMEDIR/config

# Exports
export LD_LIBRARY_PATH="$GAMEDIR/libs:$LD_LIBRARY_PATH"
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"
export SDL_FORCE_SOUNDFONTS=1
export SDL_SOUNDFONTS="$GAMEDIR/soundfont.sf2"

# Add some cheats
if [ ! -f "./cheats.txt" ]; then
echo "Error: Cheats file not found. No cheats will be used." > $CUR_TTY
pm_message "Error: Cheats file not found. No cheats will be used."
else
CHEATS=$(sed -n -E '/^[^#]*=[[:space:]]*1([^0-9#]|$)/s/(=[[:space:]]*1[^0-9#]*)//p' ./cheats.txt | tr -d '\n')
fi

# Exports
export LD_LIBRARY_PATH="$GAMEDIR/libs:$LD_LIBRARY_PATH"
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"
export SDL_FORCE_SOUNDFONTS=1
export SDL_SOUNDFONTS="$GAMEDIR/soundfont.sf2"
export TEXTINPUTPRESET=$CHEATS

# Edit .cfg file with updated resolution and aspect ratio
sed -i "s/^ResolutionX=640/ResolutionX=$DISPLAY_WIDTH/g" $GAMEDIR/config/descent.cfg
sed -i "s/^ResolutionY=480/ResolutionY=$DISPLAY_HEIGHT/g" $GAMEDIR/config/descent.cfg
sed -i "s/^AspectX=.*/AspectX=$ASPECT_Y/g" $GAMEDIR/config/descent.cfg
sed -i "s/^AspectY=.*/AspectY=$ASPECT_X/g" $GAMEDIR/config/descent.cfg

# List of compatibility firmwares
CFW_NAMES="ArkOS:ArkOS wuMMLe:ArkOS AeUX:knulli:TrimUI"

# Check if the current CFW name is in the list
contains() {
local value="$CFW_NAME"
local item
local tmp=$IFS
IFS=":" # Use : as the delimiter
echo "Checking if CFW_NAME '$value' is in the list..."
for item in $CFW_NAMES; do
echo "Comparing '$item' with '$value'..."
if [ "$item" = "$value" ]; then
echo "Match found: '$item'"
IFS=$tmp
return 0
fi
done
echo "No match found for '$value'."
IFS=$tmp
return 1
}

# If it's in the list use the compatibility binary
if contains; then
$GPTOKEYB "$GAME.compat" -c "config/joy.gptk" &
pm_platform_helper "$GAMEDIR/$GAME.compat"
./$GAME.compat -hogdir data
else
$GPTOKEYB "$GAME.$DEVICE_ARCH" -c "config/joy.gptk" &
pm_platform_helper "$GAMEDIR/$GAME.$DEVICE_ARCH"
./$GAME.$DEVICE_ARCH -hogdir data
sed -i "s/^ResolutionX=[0-9]\{1,4\}/ResolutionX=$DISPLAY_WIDTH/g" "$GAMEDIR/config/descent.cfg"
sed -i "s/^ResolutionY=[0-9]\{1,4\}/ResolutionY=$DISPLAY_HEIGHT/g" "$GAMEDIR/config/descent.cfg"
sed -i "s/^AspectX=[0-9]\{1,2\}/AspectX=$ASPECT_Y/g" "$GAMEDIR/config/descent.cfg"
sed -i "s/^AspectY=[0-9]\{1,2\}/AspectY=$ASPECT_X/g" "$GAMEDIR/config/descent.cfg"

# Use compatibility binary if low glibc
if [ $CFW_GLIBC -lt 234 ]; then
GAME="$GAME.compat"
fi

# Run game
$GPTOKEYB "$GAME" -c "config/joy.gptk" &
pm_platform_helper "$GAMEDIR/$GAME"
./$GAME -hogdir data

# Cleanup
pm_finish