Re: [dx8-34 bis] too many things for a subject ;)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

It's a resent of dx8-34 patch refreshed from current cvs + more fixes

Changelog Addons:
 - native support 32 bit support (now application can choose 16 or 32 bit 
suuport) if current resolution is 24 bit (as we can only launch games in 
windowed mode)
 - textures pallettes support
 - fix reflexion placement code (the sdk sample begin to work)
 - fix a stupid crash when using traces in vshaderdeclaration (seen in sdk 
samples)
 - more more readable traces (init/caps)
 - more cubetextures fixes

Regards,
Raphael

> Hi all,
>
>  Here we have a big Patch. Now unreal2 launch (but wiht an very ugly menu),
> UT2003 too (menu good but launching game crash)
>
> WARNING: It must be applied after lasts jason patches.
>
>  Changelop:
>   - more usefull debug functions debug_d3dusage and debug_d3ddevicetype
>   - fix a crash in pixel shader parser (happened with unreal2)
>   - currently desactive pixel shaders caps (with #define) while hw shaders
> code isn't merged
>   - when we have a special debug channel for shader, use it ;)
>   - fix again some stubs return value
>   - more more readable traces now (principaly IDirect3D8 capacities check
> adn surface locking code) using new debug functions (like debug_d3dformat)
> - fix/cleaning the surface locking code (i must find how to do the same
> thing with glPixelStore)
>   - now we support D3DTOP_SUBSTRACT so declare it in caps
>   - now support true 32bit (well X 24 bit can be used as 32 bit in caps
> code). For it extend supported modes and extend some caps validation.
> Now Warcraft3 can use 16bit (as it want it) and Unreal2 can use 32bit (as
> it need it)
>   - first try to get D3DTSS_TCI_CAMERASPACENORMAL and
> D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR looks good:
>  it's the good extensions but we have some placement vector maths error 
> who make max payne very funny (have you ever seen metal mario? ;) )
>
> Todo:
>   - we must have a real supported caps code (ie IDirect3D8Impl_Check*)
>   - fix reflexion placement code (any idea jason ?)
>   - now my kdevelop just finish to build, beautify my ugly tabs in code
>   - fix unreal2 menu. I think we have problems in 32 bit mode as we haven't
> really played with it (max payne continue working well in 32bit)
>
> Regards,
> Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD4DBQE+xlljp7NA3AmQTU4RAhgTAJdhSngfOX5zb5OQ+l9sYFZ7DJwKAJ0RgqjB
P5n5v3cTeqk5c0RGmd5JRQ==
=nXZO
-----END PGP SIGNATURE-----
Index: basetexture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/basetexture.c,v
retrieving revision 1.5
diff -u -r1.5 basetexture.c
--- basetexture.c	8 May 2003 17:36:00 -0000	1.5
+++ basetexture.c	17 May 2003 15:29:52 -0000
@@ -88,11 +88,13 @@
 }
 DWORD    WINAPI        IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew) {
     ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 DWORD    WINAPI        IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface) {
     ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 void     WINAPI        IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface) {
     ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
@@ -107,15 +109,18 @@
 /* IDirect3DBaseTexture8 */
 DWORD    WINAPI        IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew) {
     ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 DWORD    WINAPI        IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface) {
     ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 DWORD    WINAPI        IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface) {
     ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);    
+    return 0;
 }
 
 ICOM_VTABLE(IDirect3DBaseTexture8) Direct3DBaseTexture8_Vtbl =
Index: cubetexture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/cubetexture.c,v
retrieving revision 1.7
diff -u -r1.7 cubetexture.c
--- cubetexture.c	15 May 2003 04:16:47 -0000	1.7
+++ cubetexture.c	17 May 2003 15:29:53 -0000
@@ -138,6 +138,7 @@
     TRACE("(%p) : About to load texture\n", This);
     for (i = 0; i < This->levels; i++) {
       if (i == 0 && This->surfaces[0][i]->textureName != 0 && This->Dirty == FALSE) {
+	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
 #if defined(GL_VERSION_1_3)
 	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
 #else
Index: device.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/device.c,v
retrieving revision 1.57
diff -u -r1.57 device.c
--- device.c	16 May 2003 20:11:14 -0000	1.57
+++ device.c	17 May 2003 15:31:15 -0000
@@ -78,12 +78,43 @@
 
 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
 
+const char* debug_d3ddevicetype(D3DDEVTYPE devtype) {
+  switch (devtype) {
+#define DEVTYPE_TO_STR(dev) case dev: return #dev
+    DEVTYPE_TO_STR(D3DDEVTYPE_HAL);
+    DEVTYPE_TO_STR(D3DDEVTYPE_REF);
+    DEVTYPE_TO_STR(D3DDEVTYPE_SW);    
+#undef DEVTYPE_TO_STR
+  default:
+    FIXME("Unrecognized %u D3DDEVTYPE!\n", devtype);
+    return "unrecognized";
+  }
+}
+
+const char* debug_d3dusage(DWORD usage) {
+  switch (usage) {
+#define D3DUSAGE_TO_STR(u) case u: return #u
+    D3DUSAGE_TO_STR(D3DUSAGE_RENDERTARGET);
+    D3DUSAGE_TO_STR(D3DUSAGE_DEPTHSTENCIL);
+    D3DUSAGE_TO_STR(D3DUSAGE_WRITEONLY);
+    D3DUSAGE_TO_STR(D3DUSAGE_SOFTWAREPROCESSING);
+    D3DUSAGE_TO_STR(D3DUSAGE_DONOTCLIP);
+    D3DUSAGE_TO_STR(D3DUSAGE_POINTS);
+    D3DUSAGE_TO_STR(D3DUSAGE_RTPATCHES);
+    D3DUSAGE_TO_STR(D3DUSAGE_NPATCHES);
+    D3DUSAGE_TO_STR(D3DUSAGE_DYNAMIC);
+#undef D3DUSAGE_TO_STR
+  case 0: return "none";
+  default:
+    FIXME("Unrecognized %lu Usage!\n", usage);
+    return "unrecognized";
+  }
+}
 
 const char* debug_d3dformat(D3DFORMAT fmt) {
   switch (fmt) {
 #define FMT_TO_STR(fmt) case fmt: return #fmt
     FMT_TO_STR(D3DFMT_UNKNOWN);
-
     FMT_TO_STR(D3DFMT_R8G8B8);
     FMT_TO_STR(D3DFMT_A8R8G8B8);
     FMT_TO_STR(D3DFMT_X8R8G8B8);
@@ -95,21 +126,17 @@
     FMT_TO_STR(D3DFMT_A8);
     FMT_TO_STR(D3DFMT_A8R3G3B2);
     FMT_TO_STR(D3DFMT_X4R4G4B4);
-
     FMT_TO_STR(D3DFMT_A8P8);
     FMT_TO_STR(D3DFMT_P8);
-
     FMT_TO_STR(D3DFMT_L8);
     FMT_TO_STR(D3DFMT_A8L8);
     FMT_TO_STR(D3DFMT_A4L4);
-
     FMT_TO_STR(D3DFMT_V8U8);
     FMT_TO_STR(D3DFMT_L6V5U5);
     FMT_TO_STR(D3DFMT_X8L8V8U8);
     FMT_TO_STR(D3DFMT_Q8W8V8U8);
     FMT_TO_STR(D3DFMT_V16U16);
     FMT_TO_STR(D3DFMT_W11V11U10);
-
     FMT_TO_STR(D3DFMT_UYVY);
     FMT_TO_STR(D3DFMT_YUY2);
     FMT_TO_STR(D3DFMT_DXT1);
@@ -117,7 +144,6 @@
     FMT_TO_STR(D3DFMT_DXT3);
     FMT_TO_STR(D3DFMT_DXT4);
     FMT_TO_STR(D3DFMT_DXT5);
-    
     FMT_TO_STR(D3DFMT_D16_LOCKABLE);
     FMT_TO_STR(D3DFMT_D32);
     FMT_TO_STR(D3DFMT_D15S1);
@@ -125,7 +151,6 @@
     FMT_TO_STR(D3DFMT_D16);
     FMT_TO_STR(D3DFMT_D24X8);
     FMT_TO_STR(D3DFMT_D24X4S4);
-
     FMT_TO_STR(D3DFMT_VERTEXDATA);
     FMT_TO_STR(D3DFMT_INDEX16);
     FMT_TO_STR(D3DFMT_INDEX32);
@@ -153,6 +178,22 @@
   }
 }
 
+const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType) {
+  switch (PrimitiveType) {
+#define PRIM_TO_STR(prim) case prim: return #prim;
+    PRIM_TO_STR(D3DPT_POINTLIST);
+    PRIM_TO_STR(D3DPT_LINELIST);
+    PRIM_TO_STR(D3DPT_LINESTRIP);
+    PRIM_TO_STR(D3DPT_TRIANGLELIST);
+    PRIM_TO_STR(D3DPT_TRIANGLESTRIP);
+    PRIM_TO_STR(D3DPT_TRIANGLEFAN);
+#undef  PRIM_TO_STR
+  default:
+    FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType);
+    return "unrecognized";
+  }
+}
+
 /* Routine common to the draw primitive and draw indexed primitive routines */
 void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
                     int PrimitiveType,
@@ -182,21 +223,21 @@
     if (This->UpdateStateBlock->VertexShader > VS_HIGHESTFIXEDFXF) {
       vertex_shader = VERTEX_SHADER(This->UpdateStateBlock->VertexShader);
       if (NULL == vertex_shader) {
-          ERR("trying to use unitialised vertex shader: %lu\n", This->UpdateStateBlock->VertexShader);
+          ERR_(d3d_shader)("trying to use unitialised vertex shader: %lu\n", This->UpdateStateBlock->VertexShader);
           return ;
       }
       if (NULL == vertex_shader->function) {
-          TRACE("vertex shader declared without program, using FVF pure mode\n");
+          TRACE_(d3d_shader)("vertex shader declared without program, using FVF pure mode\n");
       } else {
           useVertexShaderFunction = TRUE;
       }
       fvf = (D3DFORMAT) This->UpdateStateBlock->vertexShaderDecl->fvf;
-      TRACE("vertex shader declared FVF: %lx\n", This->UpdateStateBlock->vertexShaderDecl->fvf);
+      TRACE_(d3d_shader)("vertex shader declared FVF: %08lx\n", This->UpdateStateBlock->vertexShaderDecl->fvf);
       memset(&vertex_shader->input, 0, sizeof(VSHADERINPUTDATA8));
 
       /** init Constants */
       if (TRUE == This->UpdateStateBlock->Changed.vertexShaderConstant) {
-	TRACE("vertex shader init Constant\n");
+	TRACE_(d3d_shader)("vertex shader init Constant\n");
 	IDirect3DVertexShaderImpl_SetConstantF(vertex_shader, 0, (CONST FLOAT*) &This->UpdateStateBlock->vertexShaderConstant[0], 96);
       }
 
@@ -1046,24 +1087,26 @@
 
     switch (fmt) {
     /* color buffer */
+    case D3DFMT_P8:               retVal = 1; break;
     case D3DFMT_A4R4G4B4:         retVal = 2; break;
-    case D3DFMT_A8R8G8B8:         retVal = 4; break;
-    case D3DFMT_X8R8G8B8:         retVal = 4; break;
-    case D3DFMT_R8G8B8:           retVal = 3; break;
     case D3DFMT_R5G6B5:           retVal = 2; break;
+    case D3DFMT_X1R5G5B5:         retVal = 2; break;
     case D3DFMT_A1R5G5B5:         retVal = 2; break;
+    case D3DFMT_R8G8B8:           retVal = 3; break;
+    case D3DFMT_X8R8G8B8:         retVal = 4; break;
+    case D3DFMT_A8R8G8B8:         retVal = 4; break;
     /* depth/stencil buffer */
     case D3DFMT_D16_LOCKABLE:     retVal = 2; break;
-    case D3DFMT_D32:              retVal = 4; break;
+    case D3DFMT_D16:              retVal = 2; break;
     case D3DFMT_D15S1:            retVal = 2; break;
+    case D3DFMT_D24X4S4:          retVal = 4; break;
     case D3DFMT_D24S8:            retVal = 4; break;
-    case D3DFMT_D16:              retVal = 2; break;
     case D3DFMT_D24X8:            retVal = 4; break;
-    case D3DFMT_D24X4S4:          retVal = 4; break;
+    case D3DFMT_D32:              retVal = 4; break;
     /* unknown */				  
     case D3DFMT_UNKNOWN:
       /* Guess at the highest value of the above */
-      TRACE("D3DFMT_UNKNOWN - Guessing at 4 bytes/pixel %d\n", fmt);
+      TRACE("D3DFMT_UNKNOWN - Guessing at 4 bytes/pixel %u\n", fmt);
       retVal = 4;
       break;
 
@@ -1087,7 +1130,7 @@
     case D3DFMT_A1R5G5B5:         retVal = GL_RGB5_A1; break;
     default:
         FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
-        retVal = 4;
+        retVal = GL_RGB8;
     }
     TRACE("fmt2glintFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
     return retVal;
@@ -1104,7 +1147,7 @@
     case D3DFMT_A1R5G5B5:         retVal = GL_BGRA; break;
     default:
         FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
-        retVal = 4;
+        retVal = GL_BGR;
     }
     TRACE("fmt2glFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
     return retVal;
@@ -1121,7 +1164,7 @@
     case D3DFMT_A1R5G5B5:         retVal = GL_UNSIGNED_SHORT_1_5_5_5_REV; break;
     default:
         FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
-        retVal = 4;
+        retVal = GL_UNSIGNED_BYTE;
     }
     TRACE("fmt2glType for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
     return retVal;
@@ -1386,14 +1429,15 @@
     switch (bpp) {
     case  8: pMode->Format       = D3DFMT_R8G8B8; break;
     case 16: pMode->Format       = D3DFMT_R5G6B5; break;
-    case 24: pMode->Format       = D3DFMT_R8G8B8; break;
+    case 24: /*pMode->Format       = D3DFMT_R8G8B8; break; */
     case 32: pMode->Format       = D3DFMT_A8R8G8B8; break;
     default: 
        FIXME("Unrecognized display mode format\n");
        pMode->Format       = D3DFMT_UNKNOWN;
     }
 
-    FIXME("(%p) : returning w(%d) h(%d) rr(%d) fmt(%d)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format);
+    FIXME("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate, 
+	  pMode->Format, debug_d3dformat(pMode->Format));
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
@@ -1475,7 +1519,7 @@
     ICOM_THIS(IDirect3DDevice8Impl,iface);
 
     /* Allocate the storage for the device */
-    TRACE("(%p) : W(%d) H(%d), Lvl(%d) Usage(%ld), Fmt(%d), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool);
+    TRACE("(%p) : W(%d) H(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, debug_d3dformat(Format), Pool);
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture8Impl));
     object->lpVtbl = &Direct3DTexture8_Vtbl;
     object->Device = This;
@@ -1532,7 +1576,7 @@
     ICOM_THIS(IDirect3DDevice8Impl,iface);
 
     /* Allocate the storage for it */
-    TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%ld), Fmt(%d), Pool(%d)\n", This, Width, Height, Depth, Levels, Usage, Format, Pool);
+    TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%d)\n", This, Width, Height, Depth, Levels, Usage, Format, debug_d3dformat(Format), Pool);
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture8Impl));
     object->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
     object->ResourceType = D3DRTYPE_VOLUMETEXTURE;
@@ -1594,7 +1638,7 @@
         volume->myDesc.Size     = (Width * volume->bytesPerPixel) * Height * Depth;
         volume->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->myDesc.Size);
 
-        TRACE("(%p) : Volume at w(%d) h(%d) d(%d) fmt(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Depth, Format, 
+        TRACE("(%p) : Volume at w(%d) h(%d) d(%d) fmt(%u,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Depth, Format, debug_d3dformat(Format),
                   volume, volume->allocatedMemory, volume->myDesc.Size);
 
         tmpW = max(1, tmpW / 2);
@@ -1613,7 +1657,7 @@
     UINT tmpW;
 
     /* Allocate the storage for it */
-    TRACE("(%p) : Len(%d), Lvl(%d) Usage(%ld), Fmt(%d), Pool(%d)\n", This, EdgeLength, Levels, Usage, Format, Pool);
+    TRACE("(%p) : Len(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%d)\n", This, EdgeLength, Levels, Usage, Format, debug_d3dformat(Format), Pool);
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DCubeTexture8Impl));
     object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
     object->ref = 1;
@@ -1686,7 +1730,7 @@
     IDirect3DIndexBuffer8Impl *object;
 
     ICOM_THIS(IDirect3DDevice8Impl,iface);
-    TRACE("(%p) : Len=%d, Use=%lx, Format=%x, Pool=%d\n", This, Length, Usage, Format, Pool);
+    TRACE("(%p) : Len=%d, Use=%lx, Format=(%u,%s), Pool=%d\n", This, Length, Usage, Format, debug_d3dformat(Format), Pool);
 
     /* Allocate the storage for the device */
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DIndexBuffer8Impl));
@@ -1742,7 +1786,7 @@
     object->lockable = Lockable;
     object->locked = FALSE;
 
-    TRACE("(%p) : w(%d) h(%d) fmt(%d) lockable(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, Lockable, *ppSurface, object->allocatedMemory, object->myDesc.Size);
+    TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), Lockable, *ppSurface, object->allocatedMemory, object->myDesc.Size);
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
@@ -1774,10 +1818,10 @@
     object->bytesPerPixel = bytesPerPixel(Format);
     object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
     object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
-    object->lockable = TRUE;
+    object->lockable = (D3DFMT_D16_LOCKABLE == Format) ? TRUE : FALSE;
     object->locked = FALSE;
 
-    TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, *ppSurface, object->allocatedMemory, object->myDesc.Size);
+    TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->myDesc.Size);
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
@@ -1807,7 +1851,7 @@
     object->lockable = TRUE;
     object->locked = FALSE;
 
-    TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, *ppSurface, object->allocatedMemory, object->myDesc.Size);
+    TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->myDesc.Size);
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,
@@ -2256,12 +2300,6 @@
 
     if (d3dts < 256) { 
       switch (d3dts) {
-#if 0
-      case D3DTS_WORLDMATRIX(0): /* WORLDMATRIX(0) == 256! so not here */
-        conv_mat(lpmatrix, &This->StateBlock->transforms[D3DTS_WORLDMATRIX(0)]);
-        break;
-#endif
-
       case D3DTS_VIEW:
         conv_mat(lpmatrix, &This->StateBlock->transforms[D3DTS_VIEW]);
         break;
@@ -2288,6 +2326,7 @@
     } else {
       /** 
        * Indexed Vertex Blending Matrices 256 -> 511 
+       *  where WORLDMATRIX(0) == 256!
        */
       /** store it */
       conv_mat(lpmatrix, &This->StateBlock->transforms[d3dts]);
@@ -3752,7 +3791,8 @@
         } else if (textureType == D3DRTYPE_CUBETEXTURE) {
 	  /* Standard Cube texture */
 	  FIXME("Standard Cube texture\n");
-	  /*This->UpdateStateBlock->textureDimensions[Stage] = GL_TEXTURE_4D;*/
+	  
+	  This->UpdateStateBlock->textureDimensions[Stage] = GL_TEXTURE_CUBE_MAP_ARB;
 
 	  /* Load up the texture now */
 	  IDirect3DCubeTexture8Impl_PreLoad((LPDIRECT3DCUBETEXTURE8) pTexture);
@@ -3963,6 +4003,13 @@
                         glDisable(GL_TEXTURE_3D);
                         checkGLcall("Disable GL_TEXTURE_3D");
                     }
+                    if (This->StateBlock->textureDimensions[Stage] == GL_TEXTURE_CUBE_MAP_ARB) {
+                        glEnable(GL_TEXTURE_CUBE_MAP_ARB);
+                        checkGLcall("Enable GL_TEXTURE_CUBE_MAP");
+                    } else {
+                        glDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                        checkGLcall("Disable GL_TEXTURE_CUBE_MAP");
+                    }
                 }
 
                 /* Re-Enable GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT */
@@ -4066,6 +4113,7 @@
                     FIXME("DotProduct3 extension requested but not supported via this version of opengl\n");
                     break;
 
+
                 case D3DTOP_SUBTRACT                  :
 #if defined(GL_VERSION_1_3)
                     glTexEnvi(GL_TEXTURE_ENV, Parm, GL_SUBTRACT);
@@ -4176,9 +4224,12 @@
             /** 
              * Be careful the value of the mask 0xF0000 come from d3d8types.h infos 
              */
-            switch (Value & 0xFFFFFF00) {
+            switch (Value & 0xFFFF0000) {
             case D3DTSS_TCI_PASSTHRU:
               /*Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
+	      glDisable(GL_TEXTURE_GEN_S);
+	      glDisable(GL_TEXTURE_GEN_T);
+	      glDisable(GL_TEXTURE_GEN_R);
               break;
 
             case D3DTSS_TCI_CAMERASPACEPOSITION:
@@ -4217,12 +4268,82 @@
               }
               break;
 
+#if defined(GL_ARB_texture_cube_map) || defined(GL_NV_texgen_reflection)
+	    case D3DTSS_TCI_CAMERASPACENORMAL:
+	      {
+		float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
+                float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
+                float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
+                float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
+                TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
+
+                glMatrixMode(GL_MODELVIEW);
+                glPushMatrix();
+                glLoadIdentity();
+                glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
+                glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
+                glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
+                glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
+                glPopMatrix();
+
+		glEnable(GL_TEXTURE_GEN_S);
+		checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
+		glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
+                checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)");
+		glEnable(GL_TEXTURE_GEN_T);
+		checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
+		glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
+                checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)");
+		glEnable(GL_TEXTURE_GEN_R);
+		checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
+		glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
+                checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)");
+	      }
+	      break;
+#endif
+
+#if defined(GL_ARB_texture_cube_map) || defined(GL_NV_texgen_reflection)
+	    case D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
+	      {
+
+		float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
+                float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
+                float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
+                float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
+                TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
+
+                glMatrixMode(GL_MODELVIEW);
+                glPushMatrix();
+                glLoadIdentity();
+                glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
+                glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
+                glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
+                glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
+                glPopMatrix();
+		
+		glEnable(GL_TEXTURE_GEN_S);
+		checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
+		glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
+                checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)");
+		glEnable(GL_TEXTURE_GEN_T);
+		checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
+		glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
+                checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)");
+		glEnable(GL_TEXTURE_GEN_R);
+		checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
+		glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
+                checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)");
+	      }
+	      break;
+#endif
+
             /* Unhandled types: */
-            case D3DTSS_TCI_CAMERASPACENORMAL:
-            case D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
             default:
                 /* Todo: */
-                /* ? disable GL_TEXTURE_GEN_n ? */
+                /* ? disable GL_TEXTURE_GEN_n ? */ 
+	        glDisable(GL_TEXTURE_GEN_S);
+	        glDisable(GL_TEXTURE_GEN_T);
+	        glDisable(GL_TEXTURE_GEN_R);
                 FIXME("Unhandled D3DTSS_TEXCOORDINDEX %lx\n", Value);
                 break;
             }
@@ -4283,34 +4404,54 @@
     TRACE("(%p) : stub\n", This);    /* FIXME: Needs doing, but called often and is harmless */
     return D3D_OK;
 }
-HRESULT  WINAPI  IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) {
+HRESULT  WINAPI  IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID, void* pDevInfoStruct, DWORD DevInfoStructSize) {
     ICOM_THIS(IDirect3DDevice8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);    
+    return D3D_OK;
 }
-HRESULT  WINAPI  IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber,CONST PALETTEENTRY* pEntries) {
+HRESULT  WINAPI  IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
     ICOM_THIS(IDirect3DDevice8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : setting p[%u] <= RGBA(%02x,%02x,%02x,%02x)\n", This, PaletteNumber,
+          pEntries->peRed, pEntries->peGreen, pEntries->peBlue, pEntries->peFlags);
+    memcpy(&This->palettes[PaletteNumber], pEntries, 256 * sizeof(PALETTEENTRY));
+    return D3D_OK;
 }
-HRESULT  WINAPI  IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber,PALETTEENTRY* pEntries) {
+HRESULT  WINAPI  IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
     ICOM_THIS(IDirect3DDevice8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    memcpy(pEntries, &This->palettes[PaletteNumber], 256 * sizeof(PALETTEENTRY));
+    FIXME("(%p) : returning p[%u] => RGBA(%02x,%02x,%02x,%02x)\n", This, PaletteNumber,
+          pEntries->peRed, pEntries->peGreen, pEntries->peBlue, pEntries->peFlags);
+    return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber) {
     ICOM_THIS(IDirect3DDevice8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : Setting to (%u)\n", This, PaletteNumber);
+    This->currentPalette = PaletteNumber;
+#if defined(GL_EXT_paletted_texture)
+    glColorTableEXT(GL_TEXTURE_2D,    /* target */
+		    GL_RGBA,          /* internal format */
+		    256,              /* table size */
+		    GL_RGBA,          /* table format */
+		    GL_UNSIGNED_BYTE, /* table type */
+		    &This->palettes[PaletteNumber]);
+    checkGLcall("glColorTableEXT");
+#endif
+    return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber) {
     ICOM_THIS(IDirect3DDevice8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    *PaletteNumber = This->currentPalette;
+    FIXME("(%p) : Returning (%u)\n", This, *PaletteNumber);
+    return D3D_OK;
 }
-HRESULT  WINAPI  IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) {
+HRESULT  WINAPI  IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
 
     IDirect3DVertexBuffer8     *pVB;
 
     ICOM_THIS(IDirect3DDevice8Impl,iface);
     pVB = This->StateBlock->stream_source[0];
 
-    TRACE("(%p) : Type=%d, Start=%d, Count=%d\n", This, PrimitiveType, StartVertex, PrimitiveCount);
+    TRACE("(%p) : Type=(%d,%s), Start=%d, Count=%d\n", This, PrimitiveType, debug_d3dprimitivetype(PrimitiveType), StartVertex, PrimitiveCount);
 
     DrawPrimitiveI(iface, PrimitiveType, PrimitiveCount, FALSE,
                    This->StateBlock->VertexShader, ((IDirect3DVertexBuffer8Impl *)pVB)->allocatedMemory, StartVertex, -1, 0, NULL, 0);
@@ -4328,7 +4469,8 @@
     pIB = This->StateBlock->pIndexData;
     pVB = This->StateBlock->stream_source[0];
 
-    TRACE("(%p) : Type=%d, min=%d, CountV=%d, startIdx=%d, countP=%d \n", This, PrimitiveType,
+    TRACE("(%p) : Type=(%d,%s), min=%d, CountV=%d, startIdx=%d, countP=%d \n", This, 
+          PrimitiveType, debug_d3dprimitivetype(PrimitiveType),
           minIndex, NumVertices, startIndex, primCount);
 
     IDirect3DIndexBuffer8Impl_GetDesc(pIB, &IdxBufDsc);
@@ -4347,7 +4489,8 @@
 HRESULT  WINAPI  IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) {
     ICOM_THIS(IDirect3DDevice8Impl,iface);
 
-    TRACE("(%p) : Type=%d, pCount=%d, pVtxData=%p, Stride=%d\n", This, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
+    TRACE("(%p) : Type=(%d,%s), pCount=%d, pVtxData=%p, Stride=%d\n", This, PrimitiveType, debug_d3dprimitivetype(PrimitiveType), 
+          PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
 
     if (This->StateBlock->stream_source[0] != NULL) IDirect3DVertexBuffer8Impl_Release(This->StateBlock->stream_source[0]);
 
@@ -4366,7 +4509,7 @@
                                                              UINT VertexStreamZeroStride) {
     int idxStride;
     ICOM_THIS(IDirect3DDevice8Impl,iface);
-    TRACE("(%p) : Type=%d, MinVtxIdx=%d, NumVIdx=%d, PCount=%d, pidxdata=%p, IdxFmt=%d, pVtxdata=%p, stride=%d\n", This, PrimitiveType,
+    TRACE("(%p) : Type=(%d,%s), MinVtxIdx=%d, NumVIdx=%d, PCount=%d, pidxdata=%p, IdxFmt=%d, pVtxdata=%p, stride=%d\n", This, PrimitiveType, debug_d3dprimitivetype(PrimitiveType),
           MinVertexIndex, NumVertexIndices, PrimitiveCount, pIndexData,  IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
 
     if (This->StateBlock->stream_source[0] != NULL) IDirect3DVertexBuffer8Impl_Release(This->StateBlock->stream_source[0]);
@@ -4612,7 +4755,7 @@
     *pHandle = VS_HIGHESTFIXEDFXF + i;
 
     object->function = pFunction;
-    for (i = 0; 0xFFFFFFFF != pFunction[i]; ++i) ;
+    for (i = 0; D3DPS_END() != pFunction[i]; ++i) ;
     object->functionLength = i + 1;
 
     return D3D_OK;
Index: directx.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/directx.c,v
retrieving revision 1.33
diff -u -r1.33 directx.c
--- directx.c	15 May 2003 04:16:16 -0000	1.33
+++ directx.c	17 May 2003 15:31:21 -0000
@@ -41,20 +41,63 @@
     X11DRV_GET_FONT,      /* get current X font for a DC */
 };
 
-#define NUM_MODES 10
-static const int modes[NUM_MODES][3] = {
-    {640, 480, 85},
-    {800, 600, 85},
-    {1024, 768, 85},
-    {1152, 864, 85},
-    {1280, 768, 85},
-    {1280, 960, 85},
-    {1280, 1024, 85},
-    {1600, 900, 85},
-    {1600, 1024, 85},
-    {1600, 1200, 85}
+#define NUM_MODES 20
+static const int modes[NUM_MODES][4] = {
+    {640, 480, 85, 16},
+    {640, 480, 85, 32},
+
+    {800, 600, 85, 16},
+    {800, 600, 85, 32},
+
+    {1024, 768, 85, 16},
+    {1024, 768, 85, 32},
+
+    {1152, 864, 85, 16},
+    {1152, 864, 85, 32},
+
+    {1280, 768, 85, 16},
+    {1280, 768, 85, 32},
+
+    {1280, 960, 85, 16},
+    {1280, 960, 85, 32},
+
+    {1280, 1024, 85, 16},
+    {1280, 1024, 85, 32},
+
+    {1600, 900, 85, 16},
+    {1600, 900, 85, 32},
+
+    {1600, 1024, 85, 16},
+    {1600, 1024, 85, 32},
+
+    {1600, 1200, 85, 16},
+    {1600, 1200, 85, 32}
+};
+
+#define NUM_FORMATS 7
+static const D3DFORMAT device_formats[NUM_FORMATS] = {
+  D3DFMT_P8,
+  D3DFMT_R3G3B2,
+  D3DFMT_R5G6B5, 
+  D3DFMT_X1R5G5B5,
+  D3DFMT_X4R4G4B4,
+  D3DFMT_R8G8B8,
+  D3DFMT_X8R8G8B8
 };
 
+inline static int get_bpp_from_format(D3DFORMAT fmt) {
+  switch (fmt) {
+  case D3DFMT_P8:        return  8;
+  case D3DFMT_R3G3B2:    return  8;
+  case D3DFMT_R5G6B5:    return 16;
+  case D3DFMT_X1R5G5B5:  return 16;
+  case D3DFMT_X4R4G4B4:  return 16;
+  case D3DFMT_R8G8B8:    return 24;
+  case D3DFMT_X8R8G8B8:  return 32;
+  default:               return 16;
+  }
+}
+
 /* retrieve the X display to use on a given DC */
 inline static Display *get_display( HDC hdc )
 {
@@ -132,7 +175,7 @@
         pIdentifier->SubSysId = 0;
         pIdentifier->Revision = 0;
         /*FIXME: memcpy(&pIdentifier->DeviceIdentifier, ??, sizeof(??GUID)); */
-        if (Flags & D3DENUM_NO_WHQL_LEVEL ) {
+        if (Flags & D3DENUM_NO_WHQL_LEVEL) {
             pIdentifier->WHQLLevel = 0;
         } else {
             pIdentifier->WHQLLevel = 1;
@@ -159,12 +202,14 @@
         int maxHeight       = GetSystemMetrics(SM_CYSCREEN);
         int i;
 
-        for (i=0; i<NUM_MODES; i++) {
+        for (i = 0; i < NUM_MODES; i++) {
             if (modes[i][0] > maxWidth || modes[i][1] > maxHeight) {
-                return i+1;
+  	        TRACE("(%p}->(Adapter: %d) => %d\n", This, Adapter, i + 1);
+                return i + 1;
             }
         }
-        return NUM_MODES+1;
+	TRACE("(%p}->(Adapter: %d) => %d\n", This, Adapter, NUM_MODES);
+        return NUM_MODES + 1;
     } else {
         FIXME("Adapter not primary display\n");
     }
@@ -176,7 +221,7 @@
                                                             UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
     ICOM_THIS(IDirect3D8Impl,iface);
 
-    TRACE("(%p}->(Adapter: %d, mode: %d, pMode=%p)\n", This, Adapter, Mode, pMode);
+    TRACE("(%p}->(Adapter:%d, mode:%d, pMode:%p)\n", This, Adapter, Mode, pMode);
 
     if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
         return D3DERR_INVALIDCALL;
@@ -190,27 +235,29 @@
             pMode->Width        = GetSystemMetrics(SM_CXSCREEN);
             pMode->Height       = GetSystemMetrics(SM_CYSCREEN);
             pMode->RefreshRate  = 85; /*FIXME: How to identify? */
-        } else if (Mode < (NUM_MODES+1)) {
-            pMode->Width        = modes[Mode-1][0];
-            pMode->Height       = modes[Mode-1][1];
-            pMode->RefreshRate  = modes[Mode-1][2];
+	    bpp                 = 32;
+        } else if (Mode < (NUM_MODES + 1)) {
+            pMode->Width        = modes[Mode - 1][0];
+            pMode->Height       = modes[Mode - 1][1];
+            pMode->RefreshRate  = modes[Mode - 1][2];
+	    bpp                 = modes[Mode - 1][3];
         } else {
             TRACE("Requested mode out of range %d\n", Mode);
             return D3DERR_INVALIDCALL;
         }
 
         hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
-        bpp = GetDeviceCaps(hdc, BITSPIXEL);
+        bpp = min(GetDeviceCaps(hdc, BITSPIXEL), bpp);
         DeleteDC(hdc);
 
         switch (bpp) {
-        case  8: pMode->Format       = D3DFMT_R3G3B2;   break;
-        case 16: pMode->Format       = D3DFMT_R5G6B5;   break;
-        case 24: pMode->Format       = D3DFMT_R5G6B5;   break; /* Make 24bit appear as 16 bit */
-        case 32: pMode->Format       = D3DFMT_A8R8G8B8; break;
-        default: pMode->Format       = D3DFMT_UNKNOWN;
+        case  8: pMode->Format = D3DFMT_R3G3B2;   break;
+        case 16: pMode->Format = D3DFMT_R5G6B5;   break;
+        case 24: /* pMode->Format = D3DFMT_R5G6B5;   break;*/ /* Make 24bit appear as 16 bit */
+        case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
+        default: pMode->Format = D3DFMT_UNKNOWN;
         }
-        TRACE("W %d H %d rr %d fmt %x\n", pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format);
+        TRACE("W %d H %d rr %d fmt (%x,%s) bpp %u\n", pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format), bpp);
 
     } else {
         FIXME("Adapter not primary display\n");
@@ -243,7 +290,7 @@
         switch (bpp) {
         case  8: pMode->Format       = D3DFMT_R3G3B2;   break;
         case 16: pMode->Format       = D3DFMT_R5G6B5;   break;
-        case 24: pMode->Format       = D3DFMT_R5G6B5;   break; /* Make 24bit appear as 16 bit */
+        case 24: /*pMode->Format       = D3DFMT_R5G6B5;   break;*/ /* Make 24bit appear as 16 bit */
         case 32: pMode->Format       = D3DFMT_A8R8G8B8; break;
         default: pMode->Format       = D3DFMT_UNKNOWN;
         }
@@ -261,8 +308,13 @@
                                                             UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
                                                             D3DFORMAT BackBufferFormat, BOOL Windowed) {
     ICOM_THIS(IDirect3D8Impl,iface);
-    FIXME("(%p)->(Adptr:%d, CheckType:%x, DispFmt:%x, BackBuf:%x, Win? %d): stub\n", This, Adapter, CheckType,
-          DisplayFormat, BackBufferFormat, Windowed);
+    FIXME("(%p)->(Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n", 
+	  This, 
+	  Adapter, 
+	  CheckType, debug_d3ddevicetype(CheckType),
+          DisplayFormat, debug_d3dformat(DisplayFormat),
+	  BackBufferFormat, debug_d3dformat(BackBufferFormat),
+	  Windowed);
     return D3D_OK;
 }
 
@@ -270,9 +322,16 @@
                                                             UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
                                                             DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
     ICOM_THIS(IDirect3D8Impl,iface);
-    FIXME("(%p)->(Adptr:%d, DevType: %x, AdptFmt: %d, Use: %ld, ResTyp: %x, CheckFmt: %d)\n", This, Adapter, DeviceType,
-          AdapterFormat, Usage, RType, CheckFormat);
-    switch(CheckFormat) {
+    FIXME("(%p)->(Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%lu,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s))\n", 
+          This, 
+	  Adapter, 
+	  DeviceType, debug_d3ddevicetype(DeviceType), 
+	  AdapterFormat, debug_d3dformat(AdapterFormat), 
+	  Usage, debug_d3dusage(Usage),
+	  RType, debug_d3dressourcetype(RType), 
+	  CheckFormat, debug_d3dformat(CheckFormat));
+
+    switch (CheckFormat) {
     case D3DFMT_UYVY:
     case D3DFMT_YUY2:
     case D3DFMT_DXT1:
@@ -283,11 +342,12 @@
     case D3DFMT_X8L8V8U8:
     case D3DFMT_L6V5U5:
     case D3DFMT_V8U8:
-	   /* Since we do not support these formats right now, don't pretend to. */
-	   return D3DERR_NOTAVAILABLE;
-	default:
-            break;
+      /* Since we do not support these formats right now, don't pretend to. */
+      return D3DERR_NOTAVAILABLE;
+    default:
+      break;
     }
+
     return D3D_OK;
 }
 
@@ -295,17 +355,46 @@
                                                             UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
                                                             BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) {
     ICOM_THIS(IDirect3D8Impl,iface);
-    FIXME("(%p)->(Adptr:%d, DevType: %x, SurfFmt: %x, Win? %d, MultiSamp: %x)\n", This, Adapter, DeviceType,
-          SurfaceFormat, Windowed, MultiSampleType);
-    return D3D_OK;
+    FIXME("(%p)->(Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x)\n", 
+	  This, 
+	  Adapter, 
+	  DeviceType, debug_d3ddevicetype(DeviceType),
+          SurfaceFormat, debug_d3dformat(SurfaceFormat),
+	  Windowed, 
+	  MultiSampleType);
+  
+    if (D3DMULTISAMPLE_NONE == MultiSampleType)
+      return D3D_OK;
+    return D3DERR_NOTAVAILABLE;
 }
 
 HRESULT  WINAPI  IDirect3D8Impl_CheckDepthStencilMatch     (LPDIRECT3D8 iface,
                                                             UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
                                                             D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
     ICOM_THIS(IDirect3D8Impl,iface);
-    FIXME("(%p)->(Adptr:%d, DevType: %x, AdptFmt: %x, RendrTgtFmt: %x, DepthStencilFmt: %x)\n", This, Adapter, DeviceType,
-          AdapterFormat, RenderTargetFormat, DepthStencilFormat);
+    FIXME("(%p)->(Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n", 
+	  This, 
+	  Adapter, 
+	  DeviceType, debug_d3ddevicetype(DeviceType),
+          AdapterFormat, debug_d3dformat(AdapterFormat),
+	  RenderTargetFormat, debug_d3dformat(RenderTargetFormat), 
+	  DepthStencilFormat, debug_d3dformat(DepthStencilFormat));
+
+#if 0
+    switch (DepthStencilFormat) {
+    case D3DFMT_D24X4S4:
+    case D3DFMT_D24X8: 
+    case D3DFMT_D24S8: 
+    case D3DFMT_D32:
+      /**
+       * as i don't know how to really check hard caps of graphics cards
+       * i prefer to not permit 32bit zbuffers enumeration (as few cards can do it)
+       */
+      return D3DERR_NOTAVAILABLE;
+    default:
+      break;
+    }
+#endif
     return D3D_OK;
 }
 
@@ -384,13 +473,13 @@
                            D3DTEXOPCAPS_MODULATE | D3DTEXOPCAPS_MODULATE2X | D3DTEXOPCAPS_MODULATE4X |
                            D3DTEXOPCAPS_SELECTARG1 | D3DTEXOPCAPS_SELECTARG2 | D3DTEXOPCAPS_DISABLE;
 #if defined(GL_VERSION_1_3)
-    pCaps->TextureOpCaps |= D3DTEXOPCAPS_DOTPRODUCT3;
+    pCaps->TextureOpCaps |= D3DTEXOPCAPS_DOTPRODUCT3 | D3DTEXOPCAPS_SUBTRACT;
 #endif
               /* FIXME: Add D3DTEXOPCAPS_ADDSMOOTH D3DTEXOPCAPS_BLENDCURRENTALPHA D3DTEXOPCAPS_BLENDDIFFUSEALPHA D3DTEXOPCAPS_BLENDFACTORALPHA 
                             D3DTEXOPCAPS_BLENDTEXTUREALPHA D3DTEXOPCAPS_BLENDTEXTUREALPHAPM D3DTEXOPCAPS_BUMPENVMAP D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 
                             D3DTEXOPCAPS_LERP D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 
                             D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA D3DTEXOPCAPS_MULTIPLYADD 
-                            D3DTEXOPCAPS_PREMODULATE D3DTEXOPCAPS_SUBTRACT */
+                            D3DTEXOPCAPS_PREMODULATE */
 
     {
         GLint gl_max;
@@ -427,8 +516,13 @@
     pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
     pCaps->MaxVertexShaderConst = D3D8_VSHADER_MAX_CONSTANTS;
 
+#if 0
     pCaps->PixelShaderVersion = D3DPS_VERSION(1,1);
     pCaps->MaxPixelShaderValue = 1.0;
+#else
+    pCaps->PixelShaderVersion = 0;
+    pCaps->MaxPixelShaderValue = 0.0;
+#endif
 
     return D3D_OK;
 }
@@ -478,7 +572,7 @@
     object->CreateParms.hFocusWindow = hFocusWindow;
     object->CreateParms.BehaviorFlags = BehaviourFlags;
 
-    *ppReturnedDeviceInterface = (LPDIRECT3DDEVICE8)object;
+    *ppReturnedDeviceInterface = (LPDIRECT3DDEVICE8) object;
 
     /* Initialize settings */
     object->PresentParms.BackBufferCount = 1; /* Opengl only supports one? */
@@ -488,9 +582,18 @@
     /* Initialize openGl */
     {
         HDC hDc;
-        int          dblBuf[]={GLX_STENCIL_SIZE,8,GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
+	/*int dblBuf[] = {GLX_STENCIL_SIZE,8,GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};*/
+        int dblBuf[] = {GLX_RGBA, 
+			GLX_STENCIL_SIZE, 8, /*  2 */
+			GLX_DEPTH_SIZE,  16, /*  4 */
+#if 0
+			GLX_RED_SIZE,     8, /*  6 */ 
+			GLX_GREEN_SIZE,   8, /*  8 */
+			GLX_BLUE_SIZE,    8, /* 10 */
+			GLX_ALPHA_SIZE,   8, /* 12 */
+#endif
+			GLX_DOUBLEBUFFER, None};
         /* FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat */
-	/*int          dblBuf[]={GLX_RGBA,GLX_RED_SIZE,4,GLX_GREEN_SIZE,4,GLX_BLUE_SIZE,4,GLX_DOUBLEBUFFER,None}; */
 
         /* Which hwnd are we using? */
 /*      if (pPresentationParameters->Windowed) { */
@@ -510,6 +613,39 @@
         hDc = GetDC(whichHWND);
         object->display = get_display(hDc);
 
+
+	TRACE("(%p)->(DepthStencil:(%u,%s), BackBufferFormat:(%u,%s))\n", This, 
+	      pPresentationParameters->AutoDepthStencilFormat, debug_d3dformat(pPresentationParameters->AutoDepthStencilFormat),
+	      pPresentationParameters->BackBufferFormat, debug_d3dformat(pPresentationParameters->BackBufferFormat));
+
+	
+#if 0
+	if (TRUE == pPresentationParameters->EnableAutoDepthStencil) {
+	  switch (pPresentationParameters->AutoDepthStencilFormat) {
+	  case D3DFMT_D16_LOCKABLE: dblBuf[2] =  8; dblBuf[4] = 16; break;
+	  case D3DFMT_D16:          dblBuf[2] =  8; dblBuf[4] = 16; break;
+	  case D3DFMT_D15S1:        dblBuf[2] =  1; dblBuf[4] = 16; break;
+	  case D3DFMT_D24X4S4:      dblBuf[2] =  4; dblBuf[4] = 24; break;
+	  case D3DFMT_D24S8:        dblBuf[2] =  8; dblBuf[4] = 24; break;
+	  case D3DFMT_D24X8:        dblBuf[2] =  8; dblBuf[4] = 24; break;
+	  case D3DFMT_D32:          dblBuf[2] =  8; dblBuf[4] = 32; break;
+	  default:                  dblBuf[2] =  8; dblBuf[4] = 16; break;
+	  }
+	}
+	
+	switch (pPresentationParameters->BackBufferFormat) {
+	case D3DFMT_R3G3B2:   dblBuf[6] = 3; dblBuf[8] = 3; dblBuf[10] = 2; dblBuf[12] = 0; break;
+	case D3DFMT_R5G6B5:   dblBuf[6] = 5; dblBuf[8] = 6; dblBuf[10] = 5; dblBuf[12] = 0; break;
+	case D3DFMT_X1R5G5B5: dblBuf[6] = 5; dblBuf[8] = 5; dblBuf[10] = 5; dblBuf[12] = 0; break;
+	case D3DFMT_A1R5G5B5: dblBuf[6] = 5; dblBuf[8] = 5; dblBuf[10] = 5; dblBuf[12] = 1; break;
+	case D3DFMT_X4R4G4B4: dblBuf[6] = 4; dblBuf[8] = 4; dblBuf[10] = 4; dblBuf[12] = 0; break;
+	case D3DFMT_R8G8B8:   dblBuf[6] = 8; dblBuf[8] = 8; dblBuf[10] = 8; dblBuf[12] = 0; break;
+	case D3DFMT_X8R8G8B8: dblBuf[6] = 8; dblBuf[8] = 8; dblBuf[10] = 8; dblBuf[12] = 0; break;
+	case D3DFMT_A8R8G8B8: dblBuf[6] = 8; dblBuf[8] = 8; dblBuf[10] = 8; dblBuf[12] = 8; break;
+	default:              dblBuf[6] = 5; dblBuf[8] = 6; dblBuf[10] = 5; dblBuf[12] = 0; break;
+	}
+#endif
+
         ENTER_GL();
 	object->visInfo = glXChooseVisual(object->display, DefaultScreen(object->display), dblBuf);
 	if (NULL == object->visInfo) {
@@ -519,7 +655,7 @@
 	   * second try using wine initialized visual ...
 	   * must be fixed reworking wine-glx init
 	   */
-	  template.visualid = (VisualID)GetPropA( GetDesktopWindow(), "__wine_x11_visual_id" );
+	  template.visualid = (VisualID)GetPropA(GetDesktopWindow(), "__wine_x11_visual_id");
 	  object->visInfo = XGetVisualInfo(object->display, VisualIDMask, &template, &num);
 	  if (NULL == object->visInfo) {
 	    ERR("cannot really get XVisual\n"); 
@@ -543,7 +679,7 @@
         return D3DERR_INVALIDCALL;
     } else {
         TRACE("Context created (HWND=%p, glContext=%p, Window=%ld, VisInfo=%p)\n",
-			whichHWND, object->glCtx, object->win, object->visInfo);
+	      whichHWND, object->glCtx, object->win, object->visInfo);
     }
 
     /* If not windowed, need to go fullscreen, and resize the HWND to the appropriate  */
@@ -551,7 +687,7 @@
     if (!pPresentationParameters->Windowed) {
         FIXME("Requested full screen support not implemented, expect windowed operation\n");
         SetWindowPos(whichHWND, HWND_TOP, 0, 0, pPresentationParameters->BackBufferWidth,
-            pPresentationParameters->BackBufferHeight, SWP_SHOWWINDOW);
+                     pPresentationParameters->BackBufferHeight, SWP_SHOWWINDOW);
     }
 
     TRACE("Creating back buffer\n");
@@ -559,16 +695,16 @@
        then the corresponding dimension of the client area of the hDeviceWindow
        (or the focus window, if hDeviceWindow is NULL) is taken. */
     if (pPresentationParameters->Windowed && ((pPresentationParameters->BackBufferWidth  == 0) ||
-                                              (pPresentationParameters->BackBufferHeight  == 0))) {
+                                              (pPresentationParameters->BackBufferHeight == 0))) {
         RECT Rect;
 
         GetClientRect(whichHWND, &Rect);
 
-        if (pPresentationParameters->BackBufferWidth  == 0) {
+        if (pPresentationParameters->BackBufferWidth == 0) {
            pPresentationParameters->BackBufferWidth = Rect.right;
            TRACE("Updating width to %d\n", pPresentationParameters->BackBufferWidth);
         }
-        if (pPresentationParameters->BackBufferHeight  == 0) {
+        if (pPresentationParameters->BackBufferHeight == 0) {
            pPresentationParameters->BackBufferHeight = Rect.bottom;
            TRACE("Updating height to %d\n", pPresentationParameters->BackBufferHeight);
         }
Index: resource.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/resource.c,v
retrieving revision 1.4
diff -u -r1.4 resource.c
--- resource.c	11 May 2003 03:35:27 -0000	1.4
+++ resource.c	17 May 2003 15:31:29 -0000
@@ -83,11 +83,13 @@
 }
 DWORD    WINAPI        IDirect3DResource8Impl_SetPriority(LPDIRECT3DRESOURCE8 iface, DWORD PriorityNew) {
     ICOM_THIS(IDirect3DResource8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 DWORD    WINAPI        IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOURCE8 iface) {
     ICOM_THIS(IDirect3DResource8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 void     WINAPI        IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface) {
     ICOM_THIS(IDirect3DResource8Impl,iface);
Index: shader.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/shader.c,v
retrieving revision 1.10
diff -u -r1.10 shader.c
--- shader.c	14 May 2003 19:34:00 -0000	1.10
+++ shader.c	17 May 2003 15:31:37 -0000
@@ -34,7 +34,7 @@
 
 /* Shader debugging - Change the following line to enable debugging of software
       vertex shaders                                                             */
-#if 0
+#if 1
 # define VSTRACE(A) TRACE A
 # define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w)
 #else 
@@ -603,6 +603,8 @@
   TRACE_VECTOR(input->V[D3DVSDE_TEXCOORD0]);
   TRACE_VECTOR(input->V[D3DVSDE_TEXCOORD1]);
 #endif
+
+  TRACE_VECTOR(vshader->data->C[64]);
 
   /* the first dword is the version tag */
   /* TODO: parse it */
Index: stateblock.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/stateblock.c,v
retrieving revision 1.4
diff -u -r1.4 stateblock.c
--- stateblock.c	13 May 2003 23:40:20 -0000	1.4
+++ stateblock.c	17 May 2003 15:31:46 -0000
@@ -55,6 +55,7 @@
 HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* This) {
     D3DLINEPATTERN lp;
     int i;
+    int j;
     LPDIRECT3DDEVICE8 iface = (LPDIRECT3DDEVICE8) This;
 
     /* Note this may have a large overhead but it should only be executed
@@ -153,8 +154,8 @@
     IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_NORMALORDER, D3DORDER_LINEAR);
 
     /* Texture Stage States - Put directly into state block, we will call function below */
-    for (i=0; i<This->TextureUnits;i++) {
-        memcpy(&This->StateBlock->transforms[D3DTS_TEXTURE0+i], &idmatrix, sizeof(idmatrix));
+    for (i = 0; i < This->TextureUnits; i++) {
+        memcpy(&This->StateBlock->transforms[D3DTS_TEXTURE0 + i], &idmatrix, sizeof(idmatrix));
         This->StateBlock->texture_state[i][D3DTSS_COLOROP               ] = (i==0)? D3DTOP_MODULATE :  D3DTOP_DISABLE;
         This->StateBlock->texture_state[i][D3DTSS_COLORARG1             ] = D3DTA_TEXTURE;
         This->StateBlock->texture_state[i][D3DTSS_COLORARG2             ] = D3DTA_CURRENT;
@@ -226,6 +227,17 @@
         /* Reapply all the texture state information to this texture */
         setupTextureStates(iface, i);
     }
+
+    /* defaulting palettes */
+    for (i = 0; i < MAX_PALETTES; ++i) {
+      for (j = 0; j < 256; ++j) {
+	This->palettes[i][j].peRed   = 0xFF;
+	This->palettes[i][j].peGreen = 0xFF;
+	This->palettes[i][j].peBlue  = 0xFF;
+	This->palettes[i][j].peFlags = 0xFF;
+      }
+    }
+    This->currentPalette = 0;
 
     TRACE("-----------------------> Device defaults now set up...\n");
 
Index: surface.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/surface.c,v
retrieving revision 1.8
diff -u -r1.8 surface.c
--- surface.c	12 May 2003 03:10:27 -0000	1.8
+++ surface.c	17 May 2003 15:31:49 -0000
@@ -28,7 +28,7 @@
 
 #include "d3d8_private.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
+WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
 
 /* trace: */
 #if 0
@@ -131,7 +131,17 @@
       return D3DERR_INVALIDCALL;
     }
 
-    TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
+    if (This == This->Device->backBuffer || This == This->Device->frontBuffer || This->Device->depthStencilBuffer) {
+      if (This == This->Device->backBuffer) {
+	TRACE("(%p, backBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
+      } else if (This == This->Device->frontBuffer) {
+	TRACE("(%p, frontBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
+      } else if (This == This->Device->depthStencilBuffer) {
+	TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
+      }
+    } else {
+      TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
+    }
 
     pLockedRect->Pitch = This->bytesPerPixel * This->myDesc.Width;  /* Bytes / row */    
     
@@ -183,25 +193,50 @@
 	}
 	vcheckGLcall("glReadBuffer");
 
+	/** TODO: use an enhanced version of fmt2glintFmt here instad this switch */
+#if 0
 	switch (This->myDesc.Format) { 
 	case D3DFMT_R5G6B5:
-	  {
-	    glReadPixels(This->lockedRect.left, This->lockedRect.top, 
-			 This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
-			 GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pLockedRect->pBits);
-	    vcheckGLcall("glReadPixels");
+	  { 
+	    /*
+	      glReadPixels(This->lockedRect.left, This->lockedRect.top, 
+	                   This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
+	                   GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pLockedRect->pBits);
+	      vcheckGLcall("glReadPixels");
+	    */
+	    long j;
+	    for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
+	      glReadPixels(This->lockedRect.left, 
+			   This->lockedRect.bottom - j - 1, 
+			   This->lockedRect.right - This->lockedRect.left, 
+			   1,
+			   GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pLockedRect->pBits);
+	      vcheckGLcall("glReadPixels");
+	    }
 	  }
 	  break;
 	case D3DFMT_R8G8B8:
 	  {
+	    /*
 	    glReadPixels(This->lockedRect.left, This->lockedRect.top, 
 			 This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
 			 GL_RGB, GL_UNSIGNED_BYTE, pLockedRect->pBits);
 	    vcheckGLcall("glReadPixels");
+	    */
+	    long j;
+	    for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
+	      glReadPixels(This->lockedRect.left, 
+			   This->lockedRect.bottom - j - 1, 
+			   This->lockedRect.right - This->lockedRect.left, 
+			   1,
+			   GL_RGB, GL_UNSIGNED_BYTE, pLockedRect->pBits);
+	      vcheckGLcall("glReadPixels");
+	    }
 	  }
 	  break;
 	case D3DFMT_A8R8G8B8:
 	  {
+	    /*
 	    glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
 	    vcheckGLcall("glPixelStorei");
 	    glReadPixels(This->lockedRect.left, This->lockedRect.top, 
@@ -210,11 +245,38 @@
 	    vcheckGLcall("glReadPixels");
 	    glPixelStorei(GL_PACK_SWAP_BYTES, prev_store);
 	    vcheckGLcall("glPixelStorei");
+	    */
+	    long j;
+	    glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
+	    vcheckGLcall("glPixelStorei");
+	    for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
+	      glReadPixels(This->lockedRect.left, 
+			   This->lockedRect.bottom - j - 1, 
+			   This->lockedRect.right - This->lockedRect.left, 
+			   1,
+			   GL_BGRA, GL_UNSIGNED_BYTE, pLockedRect->pBits);
+	    vcheckGLcall("glReadPixels");
+	    }
+	    glPixelStorei(GL_PACK_SWAP_BYTES, prev_store);
+	    vcheckGLcall("glPixelStorei");
 	  }
 	  break;
 	default:
 	  FIXME("Unsupported Format %u in locking func\n", This->myDesc.Format);
 	}
+#endif
+
+	{
+	  long j;
+	  for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
+	    glReadPixels(This->lockedRect.left, 
+			 This->lockedRect.bottom - j - 1, 
+			 This->lockedRect.right - This->lockedRect.left, 
+			 1,
+			 fmt2glFmt(This->myDesc.Format), fmt2glType(This->myDesc.Format), pLockedRect->pBits);
+	    vcheckGLcall("glReadPixels");
+	  }
+	}
 
 	glReadBuffer(prev_read);
 	vcheckGLcall("glReadBuffer");
@@ -262,7 +324,7 @@
       }
     }
 
-    TRACE("returning pBits=%p, pitch=%d\n", pLockedRect->pBits, pLockedRect->Pitch);
+    TRACE("returning memory@%p, pitch(%d) dirtyfied(%d)\n", pLockedRect->pBits, pLockedRect->Pitch, This->Dirty);
 
     This->locked = TRUE;
     return D3D_OK;
@@ -275,7 +337,18 @@
       return D3DERR_INVALIDCALL;
     }
 
-    TRACE("(%p) : see if behavior is correct\n", This);
+    if (This == This->Device->backBuffer || This == This->Device->frontBuffer || This->Device->depthStencilBuffer) {
+      if (This == This->Device->backBuffer) {
+	TRACE("(%p, backBuffer) : dirtyfied(%d)\n", This, This->Dirty);
+      } else if (This == This->Device->frontBuffer) {
+	TRACE("(%p, frontBuffer) : dirtyfied(%d)\n", This, This->Dirty);
+      } else if (This == This->Device->depthStencilBuffer) {
+	TRACE("(%p, stencilBuffer) : dirtyfied(%d)\n", This, This->Dirty);
+      }
+    } else {
+      TRACE("(%p) : dirtyfied(%d)\n", This, This->Dirty);
+    }
+    /*TRACE("(%p) see if behavior is correct\n", This);*/
 
     if (FALSE == This->Dirty) {
       TRACE("(%p) : Not Dirtified so nothing to do, return now\n", This);
@@ -311,7 +384,8 @@
       if (This == This->Device->backBuffer || This == This->Device->frontBuffer) {
 	GLint  prev_store;
 	GLenum prev_draw;
-	
+	GLint  prev_rasterpos[4];
+
 	ENTER_GL();
 	
 	glFlush();
@@ -320,6 +394,8 @@
 	vcheckGLcall("glIntegerv");
 	glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
 	vcheckGLcall("glIntegerv");
+	glGetIntegerv(GL_CURRENT_RASTER_POSITION, &prev_rasterpos[0]);
+	vcheckGLcall("glIntegerv");
 
 	if (This == This->Device->backBuffer) {
 	  glDrawBuffer(GL_BACK);
@@ -362,6 +438,8 @@
 
 	glDrawBuffer(prev_draw);
 	vcheckGLcall("glDrawBuffer");
+	glRasterPos3iv(&prev_rasterpos[0]);
+	vcheckGLcall("glRasterPos3iv");
 	LEAVE_GL();
       } else {
 	FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
Index: texture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/texture.c,v
retrieving revision 1.7
diff -u -r1.7 texture.c
--- texture.c	12 May 2003 03:10:27 -0000	1.7
+++ texture.c	17 May 2003 15:32:11 -0000
@@ -61,7 +61,7 @@
 
     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
     if (ref == 0) {
-        for (i=0; i<This->levels; i++) {
+        for (i = 0; i < This->levels; i++) {
             if (This->surfaces[i] != NULL) {
                 TRACE("(%p) : Releasing surface %p\n", This, This->surfaces[i]);
                 IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) This->surfaces[i]);
@@ -98,63 +98,62 @@
 }
 DWORD    WINAPI        IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 DWORD    WINAPI        IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 void     WINAPI        IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
     int i;
     ICOM_THIS(IDirect3DTexture8Impl,iface);
     TRACE("(%p) : About to load texture\n", This);
-    for (i=0; i<This->levels; i++) 
-    {
-
-        if (i==0 && This->surfaces[i]->textureName != 0 && This->Dirty == FALSE) {
-            glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName);
-            checkGLcall("glBindTexture");
-            TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName);
-            /* No need to walk through all mip-map levels, since already all assigned */
-            i = This->levels;
-
-        } else {
-            if (i==0) {
-
-                if (This->surfaces[i]->textureName == 0) {
-                    glGenTextures(1, &This->surfaces[i]->textureName);
-                    checkGLcall("glGenTextures");
-                    TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName);
-                }
-
-                glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName);
-                checkGLcall("glBindTexture");
-
-                TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels-1);   
-                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels-1);
-                checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)");
-
-            }
-            TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%lx, Mem=%p\n",
-                  GL_TEXTURE_2D, i, fmt2glintFmt(This->format), This->surfaces[i]->myDesc.Width,
-                  This->surfaces[i]->myDesc.Height, 0, fmt2glFmt(This->format),fmt2glType(This->format),
-                  This->surfaces[i]->allocatedMemory);
-            glTexImage2D(GL_TEXTURE_2D, i,
-                         fmt2glintFmt(This->format),
-                         This->surfaces[i]->myDesc.Width,
-                         This->surfaces[i]->myDesc.Height,
-                         0,
-                         fmt2glFmt(This->format),
-                         fmt2glType(This->format),
-                         This->surfaces[i]->allocatedMemory
-                        );
-            checkGLcall("glTexImage2D");
-
-            /* Removed glTexParameterf now TextureStageStates are initialized at startup */
-            This->Dirty = FALSE;
-        }
+    for (i = 0; i < This->levels; i++) {
+      if (i == 0 && This->surfaces[i]->textureName != 0 && This->Dirty == FALSE) {
+	glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName);
+	checkGLcall("glBindTexture");
+	TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName);
+	/* No need to walk through all mip-map levels, since already all assigned */
+	i = This->levels;
+      } else {
+	if (i == 0) {
+	  if (This->surfaces[i]->textureName == 0) {
+	    glGenTextures(1, &This->surfaces[i]->textureName);
+	    checkGLcall("glGenTextures");
+	    TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName);
+	  }
+	  
+	  glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName);
+	  checkGLcall("glBindTexture");
+	  
+	  TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1);   
+	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
+	  checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)");
+	  
+	}
+	TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%lx, Mem=%p\n",
+	      GL_TEXTURE_2D, i, fmt2glintFmt(This->format), 
+	      This->surfaces[i]->myDesc.Width, This->surfaces[i]->myDesc.Height, 
+	      0, fmt2glFmt(This->format), fmt2glType(This->format),
+	      This->surfaces[i]->allocatedMemory);
+	glTexImage2D(GL_TEXTURE_2D, 
+		     i,
+		     fmt2glintFmt(This->format),
+		     This->surfaces[i]->myDesc.Width,
+		     This->surfaces[i]->myDesc.Height,
+		     0,
+		     fmt2glFmt(This->format),
+		     fmt2glType(This->format),
+		     This->surfaces[i]->allocatedMemory);
+	checkGLcall("glTexImage2D");
+	
+	/* Removed glTexParameterf now TextureStageStates are initialized at startup */
+	This->Dirty = FALSE;
+      }
     }
-    return;
+    return ;
 }
 D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
@@ -165,11 +164,13 @@
 /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
 DWORD    WINAPI        IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 DWORD    WINAPI        IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
-    FIXME("(%p) : stub\n", This);    return D3D_OK;
+    FIXME("(%p) : stub\n", This);
+    return 0;
 }
 DWORD    WINAPI        IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
@@ -183,7 +184,7 @@
 
     if (Level < This->levels) {
         TRACE("(%p) Level (%d)\n", This, Level);
-        return IDirect3DSurface8Impl_GetDesc((LPDIRECT3DSURFACE8)This->surfaces[Level], pDesc);
+        return IDirect3DSurface8Impl_GetDesc((LPDIRECT3DSURFACE8) This->surfaces[Level], pDesc);
     } else {
         FIXME("(%p) Level (%d)\n", This, Level);
     }
Index: vshaderdeclaration.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/vshaderdeclaration.c,v
retrieving revision 1.2
diff -u -r1.2 vshaderdeclaration.c
--- vshaderdeclaration.c	12 Apr 2003 00:06:43 -0000	1.2
+++ vshaderdeclaration.c	17 May 2003 15:32:14 -0000
@@ -30,7 +30,7 @@
 
 #include "d3d8_private.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
+WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
 
 /**
  * DirectX9 SDK download
@@ -65,7 +65,8 @@
  */
 
 /** Vertex Shader Declaration data types tokens */
-static CONST char* VertexShaderDeclDataTypes [] = {
+#define MAX_VSHADER_DECL_TYPES 8
+static CONST char* VertexShaderDeclDataTypes[] = {
   "D3DVSDT_FLOAT1",
   "D3DVSDT_FLOAT2",
   "D3DVSDT_FLOAT3",
@@ -77,7 +78,7 @@
   NULL
 };
 
-static CONST char* VertexShaderDeclRegister [] = {
+static CONST char* VertexShaderDeclRegister[] = {
   "D3DVSDE_POSITION",
   "D3DVSDE_BLENDWEIGHT",
   "D3DVSDE_BLENDINDICES",
@@ -99,7 +100,7 @@
 };
 
 /** todo check decl validity */
-inline static DWORD Direct3DVextexShaderDeclarationImpl_ParseToken(const DWORD* pToken) {
+/*inline static*/ DWORD Direct3DVextexShaderDeclarationImpl_ParseToken(const DWORD* pToken) {
   const DWORD token = *pToken;
   DWORD tokenlen = 1;
 
@@ -143,16 +144,24 @@
       TRACE(" 0x%08lx CONST(%lu, %lu)\n", token, constaddress, count);
       ++pToken;
       for (i = 0; i < count; ++i) {
+#if 0
 	TRACE("        c[%lu] = (0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx)\n", 
 		constaddress, 
 		*pToken, 
 		*(pToken + 1), 
 		*(pToken + 2), 
 		*(pToken + 3));
+#endif
+	TRACE("        c[%lu] = (%8f, %8f, %8f, %8f)\n", 
+		constaddress, 
+		 *(float*) pToken, 
+		 *(float*) (pToken + 1), 
+		 *(float*) (pToken + 2), 
+		 *(float*) (pToken + 3));
 	pToken += 4; 
 	++constaddress;
       }
-      tokenlen = count + 1;
+      tokenlen = (4 * count) + 1;
     }
     break;
   case D3DVSD_TOKEN_EXT:
@@ -225,7 +234,11 @@
 	default: 
 	  /** errooooorr mismatched use of a register, invalid fvf computing */
 	  invalid_fvf = TRUE;
-	  TRACE("Mismatched use in VertexShader declaration of D3DVSDE_POSITION register: unsupported type %s\n", VertexShaderDeclDataTypes[type]);
+	  if (type >= MAX_VSHADER_DECL_TYPES) {
+	    TRACE("Mismatched use in VertexShader declaration of D3DVSDE_POSITION register: unsupported and unrecognized type %08lx\n", type);
+	  } else {
+	    TRACE("Mismatched use in VertexShader declaration of D3DVSDE_POSITION register: unsupported type %s\n", VertexShaderDeclDataTypes[type]);
+	  }
 	}
 	break;
 
@@ -354,7 +367,8 @@
   SHORT u, v, r, t;
   DWORD dw;
 
-  /*TRACE("(%p) - This:%p - stream:%p, startIdx=%lu, idxDecal=%lu\n", vshader, This, vertexFirstStream, StartVertexIndex, idxDecal);*/
+  TRACE("(%p) - This:%p - stream:%p, startIdx=%lu, idxDecal=%lu\n", vshader, This, vertexFirstStream, StartVertexIndex, idxDecal);
+
   while (D3DVSD_END() != *pToken) {
     token = *pToken;
     tokentype = ((token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT);
Index: d3d8_private.h
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/d3d8_private.h,v
retrieving revision 1.26
diff -u -r1.26 d3d8_private.h
--- d3d8_private.h	14 May 2003 19:33:35 -0000	1.26
+++ d3d8_private.h	17 May 2003 15:32:24 -0000
@@ -55,10 +55,11 @@
 #include "d3d8.h"
 
 /* Device caps */
+#define MAX_PALETTES      256
 #define MAX_STREAMS       16
 #define MAX_ACTIVE_LIGHTS 8
 #define MAX_CLIPPLANES    D3DMAXUSERCLIPPLANES
-#define MAX_LEVELS 256
+#define MAX_LEVELS        256
 
 /* Other useful values */
 #define HIGHEST_RENDER_STATE 174
@@ -272,13 +273,16 @@
     float                         lightPosn[MAX_ACTIVE_LIGHTS][4];
     float                         lightDirn[MAX_ACTIVE_LIGHTS][4];
 
+    /* palettes texture management */
+    PALETTEENTRY                  palettes[MAX_PALETTES][256];
+    UINT                          currentPalette;
+
     /* Optimization */
     D3DMATRIX                     lastProj;
     D3DMATRIX                     lastView;
     D3DMATRIX                     lastWorld0;
     D3DMATRIX                     lastTexTrans[8];
 
-
     /* OpenGL related */
     GLXContext                    glCtx;
     XVisualInfo                  *visInfo;
@@ -1132,6 +1136,8 @@
 /**
  * Internals debug functions
  */
+const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
+const char* debug_d3dusage(DWORD usage);
 const char* debug_d3dformat(D3DFORMAT fmt);
 const char* debug_d3dressourcetype(D3DRESOURCETYPE res);
 

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux