-
Notifications
You must be signed in to change notification settings - Fork 3
/
runcommand-onstart.sh
270 lines (233 loc) · 11.7 KB
/
runcommand-onstart.sh
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/usr/bin/env bash
#=====================================================================================================================================
#title : runcommand-onstart.sh
#description : This script perform the following - #Mike Vencio
# Determines if the game being run is a console or an arcade/fba
# For arcades, it will dynamically determine the resolution based on MAME resolution.ini file
# For consoles, hdmi_timings can be set based on emulator or system
# Dynamically creates the game_name.zip.cfg file and sets the custom_viewport_height for MAME/FBA/NeoGeo
# Dynamically add these parameters (video_allow_rotate = "true" and video_rotation = 1) for vertical games
# vertical.txt contains all the mame 0.184 vertical games
# Ability to set custom_viewport_width for MAME/FBA/NeoGeo
# Fix arcade custom_viewport_width for 320x224 and 320x240 resolutions
# Added amiga and C64 support
# Automatically set custom_viewport_y to center vertically (Removed on 0.7.1)
# Added support for 480 height arcade games like tapper
# Disable resolution change for non libretto cores
# Added support for 448 height arcade games like popeye
# Added support for 254 height arcade games like mk3
# Arcade/FBA/Mame-Libretro/NeoGeo - Set custom_viewport_width to be rom_resolution_width closest to 1920
# Removed text output when running scripts
# Reverted hdmi_timings to previous version
# Removed all logging
# Default non supported non-lr emulators to 320x240
# Default non supported non-lr emulators to 1600x240p - #CRTpi-Project
# Added config-per core scripting to change between 2048x224p / 2048x240p / 2048x192p - #CRTPi-Project
# Added config-per core scripting to change between 1920x224p / 1920x240p / 1920x200p / 1920x192p - #CRTPi-Project
# Added per-game user scripting using heavily modified Sakitoshi tv-out script - #CRTPi-Project
#og. author : Michael Vencio
#ad. author : Sakitoshi
#revision : CRTPi-Project v3.1
#rev. author : http://reddit.com/r/u_erantyint
#rev. date : July10-2020
#notes : For advance users only and would need to be tweaked
# to cater to your needs and preference
# resolution.ini (MAME 0.184) file needed http://www.progettosnaps.net/renameset/
#=====================================================================================================================================
#### Michael Vencio ####
# get the system name
system=$1
# get the emulator name
emul=$2
emul_lr=${emul:0:2}
# get the full path filename of the ROM
rom_fp=$3
rom_bn=$3
# Game or Rom name
rom_bn="${rom_bn%.*}"
rom_bn="${rom_bn##*/}"
#### Sakitoshi X CRTPi ####
#If Value found in 256.txt for Consoles
if [ -f "/opt/retropie/configs/$1/256.txt" ]; then
TwoFiveSix=$(tr -d "\r" < "/opt/retropie/configs/$1/256.txt" | sed -e 's/\[/\\\[/');
fi > /dev/null
#If Value found in 256.txt for Ports
if [ -f "/opt/retropie/configs/ports/$1/256.txt" ]; then
TwoFiveSix=$(tr -d "\r" < "/opt/retropie/configs/ports/$1/256.txt" | sed -e 's/\[/\\\[/');
fi > /dev/null
# If 256.txt is Empty
if [ ! -s "/opt/retropie/configs/$1/256.txt" ] && [ ! -s "/opt/retropie/configs/ports/$1/256.txt" ] || [ -z "$TwoFiveSix" ]; then
TwoFiveSix="empty";
fi > /dev/null
#If Value found in 320.txt for Consoles
if [ -f "/opt/retropie/configs/$1/320.txt" ]; then
ThreeTwenty=$(tr -d "\r" < "/opt/retropie/configs/$1/320.txt" | sed -e 's/\[/\\\[/');
fi > /dev/null
#If Value found in 320.txt for Ports
if [ -f "/opt/retropie/configs/ports/$1/320.txt" ]; then
ThreeTwenty=$(tr -d "\r" < "/opt/retropie/configs/ports/$1/320.txt" | sed -e 's/\[/\\\[/');
fi > /dev/null
# If 320.txt is Empty
if [ ! -s "/opt/retropie/configs/$1/320.txt" ] && [ ! -s "/opt/retropie/configs/ports/$1/320.txt" ] || [ -z "$ThreeTwenty" ];
then ThreeTwenty="empty";
fi > /dev/null
#### Michael Vencio ####
# Determine if arcade or fba then determine resolution, set hdmi_timings else goto console section
if [[ "$system" == "arcade" ]] || [[ "$system" == "fba" ]] || [[ "$system" == "mame-libretro" ]] || [[ "$system" == "neogeo" ]] ; then
# get the line number matching the rom
rom_ln=$(tac /opt/retropie/configs/all/resolution.ini | grep -w -n $rom_bn | cut -f1 -d":")
# get resolution of rom
rom_resolution=$(tac /opt/retropie/configs/all/resolution.ini | sed -n "$rom_ln,$ p" | grep -m 1 -F '[')
rom_resolution=${rom_resolution#"["}
rom_resolution=${rom_resolution//]}
rom_resolution=$(echo $rom_resolution | sed -e 's/\r//g')
rom_resolution_width=$(echo $rom_resolution | cut -f1 -d"x")
rom_resolution_height=$(echo $rom_resolution | cut -f2 -d"x")
# Set rom_resolution_height for 480p and 448p roms
if [ $rom_resolution_height == "480" ]; then
rom_resolution_height="240"
elif [ $rom_resolution_height == "448" ]; then
rom_resolution_height="224"
fi
# Create rom_name.cfg
if ! [ -f "$rom_fp"".cfg" ]; then
touch "$rom_fp"".cfg"
fi
# Set custom_viewport_height
if ! grep -q "custom_viewport_height" "$rom_fp"".cfg"; then
echo -e "custom_viewport_height = ""\"$rom_resolution_height\"" >> "$rom_fp"".cfg" 2>&1
fi
# determine if vertical
if grep -w "$rom_bn" /opt/retropie/configs/all/vertical.txt ; then
# Add vertical parameters (video_allow_rotate = "true")
if ! grep -q "video_allow_rotate" "$rom_fp"".cfg"; then
echo -e "video_allow_rotate = \"true\"" >> "$rom_fp"".cfg" 2>&1
fi
# Add vertical parameters (video_rotation = 3)
if ! grep -q "video_rotation" "$rom_fp"".cfg"; then
echo -e "video_rotation = \"3\"" >> "$rom_fp"".cfg" 2>&1
fi
# Add integer scale parameters (video_scale_integer = true)
if ! grep -q "video_scale_integer" "$rom_fp"".cfg"; then
echo -e "video_scale_integer = \"true\"" >> "$rom_fp"".cfg" 2>&1
fi
fi
# set the custom_viewport_width
if ! grep -q "custom_viewport_width" "$rom_fp"".cfg"; then
echo -e "custom_viewport_width = ""\"1920\"" >> "$rom_fp"".cfg" 2>&1
fi
fi
#### Michael Vencio X CRTPi X Sakitoshi ####
# determine and set variable resolutions for libretto cores
if [[ "$emul_lr" == "lr" ]]; then
# re-get the system name
system=$1
# change timings for 256.txt to 2048x240p
if { ! echo "$3" | grep -q -wi "$ThreeTwenty" || echo "$ThreeTwenty" | grep -q empty; } && ! echo "$ThreeTwenty" | grep -q -xi "all" && { echo "$3" | grep -q -wi "$TwoFiveSix"; } then > /dev/null
vcgencmd hdmi_timings 2048 1 160 202 320 240 1 3 5 14 0 0 0 60 0 42954545 1 > /dev/null; #CRTPi 2048x240p Timing Adjusted
tvservice -c "DMT 87" > /dev/null;
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 2048 -yres 240 > /dev/null; #24b depth
# change timings for 320.txt to 1920x240p
elif { ! echo "$3" | grep -q -wi "$TwoFiveSix" || echo "$TwoFiveSix" | grep -q empty; } && ! echo "$TwoFiveSix" | grep -q -xi "all" && { echo "$3" | grep -q -wi "$ThreeTwenty"; } then > /dev/null
vcgencmd hdmi_timings 1920 1 137 247 295 240 1 3 7 12 0 0 0 60 0 40860000 1 > /dev/null #CRTPi 1920x240p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 1920 -yres 240 > /dev/null #24b depth
# change timings for 256x224 systems to 2048x224p
elif
[[ "$system" == "snes" ]] ||
[[ "$system" == "nes" ]] ||
[[ "$system" == "romhacks" ]] ; then
vcgencmd hdmi_timings 2048 1 160 202 320 224 1 11 5 22 0 0 0 60 0 42954545 1 > /dev/null #CRTPi 2048x224p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 2048 -yres 224 > /dev/null #24b depth
# change timings for 256x240 systems to 2048x240p
elif
[[ "$system" == "fds" ]] ||
[[ "$system" == "mastersystem" ]] ||
[[ "$system" == "pcengine" ]] ||
[[ "$system" == "pce-cd" ]] ||
[[ "$system" == "ngp" ]] ||
[[ "$system" == "ngpc" ]] ||
[[ "$system" == "gb" ]] ||
[[ "$system" == "gbc" ]] ||
[[ "$system" == "gba" ]] ||
[[ "$system" == "psp" ]] ||
[[ "$system" == "gamegear" ]] ||
[[ "$system" == "virtualboy" ]] ||
[[ "$system" == "atarilynx" ]] ||
[[ "$system" == "wonderswan" ]] ||
[[ "$system" == "wonderswancolor" ]] ; then
vcgencmd hdmi_timings 2048 1 160 202 320 240 1 3 5 14 0 0 0 60 0 42954545 1 > /dev/null #CRTPi 2048x240p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 2048 -yres 240 > /dev/null #24b depth
# change timings for 256x192 systems to 2048x192p
elif
[[ "$system" == "sg-1000" ]] ; then
vcgencmd hdmi_timings 2048 1 160 202 320 192 1 27 5 38 0 0 0 60 0 42954545 1 > /dev/null #CRTPi 2048x192p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 2048 -yres 192 > /dev/null #24b depth
# change timings for 320x224 & 384x224 systems to 1920x224p
elif
[[ "$system" == "megadrive" ]] ||
[[ "$system" == "segacd" ]] ||
[[ "$system" == "sega32x" ]] ||
[[ "$system" == "fba" ]] ||
[[ "$system" == "neogeo" ]] ; then
vcgencmd hdmi_timings 1920 1 137 247 295 224 1 11 7 20 0 0 0 60 0 40860000 1 > /dev/null #CRTPi 1920x224p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 1920 -yres 224 > /dev/null #24b depth
# change timings for 320x200 systems to 1920x200p
elif
[[ "$system" == "quake" ]] ||
[[ "$system" == "doom" ]] ; then
vcgencmd hdmi_timings 1920 1 137 247 295 200 1 23 7 32 0 0 0 60 0 40860000 1 > /dev/null #CRTPi 1920x200p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 1920 -yres 200 > /dev/null #24b depth
# change timings for 320x192 systems to 1920x192p
elif
[[ "$system" == "atari5200" ]] ||
[[ "$system" == "atari800" ]] ||
[[ "$system" == "amiga" ]] ||
[[ "$system" == "zxspectrum" ]] ; then
vcgencmd hdmi_timings 1920 1 137 247 295 192 1 27 7 36 0 0 0 60 0 40860000 1 > /dev/null #CRTPi 1920x192p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 1920 -yres 192 > /dev/null #24b depth
# change timings for 320x240 systems to 1920x240p
elif
[[ "$system" == "psx" ]] ||
[[ "$system" == "atari2600" ]] ||
[[ "$system" == "dreamcast" ]] ||
[[ "$system" == "saturn" ]] ||
[[ "$system" == "atari7800" ]] ||
[[ "$system" == "n64" ]] ||
[[ "$system" == "arcade" ]] ||
[[ "$system" == "mame-libretro" ]] ||
[[ "$system" == "cavestory" ]] ; then
vcgencmd hdmi_timings 1920 1 137 247 295 240 1 3 7 12 0 0 0 60 0 40860000 1 > /dev/null #CRTPi 1920x240p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 1920 -yres 240 > /dev/null #24b depth
# default to 1600x240p for all other lr- systems
else
vcgencmd hdmi_timings 1600 1 73 157 204 240 1 4 3 15 0 0 0 60 0 32000000 1 > /dev/null #CRTPi 1600x240p Timing Adjusted
tvservice -c "DMT 87" > /dev/null
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 1600 -yres 240 > /dev/null #24b depth
fi
# otherwise -- determine and set variable resolutions for non-libretto cores
elif
# for eDuke32 switch to 320x200p
[[ "$system" == "eduke32" ]] ||
[[ "$system" == "duke3d" ]] ||
[[ "$system" == "scummvm" ]] ||
[[ "$system" == "dosbox" ]] ||
[[ "$system" == "pc" ]] ||
[[ "$system" == "c64" ]] ; then
vcgencmd hdmi_timings 320 1 10 30 40 200 1 28 3 31 0 0 0 60 0 6400000 1 > /dev/null #CRTPi 320x200p Adjusted
tvservice -c "DMT 87"
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 320 -yres 200 > /dev/null #24b depth
else
# for all other non-libretro emulators switch to 320x240p
vcgencmd hdmi_timings 320 1 15 30 42 240 1 4 3 15 1 0 0 60 0 6400000 1 > /dev/null #CRTPi 320x240p Timing Adjusted
tvservice -c "DMT 87"
fbset -depth 8 && fbset -depth 16 && fbset -depth 24 -xres 320 -yres 240 > /dev/null #24b depth
fi
#####