elishacloud / Silent-Hill-2-Enhancements

A project designed to enhance Silent Hill 2 (SH2) graphics and audio for the PC. It also includes scripts to build or modify SH2 audio files (SFX, BGM and Dialog).
http://www.enhanced.townofsilenthill.com/SH2/
zlib License
595 stars 42 forks source link

feature request: Linux Wine compatibility? #134

Closed legluondunet closed 5 years ago

legluondunet commented 5 years ago

Hello, someone in your team uses Linux/WIne? Because when I use your package the game crashes at start. I can use use sh2pcproxy and Thirteenag widescreen patch for SH2 on Linux, but not your patch.

elishacloud commented 5 years ago

Hello @legluondunet, I don't have Linux setup, as I am a Windows user. However, I tried with WineD3D on my Windows 10 system and it worked fine. I simply copied the d3d9.dll, libwine.dll and wined3d.dll files into the Silent Hill 2 folder.

Can you attach the d3d8.log file? There may be something in there that can help.

legluondunet commented 5 years ago

as requested. d3d8.log

Does your d3d8 dll need .Net?

elishacloud commented 5 years ago

It looks like there are several issues on Linux. First of all my hotpatch API hooking does not work so the UseCustomModFolder feature won't work for you. Secondly it looks like like loading dlls using the MemoryModule does not work.

I created a testing build that does not use MemoryModule and I disabled UseCustomModFolder. You can try with this build to see if that works. Just be aware that you will need to copy all files from the sh2e folder into the data folder, overwriting any files there. Make sure to backup the data folder first!

Here is the test module: d3d8.zip

legluondunet commented 5 years ago

tests results:

That's a big step forward, nice shot.

new log file: d3d8.log

my config test: Ubuntu 19.04, GPU: Nvidia, wIne-staging 4.6 64bits.

elishacloud commented 5 years ago

I don't know how work your dx8todx9 function, but Wine does not like it and the game crashes at start.

Do you have ReShade installed? Try renaming or removing the d3d9.dll file if it exists in the Silent Hill 2 folder. Almost all the crashes in d3d8to9 come from ReShade.

What about a dx8toVulkan? It is very well supported on Linux AND Windows (and MacOSX soon).

You can try dx8toVulkan by creating a folder called scripts in the Silent Hill 2 folder and then copying the d3d8.dll file from dx8toVulkan into the scripts folder. But I recommend trying to get d3d8to9 working first.

when I launch the game, I have to wait more that 15 seconds before the first logo appear (Konami)

This is a known issue with Wine. It is fixed in d3d8to9. dx8toVulkan may have a fix for it to.

widescreen, dpad controller, enhanced sound pack and module updater works, so d3d8.dll is now active. That's a big step forward, nice shot.

Ok, great. We are getting closer. I do have an update for you since some of the fixes are not enabled in the last update.

Here is the update: d3d8.zip

legluondunet commented 5 years ago

Do you have ReShade installed? Try renaming or removing the d3d9.dll file if it exists in the Silent Hill 2 folder. Almost all the crashes in d3d8to9 come from ReShade.

I don't have reshade installed, only d3d8 as we are in a testing phase, I prefer to avoid multiple bugs sources.

You can try dx8toVulkan by creating a folder called scripts in the Silent Hill 2 folder and then copying the d3d8.dll file from dx8toVulkan into the scripts folder. But I recommend trying to get d3d8to9 working first.

I didn't know this dll exists, where can I download it?

I tested last d3d8.dll you uploaded, I overwrited all files and launch the game: it launched ok even with d3d8to9 = 1 !? But I still waited more than 15 seconds for the first image to appear. Then the menu showed normally but when I start a new game, screen is all grey, I can hear sounds, can see fog but nothing else, just a grey rectangle. Videos played normally. I deactivated dx8todx9, no more grey screen. At least d3d8to9 does not crash the game anymore when activated. I joined you the log with option d3d8to9 = 1: d3d8.log

legluondunet commented 5 years ago

I did read in your faq that grey screen means I need to install Directx 9c. But normally Wine does not need true Directx 9c DLL to launches game, as directx is now understood by Wine. But some games (or wrappers) still need some true Directx DLL because a function they used are not yet Wine code include. It should be the case for your wrapper d3d8 and after several tests, I found the Directx DLL it needs for d3d8to9 to work: d3dcompiler_43 and d3dx9_43. So I set Wine to use the true d3dcompiler_43 and d3dx9_43 directx DLL instead of his builtin ones and now d3d8 does no more crash with d3d8to9 enabled and works normally, no grey screen. But the15 seconds waiting is still present.

legluondunet commented 5 years ago

Now I tested again with the default package, not the d3d8 from this post but the official release, the game still crashes at start. So it was not only the d3d8to9 option the cause, we already knew that, just a confirmation.

elishacloud commented 5 years ago

I found the Directx DLL it needs for d3d8to9 to work: d3dcompiler_43 and d3dx9_43. So I set Wine to use the true d3dcompiler_43 and d3dx9_43 directx DLL instead of his builtin ones and now d3d8 does no more crash with d3d8to9 enabled and works normally, no grey screen.

Good troubleshooting. Yes, you are correct that d3d8to9 requires d3dx9_43.

But the15 seconds waiting is still present.

Yes, I don't think there is much we can do about this now. I will need to add full debug logs later and give you a debug build. For now you will need to live with the 15 second delay.

Also since the UseCustomModFolder does not work on the Linux version of Wine you will need to continue to use the data folder for updates rather than the sh2e folder. I will look into this later to see how to patch an API in Linux version of Wine.

legluondunet commented 5 years ago

With your help Linux users have now a functional dll with most of the important features, thank you very much.

elishacloud commented 5 years ago

@legluondunet, it appears that some of the options cannot be configured with that build. I created an updated build to fix that.

Here is the update: d3d8.zip