narzoul / DDrawCompat

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

Question about WarGames and timeBeginPeriod(1); #268

Closed elishacloud closed 7 months ago

elishacloud commented 7 months ago

I am writing a tool that attempts to convert the ddraw/Direct3D functions to Direct3D9. As part of this work I ran into an issue with WarGames where it would hang for about 15 seconds or so right after the mission briefing and before starting the mission.

However, I discovered that it could be fixed by this line of code from DDrawCompat v0.3.2. I am wondering why this line of code would prevent the game from hanging for 15 seconds, if you have any ideas.

Also, I see the timeBeginPeriod() called in DDrawCompat, but I cannot find the timeEndPeriod() call, which Microsoft's documentation says must exist:

You must match each call to timeBeginPeriod with a call to timeEndPeriod, specifying the same minimum resolution in both calls. An application can make multiple timeBeginPeriod calls as long as each call is matched with a call to timeEndPeriod.

narzoul commented 7 months ago

This article probably explains what might be the problem better than I could: https://randomascii.wordpress.com/2020/10/04/windows-timer-resolution-the-great-rule-change/

Also, I see the timeBeginPeriod() called in DDrawCompat, but I cannot find the timeEndPeriod() call, which Microsoft's documentation says must exist:

Pretty sure it's cleaned up on process exit anyway. (It would be pretty bad if it wasn't, since a crashing app can't clean up such things anyway). I think that note is mainly meant for apps that intend to continue running afterwards, when they don't need the increased timer granularity anymore, in which case this can save system resources.

elishacloud commented 7 months ago

I see. Thanks for the article link!