gho - 2017-03-30

I stumbled into an interesting problem:
trying to run Forsaken HW version (the game comes with two different executables, one for SW emulation and the other using the HW) I got the game crashing because an invalid capability in the zbuffer creation.
Now, this game was a pain because it worked / didn't work depending on the hw, the OS and who knows what else, but the best I got from it was a choppy and slow framerate, with the SW version performing much better.
Digging into the causes of the problem I found that the game was trying to use a zbuffer depth that was not supported, probably because I'm cheating with the game, letting it to believe it can use the video memory while DxWnd moves everything on system memory.
The fix I made queries the DirectDrawSession capabilities, finds out what is the maximum supported zbuffer depth and, in proper conditions, repeat the CreateSurface operation with a valid depth value.
The result was unbelivealy good: not only the game now works, but I could get rid of all "special" flags and get a very fast and smooth framerate.
But the interesting thing is this: since the problem depends on the different capabilities exposed by hardware and software renderers, it is likely that this problem may appear depending on the platform. So, I had one troublesome game that surrended to the fix, but other people?
Here is the fix (a small variation of last v2.04.22 release) to try in difficult cases.

P.s. for those interested in D3DWindower, this seems to be the same approach D3DWindower uses: as soon as it opens a DirectDraw session, it queries the ddraw interfaces (all of them, from version 1 to 7) and gets the session capabilities. I believe it stores them somewhere in order to make wise decisions later on, when this info is needed. The idea seems quite good, I'm planning to apply this whenever it will prove to be useful.

 

Last edit: gho 2017-03-31