narzoul / DDrawCompat

DirectDraw and Direct3D 1-7 compatibility, performance and visual enhancements for Windows Vista, 7, 8, 10 and 11
BSD Zero Clause License
925 stars 70 forks source link

Sim City 4 - Mouse Cursor disappears #85

Closed kocane closed 3 years ago

kocane commented 3 years ago

First of all, thank you for your work.

Seemingly, this improves the performance in SC4 greatly but sadly in my case, it also makes the cursor disappear.

I'm running the game in 1920x1080p with SC4Launcher, in DirectX Hardware mode but also tried without SC4Launcher and any of the 'Compatibility-mode' tweaks it applies (0a0c 18:22:32.041 Environment variable __COMPAT_LAYER = "DWM8And16BitMitigation), but the result is the same. In Windowed mode, all is good.

I'd alternatively run windowed mode borderless but sadly the game doesn't go above 1080p and my monitor is 1440p.

This is the log:

37b4 18:10:09.023 Process path: X:\Games\SimCity 4\Apps\SimCity 4.exe
37b4 18:10:09.023 Environment variable __COMPAT_LAYER = "DWM8And16BitMitigation WinXPSp3 HighDpiAware RunAsAdmin"
37b4 18:10:09.023 Loading DDrawCompat dynamically from X:\Games\SimCity 4\Apps\DDRAW.DLL
37b4 18:10:09.025 DDrawCompat loaded successfully
37b4 18:10:09.025 Installing display mode hooks
37b4 18:10:09.025 Installing registry hooks
37b4 18:10:09.025 Installing Direct3D driver hooks
37b4 18:10:09.025 Installing Win32 hooks
37b4 18:10:09.050 Hooking user mode display driver: C:\Windows\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_9cb6a07d60163933\nvldumd.dll
37b4 18:10:09.099 Dynamic vertex buffers are available
37b4 18:10:09.099 Dynamic index buffers are available
37b4 18:10:09.101 Checking source color key support: passed
37b4 18:10:09.104 Installing DirectDraw hooks
37b4 18:10:09.104 Installing Direct3D hooks
37b4 18:10:09.107 Installing GDI hooks
37b4 18:10:09.167 Finished installing hooks
37b4 18:10:38.163 Detaching DDrawCompat due to process termination
37b4 18:10:38.163 DDrawCompat detached successfully

Any idea?

narzoul commented 3 years ago

I can't reproduce the issue using the GOG version (SimCity 4 Deluxe Edition), with or without SC4Launcher. Do you do something specific when the cursor disappears, or is it missing from the start? Are all cursors missing or only specific ones? Have you tried toggling the "color cursor" setting in the game?

Edit: Are you using Windows 10 or something older?

kocane commented 3 years ago

@narzoul It's missing from the start. I can actually point around but not see the cursor. I've tried toggliing the one cursor related setting in the game. It's just the main cursor (black with white edge) that is affected. I tried reinstalling the game (GOG version as well) along with any settings and configurations (in Documents folder) and the result is the same. I'm on Windows 10 build 2004.

narzoul commented 3 years ago

That's strange. I don't see anything special about the main cursor. It's loaded and set the same way as all the others.

I added some extra debug logs for the cursor related functions on top of the current experimental release (4370990) with the following diff: diff.txt And here's the ReleaseWithDebugLogs build of the same: ddraw.zip

Please run the game with it once, then compress and attach the DDrawCompat-SimCity 4.log file. Skip the intro and exit from the main menu as soon as possible to keep the log size to a minimum.

It will also dump all of the cursor images that the game loads, next to the executable. The main cursor should be in the first file, 1.cur. Does it show up properly in explorer or an image viewer?

kocane commented 3 years ago

@narzoul- When launching the game, the cursor appears VERY briefly, just before the EA intro comes on.

The .ico file also seems to be present: image

Here's a compressed zip with the log. DDrawCompat-SimCity 4.zip

Thanks!

narzoul commented 3 years ago

I could not yet find anything suspicious in the logs either. Have you tried DDrawCompat v0.2.1? Does it have the same problem?

By the way, do you have a flickering black box at the top left corner of the screen while the videos are playing? I have that with the experimental version, but not with v0.2.1. Another issue to investigate...

narzoul commented 3 years ago

Some additional ideas to try:

  1. Disable DDB to DIB redirection in LoadCursorFromFileA: diff.txt, ddraw.zip
  2. Suppress repeated identical SetCursor calls: diff.txt, ddraw.zip

Both of them are long shots (the second more so than the first), but I have no idea what else it could be. Maybe it's some third party program interfering, or NVIDIA drivers. It would be nice if someone else with the same drivers could comment.

kocane commented 3 years ago

@narzoul Maybe I should've done this from the start but I began closing all apps I had running and discovered that the issue didn't occur suddenly. I narrowed it down to f.lux. I've no idea why f.lux only causes trouble when using your ddraw, but at least it's possible to do something about it.

Some additional ideas to try:

1. Disable DDB to DIB redirection in LoadCursorFromFileA: [diff.txt](https://github.com/narzoul/DDrawCompat/files/5777935/diff.txt), [ddraw.zip](https://github.com/narzoul/DDrawCompat/files/5777937/ddraw.zip)

2. Suppress repeated identical SetCursor calls: [diff.txt](https://github.com/narzoul/DDrawCompat/files/5777946/diff.txt), [ddraw.zip](https://github.com/narzoul/DDrawCompat/files/5777954/ddraw.zip)

Both of them are long shots (the second more so than the first), but I have no idea what else it could be. Maybe it's some third party program interfering, or NVIDIA drivers. It would be nice if someone else with the same drivers could comment.

I tried both of these and the result is the same.

By the way, do you have a flickering black box at the top left corner of the screen while the videos are playing? I have that with the experimental version, but not with v0.2.1. Another issue to investigate...

Yup, I get the flickering on top of the EA logo (maybe Maxis logo too but it's black so I can't see?). I also tried 0.2.1 and it acted the same in all regards.

I don't know if we should just close the issue and blame it on f.lux for whatever reasons.

narzoul commented 3 years ago

Now that you found the culprit, I found some info about it here: https://godotengine.org/qa/56634/why-is-my-cursor-invisible-in-fullscreen Do you have the "Software mouse cursor when needed" option enabled? Does disabling it help?

Anyway, it's probably a bug in how f.lux overwrites the cursor then. I assume you could reproduce it without DDrawCompat also by enabling exclusive full screen mode via Microsoft Application Compatibility Toolkit.

Keep this issue open until I figure out what causes the flickering black box at least. Or we can open a separate issue for that.

kocane commented 3 years ago

Yup, it's the "software mouse cursor when needed" that causes the issue when enabled. Good to know!

Maybe the issue could be renamed to just "Sim City 4" to make it more generic.

Now I don't know if it could be considered an issue but some other ddraw wrappers allow Sim City 4 to start with resolutions higher than 1080p, for instance 1440p. By default, and with your ddraw.dll, it instantly crashes. But as explained by this guy in this thread (and elsewhere), other wrappers allow for using a higher resolution but they do not beat yours in performance.

I don't know how much can actually be improved by simply modifying the ddraw.dll but if there was a game that was ever in need of a performance boost on moder hardware, it's gotta be Sim City 4.

narzoul commented 3 years ago

Resolution is limited by the native Direct3D 7 and older APIs. There is a hack to allow higher resolutions here: https://github.com/UCyborg/LegacyD3DResolutionHack I haven't tested it since all of my monitors are full HD only, but I see no reason why it shouldn't work together with DDrawCompat.

kocane commented 3 years ago

I suppose it could be an interesting addition. I could test it, if need be.

narzoul commented 3 years ago

I've fixed the flickering black box issue and also removed the resolution limitation in the latest experimental release.