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.16k stars 83 forks source link

Questions regarding SimCity 4 #156

Closed sjkorvin closed 1 year ago

sjkorvin commented 1 year ago

Hello. I have built DxWrapper from the latest code as of today, August 23, 2022. Everything works fine in SimCity 4 from GOG on Windows 11 with my configuration. I have a few questions, however. All my searches show that SimCity 4 is a DirectX 7 game. Along with dxwrapper.dll, I have copied d3d8.dll, d3d9.dll, ddraw.dll, and dinput8.dll to the game's .exe directory.

Please find my configuration directly below. My questions will follow the configuration.

;; Config file for DirectX DLL Wrapper
;;
;; For details, see: https://github.com/elishacloud/dxwrapper/wiki/Configuration
;;
[General]
RealDllPath                = AUTO
WrapperMode                = AUTO
LoadCustomDllPath          = 
ExcludeProcess             = 
IncludeProcess             = 
RunProcess                 = 
WaitForProcess             = 0
DisableLogging             = 0

[Plugins]
LoadPlugins                = 0
LoadFromScriptsOnly        = 0

[Compatibility]
Dd7to9                     = 0
D3d8to9                    = 1
DDrawCompat                = 0
DisableHighDPIScaling      = 0
Dinputto8                  = 1
DisableGameUX              = 1
DxWnd                      = 0
EnableDdrawWrapper         = 1
EnableD3d9Wrapper          = 1
EnableDinput8Wrapper       = 1
EnableDsoundWrapper        = 0
HandleExceptions           = 1
SingleProcAffinity         = 4

[DDrawCompat]
DDrawCompat20              = 0
DDrawCompat21              = 0
DDrawCompat31              = 0
DDrawCompatDisableGDIHook  = 0
DDrawCompatNoProcAffinity  = 0

[ddraw]
ConvertToDirectDraw7       = 1
ConvertToDirect3D7         = 1
DdrawFixByteAlignment      = 0
DdrawOverrideBitMode       = 0

[Dd7to9]
AutoFrameSkip              = 0
DdrawEmulateSurface        = 0
DdrawRemoveScanlines       = 0
DdrawReadFromGDI           = 0
DdrawWriteToGDI            = 0
DdrawLimitDisplayModeCount = 0
DdrawUseNativeResolution   = 0
DdrawClippedWidth          = 0
DdrawClippedHeight         = 0
DdrawOverrideWidth         = 0
DdrawOverrideHeight        = 0
DdrawOverrideRefreshRate   = 0
DdrawIntegerScalingClamp   = 0
DdrawMaintainAspectRatio   = 0

[d3d9]
AnisotropicFiltering       = 1
AntiAliasing               = 1
CacheClipPlane             = 0
EnableVSync                = 0
EnableWindowMode           = 0
ForceMixedVertexProcessing = 0
ForceSystemMemVertexCache  = 0
ForceVsyncMode             = 0
FullscreenWindowMode       = 0
WindowModeBorder           = 0

[FullScreen]
FullScreen                 = 0
ForceWindowResize          = 0
SendAltEnter               = 0
WaitForWindowChanges       = 0
LoopSleepTime              = 120
WindowSleepTime            = 500
SetFullScreenLayer         = 0
SetNamedLayer              = 
IgnoreWindowName           = 

[dinput8]
FilterNonActiveInput       = 0

[dsound]
Num2DBuffers               = 0
Num3DBuffers               = 0
ForceCertification         = 0
ForceExclusiveMode         = 0
ForceSoftwareMixing        = 0
ForceHardwareMixing        = 0
ForceHQ3DSoftMixing        = 0
ForceNonStaticBuffers      = 0
ForceVoiceManagement       = 0
ForcePrimaryBufferFormat   = 0
PrimaryBufferBits          = 16
PrimaryBufferSamples       = 44100
PrimaryBufferChannels      = 2
AudioClipDetection         = 0

I'm having difficulty understanding why instructions have advised that I copy d3d8.dll to the game's .exe directory when the game is a DirectX 7 game. Also, would enabling D3d8to9 do anything if the game uses DirectX 7?

The SimCity 4 community recommends enabling Dinputto8 to avoid certain double input. Thus, I determined that I should enable EnableDinput8Wrapper as well. Is that correct?

The documentation for DxWrapper says that enabling both EnableDdrawWrapper and EnableD3d9Wrapper provides bugfixes. Thus, I enabled them both. Are the D3D9 bugfixes only present in native Direct3D 9 games or are they also present if an older Direct3D version is translated to Direct3D 9?

ConvertToDirectDraw7 and ConvertToDirect3D7 are clearly doing something according to my DxWrapper log. Is it useless to enable them if the game is already a DirectX 7 game? After looking things up, I saw that DirectDraw 7 was included with DirectX 7.

I don't know if AnisotropicFiltering and AntiAliasing are doing anything. Is it possible for them to do something with a DirectX 7 game using the configuration that I described above?

Finally, have I copied the correct DLLs if I am trying to get a DirectX 7 game that uses DirectDraw as well as Direct3D to function properly? I use a 4K display and DxWrapper allows me to play SimCity 4 in 4K.

Thank you so much. Please find my log attached.

dxwrapper-simcity 4.log

elishacloud commented 1 year ago

Along with dxwrapper.dll, I have copied d3d8.dll, d3d9.dll, ddraw.dll, and dinput8.dll to the game's .exe directory.

You probably only need the ddraw.dll stub and dxwrapper.dll. The other dll files you can get rid of. After deleting those dll files you can check the log file to see if the dxwrapper is still working,

Also, would enabling D3d8to9 do anything if the game uses DirectX 7?

According to the log, the game appears to already use DirectX 7 so D3d8to9, EnableD3d9Wrapper, ConvertToDirectDraw7, ConvertToDirect3D7, AnisotropicFiltering, and AntiAliasing are not doing anything.

I determined that I should enable EnableDinput8Wrapper as well. Is that correct?

You don't need to have EnableDinput8Wrapper enabled. Currently it is only needed if you want to enable FilterNonActiveInput, which is not needed for this game. Also, since you are using Dinputto8 it should be going through the DirectInput 8 wrapper already.

Are the D3D9 bugfixes only present in native Direct3D 9 games or are they also present if an older Direct3D version is translated to Direct3D 9?

Yes, only native d3d9 games require these fixes.

I don't know if AnisotropicFiltering and AntiAliasing are doing anything. Is it possible for them to do something with a DirectX 7 game using the configuration that I described above?

Those options only work with d3d9 games or 3D games converted to d3d9.

have I copied the correct DLLs if I am trying to get a DirectX 7 game that uses DirectDraw as well as Direct3D to function properly?

From the log file it looks like the game only uses DirectDraw 7 not Direct3D 7. This is only a 2D game. Any 3D visuals in this game are done by software, which means they cannot take advantage of any 3D DirectX features even if they are converted to d3d9.

elishacloud commented 1 year ago

I'm having difficulty understanding why instructions have advised that I copy d3d8.dll to the game's .exe directory when the game is a DirectX 7 game.

I have seen some games that statically link to d3d8.dll even though they are only DirectX 7 games. I am not sure if this is the case with SimCity 4 or not, but you can test with and without d3d8.dll to see if it works. Keep in mind that you only need a single stub dll in addition to dxwrapper.dll. If ddraw.dll works then you don't need d3d8.dll.

sjkorvin commented 1 year ago

Thank you so much for your answers. I have HandleExceptions enabled "just in case." I'm not sure if it's actually doing anything.

As per your answers, I have disabled EnableDinput8Wrapper, D3d8to9, EnableD3d9Wrapper, ConvertToDirectDraw7, ConvertToDirect3D7, AnisotropicFiltering, and AntiAliasing.

I have also removed d3d8.dll, d3d9.dll, and dinput8.dll, leaving only ddraw.dll and dxwrapper.dll as the only DLLs in the game's .exe directory.

Having made these changes, the game still successfully runs in 4K.

If I enable Dinputto8, then do I need dinput8.dll in the game's .exe directory or is dinput8.dll for games that natively support dinput8? Based on the following lines in my latest log file, it seems to me that the system's dinput DLLs are being used and thus, dinput8.dll is not needed in the game's .exe directory.

22516 20:01:05.739 Enabling dinputto8 wrapper
22516 20:01:05.739 Loading 'dinput.dll'...
22516 20:01:05.739 Loaded library: C:\Windows\system32\dinput.dll
22516 20:01:05.739 Hooking dinput.dll APIs...
22516 20:01:05.739 Enabling dinput8 wrapper
22516 20:01:05.739 Loading 'dinput8.dll'...
22516 20:01:05.739 Loaded library: C:\Windows\system32\dinput8.dll

Thank you again for all of your answers. For reference, I would like to post screenshots of this issue on the Simtropolis forums. Would you agree to that? Thank you again.

elishacloud commented 1 year ago

I have HandleExceptions enabled "just in case." I'm not sure if it's actually doing anything.

I don't think that is doing anything. There would be log events if it does anything. But, it's not going to hurt to leave it enabled.

If I enable Dinputto8, then do I need dinput8.dll in the game's .exe directory or is dinput8.dll for games that natively support dinput8?

You don't need dinput8.dll in the game's .exe directory. The dinput8.dll is just a stub to load dxwrapper. However, you already have ddraw.dll for that.

it seems to me that the system's dinput DLLs are being used and thus, dinput8.dll is not needed in the game's .exe directory.

Correct.

I would like to post screenshots of this issue on the Simtropolis forums. Would you agree to that?

Yes, that is fine.

sjkorvin commented 1 year ago

Thank you so much. All of my questions are answered. I will now close this issue.