• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Solved Intel Graphics Fix

amplificar

Opcode Assemblar
Storm Modder
Ahoy everybody! I've found a way to prevent crashing at the start of a New Game on computers that have onboard intel graphics. This doesn't disable the whole sea layer, or require full software rendering. It merely prevents some sea effects from being used. It also improves performance slightly. The drawback is the the sea looks worse (kinda checkerboard/oil slick), all else appears unaffected.

Just one game file needs to be modified with a hex editor.

In /MODULES/Sea.dll at file offset 0x1110
change 81 EC E0 01 00 00 53
to 90 90 90 90 90 90 C3

After doing this, on my Windows 7 MSI Wind U135DX netbook (Intel GMA3150) the game even runs well at 1280x960 32bit with an external monitor. After playing the game for half an hour, I decided I should post this on the forums. I haven't tested it with any mods yet, just vanilla PotC.

What happened is the game crashes at Sea.dll offset 0x1704 when it tries to read a null pointer from eax. I determined it's supposed to be a pointer to a d3d8.dll routine (thanks to SwiftShader making a handy debugging comparison). I worked backwards from 0x1704 and found 0x1110 was the routine's starting point in Sea.dll. The above patch just makes the routine return immediately. When I first tried this, I expected the game to just crash elsewhere or fail to create the sea layer, and I was very surprised when it worked so well.

I'm not sure, but there's a possibility PotC could crash if enhanced graphics mods are used. I'll be able to test that myself by next weekend.
 
Ahoy amplificar, welcome aboard mate! :dance

Interesting, nice find mate! Intel graphics has been the biggest problem that we have had with this game over the years, Swiftshader was really the only thing we were able to find that would even remotely work. I am no programer, but I do understand a bit about what your referring to. Would it be possible to post a screen shot of what the game looks like with the above fix?
 
Waves, animals, splash and coral/undersea rocks are drawn okay. The surface of the water can look bad, depending on the weather and time of day.

a35b7749.jpg

Standing on the dock at Oxbay.

6e2d3315.jpg

Here, at dusk, the artifacts are almost unnoticeable.

96fd72d5.jpg

Everything else looks fine.
 
The oily effect we have seen before, that was solved in THIS thread, most of the pics are gone since the forum upgrade.

That crosshatching I am not sure about, I think I may have seen it before, but I am not positive. :shrug

I am sure some of the other modders will be along shortly to make up for my lack of knowledge. If we can figure out how how to mitigate both problems, you may have given us a permanent solution to one of the most annoying problems that we have had.
 
That big checkerboard is not good, but other than that I have seen far worse. I don't think we have anyone who could look into that .dll.
 
VERY interesting! If we can replace SwiftShader with your modified sea.dll, that should improve matters a LOT. :woot

Does the game perform properly? Is there anyone who can try this on another computer? Can you upload your modified sea.dll please?
 
Anybody can use the patched sea.dll (make a backup of your original first). It has no good effect for people with nVidia or ATI graphics, but or people that have Intel graphics it keeps the game from crashing at the start. It can still be tried if you want to see the rendering artifacts yourself (or if somebody needs to improve game FPS slightly).

It is definitely pixel shaders that the game is trying to use, when it crashes.

Attached to this post is a new patched sea.dll file. It's better than the original patch in theory, less code is being skipped.
It aborts at the last spot it can, prior to where it crashes.

Just thirteen bytes changed.
sea+0x1401 was 8B4708,40,894708,8B8E68020000
changed to 5F,5E,5D,B001,5B,81C4E0010000,C3

I didn't see an improvement with the newest patch, but I know that less of the vertex shading is being skipped and more of the bump maps are being loaded. The previous screenshots are what it still looks like. I was originally hoping this would make more of a difference. A better patch is still needed.

------------------------------------------

There's three approaches I'm trying:
1) Stop rendering when pixel shader code is reached (tried)
2) Neatly bypass pixel shader code (in progress)
3) Actually fix the pixel shader code to make it work with intel graphics (in progress - maybe impossible).

I'm trying #2 right now, testing wiping out pixel shader code without skipping the rendering that comes afterwards. (replacing a bunch of opcodes with NOP, 0x90)

I've outlined below some of what is going on behind the scenes in the game. I believe it's mostly accurate.
(All of the offset numbers shown below are in hexadecimal, the .exe and .dll extensions are omitted from names)

The call chain that initializes the sea:
/PROGRAM/SEA_AI/sea.c -> CreateSeaEnvironment()

A line of code in CreateSeaEnvironment() triggers:

engine+0x3B060 -> sea!DMAInterface+3965
...when it reaches 3AF3 it runs into a call to sea+1110
engine+0x3B060 -> sea!DMAInterface+3AF3 -> sea+1110 ...
...testing with SwiftShader, from sea+1110 it should run until sea+1993, doing a bunch of conditional loops

The game crashes when sea+1704 is reached with intel graphics. At 1704, a null function pointer should be d3d8!ValidatePixelShader+XYZ (the XYZ is not the same offset with SwiftShader as it would be with intel's drivers - I checked that). I worked backwards and determined sea+142A is when the function pointer should be getting stored in the stack for later, but isn't (this pointer is put at ESP+3Ch, which on my computer is usually memory address 12EFE0+3C=12F01C). The sea+142A section of code is important for eventually figuring out why the function pointer is null, and for possibly fixing things by forcing software pixel shaders to work. I think it leads back from here to something in DX8Render.dll.

Between sea+1110 and sea+1401 vertex shaders are being initialized/created, and bump map(s) are being opened and read from files (sea.dll text constants indicate SSZ10026088_C__PROJECTS_DRIVE_V2_SEA_BumpMap, bump.zap). That's part of the reason skipping that section of code caused problems similar to the issues with B13/B14 bump.zap (as mentioned by Thagarr). The reason the newest patch didn't make a noticeable improvement is there must be more code that needs to be run after the pixel shader stuff.

I should have a better patch in a day or two, if approach #2 works.
 

Attachments

  • sea_dll_gmafix_abortsat1401.7z
    70.7 KB · Views: 1,936
That's quite a great bit of detective work there mate, fantastic job! :cheers

I understand some of what you pointed out above, but as i said before, I am no programer and some of it is just over my head. I am gonna write up a front page article for this, there may be several people out there willing to live with the crosshatching to be able to play the game without Swiftshader. The performance improvement may very well be worth it, but I will hold off for another day or two and see how your second approach turns out.

I really don't have much hope for #3, Intel has FINALLY started to pay some attention to the graphics end of things, but only because AMD forced them to. But their older chip sets have such badly designed hardware, firmware and poorly written drivers, I really don't think there is much hope for getting them to behave properly with Storm engine games. :modding
 
Excellent progress! :bow I can not test this as I don't have Intel graphics, but there are some currently active players who hopefully will be jumping all over this.
 
Good news. For approach #2, I was trying to disable less code. That was going nowhere, so then I did the opposite. By disabling three other routines before and after sea+1110, the big visual problems are gone now.

I've attached a newer sea.dll with the following nine bytes modified:
sea+6f75 was 8b11,568b8734340000
changed to e91b0e0000,90909090

Here's what the sea looks like, waves are less pronounced than normal but still there. Notice that despite the rain, the water's surface isn't speckly (it would be with pixel shading enabled). There's also a shark visible in the first image, in front of the ship. Both ship images are from the same time and place, with the view rotated.
62e1cc7a.jpg
0d450abc.jpg

1f0708a7.jpg


----------------------------------------------------------
On my netbook there are random ntdll crashes. Since I first got the game running with a patched sea.dll, I've been seeing this. I was concerned that the patch itself was causing it, but I ruled out that possibility. The game wont crash when using SwiftShader and the modified sea.dll. So, getting the game to run without SwiftShader exposed another less severe problem somehow related to DirectX.

I'll see what I can do with a debugger to find a fix. If I make any progress, I'll start a new thread for it.
 

Attachments

  • sea_gmafix_hq.7z
    70.7 KB · Views: 2,011
Firstly, hi guys great to join the forum.
I've been following this forum for a long time, seeking an answer to the most annoying problem concerning POTC and the build mods... Engine.exe, and sea.dll. I have tried literally everything to get this working and i mean EVERYTHING i've read on the internet on here etc. Even Swiftshader wouldn't do it for me but as Pieter Boelen asked if someone could confirm this fix works on Intel graphics computer, i may be able to help as it does! It's been years since i've been able to play this game and the sea.dll change via hex editor does indeed work! Personally i'd say this is headline news but I've been searching for a fix for yonks! So THANK YOU VERY MUCH to amplificar.

This really is a problem which has dogged players for years on newer computers to see a fix is truly a light at the end of the tunnel, hope this confirms the fix is legit!

I know i'm going on but i really want to exaggerate this sorted the problem instantly, it wasn't a faulty install, it doesn't matter that it's not in the DES exemption mode, and compatiability mode made no difference. This really is a game changer!

Thanks Guys! AHOY

Specs are:
Intel(R) HD Graphics Family
Windows 7 Professional 64-Bit
Latitude E5420
Intel(R) Core
DirectX 11
 
This is great news indeed amplificar! This could certainly breath some new life into this almost 10 year old game, and hopefluly even spark a bit of a modding renascence!

I do have a couple of questions though, you say you have disabled routines before and after, does this fix disable the shaders only for sea effects? Can you specify what routines were disabled?

In that last picture, it appears that the oily water effect is still there, is that as prevalent as it was before the fix? Or is that just a lighting anomaly?

Ahoy Robert Franklin, welcome aboard mate! :dance

I am glad that you are finally able to play this game after all these years, and thanks very much for confirming this! It is very much appreciated! I do have a couple of questions for you as well, are you seeing any of the oily water effects in your game? Are you seeing any other strange graphics artifacts that may be related to this?
 
This is great news indeed amplificar! This could certainly breath some new life into this almost 10 year old game, and hopefluly even spark a bit of a modding renascence!

I do have a couple of questions though, you say you have disabled routines before and after, does this fix disable the shaders only for sea effects? Can you specify what routines were disabled?

In that last picture, it appears that the oily water effect is still there, is that as prevalent as it was before the fix? Or is that just a lighting anomaly?

Ahoy Robert Franklin, welcome aboard mate! :dance

I am glad that you are finally able to play this game after all these years, and thanks very much for confirming this! It is very much appreciated! I do have a couple of questions for you as well, are you seeing any of the oily water effects in your game? Are you seeing any other strange graphics artifacts that may be related to this?



With regards to the graphics the only thing i can notice is the sea, being as said like an oil slick, however, with the first modification of sea.dll, the rain is splashing in the sea, there is an environment etc. If anything, the sea graphics are only noticeable when in Port when in sail they are much less noticeable.
Though with amplificar's second mod, the sea is much more like in the original game, however weather effects are not having an effect on the water's surface.

Other then the sea, there are no noticeable graphical errors apart from the sea, if anything the game seems to run smoother then before, if that is even possible!
 
The oil effect is still there, and definitely is a lighting anomaly. Without the ridges and softening of the waves from pixel shaders, the lighting of the water makes some sharp color contrasts.

does this fix disable the shaders only for sea effects?
Yes, the sea was where pixel shaders crashed. They work everywhere else. The sea uses the most elaborate pixel shading in the game by far (I think reflections on the water or sea foam were the problem).

It's possible that a superior fix could be created by "simplifying" the bad shader (instead of disabling it in the program's code). I wont be able to try that unless I find time, and I don't know exactly which shader is causing the problems. With either of the patched DLLs, the "bad" shader isn't being used, so one or more of the .sha files could be removed without affecting the game, thus identifying it.

Shader techniques are located in MODULES/techniques/*.sha
It looks like there's some interesting relevant stuff in MODULES/techniques/Weather/Shaders/

There appear to be specialized shaders for different graphics hardware (xbox, gfx, ati ~ and one of those may be getting used incompatibly for intel?)

Can you specify what routines were disabled?
The very last four routines that set up the appearance and behavior of the sea's surface. The spot where it crashed with intel graphics was in the second one out of the four.

call [edx+168h] (it might vary; initialization stuff)
call sea+1110 (bump maps, shaders; creating reflections on the sea's grid?)
call sea+2690 (it's a bunch of calls back to the game engine - finding stuff to reflect off the sea?)
call sea+1000 (many, many calls to DX8Render!DMAInterface+132e,137b,136a,3187c,70,3c178,...)

The game engine calls the DMAInterface of sea at offset 3965 (engine+3b060 -> sea!DMAInterface+3965). That's when everything graphical starts being created for the sea. For people with SwiftShader, Intel or ATI graphics, 3965 continues until 3b06 (then it returns to engine+3b060), but with intel graphics it crashes near 3ad5. I rewrote it to skip over 3ad5 to 3b06 (the callee cleanup & return is actually at 48f5, but 3b06 jumps to 48f5).

Most names are not left in when an application gets compiled, unless they have a special purpose. Every DLL inside the MODULES folder has symbolic export named DMAInterface. The Storm Engine is general purpose, so the DLLs and PROGRAMS would vary from one game to another. Engine.exe will try loading every DLL inside MODULES by calling their DMAInterface. That way, DLLs aren't limited to certain filenames, the same identical structure, size or number of routines and developing with the Storm Engine is more flexible as a result. For example, create a text file in the MODULES folder and rename it "test.dll", when the game is launched it'll know about the new file and complain it isn't useable. Using a compiler to create an actual DLL with the export DMAInterface should cause the code in it to be run.
 
LOL i just downloaded it and gave this a try with my intel HD 4000 processore graphics. It loaded perfect but after lookin at the sea i found that a portion of the sea was completely white with purple and red. If somebody could tell me how to post a screenshot i could give more detail. It could be some weird reflection though.
 
Press the F8 key (repeatedly if necessary), a .tga file will be created in your PotC game's folder. The filename will say "seadogs_####.tga". Then you'll need to convert it to a jpeg, host it someplace online and link it to a post.
 
Thanks for the explanation amplificar, I think i understand a bit better now exactly what is going on and why this crash happens. There are a lot more people around here that understand the game far better than I do. Hopefully they can be of much more help to you in tracking down the exact cause. I wish now that I had an Intel graphics platform that I could do some testing on. I am sure there is a permanent fix here somewhere, it's just a matter of tracking it down. :modding

JackSwarrow, thanks for the screen shot mate! It's information like that that will hopefully help us track it down. Were you able to play the game on your HD 4000 before with Swiftshader? If so, how does the performance compare now, other than the minor graphics glitch?
 
While... i never played the game with swiftshader with my intel card because my lappy also comes with an nVidia card (Geforce GT630M 2GB) If you want i install SS and compare :).
 
Ahhh, ok, dual platform. It's probably not really necessary mate, I was just curious how much the difference was. I have never played with Swiftshader either, my laptop has a dedicated ATI chipset.
 
Back
Top