* Refactor runemu to improve performance and modernize the tool.
* Fix pcsx_rearmed patching.
This commit is contained in:
parent
6356404b0a
commit
5db7f7aa37
2 changed files with 330 additions and 327 deletions
|
@ -11,7 +11,6 @@ PKG_URL="${PKG_SITE}/archive/${PKG_VERSION}.tar.gz"
|
|||
PKG_DEPENDS_TARGET="toolchain"
|
||||
PKG_SHORTDESC="ARM optimized PCSX fork"
|
||||
PKG_TOOLCHAIN="manual"
|
||||
PKG_PATCH_DIRS+="${TARGET_ARCH}/${DEVICE}"
|
||||
|
||||
pre_configure_target() {
|
||||
sed -i 's/\-O[23]/-Ofast/' ${PKG_BUILD}/Makefile
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2019-present Shanti Gilbert (https://github.com/shantigilbert)
|
||||
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
||||
|
@ -8,117 +7,316 @@
|
|||
. /etc/profile
|
||||
. /etc/os-release
|
||||
|
||||
### Switch to performance mode early to speed up configuration and reduce time it takes to get into games.
|
||||
performance
|
||||
|
||||
# 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"
|
||||
RAAPPENDCONF="/tmp/.retroarch.cfg"
|
||||
NETPLAY="No"
|
||||
SETSETTINGS_TMP="/tmp/shader"
|
||||
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
|
||||
VERBOSE=true
|
||||
fi
|
||||
|
||||
arguments="$@"
|
||||
PLATFORM="${arguments##*-P}" # read from -P onwards
|
||||
ARGUMENTS="$@"
|
||||
PLATFORM="${ARGUMENTS##*-P}" # read from -P onwards
|
||||
PLATFORM="${PLATFORM%% *}" # until a space is found
|
||||
CORE="${arguments##*--core=}" # read from --core= onwards
|
||||
CORE="${ARGUMENTS##*--core=}" # read from --core= onwards
|
||||
CORE="${CORE%% *}" # until a space is found
|
||||
EMULATOR="${arguments##*--emulator=}" # read from --emulator= onwards
|
||||
EMULATOR="${ARGUMENTS##*--emulator=}" # read from --emulator= onwards
|
||||
EMULATOR="${EMULATOR%% *}" # until a space is found
|
||||
ROMNAME="$1"
|
||||
BASEROMNAME=${ROMNAME##*/}
|
||||
GAMEFOLDER="${ROMNAME//${BASEROMNAME}}"
|
||||
|
||||
### Use performance mode to prepare to start the emulator.
|
||||
performance
|
||||
### Define the variables used throughout the script
|
||||
BLUETOOTH_STATE=$(get_setting bluetooth.enabled)
|
||||
ES_CONFIG="/storage/.emulationstation/es_settings.cfg"
|
||||
VERBOSE=false
|
||||
LOG_DIRECTORY="/var/log"
|
||||
LOG_FILE="exec.log"
|
||||
RUN_SHELL="/usr/bin/bash"
|
||||
RETROARCH_TEMP_CONFIG="/storage/.config/retroarch/retroarch.cfg"
|
||||
RETROARCH_APPEND_CONFIG="/tmp/.retroarch.cfg"
|
||||
NETWORK_PLAY="No"
|
||||
SET_SETTINGS_TMP="/tmp/shader"
|
||||
OUTPUT_LOG="${LOG_DIRECTORY}/${LOG_FILE}"
|
||||
SCRIPT_NAME=$(basename "$0")
|
||||
|
||||
### Determine if we're running a Libretro core and append the libretro suffix
|
||||
if [[ $EMULATOR = "retroarch" ]]; then
|
||||
EMU="${CORE}_libretro"
|
||||
RETROARCH="yes"
|
||||
elif [[ $EMULATOR = "mednafen" ]]; then
|
||||
EMU="mednafen"
|
||||
else
|
||||
EMU="${CORE}"
|
||||
fi
|
||||
### Function Library
|
||||
function log() {
|
||||
if [ ${LOG} == true ]
|
||||
then
|
||||
if [[ ! -d "$LOG_DIRECTORY" ]]
|
||||
then
|
||||
mkdir -p "$LOG_DIRECTORY"
|
||||
fi
|
||||
echo "${SCRIPT_NAME}: $*" 2>&1 | tee -a ${LOG_DIRECTORY}/${LOG_FILE}
|
||||
else
|
||||
echo "${SCRIPT_NAME}: $*"
|
||||
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
|
||||
function loginit() {
|
||||
if [ ${LOG} == true ]
|
||||
then
|
||||
if [ -e ${LOG_DIRECTORY}/${LOG_FILE} ]
|
||||
then
|
||||
rm -f ${LOG_DIRECTORY}/${LOG_FILE}
|
||||
fi
|
||||
cat <<EOF >${LOG_DIRECTORY}/${LOG_FILE}
|
||||
Emulation Run Log - Started at $(date)
|
||||
|
||||
# easyrpg needs runtime files to be downloaded on the first run
|
||||
if [[ ${EMU} == "easyrpg_libretro" ]]; then
|
||||
/usr/bin/easyrpg.sh
|
||||
fi
|
||||
ARG1: $1
|
||||
ARG2: $2
|
||||
ARG3: $3
|
||||
ARG4: $4
|
||||
ARGS: $*
|
||||
EMULATOR: ${EMULATOR}
|
||||
PLATFORM: ${PLATFORM}
|
||||
CORE: ${CORE}
|
||||
ROM NAME: ${ROMNAME}
|
||||
BASE ROM NAME: ${ROMNAME##*/}
|
||||
USING CONFIG: ${RETROARCH_TEMP_CONFIG}
|
||||
USING APPENDCONFIG : ${RETROARCH_APPEND_CONFIG}
|
||||
|
||||
# Make sure netplay isn't defined before we start our tests/configuration.
|
||||
del_setting netplay.mode
|
||||
EOF
|
||||
else
|
||||
log $0 "Emulation Run Log - Started at $(date)"
|
||||
fi
|
||||
}
|
||||
|
||||
# check if we started as host for a game
|
||||
if [[ "$arguments" == *"--host"* ]]; then
|
||||
NETPLAY="${arguments##*--host}" # read from --host onwards
|
||||
NETPLAY="${NETPLAY%%--nick*}" # until --nick is found
|
||||
NETPLAY="--host $NETPLAY --nick"
|
||||
function quit() {
|
||||
${VERBOSE} && log $0 "Cleaning up and exiting"
|
||||
bluetooth enable
|
||||
jslisten set "emulationstation"
|
||||
clear_screen
|
||||
DEVICE_CPU_GOVERNOR=$(get_setting system.cpugovernor)
|
||||
${DEVICE_CPU_GOVERNOR}
|
||||
exit $1
|
||||
}
|
||||
|
||||
function clear_screen() {
|
||||
${VERBOSE} && log $0 "Clearing screen"
|
||||
clear
|
||||
}
|
||||
|
||||
function bluetooth() {
|
||||
if [ "$1" == "disable" ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Disabling BT"
|
||||
if [[ "${BLUETOOTH_STATE}" == "1" ]]
|
||||
then
|
||||
NPID=$(pgrep -f batocera-bluetooth-agent)
|
||||
if [[ ! -z "$NPID" ]]; then
|
||||
kill "$NPID"
|
||||
fi
|
||||
fi
|
||||
elif [ "$1" == "enable" ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Enabling BT"
|
||||
if [[ "${BLUETOOTH_STATE}" == "1" ]]
|
||||
then
|
||||
systemd-run batocera-bluetooth-agent
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
### Enable logging
|
||||
case $(get_setting system.loglevel) in
|
||||
off|none)
|
||||
LOG=false
|
||||
;;
|
||||
verbose)
|
||||
LOG=true
|
||||
VERBOSE=true
|
||||
;;
|
||||
*)
|
||||
LOG=true
|
||||
;;
|
||||
esac
|
||||
|
||||
### Prepare to load our emulator and game.
|
||||
loginit "$1" "$2" "$3" "$4"
|
||||
clear_screen
|
||||
bluetooth disable
|
||||
jslisten stop
|
||||
|
||||
### Determine which emulator we're launching and make appropriate adjustments before launching.
|
||||
${VERBOSE} && log $0 "Configuring for ${EMULATOR}"
|
||||
case ${EMULATOR} in
|
||||
mednafen)
|
||||
jslisten set "-9 mednafen"
|
||||
RUNTHIS='${RUN_SHELL} /usr/bin/start_mednafen.sh "${ROMNAME}" "${CORE}" "${PLATFORM}"'
|
||||
;;
|
||||
retroarch)
|
||||
# Make sure NETWORK_PLAY isn't defined before we start our tests/configuration.
|
||||
del_setting netplay.mode
|
||||
|
||||
case ${ARGUMENTS} in
|
||||
*"--host"*)
|
||||
${VERBOSE} && log $0 "Setup netplay host."
|
||||
NETWORK_PLAY="${ARGUMENTS##*--host}" # read from --host onwards
|
||||
NETWORK_PLAY="${NETWORK_PLAY%%--nick*}" # until --nick is found
|
||||
NETWORK_PLAY="--host ${NETWORK_PLAY} --nick"
|
||||
set_setting netplay.mode host
|
||||
fi
|
||||
;;
|
||||
*"--connect"*)
|
||||
${VERBOSE} && log $0 "Setup netplay client."
|
||||
NETWORK_PLAY="${ARGUMENTS##*--host}" # read from --host onwards
|
||||
NETWORK_PLAY="${NETWORK_PLAY%%--nick*}" # until --nick is found
|
||||
NETWORK_PLAY="--host ${NETWORK_PLAY} --nick"
|
||||
set_setting netplay.mode host
|
||||
;;
|
||||
*"--netplaymode spectator"*)
|
||||
${VERBOSE} && log $0 "Setup netplay spectator."
|
||||
set_setting "netplay.mode" "spectator"
|
||||
;;
|
||||
esac
|
||||
|
||||
# check if we are trying to connect to a client on netplay
|
||||
if [[ "$arguments" == *"--connect"* ]]; then
|
||||
NETPLAY="${arguments##*--connect}" # read from --connect onwards
|
||||
NETPLAY="${NETPLAY%%--nick*}" # until --nick is found
|
||||
NETPLAY="--connect $NETPLAY --nick"
|
||||
set_setting netplay.mode client
|
||||
fi
|
||||
### Set jslisten to kill the appropriate retroarch
|
||||
jslisten set "retroarch retroarch32"
|
||||
|
||||
# check if we are trying to connect as spectator on netplay
|
||||
if [[ "$arguments" == *"--netplaymode spectator"* ]]; then
|
||||
set_setting "netplay.mode" "spectator"
|
||||
fi
|
||||
### Assume we're running 64bit Retroarch
|
||||
RABIN="retroarch"
|
||||
|
||||
### Offline all but the number of cores we need for this game if configured.
|
||||
NUMTHREADS=$(get_setting "threads" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ -n "${NUMTHREADS}" ] &&
|
||||
[ ! ${NUMTHREADS} = "default" ]
|
||||
then
|
||||
onlinethreads ${NUMTHREADS} 0
|
||||
fi
|
||||
case ${HW_ARCH} in
|
||||
aarch64)
|
||||
if [[ "${CORE}" =~ pcsx_rearmed32 ]] || \
|
||||
[[ "${CORE}" =~ gpsp ]] || \
|
||||
[[ "${CORE}" =~ flycast32 ]] || \
|
||||
[[ "${CORE}" =~ desmume ]]
|
||||
then
|
||||
### Configure for 32bit Retroarch
|
||||
${VERBOSE} && log $0 "Configuring for 32bit cores."
|
||||
export LIBRARY_PATH="/usr/lib32"
|
||||
export LD_LIBRARY_PATH="${LIBRARY_PATH}"
|
||||
export SPA_PLUGIN_DIR="${LIBRARY_PATH}/spa-0.2"
|
||||
export PIPEWIRE_MODULE_DIR="${LIBRARY_PATH}/pipewire-0.3/"
|
||||
export LIBGL_DRIVERS_PATH="${LIBRARY_PATH}/dri"
|
||||
export RABIN="retroarch32"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
RUNTHIS='${EMUPERF} /usr/bin/${RABIN} -L /tmp/cores/${CORE}_libretro.so --config ${RETROARCH_TEMP_CONFIG} --appendconfig ${RETROARCH_APPEND_CONFIG} "${ROMNAME}"'
|
||||
|
||||
CONTROLLERCONFIG="${ARGUMENTS#*--controllers=*}"
|
||||
|
||||
### Configure our save state slot or autosave
|
||||
CONTROLLERCONFIG="${CONTROLLERCONFIG%% --*}" # until a -- is found
|
||||
SNAPSHOT=""
|
||||
AUTOSAVE=""
|
||||
case ${ARGUMENTS} in
|
||||
*"-state_slot"*)
|
||||
${VERBOSE} && log $0 "Configuring save state slot."
|
||||
CONTROLLERCONFIG="${CONTROLLERCONFIG%% -state_slot*}" # until -state is found
|
||||
SNAPSHOT="${ARGUMENTS#*-state_slot *}" # -state_slot x
|
||||
SNAPSHOT="${SNAPSHOT%% -*}"
|
||||
;;
|
||||
*"-autosave"*)
|
||||
${VERBOSE} && log $0 "Configuring autosave."
|
||||
CONTROLLERCONFIG="${CONTROLLERCONFIG%% -autosave*}" # until -autosave is found
|
||||
AUTOSAVE="${ARGUMENTS#*-autosave *}" # -autosave x
|
||||
AUTOSAVE="${AUTOSAVE%% -*}"
|
||||
;;
|
||||
esac
|
||||
|
||||
### Configure specific emulator requirements
|
||||
case ${EMULATOR} in
|
||||
freej2me*)
|
||||
${VERBOSE} && log $0 "Setup freej2me requirements."
|
||||
/usr/bin/freej2me.sh
|
||||
JAVA_HOME='/storage/jdk'
|
||||
export JAVA_HOME
|
||||
PATH="$JAVA_HOME/bin:$PATH"
|
||||
export PATH
|
||||
;;
|
||||
easyrpg*)
|
||||
# easyrpg needs runtime files to be downloaded on the first run
|
||||
${VERBOSE} && log $0 "Setup easyrpg requirements."
|
||||
/usr/bin/easyrpg.sh
|
||||
;;
|
||||
esac
|
||||
|
||||
# Configure platform specific requirements
|
||||
case ${PLATFORM} in
|
||||
"atomiswave")
|
||||
rm ${ROMNAME}.nvmem*
|
||||
;;
|
||||
"scummvm")
|
||||
GAMEDIR=$(cat "${ROMNAME}" | awk 'BEGIN {FS="\""}; {print $2}')
|
||||
cd "${GAMEDIR}"
|
||||
RUNTHIS='${RUN_SHELL} /usr/bin/start_scummvm.sh libretro .'
|
||||
;;
|
||||
esac
|
||||
|
||||
### Configure retroarch
|
||||
if [ -e "${SET_SETTINGS_TMP}" ]
|
||||
then
|
||||
rm -f "${SET_SETTINGS_TMP}"
|
||||
fi
|
||||
${VERBOSE} && log $0 "Execute setsettings (${PLATFORM} ${ROMNAME} ${CORE} --controllers=${CONTROLLERCONFIG} --autosave=${AUTOSAVE} --snapshot=${SNAPSHOT})"
|
||||
(/usr/bin/setsettings.sh "${PLATFORM}" "${ROMNAME}" "${CORE}" --controllers="${CONTROLLERCONFIG}" --autosave="${AUTOSAVE}" --snapshot="${SNAPSHOT}" >${SET_SETTINGS_TMP})
|
||||
|
||||
### If setsettings wrote data in the background, grab it and assign it to EXTRAOPTS
|
||||
if [ -e "${SET_SETTINGS_TMP}" ]
|
||||
then
|
||||
EXTRAOPTS=$(cat ${SET_SETTINGS_TMP})
|
||||
rm -f ${SET_SETTINGS_TMP}
|
||||
${VERBOSE} && log $0 "Extra Options: ${EXTRAOPTS}"
|
||||
fi
|
||||
|
||||
if [[ ${EXTRAOPTS} != 0 ]]; then
|
||||
RUNTHIS=$(echo ${RUNTHIS} | sed "s|--config|${EXTRAOPTS} --config|")
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
case ${PLATFORM} in
|
||||
"setup")
|
||||
RUNTHIS='${RUN_SHELL} "${ROMNAME}"'
|
||||
;;
|
||||
"gamecube")
|
||||
if [ "${CORE}" = "dolphin-sa-gc" ]; then
|
||||
RUNTHIS='${RUN_SHELL} /usr/bin/start_dolphin_gc.sh "${ROMNAME}"'
|
||||
elif [ "${CORE}" = "primehack" ]; then
|
||||
RUNTHIS='${RUN_SHELL} /usr/bin/start_${CORE%-*}.sh "${ROMNAME}"'
|
||||
fi
|
||||
;;
|
||||
"wii")
|
||||
if [ "${CORE}" = "dolphin-sa-wii" ]; then
|
||||
RUNTHIS='${RUN_SHELL} /usr/bin/start_dolphin_wii.sh "${ROMNAME}"'
|
||||
elif [ "${CORE}" = "primehack" ]; then
|
||||
RUNTHIS='${RUN_SHELL} /usr/bin/start_${CORE%-*}.sh "${ROMNAME}"'
|
||||
fi
|
||||
;;
|
||||
"shell"|"ports")
|
||||
RUNTHIS='${RUN_SHELL} "${ROMNAME}"'
|
||||
;;
|
||||
*)
|
||||
RUNTHIS='${RUN_SHELL} "start_${CORE%-*}.sh" "${ROMNAME}"'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
### Execution time.
|
||||
clear_screen
|
||||
${VERBOSE} && log $0 "executing game: ${ROMNAME}"
|
||||
${VERBOSE} && log $0 "script to execute: ${RUNTHIS}"
|
||||
|
||||
### 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
|
||||
${VERBOSE} && log $0 "Configure big.little (${CORES})"
|
||||
case ${CORES} in
|
||||
little)
|
||||
EMUPERF="${SLOW_CORES}"
|
||||
;;
|
||||
big)
|
||||
EMUPERF="${FAST_CORES}"
|
||||
;;
|
||||
*)
|
||||
unset EMUPERF
|
||||
;;
|
||||
esac
|
||||
|
||||
### We need the original system cooling profile later so get it now!
|
||||
COOLINGPROFILE=$(get_setting cooling.profile)
|
||||
|
@ -131,20 +329,25 @@ case ${CPU_VENDOR} in
|
|||
OVERCLOCK=$(get_setting "overclock" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ ! -z "${OVERCLOCK}" ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Set TDP to (${OVERCLOCK})"
|
||||
/usr/bin/overclock ${OVERCLOCK}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
### Apply energy performance preference
|
||||
EPP=$(get_setting "power.epp" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ ! -z ${EPP} ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Set EPP to (${EPP})"
|
||||
/usr/bin/set_epp ${EPP}
|
||||
fi
|
||||
|
||||
### Configure GPU performance mode
|
||||
GPUPERF=$(get_setting "gpuperf" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ ! -z ${GPUPERF} ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Set GPU performance to (${GPUPERF})"
|
||||
gpu_performance_level ${GPUPERF}
|
||||
get_gpu_performance_level >/tmp/.gpu_performance_level
|
||||
fi
|
||||
|
@ -155,235 +358,35 @@ then
|
|||
GAMEFAN=$(get_setting "cooling.profile" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ ! -z "${GAMEFAN}" ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Set fan profile to (${GAMEFAN})"
|
||||
set_setting cooling.profile ${GAMEFAN}
|
||||
systemctl restart fancontrol
|
||||
fi
|
||||
fi
|
||||
|
||||
### Function Library
|
||||
|
||||
function log() {
|
||||
if [ ${LOG} == true ]
|
||||
then
|
||||
if [[ ! -d "$LOGSDIR" ]]
|
||||
then
|
||||
mkdir -p "$LOGSDIR"
|
||||
fi
|
||||
echo "${MYNAME}: $*" 2>&1 | tee -a ${LOGSDIR}/${LOGFILE}
|
||||
else
|
||||
echo "${MYNAME}: $*"
|
||||
fi
|
||||
}
|
||||
|
||||
function loginit() {
|
||||
if [ ${LOG} == true ]
|
||||
then
|
||||
if [ -e ${LOGSDIR}/${LOGFILE} ]
|
||||
then
|
||||
rm -f ${LOGSDIR}/${LOGFILE}
|
||||
fi
|
||||
cat <<EOF >${LOGSDIR}/${LOGFILE}
|
||||
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
|
||||
else
|
||||
log $0 "Emulation Run Log - Started at $(date)"
|
||||
fi
|
||||
}
|
||||
|
||||
function quit() {
|
||||
$VERBOSE && log $0 "Cleaning up and exiting"
|
||||
bluetooth enable
|
||||
jslisten set "emulationstation"
|
||||
clear_screen
|
||||
DEVICE_CPU_GOVERNOR=$(get_setting system.cpugovernor)
|
||||
${DEVICE_CPU_GOVERNOR}
|
||||
exit $1
|
||||
}
|
||||
|
||||
function clear_screen() {
|
||||
$VERBOSE && log $0 "Clearing screen"
|
||||
clear
|
||||
}
|
||||
|
||||
function bluetooth() {
|
||||
if [ "$1" == "disable" ]
|
||||
then
|
||||
$VERBOSE && log $0 "Disabling BT"
|
||||
if [[ "$BTENABLED" == "1" ]]
|
||||
then
|
||||
NPID=$(pgrep -f batocera-bluetooth-agent)
|
||||
if [[ ! -z "$NPID" ]]; then
|
||||
kill "$NPID"
|
||||
fi
|
||||
fi
|
||||
elif [ "$1" == "enable" ]
|
||||
then
|
||||
$VERBOSE && log $0 "Enabling BT"
|
||||
if [[ "$BTENABLED" == "1" ]]
|
||||
then
|
||||
systemd-run batocera-bluetooth-agent
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
### Main Screen Turn On
|
||||
|
||||
loginit "$1" "$2" "$3" "$4"
|
||||
clear_screen
|
||||
bluetooth disable
|
||||
jslisten stop
|
||||
|
||||
### Per emulator/core configurations
|
||||
if [[ $EMULATOR = "mednafen" ]]; then
|
||||
jslisten set "-9 mednafen"
|
||||
RUNTHIS='${TBASH} /usr/bin/start_mednafen.sh "${ROMNAME}" "${CORE}" "${PLATFORM}"'
|
||||
|
||||
elif [ -z ${RETROARCH} ]
|
||||
### Offline all but the number of threads we need for this game if configured.
|
||||
NUMTHREADS=$(get_setting "threads" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ -n "${NUMTHREADS}" ] &&
|
||||
[ ! ${NUMTHREADS} = "default" ]
|
||||
then
|
||||
$VERBOSE && log $0 "Configuring for a non-libretro emulator"
|
||||
case ${PLATFORM} in
|
||||
"setup")
|
||||
RUNTHIS='${TBASH} "${ROMNAME}"'
|
||||
;;
|
||||
"gamecube")
|
||||
if [ "$EMU" = "dolphin-sa-gc" ]; then
|
||||
RUNTHIS='${TBASH} /usr/bin/start_dolphin_gc.sh "${ROMNAME}"'
|
||||
elif [ "$EMU" = "primehack" ]; then
|
||||
RUNTHIS='${TBASH} /usr/bin/start_${EMU%-*}.sh "${ROMNAME}"'
|
||||
fi
|
||||
|
||||
;;
|
||||
"wii")
|
||||
if [ "$EMU" = "dolphin-sa-wii" ]; then
|
||||
RUNTHIS='${TBASH} /usr/bin/start_dolphin_wii.sh "${ROMNAME}"'
|
||||
elif [ "$EMU" = "primehack" ]; then
|
||||
RUNTHIS='${TBASH} /usr/bin/start_${EMU%-*}.sh "${ROMNAME}"'
|
||||
fi
|
||||
;;
|
||||
"shell"|"ports")
|
||||
RUNTHIS='${TBASH} "${ROMNAME}"'
|
||||
;;
|
||||
*)
|
||||
RUNTHIS='${TBASH} "start_${EMU%-*}.sh" "${ROMNAME}"'
|
||||
esac
|
||||
else
|
||||
$VERBOSE && log $0 "Configuring for a libretro core"
|
||||
|
||||
### Set jslisten to kill the appropriate retroarch
|
||||
jslisten set "retroarch retroarch32"
|
||||
|
||||
RABIN="retroarch"
|
||||
if [[ "${HW_ARCH}" =~ aarch64 ]]
|
||||
then
|
||||
### Check if we need retroarch 32 bits or 64 bits
|
||||
if [[ "${CORE}" =~ pcsx_rearmed32 ]] || \
|
||||
[[ "${CORE}" =~ gpsp ]] || \
|
||||
[[ "${CORE}" =~ flycast32 ]] || \
|
||||
[[ "${CORE}" =~ desmume ]]
|
||||
then
|
||||
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"
|
||||
export RABIN="retroarch32"
|
||||
fi
|
||||
fi
|
||||
|
||||
### Set the performance mode for emulation
|
||||
PERFORMANCE_MODE=$(get_setting "cpugovernor" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
${PERFORMANCE_MODE}
|
||||
|
||||
if [[ "${CORE}" =~ "custom" ]]
|
||||
then
|
||||
RUNTHIS='${EMUPERF} /usr/bin/${RABIN} -L /storage/.config/retroarch/cores/${EMU}.so --config ${RATMPCONF} --appendconfig ${RAAPPENDCONF} "${ROMNAME}"'
|
||||
else
|
||||
RUNTHIS='${EMUPERF} /usr/bin/${RABIN} -L /tmp/cores/${EMU}.so --config ${RATMPCONF} --appendconfig ${RAAPPENDCONF} "${ROMNAME}"'
|
||||
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
|
||||
|
||||
# CORE=${EMU%%_*}
|
||||
|
||||
# Platform specific configurations
|
||||
case ${PLATFORM} in
|
||||
"atomiswave")
|
||||
rm ${ROMNAME}.nvmem*
|
||||
;;
|
||||
"scummvm")
|
||||
GAMEDIR=$(cat "${ROMNAME}" | awk 'BEGIN {FS="\""}; {print $2}')
|
||||
cd "${GAMEDIR}"
|
||||
RUNTHIS='${TBASH} /usr/bin/start_scummvm.sh libretro .'
|
||||
;;
|
||||
esac
|
||||
${VERBOSE} && log $0 "Configure active cores (${NUMTHREADS})"
|
||||
onlinethreads ${NUMTHREADS} 0
|
||||
fi
|
||||
|
||||
if [ -e "${SETSETTINGS_TMP}" ]
|
||||
then
|
||||
rm -f "${SETSETTINGS_TMP}"
|
||||
fi
|
||||
|
||||
if [[ ${PLATFORM} == "ports" ]]; then
|
||||
(/usr/bin/setsettings.sh "${PLATFORM}" "${ROMNAME}" >${SETSETTINGS_TMP})
|
||||
else
|
||||
(/usr/bin/setsettings.sh "${PLATFORM}" "${ROMNAME}" "${CORE}" --controllers="${CONTROLLERCONFIG}" --autosave="${AUTOSAVE}" --snapshot="${SNAPSHOT}" >${SETSETTINGS_TMP})
|
||||
fi
|
||||
|
||||
### If setsettings wrote data in the background, grab it and assign it to EXTRAOPTS
|
||||
if [ -e "${SETSETTINGS_TMP}" ]
|
||||
then
|
||||
EXTRAOPTS=$(cat ${SETSETTINGS_TMP})
|
||||
rm -f ${SETSETTINGS_TMP}
|
||||
$VERBOSE && log $0 "Extra Options: ${EXTRAOPTS}"
|
||||
fi
|
||||
|
||||
if [[ ${EXTRAOPTS} != 0 ]]; then
|
||||
RUNTHIS=$(echo ${RUNTHIS} | sed "s|--config|${EXTRAOPTS} --config|")
|
||||
fi
|
||||
|
||||
clear_screen
|
||||
$VERBOSE && log $0 "executing game: ${ROMNAME}"
|
||||
$VERBOSE && log $0 "script to execute: ${RUNTHIS}"
|
||||
|
||||
### Set the performance mode for emulation
|
||||
PERFORMANCE_MODE=$(get_setting "cpugovernor" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
${VERBOSE} && log $0 "Set emulation performance mode to (${PERFORMANCE_MODE})"
|
||||
${PERFORMANCE_MODE}
|
||||
|
||||
# If the rom is a shell script just execute it, useful for DOSBOX and ScummVM scan scripts
|
||||
if [[ "${ROMNAME}" == *".sh" ]]; then
|
||||
$VERBOSE && log $0 "Executing shell script ${ROMNAME}"
|
||||
"${ROMNAME}" &>>${OUTPUT_LOG}
|
||||
${VERBOSE} && log $0 "Executing shell script ${ROMNAME}"
|
||||
"${ROMNAME}" &>>${OUTPUT_LOG}
|
||||
ret_error=$?
|
||||
else
|
||||
$VERBOSE && log $0 "Executing $(eval echo ${RUNTHIS})"
|
||||
eval ${RUNTHIS} &>>${OUTPUT_LOG}
|
||||
ret_error=$?
|
||||
${VERBOSE} && log $0 "Executing $(eval echo ${RUNTHIS})"
|
||||
eval ${RUNTHIS} &>>${OUTPUT_LOG}
|
||||
ret_error=$?
|
||||
fi
|
||||
|
||||
### Switch back to performance mode to clean up
|
||||
|
@ -393,45 +396,46 @@ clear_screen
|
|||
|
||||
### Reset the number of cores to use.
|
||||
NUMTHREADS=$(get_setting "system.threads")
|
||||
${VERBOSE} && log $0 "Restore active threads (${NUMTHREADS})"
|
||||
if [ -n "${NUMTHREADS}" ]
|
||||
then
|
||||
onlinethreads ${NUMTHREADS} 0
|
||||
onlinethreads ${NUMTHREADS} 0
|
||||
else
|
||||
onlinethreads all 1
|
||||
onlinethreads all 1
|
||||
fi
|
||||
|
||||
### 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 system TDP
|
||||
OVERCLOCK=$(get_setting "system.overclock")
|
||||
if [ ! -z "${OVERCLOCK}" ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Restore system TDP (${OVERCLOCK})"
|
||||
/usr/bin/overclock ${OVERCLOCK}
|
||||
fi
|
||||
|
||||
### Restore system EPP
|
||||
EPP=$(get_setting "system.power.epp")
|
||||
if [ ! -z ${EPP} ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Restore system EPP (${EPP})"
|
||||
/usr/bin/set_epp ${EPP}
|
||||
fi
|
||||
|
||||
### Restore cooling profile.
|
||||
if [ "${DEVICE_HAS_FAN}" = "true" ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Restore system cooling profile (${COOLINGPROFILE})"
|
||||
set_setting cooling.profile ${COOLINGPROFILE}
|
||||
systemctl restart fancontrol
|
||||
fi
|
||||
|
||||
### Restore system GPU performance mode
|
||||
GPUPERF=$(get_setting "system.gpuperf")
|
||||
if [ ! -z ${GPUPERF} ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Restore system GPU performance mode (${GPUPERF})"
|
||||
gpu_performance_level ${GPUPERF}
|
||||
else
|
||||
${VERBOSE} && log $0 "Restore system GPU performance mode (auto)"
|
||||
gpu_performance_level auto
|
||||
fi
|
||||
rm -f /tmp/.gpu_performance_level 2>/dev/null
|
||||
|
@ -448,11 +452,11 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
$VERBOSE && log $0 "Checking errors: ${ret_error} "
|
||||
${VERBOSE} && log $0 "Checking errors: ${ret_error} "
|
||||
if [ "${ret_error}" == "0" ]
|
||||
then
|
||||
quit 0
|
||||
quit 0
|
||||
else
|
||||
log $0 "exiting with $ret_error"
|
||||
quit 1
|
||||
log $0 "exiting with ${ret_error}"
|
||||
quit 1
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue