Skip to content

Commit

Permalink
Merge pull request #1185 from JeodC/descent-update
Browse files Browse the repository at this point in the history
Update Descent launchscripts
  • Loading branch information
Cebion authored Jan 13, 2025
2 parents b6b1caa + 21828b7 commit 6b8772b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 92 deletions.
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

0 comments on commit 6b8772b

Please sign in to comment.