Diablo II - Lord of Destruction Expansion

Gavriel State gav at transgaming.com
Mon Jul 30 21:27:40 CDT 2001

Bjorn Wesen wrote:
> Bjorn wrote:
> > I'll see if I can hack something out of it.. waiting for winex to
> > compile but since there are almost no diffs in the actual ddraw code
> > between the winex and winehq versions I don't expect miracles
> Right, the winex version didn't work either and in fact it didn't work
> without DGA either (probably because the winehq version didn't work
> until after june and the winex version is not synced after that).

Hrm - that's not good.  We haven't played with the LOD expansion pack
yet, but the base games should work fine in non-DGA mode.  I'm surprised 
that there were changes that broke in the expansion pack.  We'll have a 
look at it asap.

In the meantime, rather than playing with DGA mode, edit the ddraw/
dsurface/user.c file and look for the following :

  /* if you use OWN_WINDOW, don't use SYNC_UPDATE, or you may get trouble */
  /* #define SYNC_UPDATE */
  #define OWN_WINDOW

This activates code that forces all refresh events for ddraw to happen
in a seperate 'update thread'.  This is needed mostly for games that
draw directly to the ddraw primary surface.  Games like Diablo 2 that
use backbuffers properly sometimes have trouble with this, as the 
updates don't happen when the game expects them to.  At OLS we put
together a fix for this that's just been committed to WineX CVS but
which probably won't make it into WineHQ CVS until we do our next
merge (after WineHQ has stabilized a bit more).  Rather than wait for
the proper fix, you can simply turn off the update thread altogether 
by changing the defines above to read:

 #define SYNC_UPDATE
 /* #define OWN_WINDOW */

Or, if you want to try the proper fix, I've included it below.  This is
a patch against the then-current WineX cvs, so you may have to do some
editing to prep it for WineHQ.

As far as the DGA palette stuff goes, I'll leave it up to Ove to have 
a look at when he gets sufficiently in need of a break from the 
InstallShield stuff he's working on right now.


Index: user.c
RCS file: /cvsroot/winex/wine/dlls/ddraw/dsurface/user.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- user.c      2001/05/05 19:36:54     1.44
+++ user.c      2001/07/27 21:49:52     1.45
@@ -182,6 +182,36 @@
+static int User_DirectDrawSurface_init_wait(IDirectDrawSurfaceImpl* This)
+    USER_PRIV_VAR(priv, This);
+    int need_wait;
+    EnterCriticalSection(&priv->user.crit);
+    priv->user.wait_count++;
+    need_wait = priv->user.in_refresh;
+    LeaveCriticalSection(&priv->user.crit);
+    return need_wait;
+static void User_DirectDrawSurface_end_wait(IDirectDrawSurfaceImpl* This)
+    USER_PRIV_VAR(priv, This);
+    EnterCriticalSection(&priv->user.crit);
+    if (!--priv->user.wait_count)
+       ResetEvent(priv->user.refresh_event);
+    LeaveCriticalSection(&priv->user.crit);
+static void User_DirectDrawSurface_wait_update(IDirectDrawSurfaceImpl* This)
+    USER_PRIV_VAR(priv, This);
+    if (priv->user.in_refresh) {
+       if (User_DirectDrawSurface_init_wait(This))
+           WaitForSingleObject(priv->user.refresh_event, INFINITE);
+       User_DirectDrawSurface_end_wait(This);
+    }
 void User_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
                                        LPCRECT pRect, DWORD dwFlags)
@@ -189,19 +219,7 @@
 #if 0
     User_copy_from_screen(This, pRect);
-    if ((dwFlags & DDLOCK_WAIT) && priv->user.in_refresh) {
-       int need_wait;
-       EnterCriticalSection(&priv->user.crit);
-       priv->user.wait_count++;
-       need_wait = priv->user.in_refresh;
-       LeaveCriticalSection(&priv->user.crit);
-       if (need_wait)
-           WaitForSingleObject(priv->user.refresh_event, INFINITE);
-       EnterCriticalSection(&priv->user.crit);
-       if (!--priv->user.wait_count)
-           ResetEvent(priv->user.refresh_event);
-       LeaveCriticalSection(&priv->user.crit);
-    }
+    if (dwFlags & DDLOCK_WAIT) User_DirectDrawSurface_wait_update(This);
 void User_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
@@ -281,7 +299,12 @@
     USER_PRIV_VAR(priv, This);
     assert(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE);
+    if (dwFlags & DDFLIP_WAIT) User_DirectDrawSurface_init_wait(This);
+    if (dwFlags & DDFLIP_WAIT) {
+       WaitForSingleObject(priv->user.refresh_event, INFINITE);
+       User_DirectDrawSurface_end_wait(This);
+    }

Gavriel State, CEO
TransGaming Technologies Inc.
gav at transgaming.com

More information about the wine-users mailing list