|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +set -x |
| 4 | + |
| 5 | +export MALI_NOCLEAR=1 |
| 6 | + |
| 7 | +decorative_options() |
| 8 | +{ |
| 9 | + local fn="$1_options.txt" |
| 10 | + if [ ! -f "$fn" ] ; then |
| 11 | + return |
| 12 | + fi |
| 13 | + while read option ; do |
| 14 | + case "$option" in |
| 15 | + hue) printf ' --decorative-frame-hue';; |
| 16 | + luminosity) printf ' --decorative-frame-luminosity';; |
| 17 | + saturation) printf ' --decorative-frame-saturation';; |
| 18 | + esac |
| 19 | + done < "$fn" |
| 20 | +} |
| 21 | + |
| 22 | +args=$@ |
| 23 | +options="" |
| 24 | +retroarch=0 |
| 25 | +clovercon_file=/dev/clovercon1 |
| 26 | +video_mode=keep-aspect-ratio |
| 27 | +mode1="-filter 2 -magfilter 1" |
| 28 | +mode2="-filter 1 -magfilter 3" |
| 29 | +mode3="-filter 1 --pixel-perfect" |
| 30 | + |
| 31 | +while [ $# -gt 0 ] ; do |
| 32 | + case "$1" in |
| 33 | + --title-code) title_code="$2"; shift ;; |
| 34 | + --load-state-file) options="$options -resume" ;; |
| 35 | + --save-data-backing-file) options="$options --sram-file" ;; |
| 36 | + --replay-inputs) options="$options -replay-all -replay" ;; |
| 37 | + --record-inputs) options="$options -record-next -enable-pad-debug-controls" ;; |
| 38 | + --video-mode) |
| 39 | + video_mode=$2 |
| 40 | + shift |
| 41 | + ;; |
| 42 | + --no-scanlines) |
| 43 | + mode1="-filter 1 -magfilter 1" |
| 44 | + ;; |
| 45 | + --no-smooth) |
| 46 | + mode1="-filter 2 -magfilter 3" |
| 47 | + ;; |
| 48 | + --smooth43) |
| 49 | + mode2="-filter 1 -magfilter 1" |
| 50 | + ;; |
| 51 | + --rollback-mode) |
| 52 | + case "$2" in |
| 53 | + record) options="$options -rollback-mode 1" ;; |
| 54 | + replay) options="$options -rollback-mode 2" ;; |
| 55 | + esac |
| 56 | + options="$options --rollback-ui /usr/share/canoe/rollback-ui" |
| 57 | + options="-rollback-snapshot-period 720 $options" |
| 58 | + options="$options --enable-sram-file-hash" |
| 59 | + shift |
| 60 | + ;; |
| 61 | + --rollback-output-dir) options="$options -rollback-output-dir $2"; shift ;; |
| 62 | + --rollback-input-dir) options="$options -rollback-input-dir $2"; shift ;; |
| 63 | + --decorative-frame-path) options="$options --use-decorative-frame $2 $(decorative_options $2)"; shift ;; |
| 64 | + -retroarch) retroarch=1 ;; |
| 65 | + --retroarch) retroarch=1 ;; |
| 66 | + --core) core=$2; shift ;; |
| 67 | + -core) core=$2; shift ;; |
| 68 | + *.sfrom) |
| 69 | + if [ -f "$1.gz" ]; then |
| 70 | + options="$options /tmp/ROM.sfrom" |
| 71 | + gunzip -c "$1.gz" > /tmp/ROM.sfrom |
| 72 | + filename=/tmp/ROM.sfrom |
| 73 | + else |
| 74 | + options="$options $1" |
| 75 | + filename=$1 |
| 76 | + fi |
| 77 | + ;; |
| 78 | + *) options="$options $1" ;; |
| 79 | + esac |
| 80 | + shift |
| 81 | +done |
| 82 | + |
| 83 | +case "$video_mode" in |
| 84 | + keep-aspect-ratio) options="$options $mode2" ;; |
| 85 | + pixel-perfect) options="$options $mode3" ;; |
| 86 | + crt-filter) options="$options $mode1" ;; |
| 87 | +esac |
| 88 | + |
| 89 | +read BUILD_TYPE < /etc/clover/buildtype |
| 90 | +case "$BUILD_TYPE" in |
| 91 | +devel) log="-log $title_code.log -log-append --debug-menu-settings /var/lib/clover/canoe/debug-menu.json --decorative-frames-path /usr/share/backgrounds" ;; |
| 92 | +test) log="-log $title_code.log" ;; |
| 93 | +*) ;; |
| 94 | +esac |
| 95 | + |
| 96 | +# Hold up to forcely disable RetroArch |
| 97 | +[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "1000" ] && retroarch=0 |
| 98 | +# Hold down to forcely enable RetroArch |
| 99 | +[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "2000" ] && retroarch=1 |
| 100 | + |
| 101 | +if [ "$retroarch" == "0" ]; then |
| 102 | + exec canoe-shvc $options $log |
| 103 | +else |
| 104 | + [ -z "$core" ] && exec snes $filename $args |
| 105 | + [ -z "$core" ] || exec retroarch-clover $core $filename $args |
| 106 | +fi |
0 commit comments