Welcome to mirror list, hosted at ThFree Co, Russian Federation.

retroarch-clover « bin « retroarch.hmod - github.com/ClusterM/retroarch-clover.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 41cbc465ea148df20c0ea17d5d74da473949fe81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
HOME=/etc/libretro
corename=$1
core=$HOME/core/$1_libretro.so
rom=$2
filename=$(basename "$rom")
id=${filename%.*}
extension="${filename##*.}"
autosave="/var/cache/$id.state.auto"
rsram="/var/cache/$id.srm"
rsav="/var/cache/$id.sav"
t_suffix=_time.txt
shift 2

crt=0
allow_crt=0

while [ $# -gt 0 ]; do
  [ "$1" == "--load-state-file" ] && load=$2
  [ "$1" == "--save-on-quit" ] && save=$2
  [ "$1" == "--save-screenshot-on-quit" ] && screenshot=$2
  [ "$1" == "--save-data-backing-file" ] && sram=$2
  [ "$1" == "--graphic-filter" ] && filter=$2
  [ "$1" == "--enable-crt-scanlines" ] && crt=1
  [ "$1" == "--ra-allow-crt" ] && allow_crt=1
  [ "$1" == "--ra-extra" ] && extra=$2
  [ "$1" == "--ra-nosaves" ] && nosaves=1
  shift
done

# saves if any
rm -f /var/cache/*.state /var/cache/*.auto /var/cache/*.srm /var/cache/*.sav
[ ! -z "$load" ] && [ -f "$load" ] && [ -z "$nosaves" ] && cp -f "$load" "$autosave" && echo cp -f "$load" "$autosave"
# Nestopia names FDS saves as $id.sav, so here's a quick fix
if [ "$corename" == "nestopia" ] && [ "$extension" == "fds" ]; then
  [ ! -z "$sram" ] && [ -f "$sram" ] && cp -f "$sram" "$rsav" && echo cp -f "$sram" "$rsav"
else
  [ ! -z "$sram" ] && [ -f "$sram" ] && cp -f "$sram" "$rsram" && echo cp -f "$sram" "$rsram"
fi


# core provided ratio for CRT mode
[ "$filter" == "crt720" ] && ratio=21 && smooth=false && crt=1
# core provided ratio for 4:3 mode
[ "$filter" == "gpu720" ] && ratio=21 && smooth=false
# pixel perfect - 1:1 for pixel perfect mode
[ "$filter" == "ppu" ] && ratio=20 && smooth=false

# Allow scanlines only for simple systems
[ "$allow_crt" == "1" ] || crt=0

# Set aspect ratio in config only if current ratio is 20 (1:1 PAR) or 21 (core provided)
current_ratio=$(cat /etc/libretro/retroarch.cfg | grep "aspect_ratio_index" | sed 's/[^0-9]*//g')
if [ -z "$ratio" ] || [ "$current_ratio" == "21" ] || [ "$current_ratio" == "20" ]; then 
  sed -i -e 's/aspect_ratio_index = "[^"]*"/aspect_ratio_index = "'$ratio'"/g' /etc/libretro/retroarch.cfg
fi

# enable shader scanlines if need
if [ "$crt" == "1" ]; then
  sed -i -e 's/video_shader = "[^"]*"/video_shader = "~\/shaders\/retroarch\.glslp"/g' /etc/libretro/retroarch.cfg
  rsync -a -c /etc/libretro/shaders/scanline.glslp /etc/libretro/shaders/retroarch.glslp
else
  sed -i -e 's/video_shader = "[^"]*"/video_shader = ""/g' /etc/libretro/retroarch.cfg
fi

# Start timestamp
ts=$(date +"%s")
tm=0
[ -f "$load$t_suffix" ] && tm=$(cat "$load$t_suffix")

retroarch -c "$HOME/retroarch.cfg" -vfL "$core" "$rom" $extra &
rpid=$!
trap "kill $rpid" SIGTERM
sleep 2
rm -f /var/cache/*.state /var/cache/*.auto /var/cache/*.srm /var/cache/*.sav

# Playing games until reset pressed
wait $rpid

# We can't let clover shell load so fast, so killing it
pkill -KILL clover-mcp

[ ! -z "$save" ] && mkdir -p $(dirname "$save")
[ ! -z "$sram" ] && mkdir -p $(dirname "$sram")
[ ! -z "$screenshot" ] && mkdir -p $(dirname "$screenshot")

# Screenshot! It's not so fast...
[ -z "$screenshot" ] || [ -z "$nosaves" ] && fbgrab -z 0 "$screenshot"

# Saves!
[ ! -z "$save" ] && [ -f "$autosave" ] && [ -z "$nosaves" ] && mv -f "$autosave" "$save"
if [ "$corename" == "nestopia" ] && [ "$extension" == "fds" ]; then
  [ ! -z "$sram" ] && [ -f "$rsav" ] && mv -f "$rsav" "$sram"
else
  [ ! -z "$sram" ] && [ -f "$rsram" ] && mv -f "$rsram" "$sram"
fi

# Time
ts2=$(date +"%s")
tm=$((tm + ts2 - ts))
echo $tm > "$save$t_suffix"

# Back to shell
clover-mcp

return 0