🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Untitled

posted in DruinkJournal
Published October 16, 2007
Advertisement
Ok, I got distracted by things again. In the process of tinkering with my DirectSound proxy stuff for Dungeon Keeper 2 (Which still stutters and garbles), I thought it'd be nice to be able to run Dungeon Keeper 2 in windowed mode, since it doesn't support that or event alt+tabbing (Yay for multimonitor debugging).

When I started, I thought it'd just be a case of changing the calls to IDirectDraw7::SetCooperativeLevel and IDirectDraw7::SetDisplayMode to prevent it going fullscreen.
Unfortunately, the game doesn't use DDraw7, it creates a IDirectDraw interface instead, and calls it's version of functions. Also, changing the cooperative level prevents the game from making a swap chain, so I had to make my own swap chain class which is a IDirectDrawSurface proxy, and manages two real surfaces internally, calling Blt() when Flip() is called.
That also worked, but it left huge black smears over the desktop. So I added a clipper, which sorted that.

My current problem is that the game crashes reading some weird address (somewhere above 0xe0000000, which makes me think it's a surface lock (it's in kernel space) or a completely borked address). The call stack says that the crash happens in _DD_Surface_BltFast, but nothing calls my version of that. After a bit of poking about, it turns out that there were some QueryInterface() calls I didn't spot, where the game asks for an IDirectDraw2 interface, a IDirectDraw4 interface, a IDirectDrawSurface2 interface and a IDirectDrawSurface4 interface, as well as a couple of D3D ones.

So, I need to implement proxy classes for those interfaces too. I'll probably just end up making a version 4 interface and casting it to the "lower" interfaces, since the vtable is backwards compatible (But v4 interfaces take IDirectDrawSurface4* parameters and so on, meaning I need to cast bits and pieces).

Another problem is that the window style is still WS_POPUPWINDOW, and I'd like to make it WS_OVERLAPPEDWINDOW, but I can see that having all sorts of issues, so I might end up subclassing the window.

And yes, I know this is complete and utter overkill. My reasoning is that if I can get this working fully, I can make windowed mode versions of any game using D3D7 or below. Which would be nice. But also pointless.

Oh well. It's after midnight, and I've just realised I forgot to eat this evening. And I forgot to watch Heroes.

*Sigh*
Previous Entry Untitled
Next Entry Untitled
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement