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.15k stars 82 forks source link

Mech Commander Issue #222

Closed rebb closed 1 month ago

rebb commented 10 months ago

Mech Commander crashes with an Unhandled Exception ( Access Violation ) after the intro movie, in Windowed Mode. Fullscreen appears to work though.

My Debug-Fu is weak, so i couldn't get too far trying to figure out what the problem is, only that it happens after a LockRect() somewhere, according to the log file.

It also looks like the game is using DirectX v1 and v2, not sure how well these are supported or if they need any extra specialized precautions.

INI settings :

[Compatibility]
Dd7to9=1

[d3d9]
EnableWindowMode=1

Log File : dxwrapper-mcx.zip

The last few lines of the log, just in case something about them might be immediately obvious as to what the issue might be :

10284 18:04:29.241 m_IDirectDrawX::Present (005C1E00)
10284 18:04:29.241 m_IDirectDrawX::WaitForVerticalBlank (005C1E00)
10284 18:04:29.241 m_IDirect3DDevice9Ex::GetRasterStatus (057E7748)
10284 18:04:29.251 m_IDirectDrawX::TestCooperativeLevel (005C1E00)
10284 18:04:29.252 m_IDirect3DDevice9Ex::TestCooperativeLevel (057E7748)
8600 18:04:29.252 m_IDirect3DDevice9Ex::Present (057E7748)
14036 18:04:29.260 m_IDirectDrawSurfaceX::Lock (0743AAD0)
14036 18:04:29.260 m_IDirectDrawSurfaceX::Lock2 (0743AAD0)
14036 18:04:29.260 m_IDirect3DDevice9Ex::TestCooperativeLevel (057E7748)
14036 18:04:29.260 m_IDirect3DTexture9::LockRect (0740CE78)
elishacloud commented 10 months ago

It could be attempting to write to the surface outside of the d3d9 surface. With DirectDraw in Window mode the primary surface is sometimes the size of the full screen, whereas with dd7to9 the primary surface is usually only the size of the game window. For dd7to9 it is recommended to set the in-game settings to fullscreen mode, rather than windowed mode. I plan to fully support windowed mode at some point, but currently I have focused most of my effort on fullscreen mode.

rebb commented 10 months ago

Nice, it seems this is related to the issue.

The crash won't happen when setting the initial window position to 0, 0 :open_mouth:

However for some reason the Width/Height will not override with this game :thinking:

In any case, something was learned :) Thanks !

mr-mugp commented 10 months ago

Thanks for your efforts, and hope to see a fully supported window mode sooner

elishacloud commented 10 months ago

If the game is only using 2D DirectDraw and not Direct3D you could try enabling the following settings:

DdrawEmulateSurface = 1
DdrawWriteToGDI = 1
elishacloud commented 10 months ago

Ok, try this update. I added basic window support. Note: when using in-game windowed mode you should enable DdrawUseNativeResolution.

Here is the update: dxwrapper.zip

rebb commented 9 months ago

Cool, i'll check it out tomorrow :)

Windowed mode seemed to work fine for other games ( Baldurs Gate 1 and 2, Arcanum ), but Mech Commander had this problem.

I've been locally messing around with some windowed mode related code stuff too, but i'm just hacking at things and probably doing it all wrong :)

elishacloud commented 9 months ago

The latest build should fix most of the issues with windowed mode. Here is the build: dxwrapper.zip

rebb commented 9 months ago

Sorry for the lack of feedback on this, i've been getting kinda sidetracked.

I tried the newer version and it seems to fix this particular problem :) Thanks

However some others still remain, but maybe it's better to open a new issue for them ? I've been poking at some of those, and found some "solutions" that kinda work, but are probably too hacky.

Not sure where to discuss them though. At this point i don't think they good enough for a Pull Request.

elishacloud commented 9 months ago

Sure, start a new issue and list what issues you have and what fixes you found.

elishacloud commented 1 month ago

Closing this issue for now. If you have more fixed or updates you can reopen this.