-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdosbox-launcher.sh
executable file
·66 lines (51 loc) · 1.83 KB
/
dosbox-launcher.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
#!/usr/bin/env bash
dosboxromdir="${HOME}/RetroPie/roms/pc/gog"
game=$(basename -s .sh "${0}")
# DOSBox settings override
export DOSBOX_SDL_USESCANCODES=false
export LC_ALL="C"
if [[ -x "/opt/retropie/emulators/dosbox/bin/dosbox" ]]; then
emu="/opt/retropie/emulators/dosbox/bin/dosbox"
fi
if ! [[ -x "$(command -v ${emu:-dosbox})" ]]; then
echo 'DOSBox not found but is required for most GOG software. Try installing the optional package "dosbox" from the RetroPie Setup script.'
exit 1
fi
if [[ -d "${dosboxromdir}/${game}/DOSBOX" ]]; then
workdir="${dosboxromdir}/${game}/DOSBOX"
cd "${workdir}" || exit 1
#Fixes
# stargunner on Linux fix:
if [[ -f "../dosboxSTARGUN_single.conf" ]] && ! grep -q "pause" ../dosboxSTARGUN_single.conf; then
#This fixes stargunner from crashing on load on linux
ed -s ../dosboxSTARGUN_single.conf <<<$'g/STARGUN\\.exe/i\\\npause\nw'
fi
IFS=" " read -r -a dosboxargs < <(jq --raw-output '.playTasks[] | select(.isPrimary==true) | .arguments' ../goggame-*.info | sed 's:\\:/:g;s:\"::g')
# If case there is no json file with the launch command, we guess the launch command
if [[ -z "${dosboxargs[*]}" ]]; then
dosboxargs=(
-conf
"$(find .. -maxdepth 1 -name 'dosbox*.conf' | awk '{print length " " $1}' | sort -n | head -1 | awk '{print $2}')"
-conf
"$(find .. -maxdepth 1 -name 'dosbox*single.conf' | head -1)"
-c
exit
)
fi
elif [[ -d "${dosboxromdir}/${game}/dosbox" ]]; then
workdir="${dosboxromdir}/${game}"
cd "${workdir}" || exit 1
dosboxargs=(
-conf
"$(find . -maxdepth 1 -name 'dosbox*.conf' | awk '{print length " " $1}' | sort -n | head -1 | awk '{print $2}')"
-conf
"$(find . -maxdepth 1 -name 'dosbox*single.conf' | head -1)"
-c
exit
)
else
exit 1
fi
echo "Found arugments: ${dosboxargs[*]}"
echo "Launching ${game}"
"${emu:-dosbox}" "${dosboxargs[@]}"