[Guide/Research] XWAUP/DSUCP v1.6 on Linux

Need help editing the game? Check for help here!

Moderators: Darksaber, General_Trageton, Forceflow

Post Reply

[Guide/Research] XWAUP/DSUCP v1.6 on Linux

Maywind
Recruit
Posts: 3
Joined: Sun Mar 31, 2019 1:48 pm

Post by Maywind » Mon Apr 01, 2019 5:41 pm

Dear pilots,
This thread is meant to be, on the one hand, a guide for Linux users as to how to get X-Wing Alliance XWAUP/DSUCP v1.6 installed (and to get the gaming experience as close to native Windows as possible), on the other hand, a research report on some of the issues I have come across, which may potentially be of some interest to people working on the XWAUP project and its components.

Please note that if you are a Linux user and you're willing to try this guide to get XWAUP/DSUCP v1.6 installed, you need to be fluent enough in Linux in general and in using Wine in particular. You should know how to set up a custom Wine prefix with a specific Wine build, whether manually or by using tools like PlayOnLinux or Lutris.

As a person with no Windows machine (by choice), I've been playing the X-Wing series games (all of them, starting with the DOS games and up to and including XvT:BoP and XWA) on Linux for many years. I have installed and tried every single major patch and mod on these games, most of them successfully (the only mod I couldn't get running under Linux is Reshade).

As for XWAUP/DSUCP, I've played every release of the mod starting with v1.2 and up to and including the (currently most recent) v1.6. Most older versions (v1.5 and below) were easy enough to install and worked very well practically out of the box, while v1.6 needed some manual tweaking to get it working without crashing on startup.

So, first things first, how I got XWAUP/DSUCP v1.6 running on Linux.
Note: this was tried on an Intel Core i7-4770 machine with 16 GB RAM and a NVIDIA GTX 960 video card with 4 GB VRAM running Linux Mint 18.3 Cinnamon edition. Your mileage may vary on different hardware and software configurations.

1. You will need a custom Wine prefix for this installation, so please create one. I used a 64-bit Wine prefix, but possibly a 32-bit may suffice. You can use PlayOnLinux/Lutris to manage your custom Wine prefix, or you can make one manually.
2. You will need a recent enough Wine version. Any current Staging version of Wine will do (e.g. 4.4-Staging).
4. If you're planning to use Justagai's 60 fps hook in this Wine prefix, or if you're planning to use tools such as YOGEME, or if you're planning to use anything else that requires .NET Framework, or you'd like to play other games (e.g. XvT:BoP) with that 60 fps patch mentioned before, make sure you get a recent version of Winetricks and use it to install .NET Framework v4.6.1 inside this Wine prefix (use ./winetricks dotnet461 to accomplish that, and make sure you fully go through all the installation procedures - 4.0, 4.5, and 4.6.1 will be installed in succession). Note that this is recommended (check out step 10 for the reason why).
5. Since XWA with XWAUP/DSUCP uses hooks called from dinput.dll, and the DirectDraw patch which we are going to use overrides ddraw.dll, you need to set your Wine prefix up to allow the use of native versions of these libraries. Launch Wine configuration on your custom prefix (winecfg) and add dinput.dll and ddraw.dll to the list of DLL overrides (they should be set to "native,builtin") - you will be warned that it's not recommended to override these libraries, but you can and indeed should ignore this warning in this specific case.
6. Time to get XWA installed inside your custom Wine prefix. Personally I installed the GOG version of the game (I prefer GOG over Steam), but you should in theory be able to install other versions of the game as well, even the CD versions (that's what I used to do before I bought the GOG version). GOG version is probably the easiest to install though since it involves just running and completing the installation procedure from a single .exe file.
7. Once XWA is installed, install XWAUP v1.6 or DSUCP v1.6 (your choice). You can choose any options you prefer, I mostly stuck with the defaults. I also chose the resolution of my monitor (1920x1080) when prompted. Let the installation finish, it should complete without errors and warnings.
8. Now, if this were XWAUP/DSUCP v1.5 or earlier, the game would have worked at this point as is. However, in XWAUP/DSUCP v1.6, a recent change in one of the hooks (Hook_Opt_Limit.dll) currently prevents the game from working on Wine/DXVK without crashing (with the included DDraw.dll that makes the game run on D3D11), and the game would most likely crash with a memory allocation error as soon as you go into the flight engine (interestingly, it can randomly succeed in launching, but very rarely). I have come to a conclusion that it's due to the way DXVK's memory allocator is implemented, and there's little that can be done at this point with that. I tried a few workarounds, but they tend to lead to crashes in missions with many different objects. Therefore, we'll resort to using a different custom DDraw which will work just fine. We'll use a modified Aqrit's DLL, which personally I grabbed from here: https://workupload.com/file/fXsasZps
Download and install it by extracting it into the XWA+XWAUP/DSUCP folder. Overwrite the ddraw.dll which is already there.
9. Check out the settings in aqrit.cfg. I did not change any of them, but your mileage may vary. Note that it's not possible to set the single processor affinity in aqrit.cfg, since it'll slow down the game massively. We'll have to use a different approach to restrict the game to a single CPU core (check out below).
10. At this point, the game should work. However, the way Hook_Time.dll unlocks the FPS in the briefing room seems to not play ball with Aqrit's DDraw.dll - the briefings will be blazing fast and you'll barely be able to understand what's going on. If you're unhappy with that (probably), you can delete Hook_Time.dll from your XWAUP/DSUCP installation folder, then download Justagai's 60 FPS hook from here and put it in the game folder instead: https://onedrive.live.com/?authkey=!ANV ... 981!219391
Note that if you do this, you'll need .NET Framework v4.6.1 installed for this hook to work (check out step 4)
11. Now we need to restrict the game's affinity to a single CPU core. We can accomplish this by making a startup script. For example, create a file called Start_XWingAlliance.sh in your XWAUP/DSUCP folder, with these contents:

wine xwingalliance.exe &
sleep 1
taskset -cp 0 $!

(modify the path to wine as necessary if using a custom prefix, e.g.: WINEPREFIX=<path_to_wineprefix> /path/to/custom_wine/bin/wine xwingalliance.exe &
Once that is done, change its permissions to allow execution (e.g. chmod +x ./Start_XwingAlliance.sh)

12. You're now ready to play the game. Use the script we created in step 11 to play the game with XWAUP/DSUCP 1.6. :) Enjoy!

------
Thanks a lot for your attention, fellow pilots! :)
Hopefully this guide/info will be of use to some of you who are using alternative operating systems and are trying to get the modded game to work using Wine.
Last edited by Maywind on Sun Apr 07, 2019 5:07 am, edited 3 times in total.

Maywind
Recruit
Posts: 3
Joined: Sun Mar 31, 2019 1:48 pm

Post by Maywind » Sat Apr 06, 2019 4:44 pm

I updated the guide to offer a simpler and less crashy option for playing XWAUP 1.6 on Linux using Aqrit's DDraw.dll (without resorting to D3D11 and, thus, DXVK, which currently doesn't work well with Hook_Opt_Limit and causes the game to crash due to the way the memory allocator is implemented in DXVK).

Hope this helps.

JeremyaFr
Lieutenant Commander
XWAU Member
Posts: 1871
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Apr 06, 2019 4:51 pm

Thanks for the guide.

User avatar
ual002
Lieutenant JG
Galactic Empire
Posts: 531
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Sat Apr 06, 2019 8:57 pm

Reminds me of when I build out a Linux install for x64 bit kerbal space program before it hit win.
For the glory of his majesty Emperor Palpatine! Image Image Image Image

Maywind
Recruit
Posts: 3
Joined: Sun Mar 31, 2019 1:48 pm

Post by Maywind » Sun Apr 07, 2019 4:59 am

I figured out what exactly is causing Hook_Time.dll not to work correctly with other variants of DDraw.dll other than the D3D11 one (on Linux), causing incredibly high speed in the hangar (and thus, incredibly fast briefings). Looks like this change:

{ 0x13E328, "99F7FE", "33C040" }

is what's causing it. Thus, patching Hook_Time.dll not to change this offset also seems to do the trick (instead of removing Hook_Time.dll entirely and replacing it with Justagai's 60 FPS patch which requires .NET Framework). Here's a hex patch that I applied, which now works without making the hangar go crazy:

0000E651 33 39
0000E652 33 39
0000E653 43 46
0000E654 30 37
0000E655 34 46
0000E656 30 45

Not sure why exactly it is so, it's actually a part of the CPU usage patch, not a part of the FPS patch as I initially assumed. I'm testing this change to ensure that it doesn't cause any side effects or crashes. Will keep you updated. If this proves to work, I'll add this info to the first post.

Tryphon
Cadet 4th Class
Posts: 10
Joined: Mon Nov 21, 2011 1:44 pm

Post by Tryphon » Fri Apr 19, 2019 5:51 pm

Hello,

Thank for this guide. It works ... except I cannot use other resolution than 640x480. For other resolutions, the Hangar is displayed partially in a kind of picture in picture (PiP) mode smaller than the monitor screen.

Any idea to solve this?

This is what I did under Ubuntu 18.04 :

1) Wine (https://wiki.winehq.org/Ubuntu)

Code: Select all

sudo dpkg --add-architecture i386
wget -nc https://dl.winehq.org/wine-builds/winehq.key
sudo apt-key add winehq.key
sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
sudo apt update
sudo apt install --install-recommends winehq-stable
sudo apt install cabextract
2) Winetricks

Code: Select all

cd /opt
sudo wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
sudo chmod +x winetricks
Accept Mono installation (and Gecko if you want)

Code: Select all

./winetricks
I report some error messages I got but not all (too many). They seem to not have incidence on the XWA execution.
Msg : This package may not fully work on a 64 bit installation.
Validate
Install the dotnet40 component
Msg : dotnet40 does not yet fully work or install on wine. Caveat emptor
Msg : Working around wine bug 42701, 34803
Msg : Running /usr/bin/wineserver -w. This will hang until all wine processes in prefix=/home/ludwig/.wine terminate
Accept installation of dotnet 4.0
Install the dotnet45 component and uncheck dotnet40
Accept installation of dotnet 4.5
Install the dotnet461 component and uncheck dotnet40, dotnet45
Accept installation of dotnet 4.6.1
Under Winetricks, Run winecfg
Go to tab libraries
In the first field enter dinput.dll and press Add button
enter ddraw.dll and press Add button
Check that they are native builtin

To allow the game playing in full screen during the missions, go to display tab :
Check Emulate virtual desktop
Specify 1920x1200 (or you max screen resolution)

Press OK
Quit Wintetricks

3) XWA installation

Code: Select all

cd /media/<yourusername>
Insert XWA disk 1

Code: Select all

cd 'XWA Disk 1'
wine setup.exe (ignore error)
Ask a complete installation in C:\Program Files (x86)\XWingAlliance
If XWA installation is not complete, install again
Go to the wine XWAUCP 1.6 location

Code: Select all

wine XWAUCPv1.6.exe
Accept 2.02 patch install if required and do again wine XWAUCPv1.6.exe
Repeat when it tells CD disk not found
Delete or rename DDraw.dll and Hook_Time.dll
Download https://workupload.com/file/fXsasZps
Extract files in ~/.wine/drive_c/Program Files (x86)/XWingAlliance
Download https://onedrive.live.com/?authkey=!ANV ... 981!219391
Extract Hook_60FPS.dll in files in ~/.wine/drive_c/Program Files (x86)/XWingAlliance
Rename it in Hook_Time.dll
Edit/create XWA.sh file and write

Code: Select all

#!/bin/bash
cd "/home/<yourusername>/.wine/drive_c/Program Files (x86)/XWingAlliance"
wine alliance.exe &
sleep 1
taskset -cp 0 $!
Save

Code: Select all

sudo chmod +x XWA.sh
Non english XWA version

Code: Select all

mv LauncherOrig.tab Launcher.tab
mv XwaOrig.tab Xwa.tab
Download Xwahacker (easy to find) and copy xwahacker.exe in ~/.wine/drive_c/Program Files (x86)/XWingAlliance
Add a specific screen resolution according to your monitor capability

Code: Select all

wine xwahacker.exe XWINGALLIANCE.EXE -r 1 1920 1200
4) Execution

Code: Select all

./XWA.sh
to start the game
Go to Video options and choose the resolution 1920x1200

Config:
Asus P7P55D EVO
quadcore i7 2,8 GHz
Gainward Radeon HD4870
Samsung T240HD monitor on DisplayPort
Last edited by Tryphon on Sat May 04, 2019 1:27 am, edited 2 times in total.

Reimar
Cadet 1st Class
Posts: 232
Joined: Mon Jan 19, 2009 11:45 am

Post by Reimar » Sat Apr 20, 2019 8:20 am

Are the issues with hook_opt_limit documented somewhere? I would kind of think that the issue should be quite possible to avoid, as the code does nothing particularly weird.

Tryphon
Cadet 4th Class
Posts: 10
Joined: Mon Nov 21, 2011 1:44 pm

Post by Tryphon » Mon Apr 22, 2019 2:42 pm

I do not know so much about new technologies coded here on XWA.

What I tried to overcome partially the problem :
Run Wincfg under Winetricks
To allow the game playing in full screen during the missions, go to display tab :
Check Emulate virtual desktop
Specify 1920x1200 (or you max screen resolution)

I can play full screen during the missions but anywhere else the game shrinks to its native resolution at 640x480 in a small window (Briefing, settings, movies, ...). This breaks the immersive game experience.

Justagai
Cadet 1st Class
Posts: 214
Joined: Mon Dec 08, 2014 10:59 pm

Post by Justagai » Tue Apr 23, 2019 8:35 am

Isn't the concourse only rendered in 640x480? Not sure why its minimizing though.

Tryphon
Cadet 4th Class
Posts: 10
Joined: Mon Nov 21, 2011 1:44 pm

Post by Tryphon » Sat Apr 27, 2019 3:00 pm

Concourse too was minimized to 640x480.
I did some basic manipulations of XWINGALLIANCE.EXE with the xwahacker linux code compiled under Ubuntu. I put xwahacker binary into XwingAlliance folder.
First : ./xwahacker.exe XWINGALLIANCE.EXE -f 30
Second : ./xwahacker.exe XWINGALLIANCE.EXE -r 0 1920 1200 (This slot 0 was at 640x480 and in my guide I put slot 1 to 1920x1200)
During the game I tried the slot 0. With "Emulated virtual desktop" checked (winecfg) as I did from my guide, nothing changed ...
I decided to uncheck this option again and all the game is now at full screen!! But I do not know what precisely solved the screen issue.
I tried back 60 FPS, 640x480 in slot 0 and different combinations and the issue persists to be solved! I cannot reproduce the screen issue!

I played many missions and I never experienced crashes. I am not obliged to keep a Windows OS, the main security breach in my home network, and I can deploy connected linux OSes with fast startup, without the need of antiviruses that break the computer ressources, without the need to update the machine hardware every year (less $$ for both hardware / software and more available machine power). :P

Now I can tell X-Wing Alliance under linux (Ubuntu+wine) is fully working except minor things I can deal with elsewhere.
Based on this guide I suggest a specific forum branch for X-Wing Alliance game installation under linux to discuss about user experience.

Thank you all for making this real under linux.

JeremyaFr
Lieutenant Commander
XWAU Member
Posts: 1871
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Jul 09, 2019 4:57 pm

Hello,
I've updated the opt limit hook to disable the last change.
Let me know if this updated version works.

Post Reply