2022-02-05 14:23:32 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
# Copyright (C) 2019-present Shanti Gilbert (https://github.com/shantigilbert)
|
2023-10-24 16:00:57 +00:00
|
|
|
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# Source predefined functions and variables
|
|
|
|
. /etc/profile
|
|
|
|
. /etc/os-release
|
|
|
|
|
|
|
|
# Command line schema
|
|
|
|
# $1 = Game/Port
|
|
|
|
# $2 = Platform
|
|
|
|
# $3 = Core
|
|
|
|
# $4 = Emulator
|
|
|
|
|
|
|
|
### Define the variables used throughout the script
|
|
|
|
BTENABLED=$(get_setting bluetooth.enabled)
|
|
|
|
CFG="/storage/.emulationstation/es_settings.cfg"
|
|
|
|
VERBOSE=false
|
|
|
|
LOGSDIR="/var/log"
|
|
|
|
LOGFILE="exec.log"
|
|
|
|
TBASH="/usr/bin/bash"
|
|
|
|
RATMPCONF="/storage/.config/retroarch/retroarch.cfg"
|
2023-07-19 15:29:53 +00:00
|
|
|
RAAPPENDCONF="/tmp/.retroarch.cfg"
|
2022-02-05 14:23:32 +00:00
|
|
|
NETPLAY="No"
|
2023-08-13 00:33:09 +00:00
|
|
|
SETSETTINGS_TMP="/tmp/shader"
|
2022-02-05 14:23:32 +00:00
|
|
|
OUTPUT_LOG="${LOGSDIR}/${LOGFILE}"
|
|
|
|
### Do not change the variables below as it may break things.
|
|
|
|
MYNAME=$(basename "$0")
|
|
|
|
|
|
|
|
### Enable logging
|
|
|
|
if [ "$(get_es_setting string LogLevel)" == "minimal" ]; then
|
|
|
|
LOG=false
|
|
|
|
else
|
|
|
|
LOG=true
|
2022-08-23 18:45:30 +00:00
|
|
|
VERBOSE=true
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
arguments="$@"
|
|
|
|
PLATFORM="${arguments##*-P}" # read from -P onwards
|
|
|
|
PLATFORM="${PLATFORM%% *}" # until a space is found
|
|
|
|
CORE="${arguments##*--core=}" # read from --core= onwards
|
|
|
|
CORE="${CORE%% *}" # until a space is found
|
|
|
|
EMULATOR="${arguments##*--emulator=}" # read from --emulator= onwards
|
|
|
|
EMULATOR="${EMULATOR%% *}" # until a space is found
|
|
|
|
ROMNAME="$1"
|
|
|
|
BASEROMNAME=${ROMNAME##*/}
|
|
|
|
GAMEFOLDER="${ROMNAME//${BASEROMNAME}}"
|
|
|
|
|
2023-07-20 11:32:43 +00:00
|
|
|
### Use performance mode to prepare to start the emulator.
|
|
|
|
performance
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
### Determine if we're running a Libretro core and append the libretro suffix
|
|
|
|
if [[ $EMULATOR = "retroarch" ]]; then
|
2022-08-23 18:45:30 +00:00
|
|
|
EMU="${CORE}_libretro"
|
|
|
|
RETROARCH="yes"
|
2023-10-26 13:09:22 +00:00
|
|
|
elif [[ $EMULATOR = "mednafen" ]]; then
|
|
|
|
EMU="mednafen"
|
2022-02-05 14:23:32 +00:00
|
|
|
else
|
2022-08-23 18:45:30 +00:00
|
|
|
EMU="${CORE}"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# freej2me needs the JDK to be downloaded on the first run
|
|
|
|
if [[ ${EMU} == "freej2me_libretro" ]]; then
|
|
|
|
/usr/bin/freej2me.sh
|
|
|
|
JAVA_HOME='/storage/jdk'
|
|
|
|
export JAVA_HOME
|
|
|
|
PATH="$JAVA_HOME/bin:$PATH"
|
|
|
|
export PATH
|
|
|
|
fi
|
|
|
|
|
|
|
|
# easyrpg needs runtime files to be downloaded on the first run
|
|
|
|
if [[ ${EMU} == "easyrpg_libretro" ]]; then
|
|
|
|
/usr/bin/easyrpg.sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
### If we're running a port, assume it's libretro
|
|
|
|
### Re-evaluate as not all ports may be libretro cores
|
|
|
|
### perhaps rewrite to use ^ functionality
|
|
|
|
[[ ${PLATFORM} = "ports" ]] && RETROARCH="yes"
|
|
|
|
|
2023-08-13 17:56:48 +00:00
|
|
|
# Make sure netplay isn't defined before we start our tests/configuration.
|
|
|
|
del_setting netplay.mode
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
# check if we started as host for a game
|
|
|
|
if [[ "$arguments" == *"--host"* ]]; then
|
2022-08-23 18:45:30 +00:00
|
|
|
NETPLAY="${arguments##*--host}" # read from --host onwards
|
|
|
|
NETPLAY="${NETPLAY%%--nick*}" # until --nick is found
|
|
|
|
NETPLAY="--host $NETPLAY --nick"
|
2023-08-13 00:33:09 +00:00
|
|
|
set_setting netplay.mode host
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# check if we are trying to connect to a client on netplay
|
|
|
|
if [[ "$arguments" == *"--connect"* ]]; then
|
2022-08-23 18:45:30 +00:00
|
|
|
NETPLAY="${arguments##*--connect}" # read from --connect onwards
|
|
|
|
NETPLAY="${NETPLAY%%--nick*}" # until --nick is found
|
|
|
|
NETPLAY="--connect $NETPLAY --nick"
|
2023-08-13 00:33:09 +00:00
|
|
|
set_setting netplay.mode client
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if we are trying to connect as spectator on netplay
|
|
|
|
if [[ "$arguments" == *"--netplaymode spectator"* ]]; then
|
|
|
|
set_setting "netplay.mode" "spectator"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-02 22:47:44 +00:00
|
|
|
### Offline all but the number of cores we need for this game if configured.
|
2023-01-26 03:22:28 +00:00
|
|
|
NUMTHREADS=$(get_setting "threads" "${PLATFORM}" "${ROMNAME##*/}")
|
2023-01-26 00:41:58 +00:00
|
|
|
if [ -n "${NUMTHREADS}" ] &&
|
|
|
|
[ ! ${NUMTHREADS} = "default" ]
|
2023-01-02 22:47:44 +00:00
|
|
|
then
|
2023-01-26 00:41:58 +00:00
|
|
|
onlinethreads ${NUMTHREADS} 0
|
2023-01-02 22:47:44 +00:00
|
|
|
fi
|
|
|
|
|
2023-04-24 05:33:21 +00:00
|
|
|
### Set the cores to use
|
|
|
|
CORES=$(get_setting "cores" "${PLATFORM}" "${ROMNAME##*/}")
|
|
|
|
if [ "${CORES}" = "little" ]
|
|
|
|
then
|
|
|
|
EMUPERF="${SLOW_CORES}"
|
|
|
|
elif [ "${CORES}" = "big" ]
|
|
|
|
then
|
|
|
|
EMUPERF="${FAST_CORES}"
|
|
|
|
else
|
|
|
|
### All..
|
|
|
|
unset EMUPERF
|
|
|
|
fi
|
|
|
|
|
2022-04-02 14:15:12 +00:00
|
|
|
### We need the original system cooling profile later so get it now!
|
|
|
|
COOLINGPROFILE=$(get_setting cooling.profile)
|
|
|
|
|
2023-08-05 01:31:57 +00:00
|
|
|
### Set CPU TDP (AMD) or EPP (Intel)
|
|
|
|
CPU_VENDOR=$(cpu_vendor)
|
|
|
|
case ${CPU_VENDOR} in
|
|
|
|
AuthenticAMD)
|
|
|
|
### Set the overclock mode
|
|
|
|
OVERCLOCK=$(get_setting "overclock" "${PLATFORM}" "${ROMNAME##*/}")
|
|
|
|
if [ ! -z "${OVERCLOCK}" ]
|
|
|
|
then
|
|
|
|
/usr/bin/overclock ${OVERCLOCK}
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
GenuineIntel)
|
|
|
|
EPP=$(get_setting "power.epp" "${PLATFORM}" "${ROMNAME##*/}")
|
|
|
|
if [ ! -z ${EPP} ]
|
|
|
|
then
|
|
|
|
/usr/bin/set_epp ${EPP}
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2022-04-02 13:13:04 +00:00
|
|
|
|
2023-01-23 02:38:25 +00:00
|
|
|
GPUPERF=$(get_setting "gpuperf" "${PLATFORM}" "${ROMNAME##*/}")
|
2023-06-23 10:57:57 +00:00
|
|
|
if [ ! -z ${GPUPERF} ]
|
2023-01-23 02:38:25 +00:00
|
|
|
then
|
2023-06-23 10:57:57 +00:00
|
|
|
gpu_performance_level ${GPUPERF}
|
|
|
|
get_gpu_performance_level >/tmp/.gpu_performance_level
|
2023-01-23 02:38:25 +00:00
|
|
|
fi
|
|
|
|
|
2022-04-02 14:15:12 +00:00
|
|
|
if [ "${DEVICE_HAS_FAN}" = "true" ]
|
|
|
|
then
|
|
|
|
### Set any custom fan profile (make this better!)
|
|
|
|
GAMEFAN=$(get_setting "cooling.profile" "${PLATFORM}" "${ROMNAME##*/}")
|
|
|
|
if [ ! -z "${GAMEFAN}" ]
|
|
|
|
then
|
|
|
|
set_setting cooling.profile ${GAMEFAN}
|
|
|
|
systemctl restart fancontrol
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
### Function Library
|
|
|
|
|
|
|
|
function log() {
|
2022-08-23 18:45:30 +00:00
|
|
|
if [ ${LOG} == true ]
|
|
|
|
then
|
|
|
|
if [[ ! -d "$LOGSDIR" ]]
|
|
|
|
then
|
|
|
|
mkdir -p "$LOGSDIR"
|
|
|
|
fi
|
2023-07-10 11:59:09 +00:00
|
|
|
echo "${MYNAME}: $*" 2>&1 | tee -a ${LOGSDIR}/${LOGFILE}
|
2022-08-23 18:45:30 +00:00
|
|
|
else
|
2023-07-10 11:59:09 +00:00
|
|
|
echo "${MYNAME}: $*"
|
2022-08-23 18:45:30 +00:00
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function loginit() {
|
2022-08-23 18:45:30 +00:00
|
|
|
if [ ${LOG} == true ]
|
|
|
|
then
|
|
|
|
if [ -e ${LOGSDIR}/${LOGFILE} ]
|
|
|
|
then
|
|
|
|
rm -f ${LOGSDIR}/${LOGFILE}
|
|
|
|
fi
|
|
|
|
cat <<EOF >${LOGSDIR}/${LOGFILE}
|
2022-02-05 14:23:32 +00:00
|
|
|
Emulation Run Log - Started at $(date)
|
|
|
|
|
|
|
|
ARG1: $1
|
|
|
|
ARG2: $2
|
|
|
|
ARG3: $3
|
|
|
|
ARG4: $4
|
|
|
|
ARGS: $*
|
|
|
|
PLATFORM: $PLATFORM
|
|
|
|
ROM NAME: ${ROMNAME}
|
|
|
|
BASE ROM NAME: ${ROMNAME##*/}
|
|
|
|
USING CONFIG: ${RATMPCONF}
|
|
|
|
USING APPENDCONFIG : ${RAAPPENDCONF}
|
|
|
|
|
|
|
|
EOF
|
2022-08-23 18:45:30 +00:00
|
|
|
else
|
2023-01-20 02:30:33 +00:00
|
|
|
log $0 "Emulation Run Log - Started at $(date)"
|
2022-08-23 18:45:30 +00:00
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function quit() {
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Cleaning up and exiting"
|
2022-08-23 18:45:30 +00:00
|
|
|
bluetooth enable
|
2023-07-31 13:06:42 +00:00
|
|
|
jslisten set "emulationstation"
|
2022-08-23 18:45:30 +00:00
|
|
|
clear_screen
|
|
|
|
DEVICE_CPU_GOVERNOR=$(get_setting system.cpugovernor)
|
|
|
|
${DEVICE_CPU_GOVERNOR}
|
|
|
|
exit $1
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function clear_screen() {
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Clearing screen"
|
2022-09-14 21:35:38 +00:00
|
|
|
clear
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function bluetooth() {
|
2022-08-23 18:45:30 +00:00
|
|
|
if [ "$1" == "disable" ]
|
|
|
|
then
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Disabling BT"
|
2022-08-23 18:45:30 +00:00
|
|
|
if [[ "$BTENABLED" == "1" ]]
|
|
|
|
then
|
|
|
|
NPID=$(pgrep -f batocera-bluetooth-agent)
|
|
|
|
if [[ ! -z "$NPID" ]]; then
|
|
|
|
kill "$NPID"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
elif [ "$1" == "enable" ]
|
|
|
|
then
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Enabling BT"
|
2022-08-23 18:45:30 +00:00
|
|
|
if [[ "$BTENABLED" == "1" ]]
|
|
|
|
then
|
|
|
|
systemd-run batocera-bluetooth-agent
|
|
|
|
fi
|
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
### Main Screen Turn On
|
|
|
|
|
|
|
|
loginit "$1" "$2" "$3" "$4"
|
|
|
|
clear_screen
|
|
|
|
bluetooth disable
|
|
|
|
jslisten stop
|
|
|
|
|
|
|
|
### Per emulator/core configurations
|
2023-10-26 13:09:22 +00:00
|
|
|
if [[ $EMULATOR = "mednafen" ]]; then
|
|
|
|
jslisten set "-9 mednafen"
|
|
|
|
RUNTHIS='${TBASH} /usr/bin/start_mednafen.sh "${ROMNAME}" "${CORE}" "${PLATFORM}"'
|
|
|
|
|
|
|
|
elif [ -z ${RETROARCH} ]
|
2022-02-05 14:23:32 +00:00
|
|
|
then
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Configuring for a non-libretro emulator"
|
2022-08-23 18:45:30 +00:00
|
|
|
case ${PLATFORM} in
|
|
|
|
"setup")
|
2023-06-12 21:23:01 +00:00
|
|
|
RUNTHIS='${TBASH} "${ROMNAME}"'
|
2022-08-23 18:45:30 +00:00
|
|
|
;;
|
2022-11-02 14:18:15 +00:00
|
|
|
"gamecube")
|
2023-03-17 16:40:00 +00:00
|
|
|
if [ "$EMU" = "dolphin-sa-gc" ]; then
|
2022-11-02 14:18:15 +00:00
|
|
|
RUNTHIS='${TBASH} /usr/bin/start_dolphin_gc.sh "${ROMNAME}"'
|
2022-12-16 14:42:30 +00:00
|
|
|
elif [ "$EMU" = "primehack" ]; then
|
2023-06-12 21:23:01 +00:00
|
|
|
RUNTHIS='${TBASH} /usr/bin/start_${EMU%-*}.sh "${ROMNAME}"'
|
2022-08-05 14:08:26 +00:00
|
|
|
fi
|
|
|
|
|
2022-09-05 18:43:19 +00:00
|
|
|
;;
|
2022-11-02 14:18:15 +00:00
|
|
|
"wii")
|
2023-03-17 16:40:00 +00:00
|
|
|
if [ "$EMU" = "dolphin-sa-wii" ]; then
|
2022-11-02 14:18:15 +00:00
|
|
|
RUNTHIS='${TBASH} /usr/bin/start_dolphin_wii.sh "${ROMNAME}"'
|
2022-12-16 14:42:30 +00:00
|
|
|
elif [ "$EMU" = "primehack" ]; then
|
2023-06-12 21:23:01 +00:00
|
|
|
RUNTHIS='${TBASH} /usr/bin/start_${EMU%-*}.sh "${ROMNAME}"'
|
2022-11-16 16:36:25 +00:00
|
|
|
fi
|
|
|
|
;;
|
2022-08-23 18:45:30 +00:00
|
|
|
"shell")
|
|
|
|
RUNTHIS='${TBASH} "${ROMNAME}"'
|
|
|
|
;;
|
|
|
|
*)
|
2023-06-12 21:23:01 +00:00
|
|
|
RUNTHIS='${TBASH} "start_${EMU%-*}.sh" "${ROMNAME}"'
|
2022-08-23 18:45:30 +00:00
|
|
|
esac
|
2022-02-05 14:23:32 +00:00
|
|
|
else
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Configuring for a libretro core"
|
2022-08-23 18:45:30 +00:00
|
|
|
|
|
|
|
### Set jslisten to kill the appropriate retroarch
|
|
|
|
jslisten set "retroarch retroarch32"
|
|
|
|
|
2022-09-01 10:07:11 +00:00
|
|
|
RABIN="retroarch"
|
2022-08-23 18:45:30 +00:00
|
|
|
if [[ "${HW_ARCH}" =~ aarch64 ]]
|
|
|
|
then
|
|
|
|
### Check if we need retroarch 32 bits or 64 bits
|
|
|
|
if [[ "${CORE}" =~ pcsx_rearmed32 ]] || \
|
|
|
|
[[ "${CORE}" =~ gpsp ]] || \
|
2023-07-20 18:04:48 +00:00
|
|
|
[[ "${CORE}" =~ flycast32 ]] || \
|
2023-07-20 13:23:03 +00:00
|
|
|
[[ "${CORE}" =~ desmume ]]
|
2022-08-23 18:45:30 +00:00
|
|
|
then
|
2023-08-16 16:41:52 +00:00
|
|
|
export LD_LIBRARY_PATH="/usr/lib32"
|
|
|
|
export SPA_PLUGIN_DIR="/usr/lib32/spa-0.2"
|
|
|
|
export PIPEWIRE_MODULE_DIR="/usr/lib32/pipewire-0.3/"
|
|
|
|
export LIBGL_DRIVERS_PATH="/usr/lib32/dri"
|
2022-09-11 22:08:12 +00:00
|
|
|
export RABIN="retroarch32"
|
2022-08-23 18:45:30 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Platform specific configurations
|
2022-02-05 14:23:32 +00:00
|
|
|
case ${PLATFORM} in
|
|
|
|
"doom")
|
2022-08-23 18:45:30 +00:00
|
|
|
# EXT can be wad, WAD, iwad, IWAD, pwad, PWAD or doom
|
|
|
|
EXT=${ROMNAME##*.}
|
|
|
|
|
|
|
|
# If its not a simple wad (extension .doom) read the file and parse the data
|
|
|
|
if [ ${EXT} == "doom" ]; then
|
|
|
|
dos2unix "${1}"
|
|
|
|
while IFS== read -r key value; do
|
|
|
|
if [ "$key" == "IWAD" ]; then
|
|
|
|
ROMNAME="$value"
|
2022-08-29 01:53:58 +00:00
|
|
|
fi
|
|
|
|
done < "${1}"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"quake")
|
2022-08-29 03:10:14 +00:00
|
|
|
# EXT can only by quake
|
2022-08-29 01:53:58 +00:00
|
|
|
EXT=${ROMNAME##*.}
|
|
|
|
|
|
|
|
# If its not a simple pak (extension .pak0) read the file and parse the data
|
|
|
|
if [ ${EXT} == "quake" ]; then
|
|
|
|
dos2unix "${1}"
|
|
|
|
while IFS== read -r key value; do
|
|
|
|
if [ "$key" == "PAK" ]; then
|
|
|
|
ROMNAME="$value"
|
2022-08-23 18:45:30 +00:00
|
|
|
fi
|
|
|
|
done < "${1}"
|
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
;;
|
|
|
|
esac
|
2023-04-24 05:33:21 +00:00
|
|
|
|
2023-07-20 11:32:43 +00:00
|
|
|
|
|
|
|
### Set the performance mode for emulation
|
|
|
|
PERFORMANCE_MODE=$(get_setting "cpugovernor" "${PLATFORM}" "${ROMNAME##*/}")
|
2023-09-15 00:05:15 +00:00
|
|
|
${PERFORMANCE_MODE}
|
|
|
|
|
2022-08-23 18:45:30 +00:00
|
|
|
if [[ "${CORE}" =~ "custom" ]]
|
|
|
|
then
|
|
|
|
RUNTHIS='${EMUPERF} /usr/bin/${RABIN} -L /storage/.config/retroarch/cores/${EMU}.so --config ${RATMPCONF} --appendconfig ${RAAPPENDCONF} "${ROMNAME}"'
|
|
|
|
else
|
2022-08-25 12:14:03 +00:00
|
|
|
RUNTHIS='${EMUPERF} /usr/bin/${RABIN} -L /tmp/cores/${EMU}.so --config ${RATMPCONF} --appendconfig ${RAAPPENDCONF} "${ROMNAME}"'
|
2022-08-23 18:45:30 +00:00
|
|
|
fi
|
|
|
|
CONTROLLERCONFIG="${arguments#*--controllers=*}"
|
|
|
|
|
|
|
|
if [[ "$arguments" == *"-state_slot"* ]]; then
|
|
|
|
CONTROLLERCONFIG="${CONTROLLERCONFIG%% -state_slot*}" # until -state is found
|
|
|
|
SNAPSHOT="${arguments#*-state_slot *}" # -state_slot x
|
|
|
|
SNAPSHOT="${SNAPSHOT%% -*}"
|
|
|
|
if [[ "$arguments" == *"-autosave"* ]]; then
|
|
|
|
CONTROLLERCONFIG="${CONTROLLERCONFIG%% -autosave*}" # until -autosave is found
|
|
|
|
AUTOSAVE="${arguments#*-autosave *}" # -autosave x
|
|
|
|
AUTOSAVE="${AUTOSAVE%% -*}"
|
|
|
|
else
|
|
|
|
AUTOSAVE=""
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
CONTROLLERCONFIG="${CONTROLLERCONFIG%% --*}" # until a -- is found
|
|
|
|
SNAPSHOT=""
|
|
|
|
AUTOSAVE=""
|
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# CORE=${EMU%%_*}
|
|
|
|
|
2022-08-23 18:45:30 +00:00
|
|
|
# Platform specific configurations
|
2022-02-05 14:23:32 +00:00
|
|
|
case ${PLATFORM} in
|
|
|
|
"atomiswave")
|
|
|
|
rm ${ROMNAME}.nvmem*
|
|
|
|
;;
|
|
|
|
"ports")
|
|
|
|
PORTCORE="${arguments##*-C}" # read from -C onwards
|
|
|
|
EMU="${PORTCORE%% *}_libretro" # until a space is found
|
|
|
|
PORTSCRIPT="${arguments##*-SC}" # read from -SC onwards
|
|
|
|
;;
|
|
|
|
"scummvm")
|
2022-08-23 18:45:30 +00:00
|
|
|
GAMEDIR=$(cat "${ROMNAME}" | awk 'BEGIN {FS="\""}; {print $2}')
|
|
|
|
cd "${GAMEDIR}"
|
2023-03-11 00:13:05 +00:00
|
|
|
RUNTHIS='${TBASH} /usr/bin/start_scummvm.sh libretro .'
|
2022-02-05 14:23:32 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2023-08-13 00:33:09 +00:00
|
|
|
if [ -e "${SETSETTINGS_TMP}" ]
|
2022-02-05 14:23:32 +00:00
|
|
|
then
|
2023-08-13 00:33:09 +00:00
|
|
|
rm -f "${SETSETTINGS_TMP}"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${PLATFORM} == "ports" ]]; then
|
2023-08-13 00:33:09 +00:00
|
|
|
(/usr/bin/setsettings.sh "${PLATFORM}" "${PORTSCRIPT}" "${CORE}" --controllers="${CONTROLLERCONFIG}" --autosave="${AUTOSAVE}" --snapshot="${SNAPSHOT}" >${SETSETTINGS_TMP})
|
2022-02-05 14:23:32 +00:00
|
|
|
else
|
2023-08-13 00:33:09 +00:00
|
|
|
(/usr/bin/setsettings.sh "${PLATFORM}" "${ROMNAME}" "${CORE}" --controllers="${CONTROLLERCONFIG}" --autosave="${AUTOSAVE}" --snapshot="${SNAPSHOT}" >${SETSETTINGS_TMP})
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-13 00:33:09 +00:00
|
|
|
### If setsettings wrote data in the background, grab it and assign it to EXTRAOPTS
|
|
|
|
if [ -e "${SETSETTINGS_TMP}" ]
|
2022-02-05 14:23:32 +00:00
|
|
|
then
|
2023-08-13 00:33:09 +00:00
|
|
|
EXTRAOPTS=$(cat ${SETSETTINGS_TMP})
|
|
|
|
rm -f ${SETSETTINGS_TMP}
|
|
|
|
$VERBOSE && log $0 "Extra Options: ${EXTRAOPTS}"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-13 00:33:09 +00:00
|
|
|
if [[ ${EXTRAOPTS} != 0 ]]; then
|
|
|
|
RUNTHIS=$(echo ${RUNTHIS} | sed "s|--config|${EXTRAOPTS} --config|")
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
clear_screen
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "executing game: ${ROMNAME}"
|
|
|
|
$VERBOSE && log $0 "script to execute: ${RUNTHIS}"
|
2023-07-20 11:32:43 +00:00
|
|
|
|
|
|
|
### Set the performance mode for emulation
|
|
|
|
PERFORMANCE_MODE=$(get_setting "cpugovernor" "${PLATFORM}" "${ROMNAME##*/}")
|
2023-09-15 00:05:15 +00:00
|
|
|
${PERFORMANCE_MODE}
|
2022-02-05 14:23:32 +00:00
|
|
|
# If the rom is a shell script just execute it, useful for DOSBOX and ScummVM scan scripts
|
|
|
|
if [[ "${ROMNAME}" == *".sh" ]]; then
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Executing shell script ${ROMNAME}"
|
2022-08-23 18:45:30 +00:00
|
|
|
"${ROMNAME}" &>>${OUTPUT_LOG}
|
2022-02-05 14:23:32 +00:00
|
|
|
ret_error=$?
|
|
|
|
else
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Executing $(eval echo ${RUNTHIS})"
|
2022-08-23 18:45:30 +00:00
|
|
|
eval ${RUNTHIS} &>>${OUTPUT_LOG}
|
|
|
|
ret_error=$?
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
2023-07-20 11:32:43 +00:00
|
|
|
### Switch back to performance mode to clean up
|
|
|
|
performance
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
clear_screen
|
|
|
|
|
2023-01-02 22:47:44 +00:00
|
|
|
### Reset the number of cores to use.
|
2023-01-26 00:41:58 +00:00
|
|
|
NUMTHREADS=$(get_setting "system.threads")
|
|
|
|
if [ -n "${NUMTHREADS}" ]
|
2023-01-02 22:47:44 +00:00
|
|
|
then
|
2023-01-26 00:41:58 +00:00
|
|
|
onlinethreads ${NUMTHREADS} 0
|
2023-01-02 22:47:44 +00:00
|
|
|
else
|
2023-01-26 00:41:58 +00:00
|
|
|
onlinethreads all 1
|
2023-01-02 22:47:44 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-05 01:31:57 +00:00
|
|
|
### Restore CPU TDP (AMD) or EPP (Intel)
|
|
|
|
CPU_VENDOR=$(cpu_vendor)
|
|
|
|
case ${CPU_VENDOR} in
|
|
|
|
AuthenticAMD)
|
|
|
|
### Set the overclock mode
|
|
|
|
OVERCLOCK=$(get_setting "system.overclock")
|
|
|
|
if [ ! -z "${OVERCLOCK}" ]
|
|
|
|
then
|
|
|
|
/usr/bin/overclock ${OVERCLOCK}
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
GenuineIntel)
|
|
|
|
EPP=$(get_setting "system.power.epp")
|
|
|
|
if [ ! -z ${EPP} ]
|
|
|
|
then
|
|
|
|
/usr/bin/set_epp ${EPP}
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
### Restore cooling profile.
|
|
|
|
if [ "${DEVICE_HAS_FAN}" = "true" ]
|
2022-04-02 13:13:04 +00:00
|
|
|
then
|
2023-08-05 01:31:57 +00:00
|
|
|
set_setting cooling.profile ${COOLINGPROFILE}
|
|
|
|
systemctl restart fancontrol
|
2022-04-02 13:13:04 +00:00
|
|
|
fi
|
|
|
|
|
2023-06-23 10:57:57 +00:00
|
|
|
GPUPERF=$(get_setting "system.gpuperf")
|
|
|
|
if [ ! -z ${GPUPERF} ]
|
2023-01-23 02:38:25 +00:00
|
|
|
then
|
2023-06-23 10:57:57 +00:00
|
|
|
gpu_performance_level ${GPUPERF}
|
|
|
|
else
|
|
|
|
gpu_performance_level auto
|
2023-01-23 02:38:25 +00:00
|
|
|
fi
|
2023-06-23 10:57:57 +00:00
|
|
|
rm -f /tmp/.gpu_performance_level 2>/dev/null
|
2023-01-23 02:38:25 +00:00
|
|
|
|
2022-10-28 21:37:37 +00:00
|
|
|
### Backup save games
|
|
|
|
CLOUD_BACKUP=$(get_setting "cloud.backup")
|
|
|
|
if [ "${CLOUD_BACKUP}" = "1" ]
|
|
|
|
then
|
|
|
|
INETUP=$(/usr/bin/amionline >/dev/null 2>&1)
|
|
|
|
if [ $? == 0 ]
|
|
|
|
then
|
2023-01-20 02:30:33 +00:00
|
|
|
log $0 "backup saves to the cloud."
|
2022-10-28 21:37:37 +00:00
|
|
|
run /usr/bin/cloud_backup
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-01-20 02:30:33 +00:00
|
|
|
$VERBOSE && log $0 "Checking errors: ${ret_error} "
|
2022-02-05 14:23:32 +00:00
|
|
|
if [ "${ret_error}" == "0" ]
|
|
|
|
then
|
2022-08-23 18:45:30 +00:00
|
|
|
quit 0
|
2022-02-05 14:23:32 +00:00
|
|
|
else
|
2023-01-20 02:30:33 +00:00
|
|
|
log $0 "exiting with $ret_error"
|
2022-08-23 18:45:30 +00:00
|
|
|
quit 1
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|