elishacloud / dxwrapper

Fixes compatibility issues with older games running on Windows 10/11 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
zlib License
1.23k stars 90 forks source link

Visual artifacts in Baldurs Gate 2 - Possibly a regression #218

Closed rebb closed 1 year ago

rebb commented 1 year ago

The character sprites in Baldurs Gate 2 ( not the Enhanced Edition ) are showing visual artifacts with the latest dxwrapper code. These artifacts are absent in the official dxwrapper release from 2021.

Here's a picture of the problem.

dxwrapper_baldursgate_issue

Notice the glitchy 1 pixel wide vertical bars running along the character sprites. ( Not the rain drops ;) )

I investigated this a bit and it seems that changes in commit a38c6d11 introduced the problem.

It's somewhere in the CopySurface() function, but i have no idea at the moment on how to possibly fix this, and it's late so i'll drop an issue report just in case :)

DdrawFixByteAlignment=1 does not seem to help unfortunately

elishacloud commented 1 year ago

Thanks for the report. It looks like an extra line is getting copied here for some reason. I will look at this in a little while.

rebb commented 1 year ago

Thank you :)

I forgot to mention the INI settings used, here they are.

[Compatibility]
Dd7to9=1

[d3d9]
EnableWindowMode=1

The problem also shows in fullscreen mode though.

rebb commented 1 year ago

Looks like the fix is very simple. I noticed it only happened on sprites that "looked the other way". The code in CopySurface inverts the pixel read for mirrored sprites, but is apparently off-by-one.

Changing the instances of

IsMirrorLeftRight ? DestRectWidth - x : x

to

IsMirrorLeftRight ? DestRectWidth - x - 1 : x

fixed the problem here.

elishacloud commented 1 year ago

Good catch! It looks like there are 4 lines with that same issue. If you want to create a pull request I will merge it.

rebb commented 1 year ago

Ok :)

Btw, should the BuildNo.rc be included in the Pull Request or left out ?

Edit : Well, left it out for now. Pull Request is #220

elishacloud commented 1 year ago

Yes, I just bump the build number so that I can keep track of it if I give out a build to someone. It doesn't need to be updated. Thanks!

BTW: I implemented it correctly here, which is why it worked in the official release.