Skip to content

Commit 81240c7

Browse files
committed
Fixed bug causing exit on any button press, scanlines overlay
1 parent ee6bd59 commit 81240c7

File tree

11 files changed

+84
-42
lines changed

11 files changed

+84
-42
lines changed

core_modules/snes9x2010.hmod/usr/bin/clover-canoe-shvc

+33-8
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ decorative_options()
1919
done < "$fn"
2020
}
2121

22-
original_options=$@
2322
options=""
23+
retroarch=0
24+
clovercon_file=/dev/clovercon1
25+
video_mode=keep-aspect-ratio
26+
mode1="-filter 2 -magfilter 1"
27+
mode2="-filter 1 -magfilter 3"
28+
mode3="-filter 1 --pixel-perfect"
2429

2530
while [ $# -gt 0 ] ; do
2631
case "$1" in
@@ -30,13 +35,18 @@ while [ $# -gt 0 ] ; do
3035
--replay-inputs) options="$options -replay-all -replay" ;;
3136
--record-inputs) options="$options -record-next -enable-pad-debug-controls" ;;
3237
--video-mode)
33-
case "$2" in
34-
keep-aspect-ratio) options="$options -filter 1 -magfilter 3" ;;
35-
pixel-perfect) options="$options -filter 1 --pixel-perfect" ;;
36-
crt-filter) options="$options -filter 2 -magfilter 1" ;;
37-
esac
38+
video_mode=$2
3839
shift
3940
;;
41+
--no-scanlines)
42+
mode1="-filter 1 -magfilter 1"
43+
;;
44+
--no-smooth)
45+
mode1="-filter 2 -magfilter 3"
46+
;;
47+
--smooth43)
48+
mode2="-filter 1 -magfilter 1"
49+
;;
4050
--rollback-mode)
4151
case "$2" in
4252
record) options="$options -rollback-mode 1" ;;
@@ -50,7 +60,10 @@ while [ $# -gt 0 ] ; do
5060
--rollback-output-dir) options="$options -rollback-output-dir $2"; shift ;;
5161
--rollback-input-dir) options="$options -rollback-input-dir $2"; shift ;;
5262
--decorative-frame-path) options="$options --use-decorative-frame $2 $(decorative_options $2)"; shift ;;
63+
-retroarch) retroarch=1 ;;
5364
--retroarch) retroarch=1 ;;
65+
--core) core=$2; shift ;;
66+
-core) core=$2; shift ;;
5467
*.sfrom)
5568
if [ -f "$1.gz" ]; then
5669
options="$options /tmp/ROM.sfrom"
@@ -66,15 +79,27 @@ while [ $# -gt 0 ] ; do
6679
shift
6780
done
6881

82+
case "$video_mode" in
83+
keep-aspect-ratio) options="$options $mode2" ;;
84+
pixel-perfect) options="$options $mode3" ;;
85+
crt-filter) options="$options $mode1" ;;
86+
esac
87+
6988
read BUILD_TYPE < /etc/clover/buildtype
7089
case "$BUILD_TYPE" in
7190
devel) log="-log $title_code.log -log-append --debug-menu-settings /var/lib/clover/canoe/debug-menu.json --decorative-frames-path /usr/share/backgrounds" ;;
7291
test) log="-log $title_code.log" ;;
7392
*) ;;
7493
esac
7594

76-
if [ -z "$retroarch" ]; then
95+
# Hold up to forcely disable RetroArch
96+
[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "1000" ] && retroarch=0
97+
# Hold down to forcely enable RetroArch
98+
[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "2000" ] && retroarch=1
99+
100+
if [ "$retroarch" == "0" ]; then
77101
exec canoe-shvc $options $log
78102
else
79-
exec /bin/snes "$rom" $original_options
103+
[ -z "$core" ] && exec snes $filename $args
104+
[ -z "$core" ] || exec retroarch-clover $core $filename $args
80105
fi

retroarch.hmod/bin/retroarch-clover-child

+27-23
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ t_suffix=_time.txt
1717
demo_time=30
1818
shift 2
1919

20-
crt=0
21-
allow_crt=0
22-
2320
while [ $# -gt 0 ]; do
2421
[ "$1" == "--load-state-file" ] && load=$2
2522
[ "$1" == "--save-on-quit" ] && save=$2
@@ -28,11 +25,9 @@ while [ $# -gt 0 ]; do
2825
[ "$1" == "--save-screenshot-on-quit" ] && screenshot=$2
2926
[ "$1" == "--save-data-backing-file" ] && sram=$2
3027
[ "$1" == "--graphic-filter" ] && filter=$2
31-
[ "$1" == "--enable-crt-scanlines" ] && crt=1
3228
[ "$1" == "--video-mode" ] && [ "$2" == "crt-filter" ] && filter=crt720
3329
[ "$1" == "--video-mode" ] && [ "$2" == "keep-aspect-ratio" ] && filter=gpu720
3430
[ "$1" == "--video-mode" ] && [ "$2" == "pixel-perfect" ] && filter=ppu
35-
[ "$1" == "--ra-allow-crt" ] && allow_crt=1
3631
[ "$1" == "--ra-extra" ] && extra=$2
3732
[ "$1" == "--ra-nosaves" ] && nosaves=1
3833
[ "$1" == "--save-time-path" ] && timefile=$2
@@ -68,21 +63,12 @@ fi
6863
# pixel perfect - 1:1 for pixel perfect mode
6964
[ "$filter" == "ppu" ] && ratio=20 && smooth=false
7065

71-
# Allow scanlines only for simple systems
72-
[ "$allow_crt" == "1" ] || crt=0
73-
7466
smooth=$(cat /etc/libretro/$filter.smooth)
7567
sed -i -e 's/video_smooth = "[^"]*"/video_smooth = "'$smooth'"/g' /etc/libretro/retroarch.cfg
7668
ratio=$(cat /etc/libretro/$filter.ratio)
7769
sed -i -e 's/aspect_ratio_index = "[^"]*"/aspect_ratio_index = "'$ratio'"/g' /etc/libretro/retroarch.cfg
78-
79-
# enable shader scanlines if need
80-
if [ "$crt" == "1" ]; then
81-
sed -i -e 's/video_shader = "[^"]*"/video_shader = "~\/shaders\/retroarch\.glslp"/g' /etc/libretro/retroarch.cfg
82-
rsync -a -c /etc/libretro/shaders/scanline.glslp /etc/libretro/shaders/retroarch.glslp
83-
else
84-
sed -i -e 's/video_shader = "[^"]*"/video_shader = ""/g' /etc/libretro/retroarch.cfg
85-
fi
70+
overlay=$(cat /etc/libretro/$filter.overlay)
71+
sed -i -e 's/input_overlay_enable = "[^"]*"/input_overlay_enable = "'$overlay'"/g' /etc/libretro/retroarch.cfg
8672

8773
# Start timestamp
8874
ts=$(date +"%s")
@@ -92,10 +78,14 @@ tm=0
9278
retroarch -c "$HOME/retroarch.cfg" -vfL "$core" "$rom" $extra &
9379
rpid=$!
9480

95-
# We need last two files
81+
# searching for input devices
9682
for i in $(ls /dev/input/event?) ;do
97-
power_file=$reset_file
98-
reset_file=$i
83+
local id=$(basename $i)
84+
local name=$(cat /sys/class/input/$id/device/name)
85+
[ "$name" == "sunxi-knob" ] && power_file=$i
86+
[ "$name" == "sunxi-keyboard" ] && reset_file=$i
87+
[ "$name" == "Nintendo Clovercon - controller1" ] && controller1_file=$i
88+
[ "$name" == "Nintendo Clovercon - controller2" ] && controller2_file=$i
9989
done
10090

10191
dd if=$power_file of=/dev/null count=1 2> /dev/null &
@@ -105,8 +95,14 @@ reset_pid=$!
10595

10696
# Demo mode enabled
10797
if [ ! -z "$demo" ]; then
108-
dd if=/dev/input/event2 of=/dev/null count=1 2> /dev/null &
109-
anybutton_pid=$!
98+
if [ ! -z "$controller1_file" ]; then
99+
dd if=$controller1_file of=/dev/null count=1 2> /dev/null &
100+
anybutton1_pid=$!
101+
fi
102+
if [ ! -z "$controller2_file" ]; then
103+
dd if=$controller2_file of=/dev/null count=1 2> /dev/null &
104+
anybutton2_pid=$!
105+
fi
110106
fi
111107

112108
sleep 3
@@ -119,7 +115,12 @@ while [ true ]; do
119115
kill -0 $power_pid 2> /dev/null || break
120116
if [ ! -z "$demo" ]; then
121117
# Exit on any button
122-
kill -0 $anybutton_pid 2> /dev/null || break
118+
if [ ! -z "$anybutton1_pid" ]; then
119+
kill -0 $anybutton1_pid 2> /dev/null || break
120+
fi
121+
if [ ! -z "$anybutton2_pid" ]; then
122+
kill -0 $anybutton2_pid 2> /dev/null || break
123+
fi
123124
# Or after some time
124125
ts2=$(date +"%s")
125126
tp=$((ts2 - ts))
@@ -130,7 +131,8 @@ done
130131
kill $rpid 2> /dev/null
131132
kill -KILL $reset_pid 2> /dev/null
132133
kill -KILL $power_pid 2> /dev/null
133-
[ ! -z "$demo" ] && kill -KILL $anybutton_pid 2> /dev/null
134+
[ ! -z "$anybutton1_pid" ] && kill -KILL $anybutton1_pid 2> /dev/null
135+
[ ! -z "$anybutton2_pid" ] && kill -KILL $anybutton2_pid 2> /dev/null
134136

135137
[ ! -z "$save" ] && mkdir -p $(dirname "$save")
136138
[ ! -z "$sram" ] && mkdir -p $(dirname "$sram")
@@ -154,6 +156,8 @@ echo $tm > "$timefile"
154156

155157
grep video_smooth /etc/libretro/retroarch.cfg | grep true && current_smooth=true || current_smooth=false
156158
echo $current_smooth > /etc/libretro/$filter.smooth
159+
grep video_smooth /etc/libretro/retroarch.cfg | grep true && current_overlay=true || current_overlay=false
160+
echo $current_overlay > /etc/libretro/$filter.overlay
157161
current_ratio=$(cat /etc/libretro/retroarch.cfg | grep "aspect_ratio_index" | sed 's/[^0-9]*//g')
158162
echo $current_ratio > /etc/libretro/$filter.ratio
159163

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
overlays = 1
2+
overlay0_overlay = scanlines.png
3+
overlay0_full_screen = true
4+
overlay0_descs = 0
5+
overlay0_rect = "0.0,0.0,1.0,1.0"
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
false
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
false

retroarch.hmod/etc/libretro/ppu.ratio

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4
1+
14

retroarch.hmod/etc/libretro/retroarch.cfg

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ video_refresh_rate = "60.000027"
4545
audio_rate_control_delta = "0.005000"
4646
audio_max_timing_skew = "0.050000"
4747
audio_volume = "0.000000"
48-
input_overlay_opacity = "0.700000"
48+
input_overlay_opacity = "0.500000"
4949
input_overlay_scale = "1.000000"
5050
menu_wallpaper_opacity = "0.300000"
5151
menu_footer_opacity = "1.000000"
@@ -177,7 +177,7 @@ video_allow_rotate = "true"
177177
video_windowed_fullscreen = "true"
178178
video_crop_overscan = "false"
179179
video_scale_integer = "true"
180-
video_smooth = "false"
180+
video_smooth = "true"
181181
video_force_aspect = "true"
182182
video_threaded = "false"
183183
video_shared_context = "false"
@@ -216,7 +216,7 @@ rgui_show_start_screen = "false"
216216
menu_navigation_wraparound_enable = "true"
217217
menu_navigation_browser_filter_supported_extensions_enable = "false"
218218
menu_show_advanced_settings = "true"
219-
input_overlay_enable = "false"
219+
input_overlay_enable = "true"
220220
input_overlay_enable_autopreferred = "true"
221221
input_overlay_hide_in_menu = "true"
222222
network_cmd_enable = "false"
@@ -1561,6 +1561,7 @@ xmb_menu_color_theme = "4"
15611561
xmb_shadows_enable = "true"
15621562
xmb_show_settings = "true"
15631563
xmb_show_history = "true"
1564+
input_overlay = "/etc/libretro/.config/retroarch/overlay/scanlines.cfg"
15641565
xmb_font = ""
15651566
netplay_nickname = ""
15661567
video_filter = ""
@@ -1569,7 +1570,6 @@ core_updater_buildbot_url = ""
15691570
core_options_path = ""
15701571
video_shader = ""
15711572
menu_wallpaper = ""
1572-
input_overlay = ""
15731573
video_font_path = ""
15741574
content_history_dir = ""
15751575
resampler_directory = ""

retroarch.hmod/readme.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=== RetroArch module for hakchi ===
2-
version 0.8
2+
version 0.9
33

4-
This is a hakchi/hakchi2 module which adds libretro cores and RetroArch frontend to your NES Mini.
4+
This is a hakchi/hakchi2 module which adds libretro cores and RetroArch frontend to your NES/SNES Mini.
55

66
It will automatically detect unsupported NES games and run them instead of the default emulator. Save states will work as usual.
77

@@ -23,12 +23,10 @@ Available executables and arguments:
2323
- /bin/retroarch
2424
RetroArch binary
2525

26-
Sometimes default emulator of NES mini is not working with some games when it should. So you can just add "--retroarch" command line argument to use RetroArch.
26+
Sometimes default emulator of NES/SNES mini is not working with some games when it should. So you can just add "--retroarch" command line argument to use RetroArch.
2727

2828
Known issues:
2929
- Nintendo 64 save-states are not working, battery backup working fine
30-
- Default CRT filter is not working, scanlines shader added instead, only for NES
31-
3230

3331
Cores by libretro, compiled by pcm
3432
NES Mini port by madmonkey

retroarch.hmod/usr/bin/clover-kachikachi

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@ fi
2828

2929
while [ $# -gt 0 ]; do
3030
[ "$1" == "--retroarch" ] && emulator=retroarch
31-
[ "$1" == "--core" ] && core=$2
31+
[ "$1" == "-retroarch" ] && emulator=retroarch
32+
[ "$1" == "--core" ] && core=$2
33+
[ "$1" == "-core" ] && core=$2
3234
shift
3335
done
3436

3537
# Do not use retroarch for original qd games
3638
args="$(echo $args | sed 's/--retroarch//g')"
3739
[ "$extension" == "qd" ] && emulator=kachikachi
3840

41+
# Hold up to forcely disable RetroArch
42+
[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "1000" ] && emulator=kachikachi
43+
# Hold down to forcely enable RetroArch
44+
[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "2000" ] && emulator=retroarch
45+
3946
echo using $emulator
4047

4148
if [ "$emulator" == "kachikachi" ]; then

0 commit comments

Comments
 (0)