Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Set up GLSL in Wine for Artemis

Following up on How I run Artemis Spaceship Bridge Simulator on Devuan ceres, I wrote a script that will set the GLSL variable in wine. Basically, if Artemis Spaceship Bridge Simulator fails in Wine, the first thing to try is to disable GLSL (which I just learned is superseded, so I have to go test with that new key at some point). I used the Wine regedit utility to export my registry key to a file, artemis-disable-glsl.reg.

��Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Wine\Direct3D]
"UseGLSL"="disabled"

Obviously you can just copy this and modify it for the "enabled" value. And the main script.

 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
#!/bin/sh
# File: /mnt/public/Support/Games/Artemis/use-glsl.sh
# License: CC-BY-SA 4.0
# Author: bgstack15
# Startdate: 2020-11-10
# Title: Script that sets up GLSL in Wine for Artemis on Weaker Systems
# Purpose: Make it easy to toggle the registry setting
# History:
# Usage:
#    WINEPREFIX
#    GUESS=1  If set to any non-blank value, try to guess WINEPREFIX if WINEPREFIX is blank
#    ACTION=enable|disable  Enable or disable glsl. Normally underperforming systems need to disable glsl.
#    DEBUG
#    DRYRUN
# Reference:
#    /posts/2019/09/29/how-i-run-artemis-spaceship-bridge-simulator-on-devuan-ceres/
#    https://artemis.forumchitchat.com/post/show_single_post?pid=1303287265&postcount=7&forum=309502
# Improve:
#    2020-11-11 https://www.winehq.org/announce/5.0
#       says to use a different key now.
# Dependencies:
#    wine
# Documentation:

# FUNCTIONS
is_64bit() {
   # call: is_64bit "${WINEPREFIX}" && echo "this is 64-bit"
   _wineprefix="${1}"
   find "${_wineprefix}/drive_c/Program Files (x86)" -maxdepth 0 -printf '' 2> /dev/null ;
   #return $(( 1 - $? )) ;
   return $?
}

get_parent_wine_dir() {
   # call: get_parent_wine_dir /home/bgstack15/.wine-artemis/drive_c/Program\ Files/Artemis
   # returns: /home/bgstack15/.wine-artemis
   _inputdir="${1}"
   _thisdir="${_inputdir}"
   while ! basename "${_thisdir}" | grep -qE "wine" ;
   do
      _thisdir="$( dirname "${_thisdir}" )"
   done
   echo "${_thisdir}"
}

# validate input
test -z "${WINEPREFIX}" && test -z "${GUESS}" && {
   echo "Use GUESS=1 to force the guessing of which WINEPREFIX to use." 1>&2 ; exit 1 ;
}

test -z "${WINEPREFIX}" && test -n "${GUESS}" && {
   # will have to guess
   ARTEMISDIR="$( find ~/.wine-artemis ~/.wine32 ~/.wine /usr/share/wine /opt/wine -type d -path '*/.wine*' -path '*/Program\ Files*' -name 'Artemis' -print 2>/dev/null | head -n1 )"
   WINEPREFIX="$( get_parent_wine_dir "${ARTEMISDIR}" )"
   test -z "${WINEPREFIX}" && {
      echo "Fatal! Unable to find a wineprefix where Artemis is installed. Aborted." 1>&2
      exit 1
   }
   echo "Found ${WINEPREFIX} with Artemis installed." 1>&2
   export WINEPREFIX
}

test -z "${WINEARCH}" && {
   WINEARCH=win32
   is_64bit "${WINEPREFIX}" && WINEARCH=win64
   export WINEARCH
}

test -z "${ACTION}" && {
   echo "Using default action of \"disable\" glsl." 1>&2
   export ACTION=disable
}

# default
tf="/mnt/public/Support/Games/Artemis/artemis-disable-glsl.reg" 
case "${ACTION}" in
   disable|off|DISABLE|OFF|NO|0) :;;
   enable|on|ENABLE|ON|YES|1) tf="/mnt/public/Support/Games/Artemis/artemis-enable-glsl.reg" ;;
   *) echo "Unknown action \"${ACTION}\" so defaulting to disable." 1>&2 ;;
esac

test -n "${DEBUG}" && {
   echo "WINEPREFIX=${WINEPREFIX} WINEARCH=${WINEARCH} wine regedit ${tf}"
}
test -z "${DRYRUN}" && wine regedit "${tf}"

Use environment variables to control the operation! So to disable glsl, run: ACTION=enable ./use-glsl.sh As usual with my scripts, you can also use DEBUG and DRYRUN.

Comments