[PATCH 2/2] d3d9/tests: Build without -DWINE_NO_LONG_TYPES.

Zebediah Figura wine at gitlab.winehq.org
Tue Jul 5 20:00:08 CDT 2022


From: Zebediah Figura <zfigura at codeweavers.com>

---
 dlls/d3d9/tests/Makefile.in  |    1 -
 dlls/d3d9/tests/d3d9ex.c     | 1303 +++---
 dlls/d3d9/tests/device.c     | 3557 ++++++++-------
 dlls/d3d9/tests/stateblock.c |  134 +-
 dlls/d3d9/tests/utils.h      |    2 +-
 dlls/d3d9/tests/visual.c     | 8016 +++++++++++++++++-----------------
 6 files changed, 6455 insertions(+), 6558 deletions(-)

diff --git a/dlls/d3d9/tests/Makefile.in b/dlls/d3d9/tests/Makefile.in
index fc0f45c3237..f6f52ba7d2d 100644
--- a/dlls/d3d9/tests/Makefile.in
+++ b/dlls/d3d9/tests/Makefile.in
@@ -1,4 +1,3 @@
-EXTRADEFS = -DWINE_NO_LONG_TYPES
 TESTDLL   = d3d9.dll
 IMPORTS   = d3d9 user32 gdi32
 
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 86ac7cf5109..89d6df8382b 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -75,17 +75,17 @@ static DWORD get_pixel_color(IDirect3DDevice9Ex *device, unsigned int x, unsigne
     hr = IDirect3DDevice9Ex_GetRenderTarget(device, 0, &target);
     if (FAILED(hr))
     {
-        trace("Can't get the render target, hr %#x.\n", hr);
+        trace("Can't get the render target, hr %#lx.\n", hr);
         return 0xdeadbeed;
     }
 
     hr = IDirect3DSurface9_GetDesc(target, &desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, desc.Width, desc.Height,
             desc.Format, D3DPOOL_SYSTEMMEM, &surf, NULL);
     if (FAILED(hr) || !surf)
     {
-        trace("Can't create an offscreen plain surface to read the render target data, hr %#x.\n", hr);
+        trace("Can't create an offscreen plain surface to read the render target data, hr %#lx.\n", hr);
         ret = 0xdeadbeef;
         goto out;
     }
@@ -93,7 +93,7 @@ static DWORD get_pixel_color(IDirect3DDevice9Ex *device, unsigned int x, unsigne
     hr = IDirect3DDevice9Ex_GetRenderTargetData(device, target, surf);
     if (FAILED(hr))
     {
-        trace("Can't read the render target data, hr %#x.\n", hr);
+        trace("Can't read the render target data, hr %#lx.\n", hr);
         ret = 0xdeadbeec;
         goto out;
     }
@@ -101,7 +101,7 @@ static DWORD get_pixel_color(IDirect3DDevice9Ex *device, unsigned int x, unsigne
     hr = IDirect3DSurface9_LockRect(surf, &locked_rect, &rect, D3DLOCK_READONLY);
     if (FAILED(hr))
     {
-        trace("Can't lock the offscreen surface, hr %#x.\n", hr);
+        trace("Can't lock the offscreen surface, hr %#lx.\n", hr);
         ret = 0xdeadbeeb;
         goto out;
     }
@@ -112,7 +112,7 @@ static DWORD get_pixel_color(IDirect3DDevice9Ex *device, unsigned int x, unsigne
     ret = ((DWORD *)locked_rect.pBits)[0] & 0x00ffffff;
     hr = IDirect3DSurface9_UnlockRect(surf);
     if (FAILED(hr))
-        trace("Can't unlock the offscreen surface, hr %#x.\n", hr);
+        trace("Can't unlock the offscreen surface, hr %#lx.\n", hr);
 
 out:
     if (target)
@@ -256,9 +256,7 @@ static void test_qi_base_to_ex(void)
     }
 
     hr = IDirect3D9_QueryInterface(d3d9, &IID_IDirect3D9Ex, (void **) &d3d9ex);
-    ok(hr == E_NOINTERFACE,
-       "IDirect3D9::QueryInterface for IID_IDirect3D9Ex returned %08x, expected E_NOINTERFACE\n",
-       hr);
+    ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
     ok(d3d9ex == NULL, "QueryInterface returned interface %p, expected NULL\n", d3d9ex);
     if(d3d9ex) IDirect3D9Ex_Release(d3d9ex);
 
@@ -277,21 +275,17 @@ static void test_qi_base_to_ex(void)
     }
 
     hr = IDirect3DDevice9_QueryInterface(device, &IID_IDirect3DDevice9Ex, (void **) &deviceEx);
-    ok(hr == E_NOINTERFACE,
-       "IDirect3D9Device::QueryInterface for IID_IDirect3DDevice9Ex returned %08x, expected E_NOINTERFACE\n",
-       hr);
+    ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
     ok(deviceEx == NULL, "QueryInterface returned interface %p, expected NULL\n", deviceEx);
     if(deviceEx) IDirect3DDevice9Ex_Release(deviceEx);
 
     /* Get the implicit swapchain */
     hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get the implicit swapchain (%08x).\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
         hr = IDirect3DSwapChain9_QueryInterface(swapchain, &IID_IDirect3DSwapChain9Ex, (void **)&swapchainEx);
-        ok(hr == E_NOINTERFACE,
-                "IDirect3DSwapChain9::QueryInterface for IID_IDirect3DSwapChain9Ex returned %08x, expected E_NOINTERFACE.\n",
-                hr);
+        ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
         ok(swapchainEx == NULL, "QueryInterface returned interface %p, expected NULL.\n", swapchainEx);
         if (swapchainEx)
             IDirect3DSwapChain9Ex_Release(swapchainEx);
@@ -320,22 +314,20 @@ static void test_qi_ex_to_base(void)
     ULONG ref;
 
     hr = pDirect3DCreate9Ex(D3D_SDK_VERSION, &d3d9ex);
-    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Direct3DCreate9Ex returned %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got hr %#lx.\n", hr);
     if(FAILED(hr)) {
         skip("Direct3D9Ex is not available\n");
         goto out;
     }
 
     hr = IDirect3D9Ex_QueryInterface(d3d9ex, &IID_IDirect3D9, (void **) &d3d9);
-    ok(hr == D3D_OK,
-       "IDirect3D9Ex::QueryInterface for IID_IDirect3D9 returned %08x, expected D3D_OK\n",
-       hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(d3d9 != NULL && d3d9 != (void *) 0xdeadbeef,
        "QueryInterface returned interface %p, expected != NULL && != 0xdeadbeef\n", d3d9);
     ref = getref((IUnknown *) d3d9ex);
-    ok(ref == 2, "IDirect3D9Ex refcount is %d, expected 2\n", ref);
+    ok(ref == 2, "Unexpected refcount %lu.\n", ref);
     ref = getref((IUnknown *) d3d9);
-    ok(ref == 2, "IDirect3D9 refcount is %d, expected 2\n", ref);
+    ok(ref == 2, "Unexpected refcount %lu.\n", ref);
 
     memset(&present_parameters, 0, sizeof(present_parameters));
     present_parameters.Windowed = TRUE;
@@ -354,15 +346,13 @@ static void test_qi_ex_to_base(void)
     }
 
     hr = IDirect3DDevice9_QueryInterface(device, &IID_IDirect3DDevice9Ex, (void **) &deviceEx);
-    ok(hr == D3D_OK,
-       "IDirect3D9Device::QueryInterface for IID_IDirect3DDevice9Ex returned %08x, expected D3D_OK\n",
-       hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(deviceEx != NULL && deviceEx != (void *) 0xdeadbeef,
        "QueryInterface returned interface %p, expected != NULL && != 0xdeadbeef\n", deviceEx);
     ref = getref((IUnknown *) device);
-    ok(ref == 2, "IDirect3DDevice9 refcount is %d, expected 2\n", ref);
+    ok(ref == 2, "Unexpected refcount %lu.\n", ref);
     ref = getref((IUnknown *) deviceEx);
-    ok(ref == 2, "IDirect3DDevice9Ex refcount is %d, expected 2\n", ref);
+    ok(ref == 2, "Unexpected refcount %lu.\n", ref);
     if(deviceEx) IDirect3DDevice9Ex_Release(deviceEx);
     IDirect3DDevice9_Release(device);
 
@@ -374,25 +364,21 @@ static void test_qi_ex_to_base(void)
     }
 
     hr = IDirect3DDevice9_QueryInterface(device, &IID_IDirect3DDevice9Ex, (void **) &deviceEx);
-    ok(hr == D3D_OK,
-       "IDirect3D9Device::QueryInterface for IID_IDirect3DDevice9Ex returned %08x, expected D3D_OK\n",
-       hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(deviceEx != NULL && deviceEx != (void *) 0xdeadbeef,
        "QueryInterface returned interface %p, expected != NULL && != 0xdeadbeef\n", deviceEx);
     ref = getref((IUnknown *) device);
-    ok(ref == 2, "IDirect3DDevice9 refcount is %d, expected 2\n", ref);
+    ok(ref == 2, "Unexpected refcount %lu.\n", ref);
     ref = getref((IUnknown *) deviceEx);
-    ok(ref == 2, "IDirect3DDevice9Ex refcount is %d, expected 2\n", ref);
+    ok(ref == 2, "Unexpected refcount %lu.\n", ref);
 
     /* Get the implicit swapchain */
     hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get the implicit swapchain (%08x).\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
         hr = IDirect3DSwapChain9_QueryInterface(swapchain, &IID_IDirect3DSwapChain9Ex, (void **)&swapchainEx);
-        ok(hr == D3D_OK,
-                "IDirect3DSwapChain9::QueryInterface for IID_IDirect3DSwapChain9Ex returned %08x, expected D3D_OK.\n",
-                hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         ok(swapchainEx != NULL && swapchainEx != (void *)0xdeadbeef,
                 "QueryInterface returned interface %p, expected != NULL && != 0xdeadbeef.\n", swapchainEx);
         if (swapchainEx)
@@ -437,8 +423,8 @@ static void test_get_adapter_luid(void)
     }
 
     hr = IDirect3D9Ex_GetAdapterLUID(d3d9ex, D3DADAPTER_DEFAULT, &luid);
-    ok(SUCCEEDED(hr), "GetAdapterLUID failed, hr %#x.\n", hr);
-    trace("adapter luid: %08x:%08x.\n", luid.HighPart, luid.LowPart);
+    ok(SUCCEEDED(hr), "GetAdapterLUID failed, hr %#lx.\n", hr);
+    trace("Adapter luid: %08lx:%08lx.\n", luid.HighPart, luid.LowPart);
 
     IDirect3D9Ex_Release(d3d9ex);
 }
@@ -481,17 +467,17 @@ static void test_swapchain_get_displaymode_ex(void)
     /* invalid size */
     memset(&mode_ex, 0, sizeof(mode_ex));
     hr = IDirect3DSwapChain9Ex_GetDisplayModeEx(swapchainEx, &mode_ex, &rotation);
-    ok(hr == D3DERR_INVALIDCALL, "GetDisplayModeEx returned %#x instead of D3DERR_INVALIDCALL.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     mode_ex.Size = sizeof(D3DDISPLAYMODEEX);
     rotation = (D3DDISPLAYROTATION)0xdeadbeef;
     /* valid count and valid size */
     hr = IDirect3DSwapChain9Ex_GetDisplayModeEx(swapchainEx, &mode_ex, &rotation);
-    ok(SUCCEEDED(hr), "GetDisplayModeEx failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayModeEx failed, hr %#lx.\n", hr);
 
     /* compare what GetDisplayMode returns with what GetDisplayModeEx returns */
     hr = IDirect3DSwapChain9Ex_GetDisplayMode(swapchainEx, &mode);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
 
     ok(mode_ex.Size == sizeof(D3DDISPLAYMODEEX), "Size is %d.\n", mode_ex.Size);
     ok(mode_ex.Width == mode.Width, "Width is %d instead of %d.\n", mode_ex.Width, mode.Width);
@@ -513,7 +499,7 @@ static void test_swapchain_get_displaymode_ex(void)
     mode_ex.Size = sizeof(D3DDISPLAYMODEEX);
 
     hr = IDirect3DSwapChain9Ex_GetDisplayModeEx(swapchainEx, &mode_ex, NULL);
-    ok(SUCCEEDED(hr), "GetDisplayModeEx failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayModeEx failed, hr %#lx.\n", hr);
 
     ok(mode_ex.Size == sizeof(D3DDISPLAYMODEEX), "Size is %d.\n", mode_ex.Size);
     ok(mode_ex.Width == mode.Width, "Width is %d instead of %d.\n", mode_ex.Width, mode.Width);
@@ -549,7 +535,7 @@ static void test_get_adapter_displaymode_ex(void)
     hr = pDirect3DCreate9Ex(D3D_SDK_VERSION, &d3d9ex);
     if (FAILED(hr))
     {
-        skip("Direct3D9Ex is not available (%#x)\n", hr);
+        skip("Failed to create IDirect3D9Ex, hr %#lx.\n", hr);
         DestroyWindow(window);
         return;
     }
@@ -564,16 +550,14 @@ static void test_get_adapter_displaymode_ex(void)
     }
 
     hr = IDirect3D9Ex_QueryInterface(d3d9ex, &IID_IDirect3D9, (void **) &d3d9);
-    ok(hr == D3D_OK,
-       "IDirect3D9Ex::QueryInterface for IID_IDirect3D9 returned %08x, expected D3D_OK\n",
-       hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(d3d9 != NULL && d3d9 != (void *) 0xdeadbeef,
        "QueryInterface returned interface %p, expected != NULL && != 0xdeadbeef\n", d3d9);
 
     memset(&startmode, 0, sizeof(startmode));
     startmode.dmSize = sizeof(startmode);
     retval = EnumDisplaySettingsExW(NULL, ENUM_CURRENT_SETTINGS, &startmode, 0);
-    ok(retval, "Failed to retrieve current display mode, retval %d.\n", retval);
+    ok(retval, "Failed to retrieve current display mode, retval %ld.\n", retval);
     if (!retval) goto out;
 
     devmode = startmode;
@@ -586,7 +570,7 @@ static void test_get_adapter_displaymode_ex(void)
         goto out;
     }
 
-    ok(retval == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsEx failed with %d.\n", retval);
+    ok(retval == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsEx failed with %ld.\n", retval);
     /* try retrieve orientation info with EnumDisplaySettingsEx*/
     devmode.dmFields = 0;
     S2(U1(devmode)).dmDisplayOrientation = 0;
@@ -596,19 +580,19 @@ static void test_get_adapter_displaymode_ex(void)
     /*now that orientation has changed start tests for GetAdapterDisplayModeEx: invalid Size*/
     memset(&mode_ex, 0, sizeof(mode_ex));
     hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, D3DADAPTER_DEFAULT, &mode_ex, &rotation);
-    ok(hr == D3DERR_INVALIDCALL, "GetAdapterDisplayModeEx returned %#x instead of D3DERR_INVALIDCALL\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     mode_ex.Size = sizeof(D3DDISPLAYMODEEX);
     /* invalid count*/
     hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, count + 1, &mode_ex, &rotation);
-    ok(hr == D3DERR_INVALIDCALL, "GetAdapterDisplayModeEx returned %#x instead of D3DERR_INVALIDCALL\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     /*valid count and valid Size*/
     hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, D3DADAPTER_DEFAULT, &mode_ex, &rotation);
-    ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#lx.\n", hr);
 
     /* Compare what GetAdapterDisplayMode returns with what GetAdapterDisplayModeEx returns*/
     hr = IDirect3D9_GetAdapterDisplayMode(d3d9, D3DADAPTER_DEFAULT, &mode);
-    ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
 
     ok(mode_ex.Size == sizeof(D3DDISPLAYMODEEX), "size is %d\n", mode_ex.Size);
     ok(mode_ex.Width == mode.Width, "width is %d instead of %d\n", mode_ex.Width, mode.Width);
@@ -622,7 +606,7 @@ static void test_get_adapter_displaymode_ex(void)
     /* Check that orientation is returned correctly by GetAdapterDisplayModeEx
      * and EnumDisplaySettingsEx(). */
     ok(S2(U1(devmode)).dmDisplayOrientation == DMDO_180 && rotation == D3DDISPLAYROTATION_180,
-            "rotation is %d instead of %d\n", rotation, S2(U1(devmode)).dmDisplayOrientation);
+            "rotation is %d instead of %ld\n", rotation, S2(U1(devmode)).dmDisplayOrientation);
 
     trace("GetAdapterDisplayModeEx returned Width = %d, Height = %d, RefreshRate = %d, Format = %x, ScanLineOrdering = %x, rotation = %d\n",
           mode_ex.Width, mode_ex.Height, mode_ex.RefreshRate, mode_ex.Format, mode_ex.ScanLineOrdering, rotation);
@@ -632,7 +616,7 @@ static void test_get_adapter_displaymode_ex(void)
     mode_ex.Size = sizeof(D3DDISPLAYMODEEX);
 
     hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, D3DADAPTER_DEFAULT, &mode_ex, NULL);
-    ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#lx.\n", hr);
 
     ok(mode_ex.Size == sizeof(D3DDISPLAYMODEEX), "size is %d\n", mode_ex.Size);
     ok(mode_ex.Width == mode.Width, "width is %d instead of %d\n", mode_ex.Width, mode.Width);
@@ -646,7 +630,7 @@ static void test_get_adapter_displaymode_ex(void)
 
     /* return to the default mode */
     retval = ChangeDisplaySettingsExW(NULL, &startmode, NULL, 0, NULL);
-    ok(retval == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsEx failed with %d.\n", retval);
+    ok(retval == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsEx failed with %ld.\n", retval);
 out:
     IDirect3D9_Release(d3d9);
     IDirect3D9Ex_Release(d3d9ex);
@@ -689,9 +673,9 @@ static void test_create_depth_stencil_surface_ex(void)
     }
 
     hr = IDirect3DDevice9Ex_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D9, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D9, hr %#lx.\n", hr);
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     warp = adapter_is_warp(&identifier);
     IDirect3D9_Release(d3d);
 
@@ -701,20 +685,20 @@ static void test_create_depth_stencil_surface_ex(void)
         hr = IDirect3DDevice9Ex_CreateDepthStencilSurfaceEx(device, 64, 64, D3DFMT_D24S8,
                 D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL, tests[i].usage);
         ok(hr == tests[i].hr || broken(warp && tests[i].broken_warp),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (SUCCEEDED(hr))
         {
             hr = IDirect3DSurface9_GetDesc(surface, &surface_desc);
-            ok(SUCCEEDED(hr), "Test %u: GetDesc failed, hr %#x.\n", i, hr);
+            ok(SUCCEEDED(hr), "Test %u: GetDesc failed, hr %#lx.\n", i, hr);
             ok(surface_desc.Type == D3DRTYPE_SURFACE, "Test %u: Got unexpected type %#x.\n",
                     i, surface_desc.Type);
             ok(surface_desc.Pool == D3DPOOL_DEFAULT, "Test %u: Got unexpected pool %#x.\n",
                     i,  surface_desc.Pool);
             ok(surface_desc.Usage == (tests[i].usage | D3DUSAGE_DEPTHSTENCIL),
-                    "Test %u: Got unexpected usage %#x.\n", i, surface_desc.Usage);
+                    "Test %u: Got unexpected usage %#lx.\n", i, surface_desc.Usage);
 
             ref = IDirect3DSurface9_Release(surface);
-            ok(!ref, "Test %u: Surface has %u references left.\n", i, ref);
+            ok(!ref, "Test %u: Surface has %lu references left.\n", i, ref);
         }
         else
         {
@@ -724,7 +708,7 @@ static void test_create_depth_stencil_surface_ex(void)
     }
 
     ref = IDirect3DDevice9Ex_Release(device);
-    ok(!ref, "Device has %u references left.\n", ref);
+    ok(!ref, "Device has %lu references left.\n", ref);
     DestroyWindow(window);
 }
 
@@ -750,14 +734,13 @@ static void test_user_memory(void)
     IDirect3DIndexBuffer9 *index_buffer;
     IDirect3DSurface9 *surface;
     D3DLOCKED_RECT locked_rect;
-    UINT refcount;
+    unsigned int color, x, y;
+    ULONG refcount;
     HWND window;
     HRESULT hr;
     void *mem;
     char *ptr;
     D3DCAPS9 caps;
-    unsigned int x, y;
-    D3DCOLOR color;
 
     window = create_window();
     if (!(device = create_device(window, NULL)))
@@ -767,84 +750,84 @@ static void test_user_memory(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 128 * 128 * 4);
     hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 0, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, &mem);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreateTexture(device, 1, 1, 0, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, &mem);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 2, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, &mem);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_SCRATCH, &texture, &mem);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, &mem);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
     ok(locked_rect.Pitch == 128 * 4, "Got unexpected pitch %d.\n", locked_rect.Pitch);
     ok(locked_rect.pBits == mem, "Got unexpected pBits %p, expected %p.\n", locked_rect.pBits, mem);
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     if (caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP)
     {
         hr = IDirect3DDevice9Ex_CreateCubeTexture(device, 2, 1, 0, D3DFMT_A8R8G8B8,
                 D3DPOOL_SYSTEMMEM, &cube_texture, &mem);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
     if (caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)
     {
         hr = IDirect3DDevice9Ex_CreateVolumeTexture(device, 2, 2, 2, 1, 0, D3DFMT_A8R8G8B8,
                 D3DPOOL_SYSTEMMEM, &volume_texture, &mem);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9Ex_CreateIndexBuffer(device, 16, 0, D3DFMT_INDEX32, D3DPOOL_SYSTEMMEM,
             &index_buffer, &mem);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreateVertexBuffer(device, 16, 0, 0, D3DPOOL_SYSTEMMEM,
             &vertex_buffer, &mem);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &surface, &mem);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(locked_rect.Pitch == 128 * 4, "Got unexpected pitch %d.\n", locked_rect.Pitch);
     ok(locked_rect.pBits == mem, "Got unexpected pBits %p, expected %p.\n", locked_rect.pBits, mem);
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurfaceEx(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &surface, &mem, 0);
-    todo_wine ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         ok(locked_rect.Pitch == 128 * 4, "Got unexpected pitch %d.\n", locked_rect.Pitch);
         ok(locked_rect.pBits == mem, "Got unexpected pBits %p, expected %p.\n", locked_rect.pBits, mem);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
         IDirect3DSurface9_Release(surface);
     }
 
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DPOOL_SCRATCH, &surface, &mem);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurfaceEx(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DPOOL_SCRATCH, &surface, &mem, 0);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     ptr = mem;
     for (y = 0; y < 33; ++y)
@@ -853,50 +836,50 @@ static void test_user_memory(void)
 
     hr = IDirect3DDevice9Ex_CreateTexture(device, 33, 33, 1, 0, D3DFMT_L8,
             D3DPOOL_SYSTEMMEM, &texture, &mem);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
     ok(locked_rect.Pitch == 33, "Got unexpected pitch %d.\n", locked_rect.Pitch);
     ok(locked_rect.pBits == mem, "Got unexpected pBits %p, expected %p.\n", locked_rect.pBits, mem);
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_CreateTexture(device, 33, 33, 1, 0, D3DFMT_L8,
             D3DPOOL_DEFAULT, &texture2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture,
             (IDirect3DBaseTexture9 *)texture2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_pixel_color(device, 320, 240);
     ok(color_match(color, 0x007f7f7f, 2), "Got unexpected color %#x.\n", color);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture2);
     IDirect3DTexture9_Release(texture);
     HeapFree(GetProcessHeap(), 0, mem);
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     DestroyWindow(window);
@@ -915,9 +898,9 @@ static void test_reset(void)
         0x0000ffff,                                     /* end                */
     };
 
-    DWORD height, orig_height = GetSystemMetrics(SM_CYSCREEN);
-    DWORD width, orig_width = GetSystemMetrics(SM_CXSCREEN);
-    UINT i, adapter_mode_count, offset, stride;
+    unsigned int width, height, i, adapter_mode_count, offset, stride;
+    const DWORD orig_height = GetSystemMetrics(SM_CYSCREEN);
+    const DWORD orig_width = GetSystemMetrics(SM_CXSCREEN);
     IDirect3DVertexBuffer9 *vb, *cur_vb;
     IDirect3DIndexBuffer9 *ib, *cur_ib;
     IDirect3DVertexShader9 *shader;
@@ -930,8 +913,8 @@ static void test_reset(void)
     DEVMODEW devmode;
     IDirect3D9 *d3d9;
     D3DVIEWPORT9 vp;
+    ULONG refcount;
     D3DCAPS9 caps;
-    UINT refcount;
     DWORD value;
     HWND window;
     HRESULT hr;
@@ -953,9 +936,9 @@ static void test_reset(void)
     }
 
     hr = IDirect3DDevice9Ex_GetDirect3D(device, &d3d9);
-    ok(SUCCEEDED(hr), "Failed to get d3d9, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d9, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     IDirect3D9_GetAdapterDisplayMode(d3d9, D3DADAPTER_DEFAULT, &d3ddm);
     adapter_mode_count = IDirect3D9_GetAdapterModeCount(d3d9, D3DADAPTER_DEFAULT, d3ddm.Format);
@@ -965,7 +948,7 @@ static void test_reset(void)
         UINT j;
 
         hr = IDirect3D9_EnumAdapterModes(d3d9, D3DADAPTER_DEFAULT, d3ddm.Format, i, &d3ddm2);
-        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
 
         for (j = 0; j < mode_count; ++j)
         {
@@ -1008,9 +991,9 @@ static void test_reset(void)
     d3dpp.EnableAutoDepthStencil = TRUE;
     d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -1018,16 +1001,16 @@ static void test_reset(void)
     ok(height == modes[i].h, "Got screen height %u, expected %u.\n", height, modes[i].h);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == modes[i].w && rect.bottom == modes[i].h,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == modes[i].w, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].w);
-    ok(vp.Height == modes[i].h, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].h);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == modes[i].w, "Got vp.Width %lu, expected %u.\n", vp.Width, modes[i].w);
+    ok(vp.Height == modes[i].h, "Got vp.Height %lu, expected %u.\n", vp.Height, modes[i].h);
     ok(vp.MinZ == 0.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 1.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
@@ -1037,17 +1020,17 @@ static void test_reset(void)
     vp.MinZ = 2.0f;
     vp.MaxZ = 3.0f;
     hr = IDirect3DDevice9Ex_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     SetRect(&rect, 10, 20, 30, 40);
     hr = IDirect3DDevice9Ex_SetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to set scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set scissor rect, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!!value, "Got unexpected value %#x for D3DRS_LIGHTING.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected value %#lx for D3DRS_LIGHTING.\n", value);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
@@ -1056,26 +1039,26 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = modes[i].h;
     d3dpp.BackBufferFormat = d3ddm.Format;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Render states are preserved in d3d9ex. */
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!value, "Got unexpected value %#x for D3DRS_LIGHTING.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!value, "Got unexpected value %#lx for D3DRS_LIGHTING.\n", value);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == modes[i].w && rect.bottom == modes[i].h,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == modes[i].w, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].w);
-    ok(vp.Height == modes[i].h, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].h);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == modes[i].w, "Got vp.Width %lu, expected %u.\n", vp.Width, modes[i].w);
+    ok(vp.Height == modes[i].h, "Got vp.Height %lu, expected %u.\n", vp.Height, modes[i].h);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
@@ -1085,9 +1068,9 @@ static void test_reset(void)
     ok(height == modes[i].h, "Got screen height %u, expected %u.\n", height, modes[i].h);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == modes[i].w, "Got backbuffer width %u, expected %u.\n",
             d3dpp.BackBufferWidth, modes[i].w);
     ok(d3dpp.BackBufferHeight == modes[i].h, "Got backbuffer height %u, expected %u.\n",
@@ -1101,33 +1084,33 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 300;
     d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
-    ok(width == orig_width, "Got screen width %u, expected %u.\n", width, orig_width);
-    ok(height == orig_height, "Got screen height %u, expected %u.\n", height, orig_height);
+    ok(width == orig_width, "Got screen width %u, expected %lu.\n", width, orig_width);
+    ok(height == orig_height, "Got screen height %u, expected %lu.\n", height, orig_height);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == 400 && rect.bottom == 300,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == 400, "Got unexpected vp.Width %u.\n", vp.Width);
-    ok(vp.Height == 300, "Got unexpected vp.Height %u.\n", vp.Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == 400, "Got unexpected vp.Width %lu.\n", vp.Width);
+    ok(vp.Height == 300, "Got unexpected vp.Height %lu.\n", vp.Height);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == 400, "Got unexpected backbuffer width %u.\n", d3dpp.BackBufferWidth);
     ok(d3dpp.BackBufferHeight == 300, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight);
     IDirect3DSwapChain9_Release(swapchain);
@@ -1138,7 +1121,7 @@ static void test_reset(void)
     devmode.dmPelsWidth = modes[1].w;
     devmode.dmPelsHeight = modes[1].h;
     ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", ret);
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
     ok(width == modes[1].w, "Screen width is %u, expected %u.\n", width, modes[1].w);
@@ -1148,9 +1131,9 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 400;
     d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -1158,24 +1141,24 @@ static void test_reset(void)
     ok(height == modes[1].h, "Screen height is %u, expected %u.\n", height, modes[1].h);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == 500 && rect.bottom == 400,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == 500, "Got unexpected vp.Width %u.\n", vp.Width);
-    ok(vp.Height == 400, "Got unexpected vp.Height %u.\n", vp.Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == 500, "Got unexpected vp.Width %lu.\n", vp.Width);
+    ok(vp.Height == 400, "Got unexpected vp.Height %lu.\n", vp.Height);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     memset(&d3dpp, 0, sizeof(d3dpp));
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == 500, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth);
     ok(d3dpp.BackBufferHeight == 400, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight);
     IDirect3DSwapChain9_Release(swapchain);
@@ -1184,11 +1167,11 @@ static void test_reset(void)
     devmode.dmPelsWidth = orig_width;
     devmode.dmPelsHeight = orig_height;
     ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", ret);
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
-    ok(width == orig_width, "Got screen width %u, expected %u.\n", width, orig_width);
-    ok(height == orig_height, "Got screen height %u, expected %u.\n", height, orig_height);
+    ok(width == orig_width, "Got screen width %u, expected %lu.\n", width, orig_width);
+    ok(height == orig_height, "Got screen height %u, expected %lu.\n", height, orig_height);
 
     SetRect(&rect, 0, 0, 200, 150);
     ok(AdjustWindowRect(&rect, GetWindowLongW(window, GWL_STYLE), FALSE), "Failed to adjust window rect.\n");
@@ -1205,63 +1188,63 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 0;
     d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     ok(d3dpp.BackBufferWidth == client_rect.right,
-            "Got unexpected BackBufferWidth %u, expected %d.\n", d3dpp.BackBufferWidth, client_rect.right);
+            "Got unexpected BackBufferWidth %u, expected %ld.\n", d3dpp.BackBufferWidth, client_rect.right);
     ok(d3dpp.BackBufferHeight == client_rect.bottom,
-            "Got unexpected BackBufferHeight %u, expected %d.\n", d3dpp.BackBufferHeight, client_rect.bottom);
+            "Got unexpected BackBufferHeight %u, expected %ld.\n", d3dpp.BackBufferHeight, client_rect.bottom);
     ok(d3dpp.BackBufferFormat == d3ddm.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n",
             d3dpp.BackBufferFormat, d3ddm.Format);
     ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount);
     ok(!d3dpp.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType);
-    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %u.\n", d3dpp.MultiSampleQuality);
+    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %lu.\n", d3dpp.MultiSampleQuality);
     ok(d3dpp.SwapEffect == D3DSWAPEFFECT_DISCARD, "Got unexpected SwapEffect %#x.\n", d3dpp.SwapEffect);
     ok(!d3dpp.hDeviceWindow, "Got unexpected hDeviceWindow %p.\n", d3dpp.hDeviceWindow);
     ok(d3dpp.Windowed, "Got unexpected Windowed %#x.\n", d3dpp.Windowed);
     ok(!d3dpp.EnableAutoDepthStencil, "Got unexpected EnableAutoDepthStencil %#x.\n", d3dpp.EnableAutoDepthStencil);
     ok(!d3dpp.AutoDepthStencilFormat, "Got unexpected AutoDepthStencilFormat %#x.\n", d3dpp.AutoDepthStencilFormat);
-    ok(!d3dpp.Flags, "Got unexpected Flags %#x.\n", d3dpp.Flags);
+    ok(!d3dpp.Flags, "Got unexpected Flags %#lx.\n", d3dpp.Flags);
     ok(!d3dpp.FullScreen_RefreshRateInHz, "Got unexpected FullScreen_RefreshRateInHz %u.\n",
             d3dpp.FullScreen_RefreshRateInHz);
     ok(!d3dpp.PresentationInterval, "Got unexpected PresentationInterval %#x.\n", d3dpp.PresentationInterval);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(EqualRect(&rect, &client_rect), "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == client_rect.right, "Got unexpected vp.Width %u, expected %d.\n",
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == client_rect.right, "Got unexpected vp.Width %lu, expected %ld.\n",
             vp.Width, client_rect.right);
-    ok(vp.Height == client_rect.bottom, "Got unexpected vp.Height %u, expected %d.\n",
+    ok(vp.Height == client_rect.bottom, "Got unexpected vp.Height %lu, expected %ld.\n",
             vp.Height, client_rect.bottom);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
-    ok(d3dpp.BackBufferWidth == client_rect.right, "Got unexpected backbuffer width %u, expected %d.\n",
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
+    ok(d3dpp.BackBufferWidth == client_rect.right, "Got unexpected backbuffer width %u, expected %ld.\n",
             d3dpp.BackBufferWidth, client_rect.right);
-    ok(d3dpp.BackBufferHeight == client_rect.bottom, "Got unexpected backbuffer height %u, expected %d.\n",
+    ok(d3dpp.BackBufferHeight == client_rect.bottom, "Got unexpected backbuffer height %u, expected %ld.\n",
             d3dpp.BackBufferHeight, client_rect.bottom);
     ok(d3dpp.BackBufferFormat == d3ddm.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n",
             d3dpp.BackBufferFormat, d3ddm.Format);
     ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount);
     ok(!d3dpp.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType);
-    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %u.\n", d3dpp.MultiSampleQuality);
+    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %lu.\n", d3dpp.MultiSampleQuality);
     ok(d3dpp.SwapEffect == D3DSWAPEFFECT_DISCARD, "Got unexpected SwapEffect %#x.\n", d3dpp.SwapEffect);
     ok(d3dpp.hDeviceWindow == window, "Got unexpected hDeviceWindow %p, expected %p.\n", d3dpp.hDeviceWindow, window);
     ok(d3dpp.Windowed, "Got unexpected Windowed %#x.\n", d3dpp.Windowed);
     ok(!d3dpp.EnableAutoDepthStencil, "Got unexpected EnableAutoDepthStencil %#x.\n", d3dpp.EnableAutoDepthStencil);
     ok(!d3dpp.AutoDepthStencilFormat, "Got unexpected AutoDepthStencilFormat %#x.\n", d3dpp.AutoDepthStencilFormat);
-    ok(!d3dpp.Flags, "Got unexpected Flags %#x.\n", d3dpp.Flags);
+    ok(!d3dpp.Flags, "Got unexpected Flags %#lx.\n", d3dpp.Flags);
     ok(!d3dpp.FullScreen_RefreshRateInHz, "Got unexpected FullScreen_RefreshRateInHz %u.\n",
             d3dpp.FullScreen_RefreshRateInHz);
     ok(!d3dpp.PresentationInterval, "Got unexpected PresentationInterval %#x.\n", d3dpp.PresentationInterval);
@@ -1276,11 +1259,11 @@ static void test_reset(void)
     /* Reset with resources in the default pool succeeds in d3d9ex. */
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, 16, 16,
             D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     if (caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)
@@ -1289,11 +1272,11 @@ static void test_reset(void)
 
         hr = IDirect3DDevice9Ex_CreateVolumeTexture(device, 16, 16, 4, 1, 0,
                 D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &volume_texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
         hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
         hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-        ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         IDirect3DVolumeTexture9_Release(volume_texture);
     }
     else
@@ -1304,95 +1287,95 @@ static void test_reset(void)
     /* Test with resources bound but otherwise not referenced. */
     hr = IDirect3DDevice9Ex_CreateVertexBuffer(device, 16, 0,
             D3DFVF_XYZ, D3DPOOL_DEFAULT, &vb, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_SetStreamSource(device, 0, vb, 0, 16);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     refcount = IDirect3DVertexBuffer9_Release(vb);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
     hr = IDirect3DDevice9Ex_CreateIndexBuffer(device, 16, 0,
             D3DFMT_INDEX16, D3DPOOL_DEFAULT, &ib, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_SetIndices(device, ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     refcount = IDirect3DIndexBuffer9_Release(ib);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
     hr = IDirect3DDevice9Ex_CreateTexture(device, 16, 16, 0, 0,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_SetTexture(device, i, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_GetIndices(device, &cur_ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(cur_ib == ib, "Unexpected index buffer %p.\n", cur_ib);
     refcount = IDirect3DIndexBuffer9_Release(ib);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
     hr = IDirect3DDevice9Ex_GetStreamSource(device, 0, &cur_vb, &offset, &stride);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(cur_vb == vb, "Unexpected index buffer %p.\n", cur_ib);
     ok(!offset, "Unexpected offset %u.\n", offset);
     ok(stride == 16, "Unexpected stride %u.\n", stride);
     refcount = IDirect3DVertexBuffer9_Release(vb);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
     refcount = IDirect3DTexture9_Release(texture);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
 
     /* Scratch and sysmem pools are fine too. */
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, 16, 16,
             D3DFMT_R5G6B5, D3DPOOL_SCRATCH, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, 16, 16,
             D3DFMT_R5G6B5, D3DPOOL_SYSTEMMEM, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     /* The depth stencil should get reset to the auto depth stencil when present. */
     hr = IDirect3DDevice9Ex_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil surface, hr %#lx.\n", hr);
 
     d3dpp.EnableAutoDepthStencil = TRUE;
     d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_GetDepthStencilSurface(device, &surface);
-    ok(SUCCEEDED(hr), "Failed to get depth/stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get depth/stencil surface, hr %#lx.\n", hr);
     ok(!!surface, "Depth/stencil surface should not be NULL.\n");
     IDirect3DSurface9_Release(surface);
 
     d3dpp.EnableAutoDepthStencil = FALSE;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_GetDepthStencilSurface(device, &surface);
-    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!surface, "Depth/stencil surface should be NULL.\n");
 
     /* References to implicit surfaces are allowed in d3d9ex. */
     hr = IDirect3DDevice9Ex_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     /* Shaders are fine. */
     hr = IDirect3DDevice9Ex_CreateVertexShader(device, simple_vs, &shader);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     IDirect3DVertexShader9_Release(shader);
 
     /* Try setting invalid modes. */
@@ -1402,9 +1385,9 @@ static void test_reset(void)
     d3dpp.BackBufferWidth = 32;
     d3dpp.BackBufferHeight = 32;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
@@ -1412,12 +1395,12 @@ static void test_reset(void)
     d3dpp.BackBufferWidth = 801;
     d3dpp.BackBufferHeight = 600;
     hr = IDirect3DDevice9Ex_Reset(device, &d3dpp);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3D9_GetAdapterDisplayMode(d3d9, D3DADAPTER_DEFAULT, &d3ddm);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
     d3dpp.Windowed = TRUE;
@@ -1430,7 +1413,7 @@ cleanup:
     HeapFree(GetProcessHeap(), 0, modes);
     IDirect3D9_Release(d3d9);
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -1463,12 +1446,12 @@ static void test_reset_ex(void)
     }
 
     hr = IDirect3DDevice9Ex_GetDirect3D(device, (IDirect3D9 **)&d3d9);
-    ok(SUCCEEDED(hr), "Failed to get d3d9, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d9, hr %#lx.\n", hr);
 
     memset(&mode, 0, sizeof(mode));
     mode.Size = sizeof(mode);
     hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9, D3DADAPTER_DEFAULT, &mode, NULL);
-    ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#lx.\n", hr);
     memset(&mode_filter, 0, sizeof(mode_filter));
     mode_filter.Size = sizeof(mode_filter);
     mode_filter.Format = mode.Format;
@@ -1481,7 +1464,7 @@ static void test_reset_ex(void)
         memset(&mode2, 0, sizeof(mode));
         mode2.Size = sizeof(mode2);
         hr = IDirect3D9Ex_EnumAdapterModesEx(d3d9, D3DADAPTER_DEFAULT, &mode_filter, i, &mode2);
-        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
 
         for (j = 0; j < mode_count; ++j)
         {
@@ -1516,11 +1499,11 @@ static void test_reset_ex(void)
     modes[i].RefreshRate = 0;
     modes[i].ScanLineOrdering = 0;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -1528,16 +1511,16 @@ static void test_reset_ex(void)
     ok(height == modes[i].Height, "Got screen height %u, expected %u.\n", height, modes[i].Height);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == modes[i].Width && rect.bottom == modes[i].Height,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == modes[i].Width, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].Width);
-    ok(vp.Height == modes[i].Height, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == modes[i].Width, "Got vp.Width %lu, expected %u.\n", vp.Width, modes[i].Width);
+    ok(vp.Height == modes[i].Height, "Got vp.Height %lu, expected %u.\n", vp.Height, modes[i].Height);
     ok(vp.MinZ == 0.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 1.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
@@ -1547,17 +1530,17 @@ static void test_reset_ex(void)
     vp.MinZ = 2.0f;
     vp.MaxZ = 3.0f;
     hr = IDirect3DDevice9Ex_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     SetRect(&rect, 10, 20, 30, 40);
     hr = IDirect3DDevice9Ex_SetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to set scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set scissor rect, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!!value, "Got unexpected value %#x for D3DRS_LIGHTING.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected value %#lx for D3DRS_LIGHTING.\n", value);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
@@ -1568,26 +1551,26 @@ static void test_reset_ex(void)
     modes[i].RefreshRate = 0;
     modes[i].ScanLineOrdering = 0;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Render states are preserved in d3d9ex. */
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!value, "Got unexpected value %#x for D3DRS_LIGHTING.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!value, "Got unexpected value %#lx for D3DRS_LIGHTING.\n", value);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == modes[i].Width && rect.bottom == modes[i].Height,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == modes[i].Width, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].Width);
-    ok(vp.Height == modes[i].Height, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == modes[i].Width, "Got vp.Width %lu, expected %u.\n", vp.Width, modes[i].Width);
+    ok(vp.Height == modes[i].Height, "Got vp.Height %lu, expected %u.\n", vp.Height, modes[i].Height);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
@@ -1597,9 +1580,9 @@ static void test_reset_ex(void)
     ok(height == modes[i].Height, "Got screen height %u, expected %u.\n", height, modes[i].Height);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == modes[i].Width, "Got backbuffer width %u, expected %u.\n",
             d3dpp.BackBufferWidth, modes[i].Width);
     ok(d3dpp.BackBufferHeight == modes[i].Height, "Got backbuffer height %u, expected %u.\n",
@@ -1614,47 +1597,47 @@ static void test_reset_ex(void)
     d3dpp.BackBufferWidth = modes[i].Width - 10;
     d3dpp.BackBufferHeight = modes[i].Height - 10;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     d3dpp.BackBufferWidth = modes[i].Width - 1;
     d3dpp.BackBufferHeight = modes[i].Height;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     d3dpp.BackBufferWidth = modes[i].Width;
     d3dpp.BackBufferHeight = modes[i].Height - 1;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     d3dpp.BackBufferWidth = 0;
     d3dpp.BackBufferHeight = 0;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     d3dpp.BackBufferWidth = modes[i].Width;
     d3dpp.BackBufferHeight = modes[i].Height;
     mode2 = modes[i];
     mode2.Width = 0;
     mode2.Height = 0;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &mode2);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     d3dpp.BackBufferWidth = modes[i].Width;
     d3dpp.BackBufferHeight = modes[i].Height;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == modes[i].Width && rect.bottom == modes[i].Height,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == modes[i].Width, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].Width);
-    ok(vp.Height == modes[i].Height, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == modes[i].Width, "Got vp.Width %lu, expected %u.\n", vp.Width, modes[i].Width);
+    ok(vp.Height == modes[i].Height, "Got vp.Height %lu, expected %u.\n", vp.Height, modes[i].Height);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
@@ -1664,9 +1647,9 @@ static void test_reset_ex(void)
     ok(height == modes[i].Height, "Got screen height %u, expected %u.\n", height, modes[i].Height);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == modes[i].Width, "Got backbuffer width %u, expected %u.\n",
             d3dpp.BackBufferWidth, modes[i].Width);
     ok(d3dpp.BackBufferHeight == modes[i].Height, "Got backbuffer height %u, expected %u.\n",
@@ -1680,9 +1663,9 @@ static void test_reset_ex(void)
     d3dpp.BackBufferHeight = 300;
     d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, NULL);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -1690,23 +1673,23 @@ static void test_reset_ex(void)
     ok(height == orig_height, "Got screen height %u, expected %u.\n", height, orig_height);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == 400 && rect.bottom == 300,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == 400, "Got unexpected vp.Width %u.\n", vp.Width);
-    ok(vp.Height == 300, "Got unexpected vp.Height %u.\n", vp.Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == 400, "Got unexpected vp.Width %lu.\n", vp.Width);
+    ok(vp.Height == 300, "Got unexpected vp.Height %lu.\n", vp.Height);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == 400, "Got unexpected backbuffer width %u.\n", d3dpp.BackBufferWidth);
     ok(d3dpp.BackBufferHeight == 300, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight);
     IDirect3DSwapChain9_Release(swapchain);
@@ -1717,7 +1700,7 @@ static void test_reset_ex(void)
     devmode.dmPelsWidth = modes[1].Width;
     devmode.dmPelsHeight = modes[1].Height;
     ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", ret);
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
     ok(width == modes[1].Width, "Screen width is %u, expected %u.\n", width, modes[1].Width);
@@ -1727,11 +1710,11 @@ static void test_reset_ex(void)
     d3dpp.BackBufferHeight = 400;
     d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &mode);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, NULL);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -1739,24 +1722,24 @@ static void test_reset_ex(void)
     ok(height == modes[1].Height, "Screen height is %u, expected %u.\n", height, modes[1].Height);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == 500 && rect.bottom == 400,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == 500, "Got unexpected vp.Width %u.\n", vp.Width);
-    ok(vp.Height == 400, "Got unexpected vp.Height %u.\n", vp.Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == 500, "Got unexpected vp.Width %lu.\n", vp.Width);
+    ok(vp.Height == 400, "Got unexpected vp.Height %lu.\n", vp.Height);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     memset(&d3dpp, 0, sizeof(d3dpp));
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == 500, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth);
     ok(d3dpp.BackBufferHeight == 400, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight);
     IDirect3DSwapChain9_Release(swapchain);
@@ -1765,7 +1748,7 @@ static void test_reset_ex(void)
     devmode.dmPelsWidth = orig_width;
     devmode.dmPelsHeight = orig_height;
     ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", ret);
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
     ok(width == orig_width, "Got screen width %u, expected %u.\n", width, orig_width);
@@ -1786,64 +1769,64 @@ static void test_reset_ex(void)
     d3dpp.BackBufferHeight = 0;
     d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
     hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, NULL);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     ok(d3dpp.BackBufferWidth == client_rect.right,
-            "Got unexpected BackBufferWidth %u, expected %d.\n", d3dpp.BackBufferWidth, client_rect.right);
+            "Got unexpected BackBufferWidth %u, expected %ld.\n", d3dpp.BackBufferWidth, client_rect.right);
     ok(d3dpp.BackBufferHeight == client_rect.bottom,
-            "Got unexpected BackBufferHeight %u, expected %d.\n", d3dpp.BackBufferHeight, client_rect.bottom);
+            "Got unexpected BackBufferHeight %u, expected %ld.\n", d3dpp.BackBufferHeight, client_rect.bottom);
     ok(d3dpp.BackBufferFormat == mode.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n",
             d3dpp.BackBufferFormat, mode.Format);
     ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount);
     ok(!d3dpp.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType);
-    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %u.\n", d3dpp.MultiSampleQuality);
+    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %lu.\n", d3dpp.MultiSampleQuality);
     ok(d3dpp.SwapEffect == D3DSWAPEFFECT_DISCARD, "Got unexpected SwapEffect %#x.\n", d3dpp.SwapEffect);
     ok(!d3dpp.hDeviceWindow, "Got unexpected hDeviceWindow %p.\n", d3dpp.hDeviceWindow);
     ok(d3dpp.Windowed, "Got unexpected Windowed %#x.\n", d3dpp.Windowed);
     ok(!d3dpp.EnableAutoDepthStencil, "Got unexpected EnableAutoDepthStencil %#x.\n", d3dpp.EnableAutoDepthStencil);
     ok(!d3dpp.AutoDepthStencilFormat, "Got unexpected AutoDepthStencilFormat %#x.\n", d3dpp.AutoDepthStencilFormat);
-    ok(!d3dpp.Flags, "Got unexpected Flags %#x.\n", d3dpp.Flags);
+    ok(!d3dpp.Flags, "Got unexpected Flags %#lx.\n", d3dpp.Flags);
     ok(!d3dpp.FullScreen_RefreshRateInHz, "Got unexpected FullScreen_RefreshRateInHz %u.\n",
             d3dpp.FullScreen_RefreshRateInHz);
     ok(!d3dpp.PresentationInterval, "Got unexpected PresentationInterval %#x.\n", d3dpp.PresentationInterval);
 
     hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(EqualRect(&rect, &client_rect), "Got unexpected scissor rect %s, expected %s.\n",
             wine_dbgstr_rect(&rect), wine_dbgstr_rect(&client_rect));
 
     hr = IDirect3DDevice9Ex_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X);
-    ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == client_rect.right, "Got unexpected vp.Width %u, expected %d.\n",
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(vp.X == 0, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(vp.Y == 0, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == client_rect.right, "Got unexpected vp.Width %lu, expected %ld.\n",
             vp.Width, client_rect.right);
-    ok(vp.Height == client_rect.bottom, "Got unexpected vp.Height %u, expected %d.\n",
+    ok(vp.Height == client_rect.bottom, "Got unexpected vp.Height %lu, expected %ld.\n",
             vp.Height, client_rect.bottom);
     ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == client_rect.right,
-            "Got unexpected backbuffer width %u, expected %d.\n", d3dpp.BackBufferWidth, client_rect.right);
+            "Got unexpected backbuffer width %u, expected %ld.\n", d3dpp.BackBufferWidth, client_rect.right);
     ok(d3dpp.BackBufferHeight == client_rect.bottom,
-            "Got unexpected backbuffer height %u, expected %d.\n", d3dpp.BackBufferHeight, client_rect.bottom);
+            "Got unexpected backbuffer height %u, expected %ld.\n", d3dpp.BackBufferHeight, client_rect.bottom);
     ok(d3dpp.BackBufferFormat == mode.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n",
             d3dpp.BackBufferFormat, mode.Format);
     ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount);
     ok(!d3dpp.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType);
-    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %u.\n", d3dpp.MultiSampleQuality);
+    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %lu.\n", d3dpp.MultiSampleQuality);
     ok(d3dpp.SwapEffect == D3DSWAPEFFECT_DISCARD, "Got unexpected SwapEffect %#x.\n", d3dpp.SwapEffect);
     ok(d3dpp.hDeviceWindow == window, "Got unexpected hDeviceWindow %p, expected %p.\n", d3dpp.hDeviceWindow, window);
     ok(d3dpp.Windowed, "Got unexpected Windowed %#x.\n", d3dpp.Windowed);
     ok(!d3dpp.EnableAutoDepthStencil, "Got unexpected EnableAutoDepthStencil %#x.\n", d3dpp.EnableAutoDepthStencil);
     ok(!d3dpp.AutoDepthStencilFormat, "Got unexpected AutoDepthStencilFormat %#x.\n", d3dpp.AutoDepthStencilFormat);
-    ok(!d3dpp.Flags, "Got unexpected Flags %#x.\n", d3dpp.Flags);
+    ok(!d3dpp.Flags, "Got unexpected Flags %#lx.\n", d3dpp.Flags);
     ok(!d3dpp.FullScreen_RefreshRateInHz, "Got unexpected FullScreen_RefreshRateInHz %u.\n",
             d3dpp.FullScreen_RefreshRateInHz);
     ok(!d3dpp.PresentationInterval, "Got unexpected PresentationInterval %#x.\n", d3dpp.PresentationInterval);
@@ -1853,7 +1836,7 @@ cleanup:
     HeapFree(GetProcessHeap(), 0, modes);
     IDirect3D9Ex_Release(d3d9);
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -1877,25 +1860,25 @@ static void test_reset_resources(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 128, 128, D3DFMT_D24S8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth/stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth/stencil surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, surface);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil surface, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     for (i = 0; i < caps.NumSimultaneousRTs; ++i)
     {
         hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
                 D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create render target texture %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to create render target texture %u, hr %#lx.\n", i, hr);
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-        ok(SUCCEEDED(hr), "Failed to get surface %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get surface %u, hr %#lx.\n", i, hr);
         IDirect3DTexture9_Release(texture);
         hr = IDirect3DDevice9_SetRenderTarget(device, i, surface);
-        ok(SUCCEEDED(hr), "Failed to set render target surface %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to set render target surface %u, hr %#lx.\n", i, hr);
         IDirect3DSurface9_Release(surface);
     }
 
@@ -1903,9 +1886,9 @@ static void test_reset_resources(void)
     ok(SUCCEEDED(hr), "Failed to reset device.\n");
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &rt);
-    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#lx.\n", hr);
     ok(surface == rt, "Got unexpected surface %p for render target.\n", surface);
     IDirect3DSurface9_Release(surface);
     IDirect3DSurface9_Release(rt);
@@ -1913,11 +1896,11 @@ static void test_reset_resources(void)
     for (i = 1; i < caps.NumSimultaneousRTs; ++i)
     {
         hr = IDirect3DDevice9_GetRenderTarget(device, i, &surface);
-        ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     }
 
     ref = IDirect3DDevice9_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
 done:
     DestroyWindow(window);
@@ -1949,7 +1932,7 @@ static void test_vidmem_accounting(void)
         hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 1, D3DUSAGE_RENDERTARGET,
                 D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &textures[i], NULL);
         /* No D3DERR_OUTOFVIDEOMEMORY in d3d9ex */
-        ok(SUCCEEDED(hr) || hr == E_OUTOFMEMORY, "Failed to create texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr) || hr == E_OUTOFMEMORY, "Failed to create texture, hr %#lx.\n", hr);
     }
     vidmem_end = IDirect3DDevice9_GetAvailableTextureMem(device);
 
@@ -1965,7 +1948,7 @@ static void test_vidmem_accounting(void)
     }
 
     ref = IDirect3DDevice9_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
 done:
     DestroyWindow(window);
@@ -1974,6 +1957,7 @@ done:
 static void test_user_memory_getdc(void)
 {
     IDirect3DDevice9Ex *device;
+    unsigned int *data;
     HBITMAP bitmap;
     DIBSECTION dib;
     HWND window;
@@ -1981,7 +1965,6 @@ static void test_user_memory_getdc(void)
     ULONG ref;
     int size;
     IDirect3DSurface9 *surface;
-    DWORD *data;
     HDC dc;
 
     window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW,
@@ -1996,10 +1979,10 @@ static void test_user_memory_getdc(void)
     memset(data, 0xaa, sizeof(*data) * 16 * 16);
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, 16, 16,
             D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, (HANDLE *)&data);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get dc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get dc, hr %#lx.\n", hr);
     bitmap = GetCurrentObject(dc, OBJ_BITMAP);
     ok(!!bitmap, "Failed to get bitmap.\n");
     size = GetObjectA(bitmap, sizeof(dib), &dib);
@@ -2008,7 +1991,7 @@ static void test_user_memory_getdc(void)
     BitBlt(dc, 0, 0, 16, 8, NULL, 0, 0, WHITENESS);
     BitBlt(dc, 0, 8, 16, 8, NULL, 0, 0, BLACKNESS);
     hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release dc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release dc, hr %#lx.\n", hr);
 
     ok(data[0] == 0xffffffff, "Expected color 0xffffffff, got %#x.\n", data[0]);
     ok(data[8 * 16] == 0x00000000, "Expected color 0x00000000, got %#x.\n", data[8 * 16]);
@@ -2017,7 +2000,7 @@ static void test_user_memory_getdc(void)
     HeapFree(GetProcessHeap(), 0, data);
 
     ref = IDirect3DDevice9_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
 done:
     DestroyWindow(window);
@@ -2045,144 +2028,144 @@ static void test_lost_device(void)
     }
 
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == S_PRESENT_OCCLUDED || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_OCCLUDED || broken(hr == D3D_OK), "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
     ok(hr == S_PRESENT_OCCLUDED || hr == S_PRESENT_MODE_CHANGED || broken(hr == D3D_OK),
-            "Got unexpected hr %#x.\n", hr);
+            "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == S_PRESENT_OCCLUDED || hr == S_PRESENT_MODE_CHANGED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_OCCLUDED || hr == S_PRESENT_MODE_CHANGED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == D3D_OK || hr == S_PRESENT_MODE_CHANGED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || hr == S_PRESENT_MODE_CHANGED, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     desc.width = 1024;
     desc.height = 768;
     hr = reset_device(device, &desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     desc.flags = 0;
     hr = reset_device(device, &desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == S_PRESENT_MODE_CHANGED || hr == D3D_OK /* Win10 */, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_MODE_CHANGED || hr == D3D_OK /* Win10 */, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == S_PRESENT_MODE_CHANGED || hr == D3D_OK /* Win10 */, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_MODE_CHANGED || hr == D3D_OK /* Win10 */, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == S_PRESENT_MODE_CHANGED || hr == D3D_OK /* Win10 */, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_MODE_CHANGED || hr == D3D_OK /* Win10 */, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == S_PRESENT_MODE_CHANGED || hr == D3D_OK /* Win10 */, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_MODE_CHANGED || hr == D3D_OK /* Win10 */, "Got unexpected hr %#lx.\n", hr);
 
     hr = reset_device(device, &desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == S_PRESENT_OCCLUDED || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_OCCLUDED || broken(hr == D3D_OK), "Got unexpected hr %#lx.\n", hr);
     hr = reset_device(device, &desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK || broken(hr == S_FALSE), "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || broken(hr == S_FALSE), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0);
-    ok(hr == D3D_OK || broken(hr == S_FALSE), "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || broken(hr == S_FALSE), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, window);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
-    ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     DestroyWindow(window);
 }
@@ -2433,23 +2416,23 @@ static void test_unsupported_shaders(void)
     }
 
     hr = IDirect3DDevice9Ex_CreateVertexShader(device, simple_ps, &vs);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreatePixelShader(device, simple_vs, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreatePixelShader(device, ps_4_0, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     if (caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         hr = IDirect3DDevice9Ex_CreateVertexShader(device, vs_3_0, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         if (caps.VertexShaderVersion <= D3DVS_VERSION(1, 1) && caps.MaxVertexShaderConst < 256)
         {
             hr = IDirect3DDevice9Ex_CreateVertexShader(device, vs_1_255, &vs);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         }
         else
         {
@@ -2463,16 +2446,16 @@ static void test_unsupported_shaders(void)
         skip("This GPU supports SM3, skipping unsupported shader test.\n");
 
         hr = IDirect3DDevice9Ex_CreateVertexShader(device, vs_1_255, &vs);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         IDirect3DVertexShader9_Release(vs);
         hr = IDirect3DDevice9Ex_CreateVertexShader(device, vs_1_256, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9Ex_CreateVertexShader(device, vs_3_256, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9Ex_CreateVertexShader(device, vs_3_i16, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9Ex_CreateVertexShader(device, vs_3_b16, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
 
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0))
@@ -2481,19 +2464,19 @@ static void test_unsupported_shaders(void)
         goto cleanup;
     }
     hr = IDirect3DDevice9Ex_CreatePixelShader(device, ps_1_8, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreatePixelShader(device, ps_2_32, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreatePixelShader(device, ps_3_224, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreatePixelShader(device, ps_2_0_boolint, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     if (ps)
         IDirect3DPixelShader9_Release(ps);
 
 cleanup:
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -2561,7 +2544,7 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
         {
             if (expect_messages->check_wparam)
                 ok(wparam == expect_messages->expect_wparam,
-                        "Got unexpected wparam %lx for message %x, expected %lx.\n",
+                        "Got unexpected wparam %#Ix for message %#x, expected %#Ix.\n",
                         wparam, message, expect_messages->expect_wparam);
 
             if (expect_messages->store_wp)
@@ -2572,7 +2555,7 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
                 hr = IDirect3DDevice9Ex_CheckDeviceState(focus_test_device, device_window);
                 todo_wine_if(message != WM_ACTIVATEAPP && message != WM_DISPLAYCHANGE)
                     ok(hr == expect_messages->device_state,
-                        "Got device state %#x on message %#x, expected %#x.\n",
+                        "Got device state %#lx on message %#x, expected %#lx.\n",
                         hr, message, expect_messages->device_state);
             }
 
@@ -2604,7 +2587,7 @@ static DWORD WINAPI wndproc_thread(void *param)
     p->running_in_foreground = SetForegroundWindow(p->dummy_window);
 
     ret = SetEvent(p->window_created);
-    ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
+    ok(ret, "SetEvent failed, last error %#lx.\n", GetLastError());
 
     for (;;)
     {
@@ -2617,7 +2600,7 @@ static DWORD WINAPI wndproc_thread(void *param)
             break;
         if (res != WAIT_TIMEOUT)
         {
-            ok(0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+            ok(0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
             break;
         }
     }
@@ -2805,7 +2788,7 @@ static void test_wndproc(void)
     hr = pDirect3DCreate9Ex(D3D_SDK_VERSION, &d3d9ex);
     if (FAILED(hr))
     {
-        skip("Direct3D9Ex is not available (%#x)\n", hr);
+        skip("Failed to create IDirect3D9Ex, hr %#lx.\n", hr);
         return;
     }
 
@@ -2813,7 +2796,7 @@ static void test_wndproc(void)
     for (i = 0; i < adapter_mode_count; ++i)
     {
         hr = IDirect3D9Ex_EnumAdapterModes(d3d9ex, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, i, &d3ddm);
-        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
 
         if (d3ddm.Width == registry_mode.dmPelsWidth && d3ddm.Height == registry_mode.dmPelsHeight)
             continue;
@@ -2867,9 +2850,9 @@ static void test_wndproc(void)
     ok(RegisterClassA(&wc), "Failed to register window class.\n");
 
     thread_params.window_created = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!thread_params.window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
     thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#lx.\n", GetLastError());
 
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
@@ -2880,23 +2863,23 @@ static void test_wndproc(void)
         devmode.dmPelsWidth = user32_width;
         devmode.dmPelsHeight = user32_height;
         change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
         focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
                 WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, user32_width, user32_height, 0, 0, 0, 0);
         device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
                 WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, user32_width, user32_height, 0, 0, 0, 0);
         thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
-        ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+        ok(!!thread, "Failed to create thread, last error %#lx.\n", GetLastError());
 
         res = WaitForSingleObject(thread_params.window_created, INFINITE);
-        ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+        ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
 
         proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
                 (LONG_PTR)test_proc, proc);
         proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
                 (LONG_PTR)test_proc, proc);
 
         trace("device_window %p, focus_window %p, dummy_window %p.\n",
@@ -2942,11 +2925,11 @@ static void test_wndproc(void)
         flush_events();
 
         proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
                 (LONG_PTR)test_proc, proc);
 
         proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-        ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n",
+        ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n",
                 (LONG_PTR)test_proc);
 
         /* Change the mode while the device is in use and then drop focus. */
@@ -2954,15 +2937,15 @@ static void test_wndproc(void)
         devmode.dmPelsWidth = user32_width;
         devmode.dmPelsHeight = user32_height;
         change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x, i=%u.\n", change_ret, i);
+        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx, i=%u.\n", change_ret, i);
 
         /* Native needs a present call to pick up the mode change. Windows 10 15.07 never picks up the mode change
          * in these calls and returns S_OK. This is a regression from Windows 8 and has been fixed in later Win10
          * builds. */
         hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-        todo_wine ok(hr == S_PRESENT_MODE_CHANGED || broken(hr == S_OK), "Got unexpected hr %#x, i=%u.\n", hr, i);
+        todo_wine ok(hr == S_PRESENT_MODE_CHANGED || broken(hr == S_OK), "Got unexpected hr %#lx, i=%u.\n", hr, i);
         hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
-        todo_wine ok(hr == S_PRESENT_MODE_CHANGED || broken(hr == S_OK), "Got unexpected hr %#x, i=%u.\n", hr, i);
+        todo_wine ok(hr == S_PRESENT_MODE_CHANGED || broken(hr == S_OK), "Got unexpected hr %#lx, i=%u.\n", hr, i);
 
         expect_messages = tests[i].focus_loss_messages;
         /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
@@ -2979,12 +2962,12 @@ static void test_wndproc(void)
         ok(tmp != focus_window, "The focus window is active, i=%u.\n", i);
 
         hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
-        ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x, i=%u.\n", hr, i);
+        ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#lx, i=%u.\n", hr, i);
 
         ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
         ok(ret, "Failed to get display mode.\n");
         ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
-                && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %ux%u.\n",
+                && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %lux%lu.\n",
                 devmode.dmPelsWidth, devmode.dmPelsHeight);
 
         /* In d3d9ex the device and focus windows have to be minimized and restored,
@@ -3008,16 +2991,16 @@ static void test_wndproc(void)
 
         /* Calling Reset is not necessary in d3d9ex. */
         hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
-        ok(hr == S_OK, "Got unexpected hr %#x, i=%u.\n", hr, i);
+        ok(hr == S_OK, "Got unexpected hr %#lx, i=%u.\n", hr, i);
 
         ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
         ok(ret, "Failed to get display mode.\n");
         ok(devmode.dmPelsWidth == d3d_width
-                && devmode.dmPelsHeight == d3d_height, "Got unexpected screen size %ux%u.\n",
+                && devmode.dmPelsHeight == d3d_height, "Got unexpected screen size %lux%lu.\n",
                 devmode.dmPelsWidth, devmode.dmPelsHeight);
 
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
         /* Remove the WS_VISIBLE flag to test hidden windows. This is enough to trigger d3d's hidden
          * window codepath, but does not actually hide the window without a SetWindowPos(SWP_FRAMECHANGED)
@@ -3037,8 +3020,8 @@ static void test_wndproc(void)
 
         ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
         ok(ret, "Failed to get display mode.\n");
-        ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpected width %u.\n", devmode.dmPelsWidth);
-        ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected height %u.\n", devmode.dmPelsHeight);
+        ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpected width %lu.\n", devmode.dmPelsWidth);
+        ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected height %lu.\n", devmode.dmPelsHeight);
 
         /* SW_SHOWMINNOACTIVE is needed to make FVWM happy. SW_SHOWNOACTIVATE is needed to make windows
          * send SIZE_RESTORED after ShowWindow(SW_SHOWMINNOACTIVE). */
@@ -3051,7 +3034,7 @@ static void test_wndproc(void)
         SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0);
         ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
                 expect_messages->message, expect_messages->window, i);
-        ok(syscommand_received == 1, "Got unexpected number of WM_SYSCOMMAND messages: %d.\n", syscommand_received);
+        ok(syscommand_received == 1, "Got unexpected number of WM_SYSCOMMAND messages: %ld.\n", syscommand_received);
         expect_messages = NULL;
         flush_events();
 
@@ -3079,14 +3062,14 @@ static void test_wndproc(void)
 
         filter_messages = focus_window;
         ref = IDirect3DDevice9Ex_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
+        ok(!ref, "Unexpected refcount %lu, i=%u.\n", ref, i);
 
         /* Fix up the mode until Wine's device release behavior is fixed. */
         change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
         proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix, i=%u.\n",
                 (LONG_PTR)test_proc, proc, i);
 
         /* Hide the device window. It prevents WM_ACTIVATEAPP messages from being sent
@@ -3131,7 +3114,7 @@ static void test_wndproc(void)
         SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0);
         ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
                 expect_messages->message, expect_messages->window, i);
-        ok(syscommand_received == 1, "Got unexpected number of WM_SYSCOMMAND messages: %d.\n", syscommand_received);
+        ok(syscommand_received == 1, "Got unexpected number of WM_SYSCOMMAND messages: %ld.\n", syscommand_received);
         expect_messages = NULL;
         flush_events();
 
@@ -3163,7 +3146,7 @@ static void test_wndproc(void)
 
         filter_messages = focus_window;
         ref = IDirect3DDevice9Ex_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
+        ok(!ref, "Unexpected refcount %lu, i=%u.\n", ref, i);
 
         device_desc.device_window = device_window;
         if (!(device = create_device(focus_window, &device_desc)))
@@ -3180,7 +3163,7 @@ static void test_wndproc(void)
         expect_messages = tests[i].mode_change_messages;
         filter_messages = focus_window;
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
         filter_messages = NULL;
 
         /* The WINDOWPOS structure passed to the first WM_WINDOWPOSCHANGING differs between windows versions.
@@ -3206,7 +3189,7 @@ static void test_wndproc(void)
         expect_messages = tests[i].mode_change_messages_hidden;
         filter_messages = focus_window;
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
         filter_messages = NULL;
 
         flush_events();
@@ -3237,14 +3220,14 @@ static void test_wndproc(void)
         }
 
         proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-        ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n",
+        ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n",
                 (LONG_PTR)test_proc);
 
         ref = IDirect3DDevice9Ex_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+        ok(!ref, "Unexpected refcount %lu.\n", ref);
 
         proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+        ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
                 (LONG_PTR)DefWindowProcA, proc);
 
 done:
@@ -3284,9 +3267,9 @@ static void test_wndproc_windowed(void)
     ok(RegisterClassA(&wc), "Failed to register window class.\n");
 
     thread_params.window_created = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!thread_params.window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
     thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#lx.\n", GetLastError());
 
     focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
             WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
@@ -3295,16 +3278,16 @@ static void test_wndproc_windowed(void)
             WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
             registry_mode.dmPelsHeight, 0, 0, 0, 0);
     thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
-    ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+    ok(!!thread, "Failed to create thread, last error %#lx.\n", GetLastError());
 
     res = WaitForSingleObject(thread_params.window_created, INFINITE);
-    ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+    ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     trace("device_window %p, focus_window %p, dummy_window %p.\n",
@@ -3340,42 +3323,42 @@ static void test_wndproc_windowed(void)
             thread_params.dummy_window, tmp);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     filter_messages = NULL;
 
     device_desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n", (LONG_PTR)test_proc);
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     filter_messages = focus_window;
 
     ref = IDirect3DDevice9Ex_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
     filter_messages = device_window;
 
@@ -3390,31 +3373,31 @@ static void test_wndproc_windowed(void)
 
     device_desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n", (LONG_PTR)test_proc);
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     filter_messages = device_window;
 
     ref = IDirect3DDevice9Ex_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
     device_desc.device_window = device_window;
     if (!(device = create_device(focus_window, &device_desc)))
@@ -3427,31 +3410,31 @@ static void test_wndproc_windowed(void)
 
     device_desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n", (LONG_PTR)test_proc);
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     filter_messages = device_window;
 
     ref = IDirect3DDevice9Ex_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
 done:
     filter_messages = NULL;
@@ -3526,19 +3509,19 @@ static void test_window_style(void)
         style = GetWindowLongA(device_window, GWL_STYLE);
         expected_style = device_style;
         todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_OVERLAPPEDWINDOW)) /* w1064v1809 */,
-                "Expected device window style %#x, got %#x, i=%u.\n",
+                "Expected device window style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
         style = GetWindowLongA(device_window, GWL_EXSTYLE);
         expected_style = device_exstyle;
         todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
-                "Expected device window extended style %#x, got %#x, i=%u.\n",
+                "Expected device window extended style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
 
         style = GetWindowLongA(focus_window, GWL_STYLE);
-        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+        ok(style == focus_style, "Expected focus window style %#lx, got %#lx, i=%u.\n",
                 focus_style, style, i);
         style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+        ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx, i=%u.\n",
                 focus_exstyle, style, i);
 
         GetWindowRect(device_window, &r);
@@ -3557,7 +3540,7 @@ static void test_window_style(void)
 
         device_desc.flags = 0;
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
         GetWindowRect(device_window, &r);
         if (tests[i].device_flags & CREATE_DEVICE_NOWINDOWCHANGES)
@@ -3569,37 +3552,37 @@ static void test_window_style(void)
 
         style = GetWindowLongA(device_window, GWL_STYLE);
         expected_style = device_style;
-        ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+        ok(style == expected_style, "Expected device window style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
         style = GetWindowLongA(device_window, GWL_EXSTYLE);
         expected_style = device_exstyle;
-        ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+        ok(style == expected_style, "Expected device window extended style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
 
         style = GetWindowLongA(focus_window, GWL_STYLE);
-        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+        ok(style == focus_style, "Expected focus window style %#lx, got %#lx, i=%u.\n",
                 focus_style, style, i);
         style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+        ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx, i=%u.\n",
                 focus_exstyle, style, i);
 
         ref = IDirect3DDevice9Ex_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+        ok(!ref, "Unexpected refcount %lu.\n", ref);
 
         style = GetWindowLongA(device_window, GWL_STYLE);
         expected_style = device_style;
-        ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+        ok(style == expected_style, "Expected device window style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
         style = GetWindowLongA(device_window, GWL_EXSTYLE);
         expected_style = device_exstyle;
-        ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+        ok(style == expected_style, "Expected device window extended style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
 
         style = GetWindowLongA(focus_window, GWL_STYLE);
-        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+        ok(style == focus_style, "Expected focus window style %#lx, got %#lx, i=%u.\n",
                 focus_style, style, i);
         style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+        ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx, i=%u.\n",
                 focus_exstyle, style, i);
 
         /* The second time a device is created on the window the window becomes visible and
@@ -3610,22 +3593,22 @@ static void test_window_style(void)
         style = GetWindowLongA(device_window, GWL_STYLE);
         expected_style = device_style | tests[i].create2_style;
         todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_OVERLAPPEDWINDOW)) /* w1064v1809 */,
-                "Expected device window style %#x, got %#x, i=%u.\n",
+                "Expected device window style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
         style = GetWindowLongA(device_window, GWL_EXSTYLE);
         expected_style = device_exstyle | tests[i].create2_exstyle;
         todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
-                "Expected device window extended style %#x, got %#x, i=%u.\n",
+                "Expected device window extended style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
 
         style = GetWindowLongA(focus_window, GWL_STYLE);
-        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+        ok(style == focus_style, "Expected focus window style %#lx, got %#lx, i=%u.\n",
                 focus_style, style, i);
         style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+        ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx, i=%u.\n",
                 focus_exstyle, style, i);
         ref = IDirect3DDevice9Ex_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+        ok(!ref, "Unexpected refcount %lu.\n", ref);
 
         DestroyWindow(device_window);
         DestroyWindow(focus_window);
@@ -3642,22 +3625,22 @@ static void test_window_style(void)
 
         style = GetWindowLongA(device_window, GWL_STYLE);
         expected_style = device_style | tests[i].focus_loss_style;
-        todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+        todo_wine ok(style == expected_style, "Expected device window style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
         style = GetWindowLongA(device_window, GWL_EXSTYLE);
         expected_style = device_exstyle;
-        todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+        todo_wine ok(style == expected_style, "Expected device window extended style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
 
         style = GetWindowLongA(focus_window, GWL_STYLE);
-        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+        ok(style == focus_style, "Expected focus window style %#lx, got %#lx, i=%u.\n",
                 focus_style, style, i);
         style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+        ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx, i=%u.\n",
                 focus_exstyle, style, i);
 
         ref = IDirect3DDevice9Ex_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+        ok(!ref, "Unexpected refcount %lu.\n", ref);
 
         DestroyWindow(device_window);
         DestroyWindow(focus_window);
@@ -3730,7 +3713,7 @@ static void test_swapchain_parameters(void)
     hr = pDirect3DCreate9Ex(D3D_SDK_VERSION, &d3d9ex);
     if (FAILED(hr))
     {
-        skip("Direct3D9Ex is not available (%#x)\n", hr);
+        skip("Failed to create IDirect3D9Ex, hr %#lx.\n", hr);
         return;
     }
 
@@ -3773,16 +3756,16 @@ static void test_swapchain_parameters(void)
         hr = IDirect3D9Ex_CreateDeviceEx(d3d9ex, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
                 D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters,
                 tests[i].windowed ? NULL : &mode, &device);
-        ok(hr == tests[i].hr, "Expected hr %x, got %x, test %u.\n", tests[i].hr, hr, i);
+        ok(hr == tests[i].hr, "Expected hr %#lx, got %#lx, test %u.\n", tests[i].hr, hr, i);
         if (SUCCEEDED(hr))
         {
             UINT bb_count = tests[i].backbuffer_count ? tests[i].backbuffer_count : 1;
 
             hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
-            ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x, test %u.\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx, test %u.\n", hr, i);
 
             hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &present_parameters2);
-            ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x, test %u.\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx, test %u.\n", hr, i);
             ok(present_parameters2.SwapEffect == tests[i].swap_effect, "Swap effect changed from %u to %u, test %u.\n",
                     tests[i].swap_effect, present_parameters2.SwapEffect, i);
             ok(present_parameters2.BackBufferCount == bb_count, "Backbuffer count changed from %u to %u, test %u.\n",
@@ -3796,7 +3779,7 @@ static void test_swapchain_parameters(void)
 
         hr = IDirect3D9Ex_CreateDeviceEx(d3d9ex, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
                 D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters_windowed, NULL, &device);
-        ok(SUCCEEDED(hr), "Failed to create device, hr %#x, test %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to create device, hr %#lx, test %u.\n", hr, i);
 
         memset(&present_parameters, 0, sizeof(present_parameters));
         present_parameters.BackBufferWidth = registry_mode.dmPelsWidth;
@@ -3809,12 +3792,12 @@ static void test_swapchain_parameters(void)
         present_parameters.BackBufferCount = tests[i].backbuffer_count;
 
         hr = IDirect3DDevice9Ex_ResetEx(device, &present_parameters, tests[i].windowed ? NULL : &mode);
-        ok(hr == tests[i].hr, "Expected hr %x, got %x, test %u.\n", tests[i].hr, hr, i);
+        ok(hr == tests[i].hr, "Expected hr %#lx, got %#lx, test %u.\n", tests[i].hr, hr, i);
 
         if (FAILED(hr))
         {
             hr = IDirect3DDevice9Ex_ResetEx(device, &present_parameters_windowed, NULL);
-            ok(SUCCEEDED(hr), "Failed to reset device, hr %#x, test %u.\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx, test %u.\n", hr, i);
         }
         IDirect3DDevice9Ex_Release(device);
     }
@@ -3829,7 +3812,7 @@ static void test_backbuffer_resize(void)
     IDirect3DSurface9 *backbuffer, *old_backbuffer;
     D3DSURFACE_DESC surface_desc;
     IDirect3DDevice9Ex *device;
-    D3DCOLOR color;
+    unsigned int color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -3856,21 +3839,21 @@ static void test_backbuffer_resize(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     color = get_pixel_color(device, 1, 1);
     ok(color == 0x00ff0000, "Got unexpected color 0x%08x.\n", color);
 
@@ -3883,36 +3866,36 @@ static void test_backbuffer_resize(void)
     present_parameters.EnableAutoDepthStencil = TRUE;
     present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
     hr = IDirect3DDevice9_Reset(device, &present_parameters);
-    ok(SUCCEEDED(hr), "Failed to reset, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset, hr %#lx.\n", hr);
 
     old_backbuffer = backbuffer;
     hr = IDirect3DSurface9_GetDesc(old_backbuffer, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     todo_wine ok(surface_desc.Width == 640, "Got unexpected width %u.\n", surface_desc.Width);
     todo_wine ok(surface_desc.Height == 480, "Got unexpected height %u.\n", surface_desc.Height);
     refcount = IDirect3DSurface9_Release(old_backbuffer);
-    ok(!refcount, "Surface has %u references left.\n", refcount);
+    ok(!refcount, "Surface has %lu references left.\n", refcount);
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     todo_wine ok(backbuffer != old_backbuffer, "Expected new backbuffer surface.\n");
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     color = get_pixel_color(device, 1, 1);
     ok(color == 0x00ffff00, "Got unexpected color 0x%08x.\n", color);
     color = get_pixel_color(device, 700, 500);
     ok(color == 0x00ffff00, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_pixel_color(device, 1, 1);
     ok(color == 0x0000ff00, "Got unexpected color 0x%08x.\n", color);
     color = get_pixel_color(device, 700, 500);
@@ -3920,14 +3903,14 @@ static void test_backbuffer_resize(void)
 
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
 static void test_format_unknown(void)
 {
     IDirect3DDevice9Ex *device;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     void *iface;
     HRESULT hr;
@@ -3943,59 +3926,59 @@ static void test_format_unknown(void)
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateRenderTarget(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, 0, FALSE, (IDirect3DSurface9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateRenderTargetEx(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, 0, FALSE, (IDirect3DSurface9 **)&iface, NULL, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateDepthStencilSurface(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, 0, TRUE, (IDirect3DSurface9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateDepthStencilSurfaceEx(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, 0, TRUE, (IDirect3DSurface9 **)&iface, NULL, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, 64, 64,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DSurface9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurfaceEx(device, 64, 64,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DSurface9 **)&iface, NULL, 9);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     todo_wine ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateTexture(device, 64, 64, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DTexture9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateCubeTexture(device, 64, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DCubeTexture9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateVolumeTexture(device, 64, 64, 1, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DVolumeTexture9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -4016,21 +3999,21 @@ static void test_device_caps(void)
     }
 
     hr = IDirect3DDevice9Ex_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     ok(!(caps.Caps & ~(D3DCAPS_OVERLAY | D3DCAPS_READ_SCANLINE)),
-            "Caps field has unexpected flags %#x.\n", caps.Caps);
+            "Caps field has unexpected flags %#lx.\n", caps.Caps);
     ok(!(caps.Caps2 & ~(D3DCAPS2_FULLSCREENGAMMA | D3DCAPS2_CANCALIBRATEGAMMA | D3DCAPS2_RESERVED
             | D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_CANAUTOGENMIPMAP
             | D3DCAPS2_CANSHARERESOURCE)),
-            "Caps2 field has unexpected flags %#x.\n", caps.Caps2);
+            "Caps2 field has unexpected flags %#lx.\n", caps.Caps2);
     /* AMD doesn't filter all the ddraw / d3d9 caps. Consider that behavior
      * broken. */
     ok(!(caps.Caps3 & ~(D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
             | D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION | D3DCAPS3_COPY_TO_VIDMEM
             | D3DCAPS3_COPY_TO_SYSTEMMEM | D3DCAPS3_DXVAHD | D3DCAPS3_DXVAHD_LIMITED
             | D3DCAPS3_RESERVED)),
-            "Caps3 field has unexpected flags %#x.\n", caps.Caps3);
+            "Caps3 field has unexpected flags %#lx.\n", caps.Caps3);
     ok(!(caps.PrimitiveMiscCaps & ~(D3DPMISCCAPS_MASKZ | D3DPMISCCAPS_LINEPATTERNREP
             | D3DPMISCCAPS_CULLNONE | D3DPMISCCAPS_CULLCW | D3DPMISCCAPS_CULLCCW
             | D3DPMISCCAPS_COLORWRITEENABLE | D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
@@ -4040,7 +4023,7 @@ static void test_device_caps(void)
             | D3DPMISCCAPS_SEPARATEALPHABLEND | D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
             | D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING | D3DPMISCCAPS_FOGVERTEXCLAMPED
             | D3DPMISCCAPS_POSTBLENDSRGBCONVERT)),
-            "PrimitiveMiscCaps field has unexpected flags %#x.\n", caps.PrimitiveMiscCaps);
+            "PrimitiveMiscCaps field has unexpected flags %#lx.\n", caps.PrimitiveMiscCaps);
     ok(!(caps.RasterCaps & ~(D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_ZTEST
             | D3DPRASTERCAPS_FOGVERTEX | D3DPRASTERCAPS_FOGTABLE
             | D3DPRASTERCAPS_MIPMAPLODBIAS | D3DPRASTERCAPS_ZBUFFERLESSHSR
@@ -4049,7 +4032,7 @@ static void test_device_caps(void)
             | D3DPRASTERCAPS_SCISSORTEST | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
             | D3DPRASTERCAPS_DEPTHBIAS | D3DPRASTERCAPS_MULTISAMPLE_TOGGLE))
             || broken(!(caps.RasterCaps & ~0x0f736191)),
-            "RasterCaps field has unexpected flags %#x.\n", caps.RasterCaps);
+            "RasterCaps field has unexpected flags %#lx.\n", caps.RasterCaps);
     /* D3DPBLENDCAPS_SRCCOLOR2 and D3DPBLENDCAPS_INVSRCCOLOR2 are only
      * advertised on the reference rasterizer and WARP. */
     ok(!(caps.SrcBlendCaps & ~(D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR
@@ -4063,7 +4046,7 @@ static void test_device_caps(void)
             | D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA
             | D3DPBLENDCAPS_BOTHINVSRCALPHA | D3DPBLENDCAPS_BLENDFACTOR
             | D3DPBLENDCAPS_SRCCOLOR2 | D3DPBLENDCAPS_INVSRCCOLOR2))),
-            "SrcBlendCaps field has unexpected flags %#x.\n", caps.SrcBlendCaps);
+            "SrcBlendCaps field has unexpected flags %#lx.\n", caps.SrcBlendCaps);
     ok(!(caps.DestBlendCaps & ~(D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR
             | D3DPBLENDCAPS_INVSRCCOLOR | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA
             | D3DPBLENDCAPS_DESTALPHA | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR
@@ -4075,7 +4058,7 @@ static void test_device_caps(void)
             | D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA
             | D3DPBLENDCAPS_BOTHINVSRCALPHA | D3DPBLENDCAPS_BLENDFACTOR
             | D3DPBLENDCAPS_SRCCOLOR2 | D3DPBLENDCAPS_INVSRCCOLOR2))),
-            "DestBlendCaps field has unexpected flags %#x.\n", caps.DestBlendCaps);
+            "DestBlendCaps field has unexpected flags %#lx.\n", caps.DestBlendCaps);
     ok(!(caps.TextureCaps & ~(D3DPTEXTURECAPS_PERSPECTIVE | D3DPTEXTURECAPS_POW2
             | D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_SQUAREONLY
             | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE | D3DPTEXTURECAPS_ALPHAPALETTE
@@ -4084,7 +4067,7 @@ static void test_device_caps(void)
             | D3DPTEXTURECAPS_MIPVOLUMEMAP | D3DPTEXTURECAPS_MIPCUBEMAP
             | D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2
             | D3DPTEXTURECAPS_NOPROJECTEDBUMPENV)),
-            "TextureCaps field has unexpected flags %#x.\n", caps.TextureCaps);
+            "TextureCaps field has unexpected flags %#lx.\n", caps.TextureCaps);
     ok(!(caps.TextureFilterCaps & ~(D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR
             | D3DPTFILTERCAPS_MINFANISOTROPIC | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD
             | D3DPTFILTERCAPS_MINFGAUSSIANQUAD | D3DPTFILTERCAPS_MIPFPOINT
@@ -4092,42 +4075,42 @@ static void test_device_caps(void)
             | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR
             | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD
             | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD)),
-            "TextureFilterCaps field has unexpected flags %#x.\n", caps.TextureFilterCaps);
+            "TextureFilterCaps field has unexpected flags %#lx.\n", caps.TextureFilterCaps);
     ok(!(caps.CubeTextureFilterCaps & ~(D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR
             | D3DPTFILTERCAPS_MINFANISOTROPIC | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD
             | D3DPTFILTERCAPS_MINFGAUSSIANQUAD | D3DPTFILTERCAPS_MIPFPOINT
             | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR
             | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD
             | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD)),
-            "CubeTextureFilterCaps field has unexpected flags %#x.\n", caps.CubeTextureFilterCaps);
+            "CubeTextureFilterCaps field has unexpected flags %#lx.\n", caps.CubeTextureFilterCaps);
     ok(!(caps.VolumeTextureFilterCaps & ~(D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR
             | D3DPTFILTERCAPS_MINFANISOTROPIC | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD
             | D3DPTFILTERCAPS_MINFGAUSSIANQUAD | D3DPTFILTERCAPS_MIPFPOINT
             | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR
             | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD
             | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD)),
-            "VolumeTextureFilterCaps field has unexpected flags %#x.\n", caps.VolumeTextureFilterCaps);
+            "VolumeTextureFilterCaps field has unexpected flags %#lx.\n", caps.VolumeTextureFilterCaps);
     ok(!(caps.LineCaps & ~(D3DLINECAPS_TEXTURE | D3DLINECAPS_ZTEST | D3DLINECAPS_BLEND
             | D3DLINECAPS_ALPHACMP | D3DLINECAPS_FOG | D3DLINECAPS_ANTIALIAS)),
-            "LineCaps field has unexpected flags %#x.\n", caps.LineCaps);
+            "LineCaps field has unexpected flags %#lx.\n", caps.LineCaps);
     ok(!(caps.StencilCaps & ~(D3DSTENCILCAPS_KEEP | D3DSTENCILCAPS_ZERO | D3DSTENCILCAPS_REPLACE
             | D3DSTENCILCAPS_INCRSAT | D3DSTENCILCAPS_DECRSAT | D3DSTENCILCAPS_INVERT
             | D3DSTENCILCAPS_INCR | D3DSTENCILCAPS_DECR | D3DSTENCILCAPS_TWOSIDED)),
-            "StencilCaps field has unexpected flags %#x.\n", caps.StencilCaps);
+            "StencilCaps field has unexpected flags %#lx.\n", caps.StencilCaps);
     ok(!(caps.VertexProcessingCaps & ~(D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7
             | D3DVTXPCAPS_DIRECTIONALLIGHTS | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER
             | D3DVTXPCAPS_TWEENING | D3DVTXPCAPS_TEXGEN_SPHEREMAP
             | D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER)),
-            "VertexProcessingCaps field has unexpected flags %#x.\n", caps.VertexProcessingCaps);
+            "VertexProcessingCaps field has unexpected flags %#lx.\n", caps.VertexProcessingCaps);
     /* Both Nvidia and AMD give 10 here. */
     ok(caps.MaxActiveLights <= 10,
-            "MaxActiveLights field has unexpected value %u.\n", caps.MaxActiveLights);
+            "MaxActiveLights field has unexpected value %lu.\n", caps.MaxActiveLights);
     /* AMD gives 6, Nvidia returns 8. */
     ok(caps.MaxUserClipPlanes <= 8,
-            "MaxUserClipPlanes field has unexpected value %u.\n", caps.MaxUserClipPlanes);
+            "MaxUserClipPlanes field has unexpected value %lu.\n", caps.MaxUserClipPlanes);
 
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -4148,31 +4131,31 @@ static void test_frame_latency(void)
     }
 
     hr = IDirect3DDevice9Ex_GetMaximumFrameLatency(device, &latency);
-    ok(SUCCEEDED(hr), "Failed to get max frame latency, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get max frame latency, hr %#lx.\n", hr);
     ok(latency == 3, "Unexpected default max frame latency %u.\n", latency);
 
     hr = IDirect3DDevice9Ex_SetMaximumFrameLatency(device, 1);
-    ok(SUCCEEDED(hr), "Failed to set max frame latency, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set max frame latency, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_GetMaximumFrameLatency(device, &latency);
-    ok(SUCCEEDED(hr), "Failed to get max frame latency, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get max frame latency, hr %#lx.\n", hr);
     ok(latency == 1, "Unexpected max frame latency %u.\n", latency);
 
     hr = IDirect3DDevice9Ex_SetMaximumFrameLatency(device, 0);
-    ok(SUCCEEDED(hr), "Failed to set max frame latency, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set max frame latency, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_GetMaximumFrameLatency(device, &latency);
-    ok(SUCCEEDED(hr), "Failed to get max frame latency, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get max frame latency, hr %#lx.\n", hr);
     ok(latency == 3 || !latency, "Unexpected default max frame latency %u.\n", latency);
 
     hr = IDirect3DDevice9Ex_SetMaximumFrameLatency(device, 30);
-    ok(SUCCEEDED(hr), "Failed to set max frame latency, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set max frame latency, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_SetMaximumFrameLatency(device, 31);
-    ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -4290,21 +4273,21 @@ static void test_resource_access(void)
         return;
     }
     hr = IDirect3DDevice9Ex_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     warp = adapter_is_warp(&identifier);
 
     hr = IDirect3DDevice9Ex_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetDesc(backbuffer, &surface_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     colour_format = surface_desc.Format;
 
     hr = IDirect3DDevice9Ex_GetDepthStencilSurface(device, &depth_stencil);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetDesc(depth_stencil, &surface_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     depth_format = surface_desc.Format;
 
     depth_2d = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
@@ -4315,7 +4298,7 @@ static void test_resource_access(void)
             D3DFMT_X8R8G8B8, 0, D3DRTYPE_SURFACE, depth_format));
 
     hr = IDirect3DDevice9Ex_SetFVF(device, D3DFVF_XYZRHW);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(surface_types); ++i)
     {
@@ -4351,12 +4334,12 @@ static void test_resource_access(void)
                             && !tests[j].usage && tests[j].pool != D3DPOOL_MANAGED)
                         ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_2d)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
-                                "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                                "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
 
                     hr = IDirect3DTexture9_GetSurfaceLevel(texture_2d, 0, &surface);
-                    ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                    ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     IDirect3DTexture9_Release(texture_2d);
                     break;
 
@@ -4367,13 +4350,13 @@ static void test_resource_access(void)
                             && !tests[j].usage && tests[j].pool != D3DPOOL_MANAGED)
                         ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_cube)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
-                                "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                                "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
 
                     hr = IDirect3DCubeTexture9_GetCubeMapSurface(texture_cube,
                             D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
-                    ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                    ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     IDirect3DCubeTexture9_Release(texture_cube);
                     break;
 
@@ -4381,7 +4364,7 @@ static void test_resource_access(void)
                     hr = IDirect3DDevice9Ex_CreateRenderTarget(device, 16, 16, format,
                             D3DMULTISAMPLE_NONE, 0, tests[j].usage & D3DUSAGE_DYNAMIC, &surface, NULL);
                     ok(hr == (tests[j].format == FORMAT_COLOUR ? D3D_OK : D3DERR_INVALIDCALL),
-                            "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                            "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -4390,7 +4373,7 @@ static void test_resource_access(void)
                     hr = IDirect3DDevice9Ex_CreateRenderTargetEx(device, 16, 16, format, D3DMULTISAMPLE_NONE,
                             0, tests[j].pool != D3DPOOL_DEFAULT, &surface, NULL, tests[j].usage);
                     ok(hr == (tests[j].format == FORMAT_COLOUR && !tests[j].usage ? D3D_OK : D3DERR_INVALIDCALL),
-                                "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                                "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -4399,7 +4382,7 @@ static void test_resource_access(void)
                     hr = IDirect3DDevice9Ex_CreateDepthStencilSurface(device, 16, 16, format,
                             D3DMULTISAMPLE_NONE, 0, tests[j].usage & D3DUSAGE_DYNAMIC, &surface, NULL);
                     ok(hr == (tests[j].format == FORMAT_DEPTH ? D3D_OK : D3DERR_INVALIDCALL),
-                            "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                            "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -4408,7 +4391,7 @@ static void test_resource_access(void)
                     hr = IDirect3DDevice9Ex_CreateDepthStencilSurfaceEx(device, 16, 16, format, D3DMULTISAMPLE_NONE,
                             0, tests[j].pool != D3DPOOL_DEFAULT, &surface, NULL, tests[j].usage);
                     ok(hr == (tests[j].format == FORMAT_DEPTH && !tests[j].usage ? D3D_OK : D3DERR_INVALIDCALL),
-                            "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                            "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -4421,7 +4404,7 @@ static void test_resource_access(void)
                         ok(hr == (tests[j].pool != D3DPOOL_MANAGED && (tests[j].format != FORMAT_DEPTH || depth_plain)
                                 && (tests[j].format != FORMAT_ATI2 || tests[j].pool == D3DPOOL_SCRATCH)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
-                                "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                                "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -4434,7 +4417,7 @@ static void test_resource_access(void)
                                 && (tests[j].format != FORMAT_DEPTH || depth_plain)
                                 && (tests[j].format != FORMAT_ATI2 || tests[j].pool == D3DPOOL_SCRATCH)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
-                                "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                                "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -4445,31 +4428,31 @@ static void test_resource_access(void)
             }
 
             hr = IDirect3DSurface9_GetDesc(surface, &surface_desc);
-            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
             if (surface_types[i].type == SURFACE_RT || surface_types[i].type == SURFACE_RT_EX)
             {
-                ok(surface_desc.Usage == D3DUSAGE_RENDERTARGET, "Test %s %u: Got unexpected usage %#x.\n",
+                ok(surface_desc.Usage == D3DUSAGE_RENDERTARGET, "Test %s %u: Got unexpected usage %#lx.\n",
                         surface_types[i].name, j, surface_desc.Usage);
                 ok(surface_desc.Pool == D3DPOOL_DEFAULT, "Test %s %u: Got unexpected pool %#x.\n",
                         surface_types[i].name, j, surface_desc.Pool);
             }
             else if (surface_types[i].type == SURFACE_DS || surface_types[i].type == SURFACE_DS_EX)
             {
-                ok(surface_desc.Usage == D3DUSAGE_DEPTHSTENCIL, "Test %s %u: Got unexpected usage %#x.\n",
+                ok(surface_desc.Usage == D3DUSAGE_DEPTHSTENCIL, "Test %s %u: Got unexpected usage %#lx.\n",
                         surface_types[i].name, j, surface_desc.Usage);
                 ok(surface_desc.Pool == D3DPOOL_DEFAULT, "Test %s %u: Got unexpected pool %#x.\n",
                         surface_types[i].name, j, surface_desc.Pool);
             }
             else if (surface_types[i].type == SURFACE_PLAIN || surface_types[i].type == SURFACE_PLAIN_EX)
             {
-                ok(!surface_desc.Usage, "Test %s %u: Got unexpected usage %#x.\n",
+                ok(!surface_desc.Usage, "Test %s %u: Got unexpected usage %#lx.\n",
                         surface_types[i].name, j, surface_desc.Usage);
                 ok(surface_desc.Pool == tests[j].pool, "Test %s %u: Got unexpected pool %#x.\n",
                         surface_types[i].name, j, surface_desc.Pool);
             }
             else
             {
-                ok(surface_desc.Usage == tests[j].usage, "Test %s %u: Got unexpected usage %#x.\n",
+                ok(surface_desc.Usage == tests[j].usage, "Test %s %u: Got unexpected usage %#lx.\n",
                         surface_types[i].name, j, surface_desc.Usage);
                 ok(surface_desc.Pool == tests[j].pool, "Test %s %u: Got unexpected pool %#x.\n",
                         surface_types[i].name, j, surface_desc.Pool);
@@ -4484,31 +4467,31 @@ static void test_resource_access(void)
                 expected_hr = D3D_OK;
             else
                 expected_hr = D3DERR_INVALIDCALL;
-            ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+            ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
             hr = IDirect3DSurface9_UnlockRect(surface);
             todo_wine_if(expected_hr != D3D_OK && surface_types[i].type == SURFACE_2D)
-                ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
 
             if (SUCCEEDED(IDirect3DSurface9_GetContainer(surface, &IID_IDirect3DBaseTexture9, (void **)&texture)))
             {
                 hr = IDirect3DDevice9Ex_SetTexture(device, 0, texture);
-                ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                 hr = IDirect3DDevice9Ex_SetTexture(device, 0, NULL);
-                ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                 IDirect3DBaseTexture9_Release(texture);
             }
 
             hr = IDirect3DDevice9Ex_SetRenderTarget(device, 0, surface);
             ok(hr == (surface_desc.Usage & D3DUSAGE_RENDERTARGET ? D3D_OK : D3DERR_INVALIDCALL),
-                    "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                    "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
             hr = IDirect3DDevice9Ex_SetRenderTarget(device, 0, backbuffer);
-            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
 
             hr = IDirect3DDevice9Ex_SetDepthStencilSurface(device, surface);
             ok(hr == (surface_desc.Usage & D3DUSAGE_DEPTHSTENCIL ? D3D_OK : D3DERR_INVALIDCALL),
-                    "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                    "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
             hr = IDirect3DDevice9Ex_SetDepthStencilSurface(device, depth_stencil);
-            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
 
             IDirect3DSurface9_Release(surface);
         }
@@ -4536,16 +4519,16 @@ static void test_resource_access(void)
                 && (tests[i].format != FORMAT_ATI2 || tests[i].pool == D3DPOOL_SCRATCH)
                 && tests[i].pool != D3DPOOL_MANAGED ? D3D_OK : D3DERR_INVALIDCALL))
                 || (tests[i].format == FORMAT_ATI2 && (hr == D3D_OK || warp)),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirect3DVolumeTexture9_GetVolumeLevel(texture, 0, &volume);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DVolume9_GetDesc(volume, &volume_desc);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(volume_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, volume_desc.Usage);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(volume_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#lx.\n", i, volume_desc.Usage);
         ok(volume_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, volume_desc.Pool);
 
         hr = IDirect3DVolume9_LockBox(volume, &lb, NULL, 0);
@@ -4554,15 +4537,15 @@ static void test_resource_access(void)
         else
             expected_hr = D3DERR_INVALIDCALL;
         ok(hr == expected_hr || (volume_desc.Pool == D3DPOOL_DEFAULT && hr == D3D_OK),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DVolume9_UnlockBox(volume);
         ok(hr == expected_hr || (volume_desc.Pool == D3DPOOL_DEFAULT && hr == D3D_OK),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9Ex_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9Ex_SetTexture(device, 0, NULL);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         IDirect3DVolume9_Release(volume);
         IDirect3DVolumeTexture9_Release(texture);
@@ -4578,24 +4561,24 @@ static void test_resource_access(void)
                 tests[i].format == FORMAT_COLOUR ? D3DFMT_INDEX32 : D3DFMT_INDEX16, tests[i].pool, &ib, NULL);
         ok(hr == (tests[i].pool == D3DPOOL_SCRATCH || tests[i].pool == D3DPOOL_MANAGED
                 || (tests[i].usage & ~D3DUSAGE_DYNAMIC) ? D3DERR_INVALIDCALL : D3D_OK),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirect3DIndexBuffer9_GetDesc(ib, &ib_desc);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(ib_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, ib_desc.Usage);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(ib_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#lx.\n", i, ib_desc.Usage);
         ok(ib_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, ib_desc.Pool);
 
         hr = IDirect3DIndexBuffer9_Lock(ib, 0, 0, &data, 0);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DIndexBuffer9_Unlock(ib);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9Ex_SetIndices(device, ib);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9Ex_SetIndices(device, NULL);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         IDirect3DIndexBuffer9_Release(ib);
     }
@@ -4610,24 +4593,24 @@ static void test_resource_access(void)
                 tests[i].format == FORMAT_COLOUR ? 0 : D3DFVF_XYZRHW, tests[i].pool, &vb, NULL);
         ok(hr == (tests[i].pool == D3DPOOL_SCRATCH || tests[i].pool == D3DPOOL_MANAGED
                 || (tests[i].usage & ~D3DUSAGE_DYNAMIC) ? D3DERR_INVALIDCALL : D3D_OK),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirect3DVertexBuffer9_GetDesc(vb, &vb_desc);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(vb_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, vb_desc.Usage);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(vb_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#lx.\n", i, vb_desc.Usage);
         ok(vb_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, vb_desc.Pool);
 
         hr = IDirect3DVertexBuffer9_Lock(vb, 0, 0, &data, 0);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DVertexBuffer9_Unlock(vb);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9Ex_SetStreamSource(device, 0, vb, 0, 16);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9Ex_SetStreamSource(device, 0, NULL, 0, 0);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         IDirect3DVertexBuffer9_Release(vb);
     }
@@ -4635,7 +4618,7 @@ static void test_resource_access(void)
     IDirect3DSurface9_Release(depth_stencil);
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -4684,8 +4667,8 @@ static void test_sysmem_draw(void)
     IDirect3DTexture9 *texture;
     IDirect3DDevice9Ex *device;
     IDirect3DIndexBuffer9 *ib;
+    unsigned int colour;
     D3DLOCKED_RECT lr;
-    D3DCOLOR colour;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -4700,124 +4683,124 @@ static void test_sysmem_draw(void)
     }
 
     hr = IDirect3DDevice9Ex_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_CreateVertexBuffer(device, sizeof(quad), 0, 0, D3DPOOL_SYSTEMMEM, &vb, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_SetStreamSource(device, 0, vb, 0, sizeof(*quad));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = get_pixel_color(device, 320, 240);
     ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     hr = IDirect3DDevice9Ex_CreateIndexBuffer(device, sizeof(indices), 0,
             D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DIndexBuffer9_Lock(ib, 0, sizeof(indices), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, indices, sizeof(indices));
     hr = IDirect3DIndexBuffer9_Unlock(ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_SetIndices(device, ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 0, 4, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = get_pixel_color(device, 320, 240);
     ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     hr = IDirect3DDevice9Ex_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_SetVertexDeclaration(device, vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_CreateVertexBuffer(device, sizeof(quad_s0), 0, 0, D3DPOOL_SYSTEMMEM, &vb_s0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb_s0, 0, sizeof(quad_s0), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad_s0, sizeof(quad_s0));
     hr = IDirect3DVertexBuffer9_Unlock(vb_s0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_CreateVertexBuffer(device, sizeof(quad_s1), 0, 0, D3DPOOL_SYSTEMMEM, &vb_s1, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb_s1, 0, sizeof(quad_s1), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad_s1, sizeof(quad_s1));
     hr = IDirect3DVertexBuffer9_Unlock(vb_s1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_SetStreamSource(device, 0, vb_s0, 0, sizeof(*quad_s0));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_SetStreamSource(device, 1, vb_s1, 0, sizeof(*quad_s1));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 0, 4, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = get_pixel_color(device, 320, 240);
     ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     hr = IDirect3DDevice9Ex_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(lr.pBits, texture_data, sizeof(texture_data));
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-    ok(hr == D3D_OK || hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9Ex_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture);
     IDirect3DVertexBuffer9_Release(vb_s1);
@@ -4826,7 +4809,7 @@ static void test_sysmem_draw(void)
     IDirect3DIndexBuffer9_Release(ib);
     IDirect3DVertexBuffer9_Release(vb);
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -4873,14 +4856,14 @@ static void test_pinned_buffers(void)
 
         hr = IDirect3DDevice9Ex_CreateVertexBuffer(device, vertex_count * sizeof(*ptr),
                 tests[test].usage, 0, tests[test].pool, &buffer, NULL);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DVertexBuffer9_GetDesc(buffer, &desc);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         ok(desc.Pool == tests[test].pool, "Test %u: got unexpected pool %#x.\n", test, desc.Pool);
-        ok(desc.Usage == tests[test].usage, "Test %u: got unexpected usage %#x.\n", test, desc.Usage);
+        ok(desc.Usage == tests[test].usage, "Test %u: got unexpected usage %#lx.\n", test, desc.Usage);
 
         hr = IDirect3DVertexBuffer9_Lock(buffer, 0, vertex_count * sizeof(*ptr), (void **)&ptr, D3DLOCK_DISCARD);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         for (i = 0; i < vertex_count; ++i)
         {
             ptr[i].x = i * 1.0f;
@@ -4888,21 +4871,21 @@ static void test_pinned_buffers(void)
             ptr[i].z = i * 3.0f;
         }
         hr = IDirect3DVertexBuffer9_Unlock(buffer);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
 
         hr = IDirect3DDevice9Ex_SetFVF(device, D3DFVF_XYZ);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DDevice9Ex_SetStreamSource(device, 0, buffer, 0, sizeof(*ptr));
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DDevice9Ex_BeginScene(device);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DDevice9Ex_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DDevice9Ex_EndScene(device);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
 
         hr = IDirect3DVertexBuffer9_Lock(buffer, 0, vertex_count * sizeof(*ptr2), (void **)&ptr2, D3DLOCK_DISCARD);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         ok(ptr2 == ptr, "Test %u: got unexpected ptr2 %p, expected %p.\n", test, ptr2, ptr);
         for (i = 0; i < vertex_count; ++i)
         {
@@ -4914,7 +4897,7 @@ static void test_pinned_buffers(void)
             }
         }
         hr = IDirect3DVertexBuffer9_Unlock(buffer);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
 
         IDirect3DVertexBuffer9_Release(buffer);
         refcount = IDirect3DDevice9Ex_Release(device);
@@ -4927,7 +4910,7 @@ static void test_desktop_window(void)
 {
     IDirect3DVertexShader9 *shader;
     IDirect3DDevice9Ex *device;
-    D3DCOLOR color;
+    unsigned int color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -4957,22 +4940,22 @@ static void test_desktop_window(void)
     ok(!!device, "Failed to create a D3D device.\n");
 
     hr = IDirect3DDevice9Ex_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     color = get_pixel_color(device, 1, 1);
     ok(color == 0x00ff0000, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9Ex_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     /* test device with NULL HWND */
     device = create_device(NULL, NULL);
     ok(!!device, "Failed to create a D3D device\n");
 
     hr = IDirect3DDevice9Ex_CreateVertexShader(device, simple_vs, &shader);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx.\n", hr);
     IDirect3DVertexShader9_Release(shader);
 
     IDirect3DDevice9Ex_Release(device);
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 7abf9ea3df2..a939b18a5e1 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -92,10 +92,10 @@ static BOOL compare_elements(IDirect3DVertexDeclaration9 *declaration, const D3D
     HRESULT hr;
 
     hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, NULL, &element_count);
-    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#lx.\n", hr);
     elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(*elements));
     hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, elements, &element_count);
-    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#lx.\n", hr);
 
     for (i = 0; i < element_count; ++i)
     {
@@ -320,7 +320,7 @@ static HRESULT reset_device(IDirect3DDevice9 *device, const struct device_desc *
         int rc_new = rc; \
         ok(tmp1 == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, tmp1); \
     } else {\
-        trace("%s failed: %08x\n", c, r); \
+        trace("%s failed: %08lx\n", c, r); \
     }
 
 #define CHECK_RELEASE(obj,d,rc) \
@@ -356,8 +356,8 @@ static HRESULT reset_device(IDirect3DDevice9 *device, const struct device_desc *
     { \
         void *container_ptr = (void *)0x1337c0d3; \
         hr = IDirect3DSurface9_GetContainer(obj, &iid, &container_ptr); \
-        ok(SUCCEEDED(hr) && container_ptr == expected, "GetContainer returned: hr %#x, container_ptr %p. " \
-            "Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, expected); \
+        ok(SUCCEEDED(hr) && container_ptr == expected, "GetContainer returned: hr %#lx, container_ptr %p. " \
+            "Expected hr %#lx, container_ptr %p\n", hr, container_ptr, S_OK, expected); \
         if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr); \
     }
 
@@ -386,28 +386,28 @@ static void test_get_set_vertex_declaration(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, simple_decl, &declaration);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* SetVertexDeclaration() should not touch the declaration's refcount. */
     expected_refcount = get_refcount((IUnknown *)declaration);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration);
-    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)declaration);
-    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ok(refcount == expected_refcount, "Got unexpected refcount %lu, expected %lu.\n", refcount, expected_refcount);
 
     /* GetVertexDeclaration() should increase the declaration's refcount by one. */
     tmp = NULL;
     expected_refcount = refcount + 1;
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#lx.\n", hr);
     ok(tmp == declaration, "Got unexpected declaration %p, expected %p.\n", tmp, declaration);
     refcount = get_refcount((IUnknown *)declaration);
-    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ok(refcount == expected_refcount, "Got unexpected refcount %lu, expected %lu.\n", refcount, expected_refcount);
     IDirect3DVertexDeclaration9_Release(tmp);
 
     IDirect3DVertexDeclaration9_Release(declaration);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -440,19 +440,19 @@ static void test_get_declaration(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, simple_decl, &declaration);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* First test only getting the number of elements. */
     element_count = 0x1337c0de;
     expected_element_count = ARRAY_SIZE(simple_decl);
     hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, NULL, &element_count);
-    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#lx.\n", hr);
     ok(element_count == expected_element_count, "Got unexpected element count %u, expected %u.\n",
             element_count, expected_element_count);
 
     element_count = 0;
     hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, NULL, &element_count);
-    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#lx.\n", hr);
     ok(element_count == expected_element_count, "Got unexpected element count %u, expected %u.\n",
             element_count, expected_element_count);
 
@@ -461,7 +461,7 @@ static void test_get_declaration(void)
 
     element_count = 0x1337c0de;
     hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, elements, &element_count);
-    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#lx.\n", hr);
     ok(element_count == expected_element_count, "Got unexpected element count %u, expected %u.\n",
             element_count, expected_element_count);
     ok(!memcmp(elements, simple_decl, element_count * sizeof(*elements)),
@@ -471,7 +471,7 @@ static void test_get_declaration(void)
 
     element_count = 0;
     hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, elements, &element_count);
-    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get declaration, hr %#lx.\n", hr);
     ok(element_count == expected_element_count, "Got unexpected element count %u, expected %u.\n",
             element_count, expected_element_count);
     ok(!memcmp(elements, simple_decl, element_count * sizeof(*elements)),
@@ -480,7 +480,7 @@ static void test_get_declaration(void)
     HeapFree(GetProcessHeap(), 0, elements);
     IDirect3DVertexDeclaration9_Release(declaration);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -765,20 +765,20 @@ static void test_fvf_decl_conversion(void)
         /* Set a default FVF of SPECULAR and DIFFUSE to make sure it is changed
          * back to 0. */
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-        ok(SUCCEEDED(hr), "Test %u: Failed to set FVF, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to set FVF, hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_to_fvf_tests[i].elements, &declaration);
-        ok(SUCCEEDED(hr), "Test %u: Failed to create vertex declaration, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to create vertex declaration, hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration);
-        ok(SUCCEEDED(hr), "Test %u: Failed to set vertex declaration, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to set vertex declaration, hr %#lx.\n", i, hr);
 
         /* Check the FVF. */
         hr = IDirect3DDevice9_GetFVF(device, &fvf);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get FVF, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get FVF, hr %#lx.\n", i, hr);
 
         todo_wine_if (decl_to_fvf_tests[i].todo)
             ok(fvf == decl_to_fvf_tests[i].fvf,
-                    "Test %u: Got unexpected FVF %#x, expected %#x.\n",
+                    "Test %u: Got unexpected FVF %#lx, expected %#lx.\n",
                     i, fvf, decl_to_fvf_tests[i].fvf);
 
         IDirect3DDevice9_SetVertexDeclaration(device, NULL);
@@ -788,19 +788,19 @@ static void test_fvf_decl_conversion(void)
     /* Create a default declaration and FVF that does not match any of the
      * tests. */
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, default_elements, &default_decl);
-    ok(SUCCEEDED(hr), "Failed to create vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex declaration, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(fvf_to_decl_tests); ++i)
     {
         /* Set a default declaration to make sure it is changed. */
         hr = IDirect3DDevice9_SetVertexDeclaration(device, default_decl);
-        ok(SUCCEEDED(hr), "Test %u: Failed to set vertex declaration, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to set vertex declaration, hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_SetFVF(device, fvf_to_decl_tests[i].fvf);
-        ok(SUCCEEDED(hr), "Test %u: Failed to set FVF, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to set FVF, hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get vertex declaration, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get vertex declaration, hr %#lx.\n", i, hr);
         ok(!!declaration && declaration != default_decl,
                 "Test %u: Got unexpected declaration %p.\n", i, declaration);
         ok(compare_elements(declaration, fvf_to_decl_tests[i].elements),
@@ -810,17 +810,17 @@ static void test_fvf_decl_conversion(void)
 
     /* Setting the FVF to 0 should result in no change to the default decl. */
     hr = IDirect3DDevice9_SetVertexDeclaration(device, default_decl);
-    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, 0);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#lx.\n", hr);
     ok(declaration == default_decl, "Got unexpected declaration %p, expected %p.\n", declaration, default_decl);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     IDirect3DVertexDeclaration9_Release(default_decl);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -856,25 +856,25 @@ static void test_fvf_decl_management(void)
 
     /* Clear down any current vertex declaration. */
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
     /* Conversion. */
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     /* Get converted decl (#1). */
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration1);
-    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#lx.\n", hr);
     ok(compare_elements(declaration1, test_elements1), "Declaration does not match.\n");
     /* Get converted decl again (#2). */
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration2);
-    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#lx.\n", hr);
     ok(declaration2 == declaration1, "Got unexpected declaration2 %p, expected %p.\n", declaration2, declaration1);
 
     /* Conversion. */
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     /* Get converted decl (#3). */
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration3);
-    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#lx.\n", hr);
     ok(declaration3 != declaration2, "Got unexpected declaration3 %p.\n", declaration3);
     /* The contents should correspond to the second conversion. */
     ok(compare_elements(declaration3, test_elements2), "Declaration does not match.\n");
@@ -882,19 +882,19 @@ static void test_fvf_decl_management(void)
     ok(compare_elements(declaration1, test_elements1), "Declaration does not match.\n");
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration4);
-    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get vertex declaration, hr %#lx.\n", hr);
     ok(declaration4 == declaration1, "Got unexpected declaration4 %p, expected %p.\n", declaration4, declaration1);
 
     refcount = get_refcount((IUnknown*)declaration1);
-    ok(refcount == 3, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 3, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown*)declaration2);
-    ok(refcount == 3, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 3, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown*)declaration3);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown*)declaration4);
-    ok(refcount == 3, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 3, "Got unexpected refcount %lu.\n", refcount);
 
     IDirect3DVertexDeclaration9_Release(declaration4);
     IDirect3DVertexDeclaration9_Release(declaration3);
@@ -902,7 +902,7 @@ static void test_fvf_decl_management(void)
     IDirect3DVertexDeclaration9_Release(declaration1);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -974,13 +974,13 @@ static void test_vertex_declaration_alignment(void)
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DDevice9_CreateVertexDeclaration(device, test_data[i].elements, &declaration);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (SUCCEEDED(hr))
             IDirect3DVertexDeclaration9_Release(declaration);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -1047,11 +1047,11 @@ static void test_unused_declaration_type(void)
     for (i = 0; i < ARRAY_SIZE(test_elements); ++i)
     {
         hr = IDirect3DDevice9_CreateVertexDeclaration(device, test_elements[i], &declaration);
-        ok(hr == E_FAIL, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == E_FAIL, "Test %u: Got unexpected hr %#lx.\n", i, hr);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -1065,9 +1065,9 @@ static void check_mipmap_levels(IDirect3DDevice9 *device, UINT width, UINT heigh
 
     if (SUCCEEDED(hr)) {
         DWORD levels = IDirect3DBaseTexture9_GetLevelCount(texture);
-        ok(levels == count, "Invalid level count. Expected %d got %u\n", count, levels);
+        ok(levels == count, "Invalid level count. Expected %d got %lu\n", count, levels);
     } else
-        trace("CreateTexture failed: %08x\n", hr);
+        trace("CreateTexture failed: %08lx\n", hr);
 
     if (texture) IDirect3DBaseTexture9_Release( texture );
 }
@@ -1095,7 +1095,7 @@ static void test_mipmap_levels(void)
     check_mipmap_levels(device, 1, 1, 1);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -1122,61 +1122,61 @@ static void test_checkdevicemultisampletype(void)
 
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_UNKNOWN, TRUE, D3DMULTISAMPLE_NONE, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             65536, TRUE, D3DMULTISAMPLE_NONE, NULL);
-    todo_wine ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_NONE, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     quality_levels = 0;
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_NONE, &quality_levels);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(quality_levels == 1, "Got unexpected quality_levels %u.\n", quality_levels);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(quality_levels == 1, "Got unexpected quality_levels %lu.\n", quality_levels);
     quality_levels = 0;
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, FALSE, D3DMULTISAMPLE_NONE, &quality_levels);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(quality_levels == 1, "Got unexpected quality_levels %u.\n", quality_levels);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(quality_levels == 1, "Got unexpected quality_levels %lu.\n", quality_levels);
 
     quality_levels = 0;
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_NONMASKABLE, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_NONMASKABLE, &quality_levels);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(quality_levels, "Got unexpected quality_levels %u.\n", quality_levels);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(quality_levels, "Got unexpected quality_levels %lu.\n", quality_levels);
 
     quality_levels = 0;
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES, &quality_levels);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(quality_levels, "Got unexpected quality_levels %u.\n", quality_levels);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(quality_levels, "Got unexpected quality_levels %lu.\n", quality_levels);
 
     /* We assume D3DMULTISAMPLE_15_SAMPLES is never supported in practice. */
     quality_levels = 0;
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_15_SAMPLES, NULL);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_15_SAMPLES, &quality_levels);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
-    ok(quality_levels == 1, "Got unexpected quality_levels %u.\n", quality_levels);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
+    ok(quality_levels == 1, "Got unexpected quality_levels %lu.\n", quality_levels);
 
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, 65536, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_DXT5, TRUE, D3DMULTISAMPLE_2_SAMPLES, NULL);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
 
 cleanup:
     IDirect3D9_Release(d3d);
@@ -1211,15 +1211,15 @@ static void test_invalid_multisample(void)
             D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONMASKABLE, 0, FALSE, &rt, NULL);
     if (available)
     {
-        ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
         IDirect3DSurface9_Release(rt);
         hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
                 D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONMASKABLE, quality_levels, FALSE, &rt, NULL);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
     else
     {
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
 
     available = SUCCEEDED(IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
@@ -1228,27 +1228,27 @@ static void test_invalid_multisample(void)
             D3DFMT_X8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &rt, NULL);
     if (available)
     {
-        ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
         IDirect3DSurface9_Release(rt);
         hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
                 D3DFMT_X8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, quality_levels, FALSE, &rt, NULL);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
     else
     {
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
 
     /* We assume D3DMULTISAMPLE_15_SAMPLES is never supported in practice. */
     hr = IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_15_SAMPLES, NULL);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_X8R8G8B8, D3DMULTISAMPLE_15_SAMPLES, 0, FALSE, &rt, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -1284,100 +1284,100 @@ static void test_swapchain(void)
 
     /* Get the implicit swapchain */
     hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain0);
-    ok(SUCCEEDED(hr), "Failed to get the implicit swapchain (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     /* Check if the back buffer count was modified */
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain0, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferCount == 1, "Got unexpected back buffer count %u.\n", d3dpp.BackBufferCount);
     IDirect3DSwapChain9_Release(swapchain0);
 
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain0, 0, D3DBACKBUFFER_TYPE_MONO, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     /* IDirect3DDevice9::GetBackBuffer crashes if a NULL output pointer is passed. */
     backbuffer = (void *)0xdeadbeef;
     hr = IDirect3DDevice9_GetBackBuffer(device, 1, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!backbuffer, "The back buffer pointer is %p, expected NULL.\n", backbuffer);
     backbuffer = (void *)0xdeadbeef;
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 1, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!backbuffer, "The back buffer pointer is %p, expected NULL.\n", backbuffer);
 
     /* Check if there is a back buffer */
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     ok(backbuffer != NULL, "The back buffer is NULL\n");
     if(backbuffer) IDirect3DSurface9_Release(backbuffer);
 
     /* The back buffer type value is ignored. */
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain0, 0, D3DBACKBUFFER_TYPE_LEFT, &stereo_buffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#lx.\n", hr);
     ok(stereo_buffer == backbuffer, "Expected left back buffer = %p, got %p.\n", backbuffer, stereo_buffer);
     IDirect3DSurface9_Release(stereo_buffer);
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain0, 0, D3DBACKBUFFER_TYPE_RIGHT, &stereo_buffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#lx.\n", hr);
     ok(stereo_buffer == backbuffer, "Expected right back buffer = %p, got %p.\n", backbuffer, stereo_buffer);
     IDirect3DSurface9_Release(stereo_buffer);
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain0, 0, (D3DBACKBUFFER_TYPE)0xdeadbeef, &stereo_buffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#lx.\n", hr);
     ok(stereo_buffer == backbuffer, "Expected unknown buffer = %p, got %p.\n", backbuffer, stereo_buffer);
     IDirect3DSurface9_Release(stereo_buffer);
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_LEFT, &stereo_buffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#lx.\n", hr);
     ok(stereo_buffer == backbuffer, "Expected left back buffer = %p, got %p.\n", backbuffer, stereo_buffer);
     IDirect3DSurface9_Release(stereo_buffer);
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_RIGHT, &stereo_buffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#lx.\n", hr);
     ok(stereo_buffer == backbuffer, "Expected right back buffer = %p, got %p.\n", backbuffer, stereo_buffer);
     IDirect3DSurface9_Release(stereo_buffer);
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, (D3DBACKBUFFER_TYPE)0xdeadbeef, &stereo_buffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get the back buffer, hr %#lx.\n", hr);
     ok(stereo_buffer == backbuffer, "Expected unknown buffer = %p, got %p.\n", backbuffer, stereo_buffer);
     IDirect3DSurface9_Release(stereo_buffer);
 
     /* Try to get a nonexistent swapchain */
     hr = IDirect3DDevice9_GetSwapChain(device, 1, &swapchainX);
-    ok(hr == D3DERR_INVALIDCALL, "GetSwapChain on an nonexistent swapchain returned (%08x)\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     ok(swapchainX == NULL, "Swapchain 1 is %p\n", swapchainX);
     if(swapchainX) IDirect3DSwapChain9_Release(swapchainX);
 
     /* Create a bunch of swapchains */
     d3dpp.BackBufferCount = 0;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
-    ok(SUCCEEDED(hr), "Failed to create a swapchain (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     ok(d3dpp.BackBufferCount == 1, "The back buffer count in the presentparams struct is %d\n", d3dpp.BackBufferCount);
 
     d3dpp.BackBufferCount  = 1;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain2);
-    ok(SUCCEEDED(hr), "Failed to create a swapchain (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     d3dpp.BackBufferCount  = 2;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain3);
-    ok(SUCCEEDED(hr), "Failed to create a swapchain (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     if(SUCCEEDED(hr)) {
         /* Swapchain 3, created with backbuffercount 2 */
         backbuffer = (void *) 0xdeadbeef;
         hr = IDirect3DSwapChain9_GetBackBuffer(swapchain3, 0, 0, &backbuffer);
-        ok(SUCCEEDED(hr), "Failed to get the 1st back buffer (%08x)\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
         ok(backbuffer != NULL && backbuffer != (void *) 0xdeadbeef, "The back buffer is %p\n", backbuffer);
         if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface9_Release(backbuffer);
 
         backbuffer = (void *) 0xdeadbeef;
         hr = IDirect3DSwapChain9_GetBackBuffer(swapchain3, 1, 0, &backbuffer);
-        ok(SUCCEEDED(hr), "Failed to get the 2nd back buffer (%08x)\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
         ok(backbuffer != NULL && backbuffer != (void *) 0xdeadbeef, "The back buffer is %p\n", backbuffer);
         if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface9_Release(backbuffer);
 
         backbuffer = (void *) 0xdeadbeef;
         hr = IDirect3DSwapChain9_GetBackBuffer(swapchain3, 2, 0, &backbuffer);
-        ok(hr == D3DERR_INVALIDCALL, "GetBackBuffer returned %08x\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
         ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
         if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface9_Release(backbuffer);
 
         backbuffer = (void *) 0xdeadbeef;
         hr = IDirect3DSwapChain9_GetBackBuffer(swapchain3, 3, 0, &backbuffer);
-        ok(FAILED(hr), "Failed to get the back buffer (%08x)\n", hr);
+        ok(FAILED(hr), "Got hr %#lx.\n", hr);
         ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
         if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface9_Release(backbuffer);
     }
@@ -1385,32 +1385,32 @@ static void test_swapchain(void)
     /* Check the back buffers of the swapchains */
     /* Swapchain 1, created with backbuffercount 0 */
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain1, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer (%08x)\n", hr);
-    ok(backbuffer != NULL, "The back buffer is NULL (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
+    ok(backbuffer != NULL, "Got hr %#lx.\n", hr);
     if(backbuffer) IDirect3DSurface9_Release(backbuffer);
 
     backbuffer = (void *) 0xdeadbeef;
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain1, 1, 0, &backbuffer);
-    ok(FAILED(hr), "Failed to get the back buffer (%08x)\n", hr);
+    ok(FAILED(hr), "Got hr %#lx.\n", hr);
     ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
     if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface9_Release(backbuffer);
 
     /* Swapchain 2 - created with backbuffercount 1 */
     backbuffer = (void *) 0xdeadbeef;
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain2, 0, 0, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get the back buffer (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     ok(backbuffer != NULL && backbuffer != (void *) 0xdeadbeef, "The back buffer is %p\n", backbuffer);
     if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface9_Release(backbuffer);
 
     backbuffer = (void *) 0xdeadbeef;
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain2, 1, 0, &backbuffer);
-    ok(hr == D3DERR_INVALIDCALL, "GetBackBuffer returned %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
     if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface9_Release(backbuffer);
 
     backbuffer = (void *) 0xdeadbeef;
     hr = IDirect3DSwapChain9_GetBackBuffer(swapchain2, 2, 0, &backbuffer);
-    ok(FAILED(hr), "Failed to get the back buffer (%08x)\n", hr);
+    ok(FAILED(hr), "Got hr %#lx.\n", hr);
     ok(backbuffer == (void *) 0xdeadbeef, "The back buffer pointer was modified (%p)\n", backbuffer);
     if(backbuffer && backbuffer != (void *) 0xdeadbeef) IDirect3DSurface9_Release(backbuffer);
 
@@ -1419,7 +1419,7 @@ static void test_swapchain(void)
      */
     swapchainX = (void *) 0xdeadbeef;
     hr = IDirect3DDevice9_GetSwapChain(device, 1, &swapchainX);
-    ok(hr == D3DERR_INVALIDCALL, "Failed to get the second swapchain (%08x)\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     ok(swapchainX == NULL, "The swapchain pointer is %p\n", swapchainX);
     if(swapchainX && swapchainX != (void *) 0xdeadbeef ) IDirect3DSwapChain9_Release(swapchainX);
 
@@ -1431,34 +1431,34 @@ static void test_swapchain(void)
     d3dpp.hDeviceWindow = window;
     d3dpp.BackBufferCount = 1;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx\n", hr);
     d3dpp.hDeviceWindow = window2;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx\n", hr);
 
     device_desc.width = registry_mode.dmPelsWidth;
     device_desc.height = registry_mode.dmPelsHeight;
     device_desc.device_window = window;
     device_desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     d3dpp.hDeviceWindow = window;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx\n", hr);
     d3dpp.hDeviceWindow = window2;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx\n", hr);
     d3dpp.Windowed = TRUE;
     d3dpp.hDeviceWindow = window;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx\n", hr);
     d3dpp.hDeviceWindow = window2;
     hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D9_Release(d3d);
     DestroyWindow(window2);
@@ -1513,7 +1513,7 @@ static void test_refcount(void)
     }
 
     refcount = get_refcount((IUnknown *)device);
-    ok(refcount == 1, "Invalid device RefCount %d\n", refcount);
+    ok(refcount == 1, "Unexpected refcount %lu.\n", refcount);
 
     CHECK_REFCOUNT(d3d, 2);
 
@@ -1867,7 +1867,7 @@ static void test_cursor(void)
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &cursor, NULL);
-    ok(SUCCEEDED(hr), "Failed to create cursor surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create cursor surface, hr %#lx.\n", hr);
 
     /* Initially hidden */
     ret = IDirect3DDevice9_ShowCursor(device, TRUE);
@@ -1879,10 +1879,10 @@ static void test_cursor(void)
 
     /* Fails */
     hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetCursorProperties returned %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetCursorProperties returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(cursor);
 
@@ -1897,7 +1897,7 @@ static void test_cursor(void)
     memset(&info, 0, sizeof(info));
     info.cbSize = sizeof(info);
     ok(GetCursorInfo(&info), "GetCursorInfo failed\n");
-    ok(info.flags & (CURSOR_SHOWING|CURSOR_SUPPRESSED), "The gdi cursor is hidden (%08x)\n", info.flags);
+    ok(info.flags & (CURSOR_SHOWING | CURSOR_SUPPRESSED), "Got cursor flags %#lx.\n", info.flags);
     ok(info.hCursor == cur || broken(1), "The cursor handle is %p\n", info.hCursor); /* unchanged */
 
     /* Still hidden */
@@ -1911,7 +1911,7 @@ static void test_cursor(void)
     memset(&info, 0, sizeof(info));
     info.cbSize = sizeof(info);
     ok(GetCursorInfo(&info), "GetCursorInfo failed\n");
-    ok(info.flags & (CURSOR_SHOWING|CURSOR_SUPPRESSED), "The gdi cursor is hidden (%08x)\n", info.flags);
+    ok(info.flags & (CURSOR_SHOWING | CURSOR_SUPPRESSED), "Got cursor flags %#lx.\n", info.flags);
     ok(info.hCursor != cur || broken(1), "The cursor handle is %p\n", info.hCursor);
 
     /* Cursor dimensions must all be powers of two */
@@ -1921,19 +1921,19 @@ static void test_cursor(void)
         height = cursor_sizes[test_idx].cy;
         hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, D3DFMT_A8R8G8B8,
                 D3DPOOL_DEFAULT, &cursor, NULL);
-        ok(hr == D3D_OK, "Test %u: CreateOffscreenPlainSurface failed, hr %#x.\n", test_idx, hr);
+        ok(hr == D3D_OK, "Test %u: CreateOffscreenPlainSurface failed, hr %#lx.\n", test_idx, hr);
         hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor);
         if (width && !(width & (width - 1)) && height && !(height & (height - 1)))
             expected_hr = D3D_OK;
         else
             expected_hr = D3DERR_INVALIDCALL;
-        ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#x, got %#x.\n",
+        ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#lx, got %#lx.\n",
                 test_idx, expected_hr, hr);
         IDirect3DSurface9_Release(cursor);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     /* Cursor dimensions must not exceed adapter display mode */
     device_desc.device_window = window;
@@ -1954,7 +1954,7 @@ static void test_cursor(void)
             }
 
             hr = IDirect3D9_GetAdapterDisplayMode(d3d, adapter_idx, &mode);
-            ok(hr == D3D_OK, "Adapter %u test %u: GetAdapterDisplayMode failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: GetAdapterDisplayMode failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
 
             /* Find the largest width and height that are powers of two and less than the display mode */
@@ -1967,35 +1967,31 @@ static void test_cursor(void)
 
             hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height,
                     D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &cursor, NULL);
-            ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
             hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor);
-            ok(hr == D3D_OK, "Adapter %u test %u: SetCursorProperties failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: SetCursorProperties failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
             IDirect3DSurface9_Release(cursor);
 
             hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width * 2, height,
                     D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &cursor, NULL);
-            ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
             hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor);
-            ok(hr == D3DERR_INVALIDCALL,
-                    "Adapter %u test %u: Expect SetCursorProperties return %#x, got %#x.\n",
-                    adapter_idx, test_idx, D3DERR_INVALIDCALL, hr);
+            ok(hr == D3DERR_INVALIDCALL, "Adapter %u test %u: Got hr %#lx.\n", adapter_idx, test_idx, hr);
             IDirect3DSurface9_Release(cursor);
 
             hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height * 2,
                     D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &cursor, NULL);
-            ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
             hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor);
-            ok(hr == D3DERR_INVALIDCALL,
-                    "Adapter %u test %u: Expect SetCursorProperties return %#x, got %#x.\n",
-                    adapter_idx, test_idx, D3DERR_INVALIDCALL, hr);
+            ok(hr == D3DERR_INVALIDCALL, "Adapter %u test %u: Got hr %#lx.\n", adapter_idx, test_idx, hr);
             IDirect3DSurface9_Release(cursor);
 
             refcount = IDirect3DDevice9_Release(device);
-            ok(!refcount, "Adapter %u: Device has %u references left.\n", adapter_idx, refcount);
+            ok(!refcount, "Adapter %u: Device has %lu references left.\n", adapter_idx, refcount);
         }
     }
 cleanup:
@@ -2010,13 +2006,12 @@ static void test_reset(void)
     D3DPRESENT_PARAMETERS        d3dpp;
     D3DDISPLAYMODE               d3ddm, d3ddm2;
     D3DVIEWPORT9                 vp;
-    DWORD                        width, orig_width = GetSystemMetrics(SM_CXSCREEN);
-    DWORD                        height, orig_height = GetSystemMetrics(SM_CYSCREEN);
     IDirect3DSurface9            *surface;
     IDirect3DTexture9            *texture;
     IDirect3DVertexShader9       *shader;
-    UINT                         i, adapter_mode_count;
     D3DLOCKED_RECT               lockrect;
+    const DWORD orig_width = GetSystemMetrics(SM_CXSCREEN), orig_height = GetSystemMetrics(SM_CYSCREEN);
+    unsigned int mode_count = 0, adapter_mode_count, width, height, i;
     IDirect3DDevice9 *device1 = NULL;
     IDirect3DDevice9 *device2 = NULL;
     IDirect3DSwapChain9 *swapchain;
@@ -2034,7 +2029,6 @@ static void test_reset(void)
         UINT w;
         UINT h;
     } *modes = NULL;
-    UINT mode_count = 0;
 
     hwnd = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
             100, 100, 160, 160, NULL, NULL, NULL, NULL);
@@ -2050,7 +2044,7 @@ static void test_reset(void)
         UINT j;
         ZeroMemory( &d3ddm2, sizeof(d3ddm2) );
         hr = IDirect3D9_EnumAdapterModes(d3d, D3DADAPTER_DEFAULT, d3ddm.Format, i, &d3ddm2);
-        ok(hr == D3D_OK, "IDirect3D9_EnumAdapterModes returned %#x\n", hr);
+        ok(hr == D3D_OK, "IDirect3D9_EnumAdapterModes returned %#lx\n", hr);
 
         for (j = 0; j < mode_count; ++j)
         {
@@ -2093,10 +2087,10 @@ static void test_reset(void)
         goto cleanup;
     }
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after creation returned %#x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after creation returned %#lx\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device1, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -2104,11 +2098,11 @@ static void test_reset(void)
     ok(height == modes[i].h, "Screen height is %u, expected %u\n", height, modes[i].h);
 
     hr = IDirect3DDevice9_GetViewport(device1, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
-    ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
-    ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\n", vp.Y);
-    ok(vp.Width == modes[i].w, "D3DVIEWPORT->Width = %u, expected %u\n", vp.Width, modes[i].w);
-    ok(vp.Height == modes[i].h, "D3DVIEWPORT->Height = %u, expected %u\n", vp.Height, modes[i].h);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
+    ok(vp.X == 0, "D3DVIEWPORT->X = %ld\n", vp.X);
+    ok(vp.Y == 0, "D3DVIEWPORT->Y = %ld\n", vp.Y);
+    ok(vp.Width == modes[i].w, "D3DVIEWPORT->Width = %lu, expected %u\n", vp.Width, modes[i].w);
+    ok(vp.Height == modes[i].h, "D3DVIEWPORT->Height = %lu, expected %u\n", vp.Height, modes[i].h);
     ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %f\n", vp.MinZ);
     ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
 
@@ -2118,13 +2112,13 @@ static void test_reset(void)
     vp.MinZ = 2;
     vp.MaxZ = 3;
     hr = IDirect3DDevice9_SetViewport(device1, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetViewport failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(device1, D3DRS_LIGHTING, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!!value, "Got unexpected value %#x for D3DRS_LIGHTING.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected value %#lx for D3DRS_LIGHTING.\n", value);
     hr = IDirect3DDevice9_SetRenderState(device1, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     ZeroMemory( &d3dpp, sizeof(d3dpp) );
     d3dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
@@ -2133,21 +2127,21 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = modes[i].h;
     d3dpp.BackBufferFormat = d3ddm.Format;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(device1, D3DRS_LIGHTING, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!!value, "Got unexpected value %#x for D3DRS_LIGHTING.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected value %#lx for D3DRS_LIGHTING.\n", value);
 
     ZeroMemory(&vp, sizeof(vp));
     hr = IDirect3DDevice9_GetViewport(device1, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
-    ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
-    ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\n", vp.Y);
-    ok(vp.Width == modes[i].w, "D3DVIEWPORT->Width = %u, expected %u\n", vp.Width, modes[i].w);
-    ok(vp.Height == modes[i].h, "D3DVIEWPORT->Height = %u, expected %u\n", vp.Height, modes[i].h);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
+    ok(vp.X == 0, "D3DVIEWPORT->X = %ld\n", vp.X);
+    ok(vp.Y == 0, "D3DVIEWPORT->Y = %ld\n", vp.Y);
+    ok(vp.Width == modes[i].w, "D3DVIEWPORT->Width = %lu, expected %u\n", vp.Width, modes[i].w);
+    ok(vp.Height == modes[i].h, "D3DVIEWPORT->Height = %lu, expected %u\n", vp.Height, modes[i].h);
     ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %f\n", vp.MinZ);
     ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
 
@@ -2157,10 +2151,10 @@ static void test_reset(void)
     ok(height == modes[i].h, "Screen height is %u, expected %u\n", height, modes[i].h);
 
     hr = IDirect3DDevice9_GetSwapChain(device1, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     memset(&d3dpp, 0, sizeof(d3dpp));
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == modes[i].w, "Got unexpected BackBufferWidth %u, expected %u.\n",
             d3dpp.BackBufferWidth, modes[i].w);
     ok(d3dpp.BackBufferHeight == modes[i].h, "Got unexpected BackBufferHeight %u, expected %u.\n",
@@ -2174,9 +2168,9 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 300;
     d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -2185,19 +2179,19 @@ static void test_reset(void)
 
     ZeroMemory(&vp, sizeof(vp));
     hr = IDirect3DDevice9_GetViewport(device1, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
-    ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
-    ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\n", vp.Y);
-    ok(vp.Width == 400, "D3DVIEWPORT->Width = %d\n", vp.Width);
-    ok(vp.Height == 300, "D3DVIEWPORT->Height = %d\n", vp.Height);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
+    ok(vp.X == 0, "D3DVIEWPORT->X = %ld\n", vp.X);
+    ok(vp.Y == 0, "D3DVIEWPORT->Y = %ld\n", vp.Y);
+    ok(vp.Width == 400, "D3DVIEWPORT->Width = %ld\n", vp.Width);
+    ok(vp.Height == 300, "D3DVIEWPORT->Height = %ld\n", vp.Height);
     ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %f\n", vp.MinZ);
     ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
 
     hr = IDirect3DDevice9_GetSwapChain(device1, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     memset(&d3dpp, 0, sizeof(d3dpp));
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == 400, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth);
     ok(d3dpp.BackBufferHeight == 300, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight);
     IDirect3DSwapChain9_Release(swapchain);
@@ -2208,7 +2202,7 @@ static void test_reset(void)
     devmode.dmPelsWidth = modes[1].w;
     devmode.dmPelsHeight = modes[1].h;
     ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", ret);
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
     ok(width == modes[1].w, "Screen width is %u, expected %u.\n", width, modes[1].w);
@@ -2218,9 +2212,9 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 400;
     d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed, hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -2229,19 +2223,19 @@ static void test_reset(void)
 
     ZeroMemory(&vp, sizeof(vp));
     hr = IDirect3DDevice9_GetViewport(device1, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed, hr %#x.\n", hr);
-    ok(vp.X == 0, "D3DVIEWPORT->X = %d.\n", vp.X);
-    ok(vp.Y == 0, "D3DVIEWPORT->Y = %d.\n", vp.Y);
-    ok(vp.Width == 500, "D3DVIEWPORT->Width = %d.\n", vp.Width);
-    ok(vp.Height == 400, "D3DVIEWPORT->Height = %d.\n", vp.Height);
+    ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed, hr %#lx.\n", hr);
+    ok(vp.X == 0, "D3DVIEWPORT->X = %ld.\n", vp.X);
+    ok(vp.Y == 0, "D3DVIEWPORT->Y = %ld.\n", vp.Y);
+    ok(vp.Width == 500, "D3DVIEWPORT->Width = %ld.\n", vp.Width);
+    ok(vp.Height == 400, "D3DVIEWPORT->Height = %ld.\n", vp.Height);
     ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %f.\n", vp.MinZ);
     ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9_GetSwapChain(device1, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     memset(&d3dpp, 0, sizeof(d3dpp));
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == 500, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth);
     ok(d3dpp.BackBufferHeight == 400, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight);
     IDirect3DSwapChain9_Release(swapchain);
@@ -2250,11 +2244,11 @@ static void test_reset(void)
     devmode.dmPelsWidth = orig_width;
     devmode.dmPelsHeight = orig_height;
     ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", ret);
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
-    ok(width == orig_width, "Got screen width %u, expected %u.\n", width, orig_width);
-    ok(height == orig_height, "Got screen height %u, expected %u.\n", height, orig_height);
+    ok(width == orig_width, "Got screen width %u, expected %lu.\n", width, orig_width);
+    ok(height == orig_height, "Got screen height %u, expected %lu.\n", height, orig_height);
 
     SetRect(&winrect, 0, 0, 200, 150);
     ok(AdjustWindowRect(&winrect, WS_OVERLAPPEDWINDOW, FALSE), "AdjustWindowRect failed\n");
@@ -2274,61 +2268,61 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 0;
     d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
-    ok(d3dpp.BackBufferWidth == client_rect.right, "Got unexpected BackBufferWidth %u, expected %d.\n",
+    ok(d3dpp.BackBufferWidth == client_rect.right, "Got unexpected BackBufferWidth %u, expected %ld.\n",
             d3dpp.BackBufferWidth, client_rect.right);
-    ok(d3dpp.BackBufferHeight == client_rect.bottom, "Got unexpected BackBufferHeight %u, expected %d.\n",
+    ok(d3dpp.BackBufferHeight == client_rect.bottom, "Got unexpected BackBufferHeight %u, expected %ld.\n",
             d3dpp.BackBufferHeight, client_rect.bottom);
     ok(d3dpp.BackBufferFormat == d3ddm.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n",
             d3dpp.BackBufferFormat, d3ddm.Format);
     ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount);
     ok(!d3dpp.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType);
-    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %u.\n", d3dpp.MultiSampleQuality);
+    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %lu.\n", d3dpp.MultiSampleQuality);
     ok(d3dpp.SwapEffect == D3DSWAPEFFECT_DISCARD, "Got unexpected SwapEffect %#x.\n", d3dpp.SwapEffect);
     ok(!d3dpp.hDeviceWindow, "Got unexpected hDeviceWindow %p.\n", d3dpp.hDeviceWindow);
     ok(d3dpp.Windowed, "Got unexpected Windowed %#x.\n", d3dpp.Windowed);
     ok(!d3dpp.EnableAutoDepthStencil, "Got unexpected EnableAutoDepthStencil %#x.\n", d3dpp.EnableAutoDepthStencil);
     ok(!d3dpp.AutoDepthStencilFormat, "Got unexpected AutoDepthStencilFormat %#x.\n", d3dpp.AutoDepthStencilFormat);
-    ok(!d3dpp.Flags, "Got unexpected Flags %#x.\n", d3dpp.Flags);
+    ok(!d3dpp.Flags, "Got unexpected Flags %#lx.\n", d3dpp.Flags);
     ok(!d3dpp.FullScreen_RefreshRateInHz, "Got unexpected FullScreen_RefreshRateInHz %u.\n",
             d3dpp.FullScreen_RefreshRateInHz);
     ok(!d3dpp.PresentationInterval, "Got unexpected PresentationInterval %#x.\n", d3dpp.PresentationInterval);
 
     ZeroMemory(&vp, sizeof(vp));
     hr = IDirect3DDevice9_GetViewport(device1, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
-    ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
-    ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\n", vp.Y);
-    ok(vp.Width == client_rect.right, "D3DVIEWPORT->Width = %d, expected %d\n",
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
+    ok(vp.X == 0, "D3DVIEWPORT->X = %ld\n", vp.X);
+    ok(vp.Y == 0, "D3DVIEWPORT->Y = %ld\n", vp.Y);
+    ok(vp.Width == client_rect.right, "D3DVIEWPORT->Width = %ld, expected %ld\n",
             vp.Width, client_rect.right);
-    ok(vp.Height == client_rect.bottom, "D3DVIEWPORT->Height = %d, expected %d\n",
+    ok(vp.Height == client_rect.bottom, "D3DVIEWPORT->Height = %ld, expected %ld\n",
             vp.Height, client_rect.bottom);
     ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %f\n", vp.MinZ);
     ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
 
     hr = IDirect3DDevice9_GetSwapChain(device1, 0, &swapchain);
-    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx.\n", hr);
     memset(&d3dpp, 0, sizeof(d3dpp));
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.BackBufferWidth == client_rect.right,
-            "Got unexpected BackBufferWidth %u, expected %d.\n", d3dpp.BackBufferWidth, client_rect.right);
+            "Got unexpected BackBufferWidth %u, expected %ld.\n", d3dpp.BackBufferWidth, client_rect.right);
     ok(d3dpp.BackBufferHeight == client_rect.bottom,
-            "Got unexpected BackBufferHeight %u, expected %d.\n", d3dpp.BackBufferHeight, client_rect.bottom);
+            "Got unexpected BackBufferHeight %u, expected %ld.\n", d3dpp.BackBufferHeight, client_rect.bottom);
     ok(d3dpp.BackBufferFormat == d3ddm.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n",
             d3dpp.BackBufferFormat, d3ddm.Format);
     ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount);
     ok(!d3dpp.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType);
-    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %u.\n", d3dpp.MultiSampleQuality);
+    ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %lu.\n", d3dpp.MultiSampleQuality);
     ok(d3dpp.SwapEffect == D3DSWAPEFFECT_DISCARD, "Got unexpected SwapEffect %#x.\n", d3dpp.SwapEffect);
     ok(d3dpp.hDeviceWindow == hwnd, "Got unexpected hDeviceWindow %p, expected %p.\n", d3dpp.hDeviceWindow, hwnd);
     ok(d3dpp.Windowed, "Got unexpected Windowed %#x.\n", d3dpp.Windowed);
     ok(!d3dpp.EnableAutoDepthStencil, "Got unexpected EnableAutoDepthStencil %#x.\n", d3dpp.EnableAutoDepthStencil);
     ok(!d3dpp.AutoDepthStencilFormat, "Got unexpected AutoDepthStencilFormat %#x.\n", d3dpp.AutoDepthStencilFormat);
-    ok(!d3dpp.Flags, "Got unexpected Flags %#x.\n", d3dpp.Flags);
+    ok(!d3dpp.Flags, "Got unexpected Flags %#lx.\n", d3dpp.Flags);
     ok(!d3dpp.FullScreen_RefreshRateInHz, "Got unexpected FullScreen_RefreshRateInHz %u.\n",
             d3dpp.FullScreen_RefreshRateInHz);
     ok(!d3dpp.PresentationInterval, "Got unexpected PresentationInterval %#x.\n", d3dpp.PresentationInterval);
@@ -2342,17 +2336,17 @@ static void test_reset(void)
 
     /* _Reset fails if there is a resource in the default pool */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device1, 16, 16, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &surface, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "IDirect3DDevice9_TestCooperativeLevel after a failed reset returned %#x\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
     /* Reset again to get the device out of the lost state */
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     if (caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)
     {
@@ -2360,17 +2354,16 @@ static void test_reset(void)
 
         hr = IDirect3DDevice9_CreateVolumeTexture(device1, 16, 16, 4, 1, 0,
                 D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &volume_texture, NULL);
-        ok(SUCCEEDED(hr), "CreateVolumeTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateVolumeTexture failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-        ok(hr == D3DERR_INVALIDCALL, "Reset returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+        ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-        ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n",
-                hr, D3DERR_DEVICENOTRESET);
+        ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
         IDirect3DVolumeTexture9_Release(volume_texture);
         hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-        ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-        ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
     }
     else
     {
@@ -2379,112 +2372,112 @@ static void test_reset(void)
 
     /* Scratch, sysmem and managed pools are fine */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device1, 16, 16, D3DFMT_R5G6B5, D3DPOOL_SCRATCH, &surface, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device1, 16, 16,
             D3DFMT_R5G6B5, D3DPOOL_SYSTEMMEM, &surface, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device1, 16, 0,
             D3DFVF_XYZ, D3DPOOL_SYSTEMMEM, &vb, NULL);
-    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#lx.\n", hr);
     IDirect3DVertexBuffer9_Release(vb);
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device1, 16, 0,
             D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib, NULL);
-    ok(hr == D3D_OK, "Failed to create index buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create index buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#lx.\n", hr);
     IDirect3DIndexBuffer9_Release(ib);
 
     /* The depth stencil should get reset to the auto depth stencil when present. */
     hr = IDirect3DDevice9_SetDepthStencilSurface(device1, NULL);
-    ok(hr == D3D_OK, "SetDepthStencilSurface failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device1, &surface);
-    ok(hr == D3DERR_NOTFOUND, "GetDepthStencilSurface returned 0x%08x, expected D3DERR_NOTFOUND\n", hr);
+    ok(hr == D3DERR_NOTFOUND, "Got hr %#lx.\n", hr);
     ok(surface == NULL, "Depth stencil should be NULL\n");
 
     d3dpp.EnableAutoDepthStencil = TRUE;
     d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device1, &surface);
-    ok(hr == D3D_OK, "GetDepthStencilSurface failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(surface != NULL, "Depth stencil should not be NULL\n");
     if (surface) IDirect3DSurface9_Release(surface);
 
     d3dpp.EnableAutoDepthStencil = FALSE;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device1, &surface);
-    ok(hr == D3DERR_NOTFOUND, "GetDepthStencilSurface returned 0x%08x, expected D3DERR_NOTFOUND\n", hr);
+    ok(hr == D3DERR_NOTFOUND, "Got hr %#lx.\n", hr);
     ok(surface == NULL, "Depth stencil should be NULL\n");
 
     /* Will a sysmem or scratch survive while locked */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device1, 16, 16,
             D3DFMT_R5G6B5, D3DPOOL_SYSTEMMEM, &surface, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DSurface9_LockRect(surface, &lockrect, NULL, D3DLOCK_DISCARD);
-    ok(hr == D3D_OK, "IDirect3DSurface9_LockRect returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_UnlockRect(surface);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device1, 16, 16, D3DFMT_R5G6B5, D3DPOOL_SCRATCH, &surface, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DSurface9_LockRect(surface, &lockrect, NULL, D3DLOCK_DISCARD);
-    ok(hr == D3D_OK, "IDirect3DSurface9_LockRect returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_UnlockRect(surface);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_CreateTexture(device1, 16, 16, 0, 0, D3DFMT_R5G6B5, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     /* A reference held to an implicit surface causes failures as well */
     hr = IDirect3DDevice9_GetBackBuffer(device1, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetBackBuffer returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "IDirect3DDevice9_TestCooperativeLevel after a failed reset returned %#x\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Shaders are fine as well */
     hr = IDirect3DDevice9_CreateVertexShader(device1, simple_vs, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DVertexShader9_Release(shader);
 
     /* Try setting invalid modes */
@@ -2494,9 +2487,9 @@ static void test_reset(void)
     d3dpp.BackBufferWidth  = 32;
     d3dpp.BackBufferHeight = 32;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Reset to w=32, h=32, windowed=FALSE failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "IDirect3DDevice9_TestCooperativeLevel after a failed reset returned %#x\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
 
     ZeroMemory( &d3dpp, sizeof(d3dpp) );
     d3dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
@@ -2504,9 +2497,9 @@ static void test_reset(void)
     d3dpp.BackBufferWidth  = 801;
     d3dpp.BackBufferHeight = 600;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Reset to w=801, h=600, windowed=FALSE failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "IDirect3DDevice9_TestCooperativeLevel after a failed reset returned %#x\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
 
     ZeroMemory( &d3dpp, sizeof(d3dpp) );
     d3dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
@@ -2514,9 +2507,9 @@ static void test_reset(void)
     d3dpp.BackBufferWidth  = 0;
     d3dpp.BackBufferHeight = 0;
     hr = IDirect3DDevice9_Reset(device1, &d3dpp);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Reset to w=0, h=0, windowed=FALSE failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "IDirect3DDevice9_TestCooperativeLevel after a failed reset returned %#x\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
 
     IDirect3D9_GetAdapterDisplayMode(d3d, D3DADAPTER_DEFAULT, &d3ddm);
 
@@ -2530,12 +2523,12 @@ static void test_reset(void)
     if (FAILED(hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &device2)))
     {
-        skip("could not create device, IDirect3D9_CreateDevice returned %#x\n", hr);
+        skip("Failed to create device, hr %#lx.\n", hr);
         goto cleanup;
     }
 
     hr = IDirect3DDevice9_TestCooperativeLevel(device2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after creation returned %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     d3dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
     d3dpp.Windowed         = TRUE;
@@ -2545,12 +2538,12 @@ static void test_reset(void)
     d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
 
     hr = IDirect3DDevice9_Reset(device2, &d3dpp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     if (FAILED(hr)) goto cleanup;
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device2, &surface);
-    ok(hr == D3D_OK, "GetDepthStencilSurface failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(surface != NULL, "Depth stencil should not be NULL\n");
     if (surface) IDirect3DSurface9_Release(surface);
 
@@ -2558,13 +2551,13 @@ cleanup:
     HeapFree(GetProcessHeap(), 0, modes);
     if (device2)
     {
-        UINT refcount = IDirect3DDevice9_Release(device2);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ULONG refcount = IDirect3DDevice9_Release(device2);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
     if (device1)
     {
-        UINT refcount = IDirect3DDevice9_Release(device1);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ULONG refcount = IDirect3DDevice9_Release(device1);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
     IDirect3D9_Release(d3d);
     DestroyWindow(hwnd);
@@ -2581,7 +2574,7 @@ static void test_display_modes(void)
 
 #define TEST_FMT(x,r) do { \
     HRESULT res = IDirect3D9_EnumAdapterModes(d3d, 0, (x), 0, &dmode); \
-    ok(res==(r), "EnumAdapterModes("#x") did not return "#r" (got %08x)!\n", res); \
+    ok(res==(r), "EnumAdapterModes("#x") did not return "#r" (got %08lx)!\n", res); \
 } while(0)
 
     TEST_FMT(D3DFMT_R8G8B8, D3DERR_INVALIDCALL);
@@ -2683,92 +2676,92 @@ static void test_scene(void)
     /* Get the caps, they will be needed to tell if an operation is supposed to be valid */
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetCaps failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Test an EndScene without BeginScene. Should return an error */
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_EndScene returned %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     /* Test a normal BeginScene / EndScene pair, this should work */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Test another EndScene without having begun a new scene. Should return an error */
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_EndScene returned %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     /* Two nested BeginScene and EndScene calls */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_BeginScene returned %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_EndScene returned %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     /* Create some surfaces to test stretchrect between the scenes */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface1, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface2, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 800, 600,
             D3DFMT_D16, D3DMULTISAMPLE_NONE, 0, FALSE, &surface3, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateDepthStencilSurface failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateRenderTarget failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetBackBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetBackBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* First make sure a simple StretchRect call works */
     hr = IDirect3DDevice9_StretchRect(device, surface1, NULL, surface2, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_StretchRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, backBuffer, &rect, rt, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_StretchRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if (0) /* Disabled for now because it crashes in wine */
     {
         HRESULT expected = caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES ? D3D_OK : D3DERR_INVALIDCALL;
         hr = IDirect3DDevice9_StretchRect(device, ds, NULL, surface3, NULL, 0);
-        ok(hr == expected, "Got unexpected hr %#x, expected %#x.\n", hr, expected);
+        ok(hr == expected, "Got unexpected hr %#lx, expected %#lx.\n", hr, expected);
     }
 
     /* Now try it in a BeginScene - EndScene pair. Seems to be allowed in a
      * BeginScene - Endscene pair with normal surfaces and render targets, but
      * not depth stencil surfaces. */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, surface1, NULL, surface2, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_StretchRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, backBuffer, &rect, rt, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_StretchRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     /* This is supposed to fail inside a BeginScene - EndScene pair. */
     hr = IDirect3DDevice9_StretchRect(device, ds, NULL, surface3, NULL, 0);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_StretchRect returned %08x, expected D3DERR_INVALIDCALL\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Does a SetRenderTarget influence BeginScene / EndScene ?
      * Set a new render target, then see if it started a new scene. Flip the rt back and see if that maybe
      * ended the scene. Expected result is that the scene is not affected by SetRenderTarget
      */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok( hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backBuffer);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok( hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(rt);
     IDirect3DSurface9_Release(ds);
@@ -2777,7 +2770,7 @@ static void test_scene(void)
     IDirect3DSurface9_Release(surface2);
     IDirect3DSurface9_Release(surface3);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -2804,24 +2797,24 @@ static void test_limits(void)
     }
 
     hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* There are 16 pixel samplers. We should be able to access all of them */
     for (i = 0; i < 16; ++i)
     {
         hr = IDirect3DDevice9_SetTexture(device, i, (IDirect3DBaseTexture9 *)texture);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture for sampler %d failed with %08x\n", i, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, i, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture for sampler %d failed with %08x\n", i, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, i, D3DSAMP_SRGBTEXTURE, TRUE);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState for sampler %d failed with %08x\n", i, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     /* Now test all 8 textures stage states */
     for (i = 0; i < 8; ++i)
     {
         hr = IDirect3DDevice9_SetTextureStageState(device, i, D3DTSS_COLOROP, D3DTOP_ADD);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState for texture %d failed with %08x\n", i, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     /* Investigations show that accessing higher samplers / textures stage
@@ -2830,7 +2823,7 @@ static void test_limits(void)
      * there is no bounds checking. */
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3D9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -2866,7 +2859,7 @@ static void test_depthstenciltest(void)
 
     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */,
             hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice);
-    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE || broken(hr == D3DERR_INVALIDCALL), "IDirect3D9_CreateDevice failed with %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE || broken(hr == D3DERR_INVALIDCALL), "Got hr %#lx.\n", hr);
     if(!pDevice)
     {
         skip("Failed to create a d3d device\n");
@@ -2874,51 +2867,53 @@ static void test_depthstenciltest(void)
     }
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(pDevice, &pDepthStencil);
-    ok(hr == D3D_OK && pDepthStencil != NULL, "IDirect3DDevice9_GetDepthStencilSurface failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
+    ok(!!pDepthStencil, "Got surface %p.\n", pDepthStencil);
 
     /* Try to clear */
     hr = IDirect3DDevice9_Clear(pDevice, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 1.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(pDevice, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetDepthStencilSurface failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Check if the set buffer is returned on a get. WineD3D had a bug with that once, prevent it from coming back */
     hr = IDirect3DDevice9_GetDepthStencilSurface(pDevice, &pDepthStencil2);
-    ok(hr == D3DERR_NOTFOUND && pDepthStencil2 == NULL, "IDirect3DDevice9_GetDepthStencilSurface failed with %08x\n", hr);
+    ok(hr == D3DERR_NOTFOUND, "Got hr %#lx.\n", hr);
+    ok(!pDepthStencil2, "Got surface %p.\n", pDepthStencil2);
     if(pDepthStencil2) IDirect3DSurface9_Release(pDepthStencil2);
 
     /* This left the render states untouched! */
     hr = IDirect3DDevice9_GetRenderState(pDevice, D3DRS_ZENABLE, &state);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(state == D3DZB_TRUE, "D3DRS_ZENABLE is %s\n", state == D3DZB_FALSE ? "D3DZB_FALSE" : (state == D3DZB_TRUE ? "D3DZB_TRUE" : "D3DZB_USEW"));
     hr = IDirect3DDevice9_GetRenderState(pDevice, D3DRS_ZWRITEENABLE, &state);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(state == TRUE, "D3DRS_ZWRITEENABLE is %s\n", state ? "TRUE" : "FALSE");
     hr = IDirect3DDevice9_GetRenderState(pDevice, D3DRS_STENCILENABLE, &state);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(state == FALSE, "D3DRS_STENCILENABLE is %s\n", state ? "TRUE" : "FALSE");
     hr = IDirect3DDevice9_GetRenderState(pDevice, D3DRS_STENCILWRITEMASK, &state);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed with %08x\n", hr);
-    ok(state == 0xffffffff, "D3DRS_STENCILWRITEMASK is 0x%08x\n", state);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
+    ok(state == 0xffffffff, "Got state %#lx.\n", state);
 
     /* This is supposed to fail now */
     hr = IDirect3DDevice9_Clear(pDevice, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 1.0, 0);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(pDevice, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(pDevice, pDepthStencil);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetDepthStencilSurface failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(pDevice, D3DRS_ZENABLE, &state);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(state == D3DZB_FALSE, "D3DRS_ZENABLE is %s\n", state == D3DZB_FALSE ? "D3DZB_FALSE" : (state == D3DZB_TRUE ? "D3DZB_TRUE" : "D3DZB_USEW"));
 
     /* Now it works again */
     hr = IDirect3DDevice9_Clear(pDevice, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 1.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     if(pDepthStencil) IDirect3DSurface9_Release(pDepthStencil);
     IDirect3D9_Release(pDevice);
@@ -2935,7 +2930,7 @@ static void test_depthstenciltest(void)
 
     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */,
             hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice);
-    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "IDirect3D9_CreateDevice failed with %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got hr %#lx.\n", hr);
     if(!pDevice)
     {
         skip("Failed to create a d3d device\n");
@@ -2944,7 +2939,8 @@ static void test_depthstenciltest(void)
 
     pDepthStencil = NULL;
     hr = IDirect3DDevice9_GetDepthStencilSurface(pDevice, &pDepthStencil);
-    ok(hr == D3DERR_NOTFOUND && pDepthStencil == NULL, "IDirect3DDevice9_GetDepthStencilSurface returned %08x, surface = %p\n", hr, pDepthStencil);
+    ok(hr == D3DERR_NOTFOUND, "Got hr %#lx.\n", hr);
+    ok(!pDepthStencil, "Got surface %p.\n", pDepthStencil);
     if(pDepthStencil) {
         IDirect3DSurface9_Release(pDepthStencil);
         pDepthStencil = NULL;
@@ -2952,7 +2948,7 @@ static void test_depthstenciltest(void)
 
     /* Check the depth test state */
     hr = IDirect3DDevice9_GetRenderState(pDevice, D3DRS_ZENABLE, &state);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(state == D3DZB_FALSE, "D3DRS_ZENABLE is %s\n", state == D3DZB_FALSE ? "D3DZB_FALSE" : (state == D3DZB_TRUE ? "D3DZB_TRUE" : "D3DZB_USEW"));
 
     IDirect3D9_Release(pDevice);
@@ -2969,7 +2965,7 @@ static void test_depthstenciltest(void)
 
     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */,
             hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice);
-    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "IDirect3D9_CreateDevice failed with %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got hr %#lx.\n", hr);
     if(!pDevice)
     {
         skip("Failed to create a d3d device\n");
@@ -2978,22 +2974,23 @@ static void test_depthstenciltest(void)
 
     pDepthStencil = NULL;
     hr = IDirect3DDevice9_GetDepthStencilSurface(pDevice, &pDepthStencil);
-    ok(hr == D3DERR_NOTFOUND && pDepthStencil == NULL, "IDirect3DDevice9_GetDepthStencilSurface returned %08x, surface = %p\n", hr, pDepthStencil);
+    ok(hr == D3DERR_NOTFOUND, "Got hr %#lx.\n", hr);
+    ok(!pDepthStencil, "Got surface %p.\n", pDepthStencil);
     if(pDepthStencil) {
         IDirect3DSurface9_Release(pDepthStencil);
         pDepthStencil = NULL;
     }
 
     hr = IDirect3DDevice9_GetRenderState(pDevice, D3DRS_ZENABLE, &state);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(state == D3DZB_FALSE, "D3DRS_ZENABLE is %s\n", state == D3DZB_FALSE ? "D3DZB_FALSE" : (state == D3DZB_TRUE ? "D3DZB_TRUE" : "D3DZB_USEW"));
 
 cleanup:
     if(pDepthStencil) IDirect3DSurface9_Release(pDepthStencil);
     if (pDevice)
     {
-        UINT refcount = IDirect3D9_Release(pDevice);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ULONG refcount = IDirect3D9_Release(pDevice);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
     IDirect3D9_Release(d3d);
     DestroyWindow(hwnd);
@@ -3021,24 +3018,24 @@ static void test_get_rt(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     ok(!!backbuffer, "Got a NULL backbuffer.\n");
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     for (i = 1; i < caps.NumSimultaneousRTs; ++i)
     {
         rt = backbuffer;
         hr = IDirect3DDevice9_GetRenderTarget(device, i, &rt);
-        ok(hr == D3DERR_NOTFOUND, "IDirect3DDevice9_GetRenderTarget returned %#x.\n", hr);
+        ok(hr == D3DERR_NOTFOUND, "Got hr %#lx.\n", hr);
         ok(!rt, "Got rt %p.\n", rt);
     }
 
     IDirect3DSurface9_Release(backbuffer);
 
     ref = IDirect3DDevice9_Release(device);
-    ok(!ref, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 done:
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
@@ -3090,52 +3087,52 @@ static void test_draw_primitive(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), 0, 0,
             D3DPOOL_DEFAULT, &vertex_buffer, NULL);
-    ok(SUCCEEDED(hr), "CreateVertexBuffer failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexBuffer failed, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vertex_buffer, 0, 0, &ptr, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "Lock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Lock failed, hr %#lx.\n", hr);
     memcpy(ptr, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer9_Unlock(vertex_buffer);
-    ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vertex_buffer, 0, sizeof(*quad));
-    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0, D3DFMT_INDEX16,
             D3DPOOL_DEFAULT, &index_buffer, NULL);
-    ok(SUCCEEDED(hr), "CreateIndexBuffer failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateIndexBuffer failed, hr %#lx.\n", hr);
     hr = IDirect3DIndexBuffer9_Lock(index_buffer, 0, 0, &ptr, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "Lock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Lock failed, hr %#lx.\n", hr);
     memcpy(ptr, indices, sizeof(indices));
     hr = IDirect3DIndexBuffer9_Unlock(index_buffer);
-    ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState D3DRS_LIGHTING failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState D3DRS_LIGHTING failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
-    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#lx.\n", hr);
     ok(current_vb == vertex_buffer, "Unexpected vb %p.\n", current_vb);
     ok(!offset, "Unexpected offset %u.\n", offset);
     ok(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
     IDirect3DVertexBuffer9_Release(current_vb);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
-    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#lx.\n", hr);
     todo_wine ok(!current_vb, "Unexpected vb %p.\n", current_vb);
     ok(!offset, "Unexpected offset %u.\n", offset);
     ok(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
@@ -3143,142 +3140,142 @@ static void test_draw_primitive(void)
         IDirect3DVertexBuffer9_Release(current_vb);
 
     hr = IDirect3DDevice9_SetIndices(device, NULL);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
             0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     /* Valid index buffer, NULL vertex declaration. */
     hr = IDirect3DDevice9_SetIndices(device, index_buffer);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
             0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 2,
             indices, D3DFMT_INDEX16, quad, sizeof(*quad));
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetIndices(device, &current_ib);
-    ok(SUCCEEDED(hr), "GetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetIndices failed, hr %#lx.\n", hr);
     todo_wine ok(!current_ib, "Unexpected index buffer %p.\n", current_vb);
     if (current_ib)
         IDirect3DIndexBuffer9_Release(current_ib);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2);
-    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, quad, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
-    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#lx.\n", hr);
     ok(!current_vb, "Unexpected vb %p.\n", current_vb);
     ok(!offset, "Unexpected offset %u.\n", offset);
     ok(!stride, "Unexpected stride %u.\n", stride);
 
     /* NULL index buffer, valid vertex declaration, NULL stream source. */
     hr = IDirect3DDevice9_SetIndices(device, NULL);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
             0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
-    todo_wine ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#lx.\n", hr);
 
     /* Valid index buffer and vertex declaration, NULL stream source. */
     hr = IDirect3DDevice9_SetIndices(device, index_buffer);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
             0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
-    ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetIndices(device, &current_ib);
-    ok(SUCCEEDED(hr), "GetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetIndices failed, hr %#lx.\n", hr);
     ok(current_ib == index_buffer, "Unexpected index buffer %p.\n", current_ib);
     IDirect3DIndexBuffer9_Release(current_ib);
 
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 2,
             indices, D3DFMT_INDEX16, quad, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 0,
             indices, D3DFMT_INDEX16, quad, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 2,
             indices, D3DFMT_INDEX16, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetIndices(device, &current_ib);
-    ok(SUCCEEDED(hr), "GetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetIndices failed, hr %#lx.\n", hr);
     ok(!current_ib, "Unexpected index buffer %p.\n", current_ib);
 
     /* Resetting of stream source and index buffer is not recorded in stateblocks. */
 
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vertex_buffer, 0, sizeof(*quad));
-    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetIndices(device, index_buffer);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginStateBlock(device);
-    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 2,
             indices, D3DFMT_INDEX16, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndStateBlock(device, &stateblock);
-    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
-    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#lx.\n", hr);
     ok(!current_vb, "Unexpected vb %p.\n", current_vb);
     ok(!offset, "Unexpected offset %u.\n", offset);
     ok(!stride, "Unexpected stride %u.\n", stride);
     hr = IDirect3DDevice9_GetIndices(device, &current_ib);
-    ok(SUCCEEDED(hr), "GetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetIndices failed, hr %#lx.\n", hr);
     ok(!current_ib, "Unexpected index buffer %p.\n", current_ib);
 
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vertex_buffer, 0, sizeof(*quad));
-    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetIndices(device, index_buffer);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
 
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
-    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#lx.\n", hr);
     ok(current_vb == vertex_buffer, "Unexpected vb %p.\n", current_vb);
     ok(!offset, "Unexpected offset %u.\n", offset);
     ok(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
     IDirect3DVertexBuffer9_Release(current_vb);
     hr = IDirect3DDevice9_GetIndices(device, &current_ib);
-    ok(SUCCEEDED(hr), "GetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetIndices failed, hr %#lx.\n", hr);
     ok(current_ib == index_buffer, "Unexpected index buffer %p.\n", current_ib);
     IDirect3DIndexBuffer9_Release(current_ib);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
     IDirect3DStateBlock9_Release(stateblock);
     IDirect3DVertexBuffer9_Release(vertex_buffer);
     IDirect3DIndexBuffer9_Release(index_buffer);
     IDirect3DVertexDeclaration9_Release(vertex_declaration);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -3322,33 +3319,33 @@ static void test_null_stream(void)
         goto cleanup;
     }
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &decl);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexDeclaration failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     if (FAILED(hr)) {
         skip("Vertex declaration handling not possible.\n");
         goto cleanup;
     }
     hr = IDirect3DDevice9_CreateVertexBuffer(device, 12 * sizeof(float), 0, 0, D3DPOOL_MANAGED, &buffer, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexBuffer failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     if (FAILED(hr)) {
         skip("Vertex buffer handling not possible.\n");
         goto cleanup;
     }
 
     hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetStreamSource failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 1, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetStreamSource failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShader failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, decl);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexDeclaration failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_POINTLIST, 0, 1);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     IDirect3DDevice9_SetStreamSource(device, 0, NULL, 0, 0);
     IDirect3DDevice9_SetVertexShader(device, NULL);
@@ -3361,7 +3358,7 @@ cleanup:
     if (device)
     {
         refcount = IDirect3DDevice9_Release(device);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
@@ -3390,32 +3387,32 @@ static void test_lights(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for(i = 1; i <= caps.MaxActiveLights; i++) {
         hr = IDirect3DDevice9_LightEnable(device, i, TRUE);
-        ok(hr == D3D_OK, "Enabling light %u failed with %08x\n", i, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetLightEnable(device, i, &enabled);
-        ok(hr == D3D_OK, "GetLightEnable on light %u failed with %08x\n", i, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         ok(enabled, "Light %d is %s\n", i, enabled ? "enabled" : "disabled");
     }
 
     /* TODO: Test the rendering results in this situation */
     hr = IDirect3DDevice9_LightEnable(device, i + 1, TRUE);
-    ok(hr == D3D_OK, "Enabling one light more than supported returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetLightEnable(device, i + 1, &enabled);
-    ok(hr == D3D_OK, "GetLightEnable on light %u failed with %08x\n", i + 1, hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(enabled, "Light %d is %s\n", i + 1, enabled ? "enabled" : "disabled");
     hr = IDirect3DDevice9_LightEnable(device, i + 1, FALSE);
-    ok(hr == D3D_OK, "Disabling the additional returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     for(i = 1; i <= caps.MaxActiveLights; i++) {
         hr = IDirect3DDevice9_LightEnable(device, i, FALSE);
-        ok(hr == D3D_OK, "Disabling light %u failed with %08x\n", i, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
@@ -3442,35 +3439,35 @@ static void test_set_stream_source(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, 512, 0, 0, D3DPOOL_DEFAULT, &vb, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a vertex buffer, hr %#lx.\n", hr);
 
     /* Some cards (GeForce 7400 at least) accept non-aligned offsets, others
      * (Radeon 9000 verified) reject them, so accept both results. Wine
      * currently rejects this to be able to optimize the vbo conversion, but
      * writes a WARN. */
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, 32);
-    ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 1, 32);
-    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 2, 32);
-    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 3, 32);
-    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 4, 32);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 0, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(!current_vb, "Got unexpected vb %p.\n", current_vb);
     ok(offset == 4, "Got unexpected offset %u.\n", offset);
     ok(stride == 32, "Got unexpected stride %u.\n", stride);
 
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(current_vb == vb, "Got unexpected vb %p.\n", current_vb);
     IDirect3DVertexBuffer9_Release(current_vb);
     ok(!offset, "Got unexpected offset %u.\n", offset);
@@ -3478,22 +3475,22 @@ static void test_set_stream_source(void)
 
     /* Try to set the NULL buffer with an offset and stride 0 */
     hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 1, 0);
-    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 2, 0);
-    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 3, 0);
-    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer9_Release(vb);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
@@ -3575,7 +3572,7 @@ static void test_display_formats(void)
                 hr = IDirect3D9_CheckDeviceType(d3d9, D3DADAPTER_DEFAULT, device_type,
                         formats[display].format, formats[backbuffer].format, windowed);
                 ok(SUCCEEDED(hr) == should_pass || broken(SUCCEEDED(hr) && !has_modes) /* Win8 64-bit */,
-                        "Got unexpected hr %#x for %s / %s, windowed %#x, should_pass %#x.\n",
+                        "Got unexpected hr %#lx for %s / %s, windowed %#x, should_pass %#x.\n",
                         hr, formats[display].name, formats[backbuffer].name, windowed, should_pass);
             }
         }
@@ -3604,9 +3601,9 @@ static void test_scissor_size(void)
     for (i = 0; i < ARRAY_SIZE(scts); i++)
     {
         IDirect3DDevice9 *device_ptr = 0;
+        RECT scissorrect, expect;
         HRESULT hr;
         HWND hwnd = 0;
-        RECT scissorrect;
 
         hwnd = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION,
                 0, 0, scts[i].winx, scts[i].winy, 0, 0, 0, 0);
@@ -3631,27 +3628,24 @@ static void test_scissor_size(void)
 
         /* Check for the default scissor rect size */
         hr = IDirect3DDevice9_GetScissorRect(device_ptr, &scissorrect);
-        ok(hr == D3D_OK, "IDirect3DDevice9_GetScissorRect failed with: %08x\n", hr);
-        ok(scissorrect.right == scts[i].backx && scissorrect.bottom == scts[i].backy
-                && scissorrect.top == 0 && scissorrect.left == 0,
-                "Scissorrect mismatch (%d, %d) should be (%d, %d)\n", scissorrect.right, scissorrect.bottom,
-                scts[i].backx, scts[i].backy);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
+        SetRect(&expect, 0, 0, scts[i].backx, scts[i].backy);
+        ok(EqualRect(&scissorrect, &expect), "Expected rect %s, got %s.\n",
+                wine_dbgstr_rect(&expect), wine_dbgstr_rect(&scissorrect));
 
         /* check the scissorrect values after a reset */
         device_desc.width = registry_mode.dmPelsWidth;
         device_desc.height = registry_mode.dmPelsHeight;
         device_desc.flags = scts[i].flags;
         hr = reset_device(device_ptr, &device_desc);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_TestCooperativeLevel(device_ptr);
-        ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_GetScissorRect(device_ptr, &scissorrect);
-        ok(hr == D3D_OK, "IDirect3DDevice9_GetScissorRect failed with: %08x\n", hr);
-        ok(scissorrect.right == registry_mode.dmPelsWidth && scissorrect.bottom == registry_mode.dmPelsHeight
-                && scissorrect.top == 0 && scissorrect.left == 0,
-                "Scissorrect mismatch (%d, %d) should be (%u, %u)\n", scissorrect.right, scissorrect.bottom,
-                registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
+        ok(EqualRect(&scissorrect, &expect), "Expected rect %s, got %s.\n",
+                wine_dbgstr_rect(&expect), wine_dbgstr_rect(&scissorrect));
 
         if (device_ptr)
         {
@@ -3659,7 +3653,7 @@ static void test_scissor_size(void)
 
             ref = IDirect3DDevice9_Release(device_ptr);
             DestroyWindow(hwnd);
-            ok(ref == 0, "The device was not properly freed: refcount %u\n", ref);
+            ok(!ref, "Unexpected refcount %lu.\n", ref);
         }
     }
 
@@ -3695,9 +3689,9 @@ static void test_multi_device(void)
     IDirect3D9_Release(d3d9);
 
     refcount = IDirect3DDevice9_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirect3DDevice9_Release(device1);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window2);
     DestroyWindow(window1);
 }
@@ -3766,7 +3760,7 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
         {
             if (expect_messages->check_wparam)
                 ok(wparam == expect_messages->expect_wparam,
-                        "Got unexpected wparam %lx for message %x, expected %lx.\n",
+                        "Got unexpected wparam %#Ix for message %#x, expected %#Ix.\n",
                         wparam, message, expect_messages->expect_wparam);
 
             if (expect_messages->store_wp)
@@ -3780,7 +3774,7 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
                  * about the D3DERR_DEVICENOTRESET behavior, */
                 todo_wine_if(message != WM_ACTIVATEAPP || hr == D3D_OK)
                         ok(hr == expect_messages->device_state,
-                        "Got device state %#x on message %#x, expected %#x.\n",
+                        "Got device state %#lx on message %#x, expected %#lx.\n",
                         hr, message, expect_messages->device_state);
             }
 
@@ -3814,7 +3808,7 @@ static DWORD WINAPI wndproc_thread(void *param)
     p->running_in_foreground = SetForegroundWindow(p->dummy_window);
 
     ret = SetEvent(p->window_created);
-    ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
+    ok(ret, "SetEvent failed, last error %#lx.\n", GetLastError());
 
     for (;;)
     {
@@ -3825,7 +3819,7 @@ static DWORD WINAPI wndproc_thread(void *param)
         if (res == WAIT_OBJECT_0) break;
         if (res != WAIT_TIMEOUT)
         {
-            ok(0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+            ok(0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
             break;
         }
     }
@@ -3837,6 +3831,7 @@ static DWORD WINAPI wndproc_thread(void *param)
 
 static void test_wndproc(void)
 {
+    unsigned int adapter_mode_count, i, d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
     struct wndproc_thread_param thread_params;
     struct device_desc device_desc;
     static WINDOWPOS windowpos;
@@ -3848,10 +3843,8 @@ static void test_wndproc(void)
     ULONG ref;
     DWORD res, tid;
     HWND tmp;
-    UINT i, adapter_mode_count;
     HRESULT hr;
     D3DDISPLAYMODE d3ddm;
-    DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
     DEVMODEW devmode;
     LONG change_ret, device_style;
     BOOL ret;
@@ -4032,7 +4025,7 @@ static void test_wndproc(void)
     for (i = 0; i < adapter_mode_count; ++i)
     {
         hr = IDirect3D9_EnumAdapterModes(d3d9, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, i, &d3ddm);
-        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
 
         if (d3ddm.Width == registry_mode.dmPelsWidth && d3ddm.Height == registry_mode.dmPelsHeight)
             continue;
@@ -4085,9 +4078,9 @@ static void test_wndproc(void)
     ok(RegisterClassA(&wc), "Failed to register window class.\n");
 
     thread_params.window_created = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!thread_params.window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
     thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#lx.\n", GetLastError());
 
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
@@ -4097,23 +4090,23 @@ static void test_wndproc(void)
         devmode.dmPelsWidth = user32_width;
         devmode.dmPelsHeight = user32_height;
         change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
         focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
                 WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, user32_width, user32_height, 0, 0, 0, 0);
         device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
                 WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, user32_width, user32_height, 0, 0, 0, 0);
         thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
-        ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+        ok(!!thread, "Failed to create thread, last error %#lx.\n", GetLastError());
 
         res = WaitForSingleObject(thread_params.window_created, INFINITE);
-        ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+        ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
 
         proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
                 (LONG_PTR)test_proc, proc);
         proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
                 (LONG_PTR)test_proc, proc);
 
         trace("device_window %p, focus_window %p, dummy_window %p.\n",
@@ -4160,11 +4153,11 @@ static void test_wndproc(void)
         flush_events();
 
         proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix, i=%u.\n",
                 (LONG_PTR)test_proc, proc, i);
 
         proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-        ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, i=%u.\n",
+        ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, i=%u.\n",
                 (LONG_PTR)test_proc, i);
 
         /* Change the mode while the device is in use and then drop focus. */
@@ -4172,14 +4165,14 @@ static void test_wndproc(void)
         devmode.dmPelsWidth = user32_width;
         devmode.dmPelsHeight = user32_height;
         change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x, i=%u.\n", change_ret, i);
+        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx, i=%u.\n", change_ret, i);
 
         /* Wine doesn't (yet) mark the device not reset when the mode is changed, thus the todo_wine.
          * But sometimes focus-follows-mouse WMs also temporarily drop window focus, which makes
          * mark the device lost, then not reset, causing the test to succeed for the wrong reason. */
         hr = IDirect3DDevice9_TestCooperativeLevel(device);
         todo_wine_if (hr != D3DERR_DEVICENOTRESET)
-            ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#lx.\n", hr);
 
         focus_test_device = device;
         expect_messages = tests[i].focus_loss_messages;
@@ -4198,12 +4191,12 @@ static void test_wndproc(void)
         focus_test_device = NULL;
 
         hr = IDirect3DDevice9_TestCooperativeLevel(device);
-        ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#lx.\n", hr);
 
         ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
         ok(ret, "Failed to get display mode.\n");
         ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
-                && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %ux%u.\n",
+                && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %lux%lu.\n",
                 devmode.dmPelsWidth, devmode.dmPelsHeight);
 
         /* This is needed on native with D3DCREATE_NOWINDOWCHANGES, and it needs to be
@@ -4233,16 +4226,16 @@ static void test_wndproc(void)
         expect_messages = NULL;
 
         hr = IDirect3DDevice9_TestCooperativeLevel(device);
-        ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#lx.\n", hr);
 
         ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
         ok(ret, "Failed to get display mode.\n");
         ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
-                && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %ux%u.\n",
+                && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %lux%lu.\n",
                 devmode.dmPelsWidth, devmode.dmPelsHeight);
 
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
         /* Remove the WS_VISIBLE flag to test hidden windows. This is enough to trigger d3d's hidden
          * window codepath, but does not actually hide the window without a SetWindowPos(SWP_FRAMECHANGED)
@@ -4262,8 +4255,8 @@ static void test_wndproc(void)
 
         ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
         ok(ret, "Failed to get display mode.\n");
-        ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpected width %u.\n", devmode.dmPelsWidth);
-        ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected height %u.\n", devmode.dmPelsHeight);
+        ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpected width %lu.\n", devmode.dmPelsWidth);
+        ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected height %lu.\n", devmode.dmPelsHeight);
 
         /* SW_SHOWMINNOACTIVE is needed to make FVWM happy. SW_SHOWNOACTIVATE is needed to make windows
          * send SIZE_RESTORED after ShowWindow(SW_SHOWMINNOACTIVE). */
@@ -4276,7 +4269,7 @@ static void test_wndproc(void)
         SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0);
         ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
                 expect_messages->message, expect_messages->window, i);
-        ok(syscommand_received == 1, "Got unexpected number of WM_SYSCOMMAND messages: %d.\n", syscommand_received);
+        ok(syscommand_received == 1, "Got %ld WM_SYSCOMMAND messages.\n", syscommand_received);
         expect_messages = NULL;
         flush_events();
 
@@ -4307,20 +4300,20 @@ static void test_wndproc(void)
         if (hr == D3DERR_DEVICENOTRESET)
         {
             hr = reset_device(device, &device_desc);
-            ok(SUCCEEDED(hr), "Failed to reset device, hr %#x, i=%u.\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx, i=%u.\n", hr, i);
         }
 
         filter_messages = focus_window;
 
         ref = IDirect3DDevice9_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
+        ok(!ref, "Unexpected refcount %lu, i=%u.\n", ref, i);
 
         /* Fix up the mode until Wine's device release behavior is fixed. */
         change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+        ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
         proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+        ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix, i=%u.\n",
                 (LONG_PTR)test_proc, proc, i);
 
         /* Hide the device window. It prevents WM_ACTIVATEAPP messages from being sent
@@ -4356,7 +4349,7 @@ static void test_wndproc(void)
                 "Expected IsIconic %u, got %u, i=%u.\n", tests[i].iconic, IsIconic(focus_window), i);
 
         hr = IDirect3DDevice9_TestCooperativeLevel(device);
-        ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#lx.\n", hr);
 
         if (tests[i].create_flags & CREATE_DEVICE_NOWINDOWCHANGES)
             ShowWindow(focus_window, SW_MINIMIZE);
@@ -4366,7 +4359,7 @@ static void test_wndproc(void)
         SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0);
         ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
                 expect_messages->message, expect_messages->window, i);
-        ok(syscommand_received == 1, "Got unexpected number of WM_SYSCOMMAND messages: %d.\n", syscommand_received);
+        ok(syscommand_received == 1, "Got %ld WM_SYSCOMMAND messages.\n", syscommand_received);
         expect_messages = NULL;
         flush_events();
 
@@ -4409,13 +4402,13 @@ static void test_wndproc(void)
         /* On Windows 10 style change messages are delivered both on reset and
          * on release. */
         hr = IDirect3DDevice9_TestCooperativeLevel(device);
-        ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#lx.\n", hr);
 
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
         ref = IDirect3DDevice9_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
+        ok(!ref, "Unexpected refcount %lu, i=%u.\n", ref, i);
 
         filter_messages = focus_window;
         device_desc.device_window = device_window;
@@ -4433,7 +4426,7 @@ static void test_wndproc(void)
         expect_messages = tests[i].mode_change_messages;
         filter_messages = focus_window;
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
         filter_messages = NULL;
 
         /* The WINDOWPOS structure passed to the first WM_WINDOWPOSCHANGING differs between windows versions.
@@ -4459,7 +4452,7 @@ static void test_wndproc(void)
         expect_messages = tests[i].mode_change_messages_hidden;
         filter_messages = focus_window;
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
         filter_messages = NULL;
 
         flush_events();
@@ -4490,15 +4483,15 @@ static void test_wndproc(void)
         }
 
         proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-        ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, i=%u.\n",
+        ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, i=%u.\n",
                 (LONG_PTR)test_proc, i);
 
         filter_messages = focus_window;
         ref = IDirect3DDevice9_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
+        ok(!ref, "Unexpected refcount %lu, i=%u.\n", ref, i);
 
         proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-        ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+        ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix, i=%u.\n",
                 (LONG_PTR)DefWindowProcA, proc, i);
 
 done:
@@ -4516,7 +4509,7 @@ done:
     CloseHandle(thread_params.window_created);
     UnregisterClassA("d3d9_test_wndproc_wc", GetModuleHandleA(NULL));
     change_ret = ChangeDisplaySettingsExW(NULL, NULL, NULL, 0, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 }
 
 static void test_wndproc_windowed(void)
@@ -4544,9 +4537,9 @@ static void test_wndproc_windowed(void)
     ok(RegisterClassA(&wc), "Failed to register window class.\n");
 
     thread_params.window_created = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!thread_params.window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
     thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#lx.\n", GetLastError());
 
     focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
             WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
@@ -4555,16 +4548,16 @@ static void test_wndproc_windowed(void)
             WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
             registry_mode.dmPelsHeight, 0, 0, 0, 0);
     thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
-    ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+    ok(!!thread, "Failed to create thread, last error %#lx.\n", GetLastError());
 
     res = WaitForSingleObject(thread_params.window_created, INFINITE);
-    ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+    ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     trace("device_window %p, focus_window %p, dummy_window %p.\n",
@@ -4601,11 +4594,11 @@ static void test_wndproc_windowed(void)
             thread_params.dummy_window, tmp);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     filter_messages = NULL;
@@ -4614,31 +4607,31 @@ static void test_wndproc_windowed(void)
     device_desc.height = registry_mode.dmPelsHeight;
     device_desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n", (LONG_PTR)test_proc);
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     filter_messages = focus_window;
 
     ref = IDirect3DDevice9_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
     filter_messages = device_window;
 
@@ -4653,31 +4646,31 @@ static void test_wndproc_windowed(void)
 
     device_desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n", (LONG_PTR)test_proc);
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     filter_messages = device_window;
 
     ref = IDirect3DDevice9_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
     device_desc.device_window = device_window;
     if (!(device = create_device(d3d9, focus_window, &device_desc)))
@@ -4691,31 +4684,31 @@ static void test_wndproc_windowed(void)
     device_desc.device_window = device_window;
     device_desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n", (LONG_PTR)test_proc);
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     filter_messages = device_window;
 
     ref = IDirect3DDevice9_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
 done:
     filter_messages = NULL;
@@ -4760,11 +4753,11 @@ static void test_reset_fullscreen(void)
     wc.lpszClassName = "test_reset_fullscreen";
 
     atom = RegisterClassExA(&wc);
-    ok(atom, "Failed to register a new window class. GetLastError:%d\n", GetLastError());
+    ok(atom, "Failed to register class, error %lu.\n", GetLastError());
 
     device_window = focus_window = CreateWindowExA(0, wc.lpszClassName, "Test Reset Fullscreen", 0,
             0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, NULL, NULL, NULL, NULL);
-    ok(device_window != NULL, "Failed to create a window. GetLastError:%d\n", GetLastError());
+    ok(device_window != NULL, "Failed to create window. error %lu.\n", GetLastError());
 
     /*
      * Create a device in windowed mode.
@@ -4798,7 +4791,7 @@ static void test_reset_fullscreen(void)
     for (i = 0; i < mode_count; ++i)
     {
         hr = IDirect3D9_EnumAdapterModes(d3d, D3DADAPTER_DEFAULT, d3ddm.Format, i, &d3ddm2);
-        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
 
         if (d3ddm2.Width != d3ddm.Width || d3ddm2.Height != d3ddm.Height)
             break;
@@ -4938,12 +4931,12 @@ static void test_fpu_setup(void)
     ok(cw == expected_cw, "cw is %#x, expected %#x.\n", cw, expected_cw);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#lx.\n", hr);
 
     callback_set_cw = 0xf60;
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             &dummy_object, sizeof(IUnknown *), D3DSPD_IUNKNOWN);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     todo_wine_if(is_64bit)
     ok(callback_cw == expected_cw, "Callback cw is %#x, expected %#x.\n", callback_cw, expected_cw);
     ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n");
@@ -4953,7 +4946,7 @@ static void test_fpu_setup(void)
     callback_cw = 0;
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             &dummy_object, sizeof(IUnknown *), D3DSPD_IUNKNOWN);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     ok(callback_cw == 0xf60, "Callback cw is %#x, expected 0xf60.\n", callback_cw);
     ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n");
 
@@ -4981,13 +4974,13 @@ static void test_fpu_setup(void)
     ok(cw == 0xf60, "cw is %#x, expected 0xf60.\n", cw);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#lx.\n", hr);
 
     callback_cw = 0;
     callback_set_cw = 0x37f;
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             &dummy_object, sizeof(IUnknown *), D3DSPD_IUNKNOWN);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     ok(callback_cw == 0xf60, "Callback cw is %#x, expected 0xf60.\n", callback_cw);
     ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n");
     cw = get_fpu_cw();
@@ -5067,19 +5060,19 @@ static void test_window_style(void)
         style = GetWindowLongA(device_window, GWL_STYLE);
         expected_style = device_style | tests[i].style;
         todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_OVERLAPPEDWINDOW)) /* w1064v1809 */,
-                "Expected device window style %#x, got %#x, i=%u.\n",
+                "Expected device window style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
         style = GetWindowLongA(device_window, GWL_EXSTYLE);
         expected_style = device_exstyle | tests[i].exstyle;
         todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
-                "Expected device window extended style %#x, got %#x, i=%u.\n",
+                "Expected device window extended style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
 
         style = GetWindowLongA(focus_window, GWL_STYLE);
-        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+        ok(style == focus_style, "Expected focus window style %#lx, got %#lx, i=%u.\n",
                 focus_style, style, i);
         style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+        ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx, i=%u.\n",
                 focus_exstyle, style, i);
 
         GetWindowRect(device_window, &r);
@@ -5098,45 +5091,45 @@ static void test_window_style(void)
 
         device_desc.flags = 0;
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
         style = GetWindowLongA(device_window, GWL_STYLE);
         expected_style = device_style | tests[i].style;
-        ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+        ok(style == expected_style, "Expected device window style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
         style = GetWindowLongA(device_window, GWL_EXSTYLE);
         expected_style = device_exstyle | tests[i].exstyle;
         todo_wine_if (!(tests[i].device_flags & CREATE_DEVICE_NOWINDOWCHANGES) && (tests[i].create_style & WS_VISIBLE))
-            ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+            ok(style == expected_style, "Expected device window extended style %#lx, got %#lx, i=%u.\n",
                     expected_style, style, i);
 
         style = GetWindowLongA(focus_window, GWL_STYLE);
-        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+        ok(style == focus_style, "Expected focus window style %#lx, got %#lx, i=%u.\n",
                 focus_style, style, i);
         style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+        ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx, i=%u.\n",
                 focus_exstyle, style, i);
 
         device_desc.flags = CREATE_DEVICE_FULLSCREEN;
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
         ret = SetForegroundWindow(GetDesktopWindow());
         ok(ret, "Failed to set foreground window.\n");
 
         style = GetWindowLongA(device_window, GWL_STYLE);
         expected_style = device_style | tests[i].focus_loss_style | tests[i].style;
-        todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+        todo_wine ok(style == expected_style, "Expected device window style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
         style = GetWindowLongA(device_window, GWL_EXSTYLE);
         expected_style = device_exstyle | tests[i].focus_loss_exstyle | tests[i].exstyle;
-        todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+        todo_wine ok(style == expected_style, "Expected device window extended style %#lx, got %#lx, i=%u.\n",
                 expected_style, style, i);
 
         style = GetWindowLongA(focus_window, GWL_STYLE);
-        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+        ok(style == focus_style, "Expected focus window style %#lx, got %#lx, i=%u.\n",
                 focus_style, style, i);
         style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+        ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx, i=%u.\n",
                 focus_exstyle, style, i);
 
         /* In d3d8 follow-up tests fail on native if the device is destroyed while
@@ -5148,10 +5141,10 @@ static void test_window_style(void)
         ok(ret, "Failed to set foreground window.\n");
         flush_events();
         hr = reset_device(device, &device_desc);
-        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
         ref = IDirect3DDevice9_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+        ok(!ref, "Unexpected refcount %lu.\n", ref);
 
         DestroyWindow(device_window);
         DestroyWindow(focus_window);
@@ -5184,7 +5177,7 @@ static void test_cursor_pos(void)
     IDirect3DDevice9 *device;
     WNDCLASSA wc = {0};
     IDirect3D9 *d3d9;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     HRESULT hr;
     BOOL ret;
@@ -5228,7 +5221,7 @@ static void test_cursor_pos(void)
     ok(ret, "Failed to get cursor position.\n");
     if (pt.x != 99 || pt.y != 99)
     {
-        skip("Could not warp the cursor (cur pos %ux%u), skipping test.\n", pt.x, pt.y);
+        skip("Could not warp the cursor (cur pos %ld,%ld), skipping test.\n", pt.x, pt.y);
         return;
     }
 
@@ -5250,12 +5243,12 @@ static void test_cursor_pos(void)
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &cursor, NULL);
-    ok(SUCCEEDED(hr), "Failed to create cursor surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create cursor surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor);
-    ok(SUCCEEDED(hr), "Failed to set cursor properties, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cursor properties, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(cursor);
     ret = IDirect3DDevice9_ShowCursor(device, TRUE);
-    ok(!ret, "Failed to show cursor, hr %#x.\n", ret);
+    ok(!ret, "Got %#x.\n", ret);
 
     flush_events();
     expect_pos = points;
@@ -5294,11 +5287,11 @@ static void test_cursor_pos(void)
     flush_events();
 
     ok((!expect_pos->x && !expect_pos->y) || broken(expect_pos - points == 7),
-        "Didn't receive MOUSEMOVE %u (%d, %d).\n",
+        "Didn't receive MOUSEMOVE %u (%ld, %ld).\n",
         (unsigned)(expect_pos - points), expect_pos->x, expect_pos->y);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     DestroyWindow(window);
     UnregisterClassA("d3d9_test_cursor_wc", GetModuleHandleA(NULL));
@@ -5307,11 +5300,11 @@ done:
 
 static void test_mode_change(void)
 {
+    unsigned int display_count = 0, d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
     DEVMODEW old_devmode, devmode, devmode2, *original_modes = NULL;
     struct device_desc device_desc, device_desc2;
     WCHAR second_monitor_name[CCHDEVICENAME];
     IDirect3DDevice9 *device, *device2;
-    unsigned int display_count = 0;
     RECT d3d_rect, focus_rect, r;
     IDirect3DSurface9 *backbuffer;
     MONITORINFOEXW monitor_info;
@@ -5324,15 +5317,14 @@ static void test_mode_change(void)
     BOOL ret;
     LONG change_ret;
     D3DDISPLAYMODE d3ddm;
-    DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
 
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
@@ -5342,7 +5334,7 @@ static void test_mode_change(void)
     for (i = 0; i < adapter_mode_count; ++i)
     {
         hr = IDirect3D9_EnumAdapterModes(d3d9, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, i, &d3ddm);
-        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
 
         if (d3ddm.Width == registry_mode.dmPelsWidth && d3ddm.Height == registry_mode.dmPelsHeight)
             continue;
@@ -5396,7 +5388,7 @@ static void test_mode_change(void)
     devmode.dmPelsWidth = user32_width;
     devmode.dmPelsHeight = user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
             0, 0, user32_width / 2, user32_height / 2, 0, 0, 0, 0);
@@ -5420,12 +5412,12 @@ static void test_mode_change(void)
     devmode.dmPelsWidth = user32_width;
     devmode.dmPelsHeight = user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == user32_width && devmode.dmPelsHeight == user32_height,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %ux%u, got %lux%lu.\n",
             user32_width, user32_height, devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     GetWindowRect(device_window, &r);
@@ -5436,9 +5428,9 @@ static void test_mode_change(void)
             wine_dbgstr_rect(&focus_rect), wine_dbgstr_rect(&r));
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetDesc(backbuffer, &desc);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer desc, hr %#lx.\n", hr);
     ok(desc.Width == d3d_width, "Got unexpected backbuffer width %u, expected %u.\n",
             desc.Width, d3d_width);
     ok(desc.Height == d3d_height, "Got unexpected backbuffer height %u, expected %u.\n",
@@ -5446,17 +5438,17 @@ static void test_mode_change(void)
     IDirect3DSurface9_Release(backbuffer);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     /* The mode restore also happens when the device was created at the original screen size. */
 
@@ -5471,10 +5463,10 @@ static void test_mode_change(void)
     devmode.dmPelsWidth = user32_width;
     devmode.dmPelsHeight = user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
@@ -5482,14 +5474,14 @@ static void test_mode_change(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode2.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode2.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", registry_mode.dmPelsWidth,
+            "Expected resolution %lux%lu, got %lux%lu.\n", registry_mode.dmPelsWidth,
             registry_mode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
     /* Test that no mode restorations if no mode changes happened */
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     device_desc.device_window = device_window;
@@ -5499,17 +5491,17 @@ static void test_mode_change(void)
     device = create_device(d3d9, device_window, &device_desc);
     ok(!!device, "Failed to create a D3D device.\n");
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
     /* Test that mode restorations use display settings in the registry with a fullscreen device */
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     device_desc.device_window = device_window;
@@ -5519,13 +5511,13 @@ static void test_mode_change(void)
     device = create_device(d3d9, device_window, &device_desc);
     ok(!!device, "Failed to create a D3D device.\n");
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -5533,7 +5525,7 @@ static void test_mode_change(void)
     /* Test that mode restorations use display settings in the registry with a fullscreen device
      * having the same display mode and then reset to a different mode */
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     device_desc.device_window = device_window;
@@ -5546,21 +5538,21 @@ static void test_mode_change(void)
     device_desc.width = d3d_width;
     device_desc.height = d3d_height;
     hr = reset_device(device, &device_desc);
-    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#lx.\n", hr);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == d3d_width && devmode2.dmPelsHeight == d3d_height,
-            "Expected resolution %ux%u, got %ux%u.\n", d3d_width, d3d_height,
+            "Expected resolution %ux%u, got %lux%lu.\n", d3d_width, d3d_height,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -5574,13 +5566,13 @@ static void test_mode_change(void)
     second_monitor = IDirect3D9_GetAdapterMonitor(d3d9, 1);
     monitor_info.cbSize = sizeof(monitor_info);
     ret = GetMonitorInfoW(second_monitor, (MONITORINFO *)&monitor_info);
-    ok(ret, "GetMonitorInfoW failed, error %#x.\n", GetLastError());
+    ok(ret, "GetMonitorInfoW failed, error %#lx.\n", GetLastError());
     lstrcpyW(second_monitor_name, monitor_info.szDevice);
 
     memset(&old_devmode, 0, sizeof(old_devmode));
     old_devmode.dmSize = sizeof(old_devmode);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &old_devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     i = 0;
     d3d_width = 0;
@@ -5623,37 +5615,37 @@ static void test_mode_change(void)
     ok(!!device, "Failed to create a D3D device.\n");
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     if (devmode2.dmPelsWidth == old_devmode.dmPelsWidth
             && devmode2.dmPelsHeight == old_devmode.dmPelsHeight)
     {
         skip("Failed to change display settings of the second monitor.\n");
         refcount = IDirect3DDevice9_Release(device);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
         goto done;
     }
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
-    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
-    ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n",
+    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
+    ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %lu, got %u.\n",
             old_devmode.dmPelsWidth, d3ddm.Width);
-    ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n",
+    ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %lu, got %u.\n",
             old_devmode.dmPelsHeight, d3ddm.Height);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -5667,22 +5659,22 @@ static void test_mode_change(void)
     ok(!!device, "Failed to create a D3D device.\n");
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
-    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
-    ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n",
+    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
+    ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %lu, got %u.\n",
             old_devmode.dmPelsWidth, d3ddm.Width);
-    ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n",
+    ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %lu, got %u.\n",
             old_devmode.dmPelsHeight, d3ddm.Height);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -5693,25 +5685,25 @@ static void test_mode_change(void)
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL,
             CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
-    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
     ok(d3ddm.Width == devmode.dmPelsWidth && d3ddm.Height == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             d3ddm.Width, d3ddm.Height);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -5729,28 +5721,28 @@ static void test_mode_change(void)
     ok(!!device2, "Failed to create a D3D device.\n");
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
-    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
     ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", old_devmode.dmPelsWidth,
+            "Expected resolution %lux%lu, got %ux%u.\n", old_devmode.dmPelsWidth,
             old_devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height);
 
     refcount = IDirect3DDevice9_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -5762,25 +5754,25 @@ static void test_mode_change(void)
     ok(!!device2, "Failed to create a D3D device.\n");
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm);
-    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
     ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", old_devmode.dmPelsWidth,
+            "Expected resolution %lux%lu, got %ux%u.\n", old_devmode.dmPelsWidth,
             old_devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height);
 
     refcount = IDirect3DDevice9_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     DestroyWindow(device_window);
@@ -5820,10 +5812,10 @@ static void test_device_window_reset(void)
     GetWindowRect(device_window, &device_rect);
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
@@ -5845,10 +5837,10 @@ static void test_device_window_reset(void)
             wine_dbgstr_rect(&device_rect), wine_dbgstr_rect(&r));
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n", (LONG_PTR)test_proc);
 
     device_desc.device_window = device_window;
     hr = reset_device(device, &device_desc);
@@ -5862,13 +5854,13 @@ static void test_device_window_reset(void)
             wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
 
     proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix.\n", (LONG_PTR)test_proc);
 
     ref = IDirect3DDevice9_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
 done:
     IDirect3D9_Release(d3d9);
@@ -5900,25 +5892,25 @@ static void test_reset_resources(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 128, 128,
             D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth/stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth/stencil surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, surface);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil surface, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     for (i = 0; i < caps.NumSimultaneousRTs; ++i)
     {
         hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
                 D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create render target texture %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to create render target texture %u, hr %#lx.\n", i, hr);
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-        ok(SUCCEEDED(hr), "Failed to get surface %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get surface %u, hr %#lx.\n", i, hr);
         IDirect3DTexture9_Release(texture);
         hr = IDirect3DDevice9_SetRenderTarget(device, i, surface);
-        ok(SUCCEEDED(hr), "Failed to set render target surface %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to set render target surface %u, hr %#lx.\n", i, hr);
         IDirect3DSurface9_Release(surface);
     }
 
@@ -5926,9 +5918,9 @@ static void test_reset_resources(void)
     ok(SUCCEEDED(hr), "Failed to reset device.\n");
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &rt);
-    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target surface, hr %#lx.\n", hr);
     ok(surface == rt, "Got unexpected surface %p for render target.\n", surface);
     IDirect3DSurface9_Release(surface);
     IDirect3DSurface9_Release(rt);
@@ -5936,11 +5928,11 @@ static void test_reset_resources(void)
     for (i = 1; i < caps.NumSimultaneousRTs; ++i)
     {
         hr = IDirect3DDevice9_GetRenderTarget(device, i, &surface);
-        ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     }
 
     ref = IDirect3DDevice9_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Unexpected refcount %lu.\n", ref);
 
 done:
     IDirect3D9_Release(d3d9);
@@ -5954,7 +5946,7 @@ static void test_set_rt_vp_scissor(void)
     IDirect3DSurface9 *rt;
     IDirect3D9 *d3d9;
     D3DVIEWPORT9 vp;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     HRESULT hr;
     RECT rect;
@@ -5971,48 +5963,48 @@ static void test_set_rt_vp_scissor(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(!vp.X, "Got unexpected vp.X %u.\n", vp.X);
-    ok(!vp.Y, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == 640, "Got unexpected vp.Width %u.\n", vp.Width);
-    ok(vp.Height == 480, "Got unexpected vp.Height %u.\n", vp.Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(!vp.X, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(!vp.Y, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == 640, "Got unexpected vp.Width %lu.\n", vp.Width);
+    ok(vp.Height == 480, "Got unexpected vp.Height %lu.\n", vp.Height);
     ok(vp.MinZ == 0.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 1.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == 640 && rect.bottom == 480,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9_BeginStateBlock(device);
-    ok(SUCCEEDED(hr), "Failed to begin stateblock, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin stateblock, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndStateBlock(device, &stateblock);
-    ok(SUCCEEDED(hr), "Failed to end stateblock, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end stateblock, hr %#lx.\n", hr);
     IDirect3DStateBlock9_Release(stateblock);
 
     hr = IDirect3DDevice9_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(!vp.X, "Got unexpected vp.X %u.\n", vp.X);
-    ok(!vp.Y, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == 128, "Got unexpected vp.Width %u.\n", vp.Width);
-    ok(vp.Height == 128, "Got unexpected vp.Height %u.\n", vp.Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(!vp.X, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(!vp.Y, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == 128, "Got unexpected vp.Width %lu.\n", vp.Width);
+    ok(vp.Height == 128, "Got unexpected vp.Height %lu.\n", vp.Height);
     ok(vp.MinZ == 0.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 1.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == 128 && rect.bottom == 128,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     vp.X = 10;
     vp.Y = 20;
@@ -6021,32 +6013,32 @@ static void test_set_rt_vp_scissor(void)
     vp.MinZ = 0.25f;
     vp.MaxZ = 0.75f;
     hr = IDirect3DDevice9_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     SetRect(&rect, 50, 60, 70, 80);
     hr = IDirect3DDevice9_SetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to set scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set scissor rect, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
-    ok(!vp.X, "Got unexpected vp.X %u.\n", vp.X);
-    ok(!vp.Y, "Got unexpected vp.Y %u.\n", vp.Y);
-    ok(vp.Width == 128, "Got unexpected vp.Width %u.\n", vp.Width);
-    ok(vp.Height == 128, "Got unexpected vp.Height %u.\n", vp.Height);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
+    ok(!vp.X, "Got unexpected vp.X %lu.\n", vp.X);
+    ok(!vp.Y, "Got unexpected vp.Y %lu.\n", vp.Y);
+    ok(vp.Width == 128, "Got unexpected vp.Width %lu.\n", vp.Width);
+    ok(vp.Height == 128, "Got unexpected vp.Height %lu.\n", vp.Height);
     ok(vp.MinZ == 0.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
     ok(vp.MaxZ == 1.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
 
     hr = IDirect3DDevice9_GetScissorRect(device, &rect);
-    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#lx.\n", hr);
     ok(rect.left == 0 && rect.top == 0 && rect.right == 128 && rect.bottom == 128,
             "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
 
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -6075,7 +6067,7 @@ static void test_volume_get_container(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP))
     {
         skip("No volume texture support, skipping tests.\n");
@@ -6087,47 +6079,47 @@ static void test_volume_get_container(void)
 
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 128, 128, 128, 1, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, 0);
-    ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
     ok(!!texture, "Got unexpected texture %p.\n", texture);
 
     hr = IDirect3DVolumeTexture9_GetVolumeLevel(texture, 0, &volume);
-    ok(SUCCEEDED(hr), "Failed to get volume level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get volume level, hr %#lx.\n", hr);
     ok(!!volume, "Got unexpected volume %p.\n", volume);
 
     /* These should work... */
     container = NULL;
     hr = IDirect3DVolume9_GetContainer(volume, &IID_IUnknown, (void **)&container);
-    ok(SUCCEEDED(hr), "Failed to get volume container, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get volume container, hr %#lx.\n", hr);
     ok(container == (IUnknown *)texture, "Got unexpected container %p, expected %p.\n", container, texture);
     IUnknown_Release(container);
 
     container = NULL;
     hr = IDirect3DVolume9_GetContainer(volume, &IID_IDirect3DResource9, (void **)&container);
-    ok(SUCCEEDED(hr), "Failed to get volume container, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get volume container, hr %#lx.\n", hr);
     ok(container == (IUnknown *)texture, "Got unexpected container %p, expected %p.\n", container, texture);
     IUnknown_Release(container);
 
     container = NULL;
     hr = IDirect3DVolume9_GetContainer(volume, &IID_IDirect3DBaseTexture9, (void **)&container);
-    ok(SUCCEEDED(hr), "Failed to get volume container, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get volume container, hr %#lx.\n", hr);
     ok(container == (IUnknown *)texture, "Got unexpected container %p, expected %p.\n", container, texture);
     IUnknown_Release(container);
 
     container = NULL;
     hr = IDirect3DVolume9_GetContainer(volume, &IID_IDirect3DVolumeTexture9, (void **)&container);
-    ok(SUCCEEDED(hr), "Failed to get volume container, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get volume container, hr %#lx.\n", hr);
     ok(container == (IUnknown *)texture, "Got unexpected container %p, expected %p.\n", container, texture);
     IUnknown_Release(container);
 
     /* ...and this one shouldn't. This should return E_NOINTERFACE and set container to NULL. */
     hr = IDirect3DVolume9_GetContainer(volume, &IID_IDirect3DVolume9, (void **)&container);
-    ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
     ok(!container, "Got unexpected container %p.\n", container);
 
     IDirect3DVolume9_Release(volume);
     IDirect3DVolumeTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -6156,7 +6148,7 @@ static void test_volume_resource(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP))
     {
         skip("No volume texture support, skipping tests.\n");
@@ -6168,17 +6160,17 @@ static void test_volume_resource(void)
 
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 128, 128, 128, 1, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, 0);
-    ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
     hr = IDirect3DVolumeTexture9_GetVolumeLevel(texture, 0, &volume);
-    ok(SUCCEEDED(hr), "Failed to get volume level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get volume level, hr %#lx.\n", hr);
     IDirect3DVolumeTexture9_Release(texture);
 
     hr = IDirect3DVolume9_QueryInterface(volume, &IID_IDirect3DResource9, (void **)&resource);
-    ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DVolume9_Release(volume);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -6224,7 +6216,7 @@ static void test_vb_lock_flags(void)
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, 1024, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
             0, D3DPOOL_DEFAULT, &buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -6233,19 +6225,19 @@ static void test_vb_lock_flags(void)
          * sense. Windows 7 returns an error. At least one game (Shaiya)
          * depends on the Windows XP result, so mark the Windows 7 behavior as
          * broken. */
-        ok(hr == D3D_OK || broken(hr == test_data[i].win7_result), "Got unexpected hr %#x for %s.\n",
+        ok(hr == D3D_OK || broken(hr == test_data[i].win7_result), "Got unexpected hr %#lx for %s.\n",
                 hr, test_data[i].debug_string);
         if (SUCCEEDED(hr))
         {
             ok(!!data, "Got unexpected data %p.\n", data);
             hr = IDirect3DVertexBuffer9_Unlock(buffer);
-            ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
         }
     }
 
     IDirect3DVertexBuffer9_Release(buffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -6270,7 +6262,7 @@ static const char *debug_d3dpool(D3DPOOL pool)
 static void test_vertex_buffer_alignment(void)
 {
     static const D3DPOOL pools[] = {D3DPOOL_DEFAULT, D3DPOOL_SYSTEMMEM, D3DPOOL_SCRATCH, D3DPOOL_MANAGED};
-    static const DWORD sizes[] = {1, 4, 16, 17, 32, 33, 64, 65, 1024, 1025, 1048576, 1048577};
+    static const unsigned int sizes[] = {1, 4, 16, 17, 32, 33, 64, 65, 1024, 1025, 1048576, 1048577};
     IDirect3DVertexBuffer9 *buffer = NULL;
     const unsigned int align = 16;
     IDirect3DDevice9 *device;
@@ -6298,26 +6290,26 @@ static void test_vertex_buffer_alignment(void)
         {
             hr = IDirect3DDevice9_CreateVertexBuffer(device, sizes[i], 0, 0, pools[j], &buffer, NULL);
             if (pools[j] == D3DPOOL_SCRATCH)
-                ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x trying to create a D3DPOOL_SCRATCH buffer.\n", hr);
+                ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx trying to create a D3DPOOL_SCRATCH buffer.\n", hr);
             else
-                ok(SUCCEEDED(hr), "Failed to create vertex buffer in pool %s with size %u, hr %#x.\n",
+                ok(SUCCEEDED(hr), "Failed to create vertex buffer in pool %s with size %u, hr %#lx.\n",
                         debug_d3dpool(pools[j]), sizes[i], hr);
             if (FAILED(hr))
                 continue;
 
             hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &data, 0);
-            ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
             ok(!((DWORD_PTR)data & (align - 1)),
                     "Vertex buffer start address %p is not %u byte aligned (size %u, pool %s).\n",
                     data, align, sizes[i], debug_d3dpool(pools[j]));
             hr = IDirect3DVertexBuffer9_Unlock(buffer);
-            ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
             IDirect3DVertexBuffer9_Release(buffer);
         }
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -6364,12 +6356,12 @@ static void test_query_support(void)
     for (i = 0; i < ARRAY_SIZE(queries); ++i)
     {
         hr = IDirect3DDevice9_CreateQuery(device, queries[i], NULL);
-        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x for query %#x.\n", hr, queries[i]);
+        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx for query %#x.\n", hr, queries[i]);
 
         supported = hr == D3D_OK;
 
         hr = IDirect3DDevice9_CreateQuery(device, queries[i], &query);
-        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x for query %#x.\n", hr, queries[i]);
+        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx for query %#x.\n", hr, queries[i]);
 
         ok(!supported || query, "Query %#x was claimed to be supported, but can't be created.\n", queries[i]);
         ok(supported || !query, "Query %#x was claimed not to be supported, but can be created.\n", queries[i]);
@@ -6389,16 +6381,16 @@ static void test_query_support(void)
             continue;
 
         hr = IDirect3DDevice9_CreateQuery(device, i, NULL);
-        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x for query %#x.\n", hr, i);
+        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx for query %#x.\n", hr, i);
 
         query = (IDirect3DQuery9 *)0xdeadbeef;
         hr = IDirect3DDevice9_CreateQuery(device, i, &query);
-        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x for query %#x.\n", hr, i);
+        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx for query %#x.\n", hr, i);
         ok(query == (IDirect3DQuery9 *)0xdeadbeef, "Got unexpected query %p.\n", query);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -6426,7 +6418,7 @@ static void test_occlusion_query(void)
     union
     {
         WORD word[4];
-        DWORD dword[2];
+        unsigned int dword[2];
         UINT64 uint;
     } data, expected;
     BOOL broken_occlusion = FALSE;
@@ -6449,14 +6441,14 @@ static void test_occlusion_query(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateQuery(device, D3DQUERYTYPE_OCCLUSION, &query);
-    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
     if (!query)
     {
         skip("Occlusion queries are not supported, skipping tests.\n");
@@ -6471,42 +6463,42 @@ static void test_occlusion_query(void)
 
     memset(&data, 0xff, sizeof(data));
     hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(data.dword[0] == 0xdddddddd && data.dword[1] == 0xffffffff,
             "Got unexpected query result 0x%08x%08x.\n", data.dword[1], data.dword[0]);
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     data.dword[0] = 0x12345678;
     hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH);
-    ok(hr == S_FALSE || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_FALSE || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH);
-    ok(hr == S_FALSE || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_FALSE || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (hr == D3D_OK)
         ok(!data.dword[0], "Got unexpected query result %u.\n", data.dword[0]);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLEFAN, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     wait_query(query);
 
     memset(&data, 0xff, sizeof(data));
     hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(data.dword[0] == expected.dword[0] || broken(!data.dword[0]),
             "Occlusion query returned an unexpected result (0x%.8x).\n", data.dword[0]);
     if (!data.dword[0])
@@ -6517,7 +6509,7 @@ static void test_occlusion_query(void)
 
     memset(&data, 0xff, sizeof(data));
     hr = IDirect3DQuery9_GetData(query, &data, sizeof(WORD), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     if (!broken_occlusion)
         ok(data.word[0] == expected.word[0],
                 "Occlusion query returned an unexpected result (0x%.8x).\n", data.dword[0]);
@@ -6526,7 +6518,7 @@ static void test_occlusion_query(void)
 
     memset(&data, 0xf0, sizeof(data));
     hr = IDirect3DQuery9_GetData(query, &data, sizeof(data), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     if (!broken_occlusion)
         ok(data.dword[0] == expected.dword[0],
                 "Occlusion query returned an unexpected result (0x%.8x).\n", data.dword[0]);
@@ -6541,48 +6533,48 @@ static void test_occlusion_query(void)
 
     memset(&data, 0xff, sizeof(data));
     hr = IDirect3DQuery9_GetData(query, &data, 0, D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(data.dword[0] == 0xffffffff, "Occlusion query returned an unexpected result (0x%.8x).\n", data.dword[0]);
 
     /* This crashes on Windows. */
     if (0)
     {
         hr = IDirect3DQuery9_GetData(query, NULL, data_size, D3DGETDATA_FLUSH);
-        ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     if (broken_occlusion)
         goto done;
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Failed to begin scene, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to begin scene, hr %#lx.\n", hr);
     for (i = 0; i < 50000; ++i)
     {
         hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Failed to end scene, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to end scene, hr %#lx.\n", hr);
 
     wait_query(query);
 
     memset(&data, 0xff, sizeof(data));
     hr = IDirect3DQuery9_GetData(query, &data, sizeof(data), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(data.dword[0] == 0 && data.dword[1] == 0,
             "Got unexpected query result 0x%08x%08x.\n", data.dword[1], data.dword[0]);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     vp.X = 0;
     vp.Y = 0;
@@ -6591,20 +6583,20 @@ static void test_occlusion_query(void)
     vp.MinZ = 0.0f;
     vp.MaxZ = 1.0f;
     hr = IDirect3DDevice9_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, vp.Width, vp.Height,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
     if (FAILED(hr))
     {
-        skip("Failed to create render target (width %u, height %u), hr %#x.\n", vp.Width, vp.Height, hr);
+        skip("Failed to create render target (width %lu, height %lu), hr %#lx.\n", vp.Width, vp.Height, hr);
         goto done;
     }
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     expected.uint = vp.Width * vp.Height;
     count = ((((UINT64)~0u) + 1) / expected.uint) + 1;
@@ -6613,24 +6605,24 @@ static void test_occlusion_query(void)
     trace("Expects 0x%08x%08x samples.\n", expected.dword[1], expected.dword[0]);
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     for (i = 0; i < count; i++)
     {
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLEFAN, 2, quad, 3 * sizeof(float));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     }
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     wait_query(query);
 
     memset(&data, 0xff, sizeof(data));
     hr = IDirect3DQuery9_GetData(query, &data, sizeof(data), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok((data.dword[0] == expected.dword[0] && data.dword[1] == expected.dword[1])
             || (data.dword[0] == 0xffffffff && !data.dword[1])
             || broken(data.dword[0] < 0xffffffff && !data.dword[1]),
@@ -6641,7 +6633,7 @@ static void test_occlusion_query(void)
 done:
     IDirect3DQuery9_Release(query);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -6656,13 +6648,12 @@ static void test_timestamp_query(void)
          1.0f, -1.0f, 0.0f,
     };
     IDirect3DQuery9 *query, *disjoint_query, *freq_query;
+    unsigned int data_size, timestamp[2], freq[2];
     IDirect3DDevice9 *device;
-    unsigned int data_size;
     IDirect3D9 *d3d9;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    DWORD timestamp[2], freq[2];
     WORD disjoint[2];
 
     window = create_window();
@@ -6677,7 +6668,7 @@ static void test_timestamp_query(void)
     }
 
     hr = IDirect3DDevice9_CreateQuery(device, D3DQUERYTYPE_TIMESTAMPFREQ, &freq_query);
-    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         skip("Timestamp queries are not supported, skipping tests.\n");
@@ -6691,31 +6682,31 @@ static void test_timestamp_query(void)
 
     memset(freq, 0xff, sizeof(freq));
     hr = IDirect3DQuery9_GetData(freq_query, NULL, 0, D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_GetData(freq_query, freq, sizeof(DWORD), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(freq[0] == 0xdddddddd && freq[1] == 0xffffffff,
             "Got unexpected query result 0x%08x%08x.\n", freq[1], freq[0]);
 
     hr = IDirect3DDevice9_CreateQuery(device, D3DQUERYTYPE_TIMESTAMPDISJOINT, &disjoint_query);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     data_size = IDirect3DQuery9_GetDataSize(disjoint_query);
     ok(data_size == sizeof(BOOL), "Query data size is %u, 4 expected.\n", data_size);
 
     memset(disjoint, 0xff, sizeof(disjoint));
     hr = IDirect3DQuery9_GetData(disjoint_query, NULL, 0, D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_GetData(disjoint_query, &disjoint, sizeof(WORD), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(disjoint[0] == 0xdddd && disjoint[1] == 0xffff,
             "Got unexpected query result 0x%04x%04x.\n", disjoint[1], disjoint[0]);
     hr = IDirect3DQuery9_GetData(disjoint_query, &disjoint, sizeof(DWORD), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(disjoint[0] == 0xdddd && disjoint[1] == 0xdddd,
             "Got unexpected query result 0x%04x%04x.\n", disjoint[1], disjoint[0]);
 
     hr = IDirect3DDevice9_CreateQuery(device, D3DQUERYTYPE_TIMESTAMP, &query);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     data_size = IDirect3DQuery9_GetDataSize(query);
     ok(data_size == sizeof(UINT64), "Query data size is %u, 8 expected.\n", data_size);
 
@@ -6725,100 +6716,100 @@ static void test_timestamp_query(void)
 
     memset(freq, 0xff, sizeof(freq));
     hr = IDirect3DQuery9_GetData(freq_query, freq, sizeof(DWORD), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(freq[1] == 0xffffffff,
             "Freq was modified outside of the expected size (0x%.8x).\n", freq[1]);
     hr = IDirect3DQuery9_GetData(freq_query, &freq, sizeof(freq), D3DGETDATA_FLUSH);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(freq[1] != 0xffffffff, "High bytes of freq were not modified (0x%.8x).\n",
             freq[1]);
 
     memset(timestamp, 0xff, sizeof(timestamp));
     hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(DWORD), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(timestamp[0] == 0xdddddddd && timestamp[1] == 0xffffffff,
             "Got unexpected query result 0x%08x%08x.\n", timestamp[1], timestamp[0]);
     hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(timestamp), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(timestamp[0] == 0xdddddddd && timestamp[1] == 0xdddddddd,
             "Got unexpected query result 0x%08x%08x.\n", timestamp[1], timestamp[0]);
 
     hr = IDirect3DQuery9_Issue(disjoint_query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(disjoint_query, D3DISSUE_BEGIN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(disjoint_query, D3DISSUE_BEGIN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(timestamp), D3DGETDATA_FLUSH);
-    ok(hr == S_FALSE || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_FALSE || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLEFAN, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     wait_query(query);
 
     memset(timestamp, 0xff, sizeof(timestamp));
     hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(DWORD), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(timestamp[1] == 0xffffffff,
             "Timestamp was modified outside of the expected size (0x%.8x).\n",
             timestamp[1]);
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DQuery9_Issue(disjoint_query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     wait_query(disjoint_query);
 
     memset(disjoint, 0xff, sizeof(disjoint));
     hr = IDirect3DQuery9_GetData(disjoint_query, disjoint, sizeof(WORD), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(disjoint[1] == 0xffff,
             "Disjoint was modified outside of the expected size (0x%.4hx).\n", disjoint[1]);
     hr = IDirect3DQuery9_GetData(disjoint_query, disjoint, sizeof(disjoint), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(disjoint[1] != 0xffff, "High bytes of disjoint were not modified (0x%.4hx).\n", disjoint[1]);
 
     /* It's not strictly necessary for the TIMESTAMP query to be inside
      * a TIMESTAMP_DISJOINT query. */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLEFAN, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     wait_query(query);
 
     hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(timestamp), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DQuery9_Release(query);
     IDirect3DQuery9_Release(disjoint_query);
     IDirect3DQuery9_Release(freq_query);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -6847,7 +6838,7 @@ static void test_get_set_vertex_shader(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.VertexShaderVersion & 0xffff))
     {
         skip("No vertex shader support, skipping tests.\n");
@@ -6858,22 +6849,22 @@ static void test_get_set_vertex_shader(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexShader(device, simple_vs, &shader);
-    ok(SUCCEEDED(hr), "Failed to create shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create shader, hr %#lx.\n", hr);
     ok(!!shader, "Got unexpected shader %p.\n", shader);
 
     /* SetVertexShader() should not touch the shader's refcount. */
     i = get_refcount((IUnknown *)shader);
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
     refcount = get_refcount((IUnknown *)shader);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
-    ok(refcount == i, "Got unexpected refcount %u, expected %u.\n", refcount, i);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
+    ok(refcount == i, "Got unexpected refcount %lu, expected %lu.\n", refcount, i);
 
     /* GetVertexShader() should increase the shader's refcount by one. */
     i = refcount + 1;
     hr = IDirect3DDevice9_GetVertexShader(device, &current_shader);
     refcount = get_refcount((IUnknown *)shader);
-    ok(SUCCEEDED(hr), "Failed to get vertex shader, hr %#x.\n", hr);
-    ok(refcount == i, "Got unexpected refcount %u, expected %u.\n", refcount, i);
+    ok(SUCCEEDED(hr), "Failed to get vertex shader, hr %#lx.\n", hr);
+    ok(refcount == i, "Got unexpected refcount %lu, expected %lu.\n", refcount, i);
     ok(current_shader == shader, "Got unexpected shader %p, expected %p.\n", current_shader, shader);
     IDirect3DVertexShader9_Release(current_shader);
 
@@ -6881,15 +6872,15 @@ static void test_get_set_vertex_shader(void)
     shader_vtbl = shader->lpVtbl;
     shader->lpVtbl = (IDirect3DVertexShader9Vtbl *)0xdeadbeef;
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     shader->lpVtbl = NULL;
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     shader->lpVtbl = shader_vtbl;
 
     IDirect3DVertexShader9_Release(shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -6920,7 +6911,7 @@ static void test_vertex_shader_constant(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.VertexShaderVersion & 0xffff))
     {
         skip("No vertex shader support, skipping tests.\n");
@@ -6933,25 +6924,25 @@ static void test_vertex_shader_constant(void)
 
     /* A simple check that the stuff works at all. */
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, c, 1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Test corner cases: Write to const MAX - 1, MAX, MAX + 1, and writing 4
      * consts from MAX - 1. */
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts - 1, c, 1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts + 0, c, 1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts + 1, c, 1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts - 1, d, 4);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     /* Constant -1. */
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, -1, c, 1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     desc.device_window = window;
@@ -6967,27 +6958,27 @@ static void test_vertex_shader_constant(void)
         return;
     }
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     consts_swvp = caps.MaxVertexShaderConst;
     todo_wine
-    ok(consts_swvp == 8192, "Unexpected consts_swvp %u.\n", consts_swvp);
+    ok(consts_swvp == 8192, "Unexpected consts_swvp %lu.\n", consts_swvp);
 
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts + 0, c, 1);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts + 1, c, 1);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts - 1, d, 4);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts_swvp - 1, c, 1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts_swvp, c, 1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     desc.flags = CREATE_DEVICE_MIXED_ONLY;
     if (!(device = create_device(d3d, window, &desc)))
@@ -6998,27 +6989,27 @@ static void test_vertex_shader_constant(void)
         return;
     }
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
-    ok(consts == caps.MaxVertexShaderConst, "Unexpected caps.MaxVertexShaderConst %u, consts %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
+    ok(consts == caps.MaxVertexShaderConst, "Unexpected caps.MaxVertexShaderConst %lu, consts %lu.\n",
             caps.MaxVertexShaderConst, consts);
 
     IDirect3DDevice9_SetSoftwareVertexProcessing(device, 0);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts + 0, c, 1);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts_swvp - 1, c, 1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DDevice9_SetSoftwareVertexProcessing(device, 1);
 
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts + 0, c, 1);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts_swvp - 1, c, 1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -7048,7 +7039,7 @@ static void test_get_set_pixel_shader(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.PixelShaderVersion & 0xffff))
     {
         skip("No pixel shader support, skipping tests.\n");
@@ -7059,22 +7050,22 @@ static void test_get_set_pixel_shader(void)
     }
 
     hr = IDirect3DDevice9_CreatePixelShader(device, simple_ps, &shader);
-    ok(SUCCEEDED(hr), "Failed to create shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create shader, hr %#lx.\n", hr);
     ok(!!shader, "Got unexpected shader %p.\n", shader);
 
     /* SetPixelShader() should not touch the shader's refcount. */
     i = get_refcount((IUnknown *)shader);
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
     refcount = get_refcount((IUnknown *)shader);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
-    ok(refcount == i, "Got unexpected refcount %u, expected %u.\n", refcount, i);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
+    ok(refcount == i, "Got unexpected refcount %lu, expected %lu.\n", refcount, i);
 
     /* GetPixelShader() should increase the shader's refcount by one. */
     i = refcount + 1;
     hr = IDirect3DDevice9_GetPixelShader(device, &current_shader);
     refcount = get_refcount((IUnknown *)shader);
-    ok(SUCCEEDED(hr), "Failed to get pixel shader, hr %#x.\n", hr);
-    ok(refcount == i, "Got unexpected refcount %u, expected %u.\n", refcount, i);
+    ok(SUCCEEDED(hr), "Failed to get pixel shader, hr %#lx.\n", hr);
+    ok(refcount == i, "Got unexpected refcount %lu, expected %lu.\n", refcount, i);
     ok(current_shader == shader, "Got unexpected shader %p, expected %p.\n", current_shader, shader);
     IDirect3DPixelShader9_Release(current_shader);
 
@@ -7082,15 +7073,15 @@ static void test_get_set_pixel_shader(void)
     shader_vtbl = shader->lpVtbl;
     shader->lpVtbl = (IDirect3DPixelShader9Vtbl *)0xdeadbeef;
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     shader->lpVtbl = NULL;
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     shader->lpVtbl = shader_vtbl;
 
     IDirect3DPixelShader9_Release(shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -7119,7 +7110,7 @@ static void test_pixel_shader_constant(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.PixelShaderVersion & 0xffff))
     {
         skip("No pixel shader support, skipping tests.\n");
@@ -7131,24 +7122,24 @@ static void test_pixel_shader_constant(void)
 
     /* A simple check that the stuff works at all. */
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, c, 1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Is there really no max pixel shader constant value??? Test how far I can go. */
     while (SUCCEEDED(IDirect3DDevice9_SetPixelShaderConstantF(device, consts++, c, 1)));
     consts = consts - 1;
-    trace("SetPixelShaderConstantF was able to set %u shader constants.\n", consts);
+    trace("SetPixelShaderConstantF was able to set %lu shader constants.\n", consts);
 
     /* Test corner cases: Write 4 consts from MAX - 1, everything else is
      * pointless given the way the constant limit was determined. */
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, consts - 1, d, 4);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     /* Constant -1. */
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, -1, c, 1);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -7391,22 +7382,22 @@ float4 main(const float4 color : COLOR) : SV_TARGET
 
     /* These should always fail, regardless of supported shader version. */
     hr = IDirect3DDevice9_CreateVertexShader(device, simple_ps, &vs);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, simple_vs, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_4_0, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_3_0, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         if (caps.VertexShaderVersion <= D3DVS_VERSION(1, 1) && caps.MaxVertexShaderConst < 256)
         {
             hr = IDirect3DDevice9_CreateVertexShader(device, vs_1_255, &vs);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         }
         else
         {
@@ -7420,16 +7411,16 @@ float4 main(const float4 color : COLOR) : SV_TARGET
         skip("This GPU supports SM3, skipping unsupported shader test.\n");
 
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_1_255, &vs);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         IDirect3DVertexShader9_Release(vs);
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_1_256, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_3_256, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_3_i16, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_3_b16, &vs);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
 
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0))
@@ -7438,18 +7429,18 @@ float4 main(const float4 color : COLOR) : SV_TARGET
         goto cleanup;
     }
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_1_8, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_2_32, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_3_224, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_2_0_boolint, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     if (ps)
         IDirect3DPixelShader9_Release(ps);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     desc.device_window = window;
@@ -7468,17 +7459,17 @@ float4 main(const float4 color : COLOR) : SV_TARGET
     vs = NULL;
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_1_256, &vs);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (vs)
         IDirect3DVertexShader9_Release(vs);
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_3_256, &vs);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (vs)
         IDirect3DVertexShader9_Release(vs);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     desc.flags = CREATE_DEVICE_MIXED_ONLY;
     if (!(device = create_device(d3d, window, &desc)))
@@ -7489,27 +7480,27 @@ float4 main(const float4 color : COLOR) : SV_TARGET
         return;
     }
     hr = IDirect3DDevice9_SetSoftwareVertexProcessing(device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_1_256, &vs);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vs);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (vs)
         IDirect3DVertexShader9_Release(vs);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_3_256, &vs);
     todo_wine
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vs);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (vs)
         IDirect3DVertexShader9_Release(vs);
 
 cleanup:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -7538,71 +7529,71 @@ static void test_texture_stage_states(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     for (i = 0; i < caps.MaxTextureBlendStages; ++i)
     {
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_COLOROP, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
         ok(value == (i ? D3DTOP_DISABLE : D3DTOP_MODULATE),
-                "Got unexpected value %#x for D3DTSS_COLOROP, stage %u.\n", value, i);
+                "Got unexpected value %#lx for D3DTSS_COLOROP, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_COLORARG1, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(value == D3DTA_TEXTURE, "Got unexpected value %#x for D3DTSS_COLORARG1, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(value == D3DTA_TEXTURE, "Got unexpected value %#lx for D3DTSS_COLORARG1, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_COLORARG2, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(value == D3DTA_CURRENT, "Got unexpected value %#x for D3DTSS_COLORARG2, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(value == D3DTA_CURRENT, "Got unexpected value %#lx for D3DTSS_COLORARG2, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_ALPHAOP, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
         ok(value == (i ? D3DTOP_DISABLE : D3DTOP_SELECTARG1),
-                "Got unexpected value %#x for D3DTSS_ALPHAOP, stage %u.\n", value, i);
+                "Got unexpected value %#lx for D3DTSS_ALPHAOP, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_ALPHAARG1, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(value == D3DTA_TEXTURE, "Got unexpected value %#x for D3DTSS_ALPHAARG1, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(value == D3DTA_TEXTURE, "Got unexpected value %#lx for D3DTSS_ALPHAARG1, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_ALPHAARG2, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(value == D3DTA_CURRENT, "Got unexpected value %#x for D3DTSS_ALPHAARG2, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(value == D3DTA_CURRENT, "Got unexpected value %#lx for D3DTSS_ALPHAARG2, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_BUMPENVMAT00, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(!value, "Got unexpected value %#x for D3DTSS_BUMPENVMAT00, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(!value, "Got unexpected value %#lx for D3DTSS_BUMPENVMAT00, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_BUMPENVMAT01, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(!value, "Got unexpected value %#x for D3DTSS_BUMPENVMAT01, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(!value, "Got unexpected value %#lx for D3DTSS_BUMPENVMAT01, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_BUMPENVMAT10, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(!value, "Got unexpected value %#x for D3DTSS_BUMPENVMAT10, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(!value, "Got unexpected value %#lx for D3DTSS_BUMPENVMAT10, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_BUMPENVMAT11, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(!value, "Got unexpected value %#x for D3DTSS_BUMPENVMAT11, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(!value, "Got unexpected value %#lx for D3DTSS_BUMPENVMAT11, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_TEXCOORDINDEX, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(value == i, "Got unexpected value %#x for D3DTSS_TEXCOORDINDEX, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(value == i, "Got unexpected value %#lx for D3DTSS_TEXCOORDINDEX, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_BUMPENVLSCALE, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(!value, "Got unexpected value %#x for D3DTSS_BUMPENVLSCALE, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(!value, "Got unexpected value %#lx for D3DTSS_BUMPENVLSCALE, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_BUMPENVLOFFSET, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(!value, "Got unexpected value %#x for D3DTSS_BUMPENVLOFFSET, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(!value, "Got unexpected value %#lx for D3DTSS_BUMPENVLOFFSET, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_TEXTURETRANSFORMFLAGS, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
         ok(value == D3DTTFF_DISABLE,
-                "Got unexpected value %#x for D3DTSS_TEXTURETRANSFORMFLAGS, stage %u.\n", value, i);
+                "Got unexpected value %#lx for D3DTSS_TEXTURETRANSFORMFLAGS, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_COLORARG0, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(value == D3DTA_CURRENT, "Got unexpected value %#x for D3DTSS_COLORARG0, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(value == D3DTA_CURRENT, "Got unexpected value %#lx for D3DTSS_COLORARG0, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_ALPHAARG0, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(value == D3DTA_CURRENT, "Got unexpected value %#x for D3DTSS_ALPHAARG0, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(value == D3DTA_CURRENT, "Got unexpected value %#lx for D3DTSS_ALPHAARG0, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_RESULTARG, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(value == D3DTA_CURRENT, "Got unexpected value %#x for D3DTSS_RESULTARG, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(value == D3DTA_CURRENT, "Got unexpected value %#lx for D3DTSS_RESULTARG, stage %u.\n", value, i);
         hr = IDirect3DDevice9_GetTextureStageState(device, i, D3DTSS_CONSTANT, &value);
-        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#x.\n", hr);
-        ok(!value, "Got unexpected value %#x for D3DTSS_CONSTANT, stage %u.\n", value, i);
+        ok(SUCCEEDED(hr), "Failed to get texture stage state, hr %#lx.\n", hr);
+        ok(!value, "Got unexpected value %#lx for D3DTSS_CONSTANT, stage %u.\n", value, i);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -7614,7 +7605,7 @@ static void test_cube_texture_mipmap_gen(IDirect3DDevice9 *device)
     HRESULT hr;
 
     hr = IDirect3DDevice9_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get D3D, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get D3D, hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_CUBETEXTURE, D3DFMT_X8R8G8B8);
     IDirect3D9_Release(d3d);
@@ -7626,12 +7617,12 @@ static void test_cube_texture_mipmap_gen(IDirect3DDevice9 *device)
 
     hr = IDirect3DDevice9_CreateCubeTexture(device, 64, 0, (D3DUSAGE_RENDERTARGET | D3DUSAGE_AUTOGENMIPMAP),
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DCubeTexture9_Release(texture);
 
     hr = IDirect3DDevice9_CreateCubeTexture(device, 64, 0, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DCubeTexture9_Release(texture);
 }
 
@@ -7645,7 +7636,7 @@ static void test_cube_texture_levels(IDirect3DDevice9 *device)
     D3DCAPS9 caps;
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (FAILED(IDirect3DDevice9_CreateCubeTexture(device, 64, 0, 0,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL)))
     {
@@ -7655,24 +7646,24 @@ static void test_cube_texture_levels(IDirect3DDevice9 *device)
 
     levels = IDirect3DCubeTexture9_GetLevelCount(texture);
     if (caps.TextureCaps & D3DPTEXTURECAPS_MIPCUBEMAP)
-        ok(levels == 7, "Got unexpected levels %u.\n", levels);
+        ok(levels == 7, "Got unexpected levels %lu.\n", levels);
     else
-        ok(levels == 1, "Got unexpected levels %u.\n", levels);
+        ok(levels == 1, "Got unexpected levels %lu.\n", levels);
 
     hr = IDirect3DCubeTexture9_GetLevelDesc(texture, levels - 1, &desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DCubeTexture9_GetLevelDesc(texture, levels, &desc);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DCubeTexture9_GetLevelDesc(texture, levels + 1, &desc);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DCubeTexture9_GetCubeMapSurface(texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
     hr = IDirect3DCubeTexture9_GetCubeMapSurface(texture, D3DCUBEMAP_FACE_NEGATIVE_Z + 1, 0, &surface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DCubeTexture9_GetCubeMapSurface(texture, D3DCUBEMAP_FACE_POSITIVE_X - 1, 0, &surface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DCubeTexture9_Release(texture);
 }
@@ -7699,38 +7690,38 @@ static void test_cube_textures(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     if (caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP)
     {
         hr = IDirect3DDevice9_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-        ok(hr == D3D_OK, "Failed to create D3DPOOL_DEFAULT cube texture, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to create D3DPOOL_DEFAULT cube texture, hr %#lx.\n", hr);
         IDirect3DCubeTexture9_Release(texture);
         hr = IDirect3DDevice9_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-        ok(hr == D3D_OK, "Failed to create D3DPOOL_MANAGED cube texture, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to create D3DPOOL_MANAGED cube texture, hr %#lx.\n", hr);
         IDirect3DCubeTexture9_Release(texture);
         hr = IDirect3DDevice9_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, NULL);
-        ok(hr == D3D_OK, "Failed to create D3DPOOL_SYSTEMMEM cube texture, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to create D3DPOOL_SYSTEMMEM cube texture, hr %#lx.\n", hr);
         IDirect3DCubeTexture9_Release(texture);
     }
     else
     {
         hr = IDirect3DDevice9_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for D3DPOOL_DEFAULT cube texture.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for D3DPOOL_DEFAULT cube texture.\n", hr);
         hr = IDirect3DDevice9_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for D3DPOOL_MANAGED cube texture.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for D3DPOOL_MANAGED cube texture.\n", hr);
         hr = IDirect3DDevice9_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, NULL);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for D3DPOOL_SYSTEMMEM cube texture.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for D3DPOOL_SYSTEMMEM cube texture.\n", hr);
     }
     hr = IDirect3DDevice9_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_SCRATCH, &texture, NULL);
-    ok(hr == D3D_OK, "Failed to create D3DPOOL_SCRATCH cube texture, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create D3DPOOL_SCRATCH cube texture, hr %#lx.\n", hr);
     IDirect3DCubeTexture9_Release(texture);
 
     test_cube_texture_mipmap_gen(device);
     test_cube_texture_levels(device);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -7780,7 +7771,7 @@ static void test_mipmap_gen(void)
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
                 D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, formats[i]);
         ok((hr == D3D_OK && renderable) || hr == D3DOK_NOAUTOGEN,
-                "Got unexpected hr %#x for %srenderable format %#x.\n",
+                "Got unexpected hr %#lx for %srenderable format %#x.\n",
                 hr, renderable ? "" : "non", formats[i]);
     }
 
@@ -7803,74 +7794,74 @@ static void test_mipmap_gen(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, (D3DUSAGE_RENDERTARGET | D3DUSAGE_AUTOGENMIPMAP),
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     filter_type = IDirect3DTexture9_GetAutoGenFilterType(texture);
     ok(filter_type == D3DTEXF_LINEAR, "Got unexpected filter_type %#x.\n", filter_type);
     hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_NONE);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_ANISOTROPIC);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     filter_type = IDirect3DTexture9_GetAutoGenFilterType(texture);
     ok(filter_type == D3DTEXF_ANISOTROPIC, "Got unexpected filter_type %#x.\n", filter_type);
     hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_LINEAR);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     levels = IDirect3DTexture9_GetLevelCount(texture);
-    ok(levels == 1, "Got unexpected levels %u.\n", levels);
+    ok(levels == 1, "Got unexpected levels %lu.\n", levels);
 
     for (i = 0; i < 6 /* 64 = 2 ^ 6 */; ++i)
     {
         surface = NULL;
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, i, &surface);
-        ok(hr == (i ? D3DERR_INVALIDCALL : D3D_OK), "Got unexpected hr %#x for level %u.\n", hr, i);
+        ok(hr == (i ? D3DERR_INVALIDCALL : D3D_OK), "Got unexpected hr %#lx for level %u.\n", hr, i);
         if (surface)
             IDirect3DSurface9_Release(surface);
 
         hr = IDirect3DTexture9_GetLevelDesc(texture, i, &desc);
-        ok(hr == (i ? D3DERR_INVALIDCALL : D3D_OK), "Got unexpected hr %#x for level %u.\n", hr, i);
+        ok(hr == (i ? D3DERR_INVALIDCALL : D3D_OK), "Got unexpected hr %#lx for level %u.\n", hr, i);
 
         hr = IDirect3DTexture9_LockRect(texture, i, &lr, NULL, 0);
-        ok(hr == (i ? D3DERR_INVALIDCALL : D3D_OK), "Got unexpected hr %#x for level %u.\n", hr, i);
+        ok(hr == (i ? D3DERR_INVALIDCALL : D3D_OK), "Got unexpected hr %#lx for level %u.\n", hr, i);
         if (SUCCEEDED(hr))
         {
             hr = IDirect3DTexture9_UnlockRect(texture, i);
-            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
         }
     }
     IDirect3DTexture9_Release(texture);
 
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 2, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 6, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     levels = IDirect3DTexture9_GetLevelCount(texture);
-    ok(levels == 1, "Got unexpected levels %u.\n", levels);
+    ok(levels == 1, "Got unexpected levels %lu.\n", levels);
     hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(desc.Usage == D3DUSAGE_AUTOGENMIPMAP, "Got unexpected usage %#x.\n", desc.Usage);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(desc.Usage == D3DUSAGE_AUTOGENMIPMAP, "Got unexpected usage %#lx.\n", desc.Usage);
     IDirect3DTexture9_Release(texture);
 
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(formats); ++i)
     {
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8,
                 D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, formats[i]);
-        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
                 D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, formats[i]);
@@ -7880,20 +7871,20 @@ static void test_mipmap_gen(void)
              * D3DOK_NOAUTOGEN cases. */
             hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, D3DUSAGE_AUTOGENMIPMAP,
                     formats[i], D3DPOOL_SYSTEMMEM, &texture, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, D3DUSAGE_AUTOGENMIPMAP,
                     formats[i], D3DPOOL_DEFAULT, &texture, 0);
-            ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
             count = IDirect3DTexture9_GetLevelCount(texture);
             ok(count == 1, "Unexpected level count %u.\n", count);
             hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-            ok(desc.Usage == D3DUSAGE_AUTOGENMIPMAP, "Got unexpected usage %#x.\n", desc.Usage);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+            ok(desc.Usage == D3DUSAGE_AUTOGENMIPMAP, "Got unexpected usage %#lx.\n", desc.Usage);
             filter_type = IDirect3DTexture9_GetAutoGenFilterType(texture);
             ok(filter_type == D3DTEXF_LINEAR, "Got unexpected filter_type %#x.\n", filter_type);
             hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_ANISOTROPIC);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             filter_type = IDirect3DTexture9_GetAutoGenFilterType(texture);
             ok(filter_type == D3DTEXF_ANISOTROPIC, "Got unexpected filter_type %#x.\n", filter_type);
             IDirect3DTexture9_Release(texture);
@@ -7906,22 +7897,22 @@ static void test_mipmap_gen(void)
     {
         hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, 0,
                 D3DFMT_D16, D3DPOOL_DEFAULT, &texture, 0);
-        ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
         count = IDirect3DTexture9_GetLevelCount(texture);
         ok(count == 7, "Unexpected level count %u.\n", count);
         IDirect3DTexture9_Release(texture);
 
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL,
                 D3DFMT_X8R8G8B8, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, D3DFMT_D16);
-        ok(hr == D3DOK_NOAUTOGEN, "Unexpected hr %#x.\n", hr);
+        ok(hr == D3DOK_NOAUTOGEN, "Unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, D3DUSAGE_AUTOGENMIPMAP,
                 D3DFMT_D16, D3DPOOL_DEFAULT, &texture, 0);
-        ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
         count = IDirect3DTexture9_GetLevelCount(texture);
         ok(count == 1, "Unexpected level count %u.\n", count);
         hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(desc.Usage == D3DUSAGE_AUTOGENMIPMAP, "Got unexpected usage %#x.\n", desc.Usage);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(desc.Usage == D3DUSAGE_AUTOGENMIPMAP, "Got unexpected usage %#lx.\n", desc.Usage);
         IDirect3DTexture9_Release(texture);
     }
     else
@@ -7931,10 +7922,10 @@ static void test_mipmap_gen(void)
 
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 64, 64, 64, 0, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, (IDirect3DVolumeTexture9 **)&texture, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8005,50 +7996,50 @@ static void test_filter(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 0, 0,
             D3DFMT_A32B32G32R32F, D3DPOOL_MANAGED, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     /* Needed for ValidateDevice(). */
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         if (tests[i].has_texture)
         {
             hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
         }
 
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, tests[i].magfilter);
-        ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, tests[i].minfilter);
-        ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, tests[i].mipfilter);
-        ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
 
         passes = 0xdeadbeef;
         hr = IDirect3DDevice9_ValidateDevice(device, &passes);
         ok(hr == tests[i].result,
-                "Got unexpected hr %#x, expected %#x (mag %#x, min %#x, mip %#x, has_texture %#x).\n",
+                "Got unexpected hr %#lx, expected %#lx (mag %#lx, min %#lx, mip %#lx, has_texture %#x).\n",
                 hr, tests[i].result, tests[i].magfilter, tests[i].minfilter,
                 tests[i].mipfilter, tests[i].has_texture);
         if (SUCCEEDED(hr))
-            ok(!!passes, "Got unexpected passes %#x.\n", passes);
+            ok(!!passes, "Got unexpected passes %#lx.\n", passes);
         else
-            ok(passes == 0xdeadbeef, "Got unexpected passes %#x.\n", passes);
+            ok(passes == 0xdeadbeef, "Got unexpected passes %#lx.\n", passes);
     }
 
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8076,30 +8067,30 @@ static void test_get_set_texture(void)
 
     texture = (IDirect3DBaseTexture9 *)0xdeadbeef;
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetTexture(device, 0, &texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(!texture, "Got unexpected texture %p.\n", texture);
 
     hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_MANAGED, (IDirect3DTexture9 **)&texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     texture_vtbl = texture->lpVtbl;
     texture->lpVtbl = (IDirect3DBaseTexture9Vtbl *)0xdeadbeef;
     hr = IDirect3DDevice9_SetTexture(device, 0, texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     texture->lpVtbl = NULL;
     hr = IDirect3DDevice9_SetTexture(device, 0, texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     texture->lpVtbl = texture_vtbl;
     IDirect3DBaseTexture9_Release(texture);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8127,23 +8118,23 @@ static void test_lod(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 3, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     /* SetLOD() is only supported on D3DPOOL_MANAGED textures, but doesn't
      * return a HRESULT, so it can't return a normal error. Instead, the call
      * is simply ignored. */
     ret = IDirect3DTexture9_SetLOD(texture, 0);
-    ok(!ret, "Got unexpected ret %u.\n", ret);
+    ok(!ret, "Got unexpected ret %lu.\n", ret);
     ret = IDirect3DTexture9_SetLOD(texture, 1);
-    ok(!ret, "Got unexpected ret %u.\n", ret);
+    ok(!ret, "Got unexpected ret %lu.\n", ret);
     ret = IDirect3DTexture9_SetLOD(texture, 2);
-    ok(!ret, "Got unexpected ret %u.\n", ret);
+    ok(!ret, "Got unexpected ret %lu.\n", ret);
     ret = IDirect3DTexture9_GetLOD(texture);
-    ok(!ret, "Got unexpected ret %u.\n", ret);
+    ok(!ret, "Got unexpected ret %lu.\n", ret);
 
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8172,47 +8163,47 @@ static void test_surface_get_container(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     ok(!!texture, "Got unexpected texture %p.\n", texture);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     ok(!!surface, "Got unexpected surface %p.\n", surface);
 
     /* These should work... */
     container = NULL;
     hr = IDirect3DSurface9_GetContainer(surface, &IID_IUnknown, (void **)&container);
-    ok(SUCCEEDED(hr), "Failed to get surface container, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface container, hr %#lx.\n", hr);
     ok(container == (IUnknown *)texture, "Got unexpected container %p, expected %p.\n", container, texture);
     IUnknown_Release(container);
 
     container = NULL;
     hr = IDirect3DSurface9_GetContainer(surface, &IID_IDirect3DResource9, (void **)&container);
-    ok(SUCCEEDED(hr), "Failed to get surface container, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface container, hr %#lx.\n", hr);
     ok(container == (IUnknown *)texture, "Got unexpected container %p, expected %p.\n", container, texture);
     IUnknown_Release(container);
 
     container = NULL;
     hr = IDirect3DSurface9_GetContainer(surface, &IID_IDirect3DBaseTexture9, (void **)&container);
-    ok(SUCCEEDED(hr), "Failed to get surface container, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface container, hr %#lx.\n", hr);
     ok(container == (IUnknown *)texture, "Got unexpected container %p, expected %p.\n", container, texture);
     IUnknown_Release(container);
 
     container = NULL;
     hr = IDirect3DSurface9_GetContainer(surface, &IID_IDirect3DTexture9, (void **)&container);
-    ok(SUCCEEDED(hr), "Failed to get surface container, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface container, hr %#lx.\n", hr);
     ok(container == (IUnknown *)texture, "Got unexpected container %p, expected %p.\n", container, texture);
     IUnknown_Release(container);
 
     /* ...and this one shouldn't. This should return E_NOINTERFACE and set container to NULL. */
     hr = IDirect3DSurface9_GetContainer(surface, &IID_IDirect3DSurface9, (void **)&container);
-    ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
     ok(!container, "Got unexpected container %p.\n", container);
 
     IDirect3DSurface9_Release(surface);
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8242,16 +8233,16 @@ static void test_surface_alignment(void)
     /* Test a sysmem surface because those aren't affected by the hardware's np2 restrictions. */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 5, 5,
             D3DFMT_R5G6B5, D3DPOOL_SYSTEMMEM, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(!(lr.Pitch & 3), "Got misaligned pitch %d.\n", lr.Pitch);
     /* Some applications also depend on the exact pitch, rather than just the
      * alignment. */
     ok(lr.Pitch == 12, "Got unexpected pitch %d.\n", lr.Pitch);
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     for (i = 0; i < 5; ++i)
@@ -8263,7 +8254,7 @@ static void test_surface_alignment(void)
 
         hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, 0,
                 MAKEFOURCC('D', 'X', 'T', '1' + i), D3DPOOL_MANAGED, &texture, NULL);
-        ok(SUCCEEDED(hr) || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(SUCCEEDED(hr) || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         if (FAILED(hr))
         {
             skip("DXT%u surfaces are not supported, skipping tests.\n", i + 1);
@@ -8275,9 +8266,9 @@ static void test_surface_alignment(void)
         {
             IDirect3DTexture9_GetLevelDesc(texture, j, &desc);
             hr = IDirect3DTexture9_LockRect(texture, j, &lr, NULL, 0);
-            ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
             hr = IDirect3DTexture9_UnlockRect(texture, j);
-            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
             expected_pitch = ((desc.Width + 3) >> 2) << 3;
             if (i > 0)
@@ -8289,7 +8280,7 @@ static void test_surface_alignment(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8351,10 +8342,10 @@ static void test_lockrect_offset(void)
 
         hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
                 dxt_formats[i].format, D3DPOOL_SCRATCH, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
         base = locked_rect.pBits;
         expected_pitch = (128 + dxt_formats[i].block_height - 1) / dxt_formats[i].block_width
@@ -8363,10 +8354,10 @@ static void test_lockrect_offset(void)
                 locked_rect.Pitch, dxt_formats[i].name, expected_pitch);
 
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &rect, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
         offset = (BYTE *)locked_rect.pBits - base;
         expected_offset = (rect.top / dxt_formats[i].block_height) * expected_pitch
@@ -8375,13 +8366,13 @@ static void test_lockrect_offset(void)
                 offset, dxt_formats[i].name, expected_offset);
 
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         IDirect3DSurface9_Release(surface);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8458,28 +8449,28 @@ static void test_lockrect_invalid(void)
             case D3DRTYPE_SURFACE:
                 hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
                         D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL);
-                ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, type %s.\n",
+                ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, type %s.\n",
                         hr, resources[r].name);
                 break;
 
             case D3DRTYPE_TEXTURE:
                 hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
                         resources[r].pool, &texture, NULL);
-                ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, type %s.\n",
+                ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, type %s.\n",
                         hr, resources[r].name);
                 hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-                ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x, type %s.\n",
+                ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx, type %s.\n",
                         hr, resources[r].name);
                 break;
 
             case D3DRTYPE_CUBETEXTURE:
                 hr = IDirect3DDevice9_CreateCubeTexture(device, 128, 1, 0, D3DFMT_A8R8G8B8,
                         resources[r].pool, &cube_texture, NULL);
-                ok(SUCCEEDED(hr), "Failed to create cube texture, hr %#x, type %s.\n",
+                ok(SUCCEEDED(hr), "Failed to create cube texture, hr %#lx, type %s.\n",
                         hr, resources[r].name);
                 hr = IDirect3DCubeTexture9_GetCubeMapSurface(cube_texture,
                         D3DCUBEMAP_FACE_NEGATIVE_X, 0, &surface);
-                ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x, type %s.\n",
+                ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx, type %s.\n",
                         hr, resources[r].name);
                 break;
 
@@ -8488,13 +8479,13 @@ static void test_lockrect_invalid(void)
         }
 
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, type %s.\n", hr, resources[r].name);
         base = locked_rect.pBits;
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
         expected_hr = resources[r].type == D3DRTYPE_TEXTURE ? D3D_OK : D3DERR_INVALIDCALL;
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(hr == expected_hr, "Got hr %#x, expected %#x, type %s.\n", hr, expected_hr, resources[r].name);
+        ok(hr == expected_hr, "Got hr %#lx, expected %#lx, type %s.\n", hr, expected_hr, resources[r].name);
 
         for (i = 0; i < ARRAY_SIZE(test_data); ++i)
         {
@@ -8509,7 +8500,7 @@ static void test_lockrect_invalid(void)
              * them. Some games (C&C3) depend on the XP behavior, mark the Win 7
              * one broken. */
             ok(SUCCEEDED(hr) || broken(hr == test_data[i].win7_result),
-                    "Failed to lock surface with rect %s, hr %#x, type %s.\n",
+                    "Failed to lock surface with rect %s, hr %#lx, type %s.\n",
                     wine_dbgstr_rect(rect), hr, resources[r].name);
             if (FAILED(hr))
                 continue;
@@ -8521,13 +8512,13 @@ static void test_lockrect_invalid(void)
                     offset, expected_offset, wine_dbgstr_rect(rect), resources[r].name);
 
             hr = IDirect3DSurface9_UnlockRect(surface);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
             if (texture)
             {
                 hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, rect, 0);
                 ok(SUCCEEDED(hr),
-                        "Failed to lock texture with rect %s, hr %#x, type %s.\n",
+                        "Failed to lock texture with rect %s, hr %#lx, type %s.\n",
                         wine_dbgstr_rect(rect), hr, resources[r].name);
                 if (FAILED(hr))
                     continue;
@@ -8539,14 +8530,14 @@ static void test_lockrect_invalid(void)
                         offset, expected_offset, wine_dbgstr_rect(rect), resources[r].name);
 
                 hr = IDirect3DTexture9_UnlockRect(texture, 0);
-                ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx, type %s.\n", hr, resources[r].name);
             }
             if (cube_texture)
             {
                 hr = IDirect3DCubeTexture9_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                         &locked_rect, rect, 0);
                 ok(SUCCEEDED(hr),
-                        "Failed to lock texture with rect %s, hr %#x, type %s.\n",
+                        "Failed to lock texture with rect %s, hr %#lx, type %s.\n",
                         wine_dbgstr_rect(rect), hr, resources[r].name);
                 if (FAILED(hr))
                     continue;
@@ -8558,124 +8549,124 @@ static void test_lockrect_invalid(void)
                         offset, expected_offset, wine_dbgstr_rect(rect), resources[r].name);
 
                 hr = IDirect3DCubeTexture9_UnlockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0);
-                ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx, type %s.\n", hr, resources[r].name);
             }
         }
 
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface with rect NULL, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to lock surface with rect NULL, hr %#lx, type %s.\n", hr, resources[r].name);
         locked_rect.pBits = (BYTE *)0xdeadbeef;
         locked_rect.Pitch = 1;
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
         ok(locked_rect.pBits == (BYTE *)0xdeadbeef, "Got unexpected pBits: %p, type %s.\n",
                 locked_rect.pBits, resources[r].name);
         ok(locked_rect.Pitch == 1, "Got unexpected pitch %d, type %s.\n",
                 locked_rect.Pitch, resources[r].name);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &test_data[0].rect, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x for rect %s, type %s.\n",
+        ok(hr == D3D_OK, "Got unexpected hr %#lx for rect %s, type %s.\n",
                 hr, wine_dbgstr_rect(&test_data[0].rect), resources[r].name);
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &test_data[0].rect, 0);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for rect %s, type %s.\n",
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for rect %s, type %s.\n",
                 hr, wine_dbgstr_rect(&test_data[0].rect), resources[r].name);
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &test_rect_2, 0);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for rect %s, type %s.\n",
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for rect %s, type %s.\n",
                 hr, wine_dbgstr_rect(&test_rect_2), resources[r].name);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         IDirect3DSurface9_Release(surface);
 
         if (texture)
         {
             hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-            ok(SUCCEEDED(hr), "Failed to lock texture with rect NULL, hr %#x, type %s.\n",
+            ok(SUCCEEDED(hr), "Failed to lock texture with rect NULL, hr %#lx, type %s.\n",
                     hr, resources[r].name);
             locked_rect.pBits = (BYTE *)0xdeadbeef;
             locked_rect.Pitch = 1;
             hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
             ok(locked_rect.pBits == (BYTE *)0xdeadbeef, "Got unexpected pBits: %p, type %s.\n",
                     locked_rect.pBits, resources[r].name);
             ok(locked_rect.Pitch == 1, "Got unexpected pitch %d, type %s.\n",
                     locked_rect.Pitch, resources[r].name);
             hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
             hr = IDirect3DTexture9_UnlockRect(texture, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx, type %s.\n", hr, resources[r].name);
             hr = IDirect3DTexture9_UnlockRect(texture, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
 
             hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, &test_data[0].rect, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x for rect %s, type %s.\n",
+            ok(hr == D3D_OK, "Got unexpected hr %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(&test_data[0].rect), resources[r].name);
             hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, &test_data[0].rect, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for rect %s, type %s.\n",
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(&test_data[0].rect), resources[r].name);
             hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, &test_rect_2, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for rect %s, type %s.\n",
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(&test_rect_2), resources[r].name);
             hr = IDirect3DTexture9_UnlockRect(texture, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx, type %s.\n", hr, resources[r].name);
 
             IDirect3DTexture9_Release(texture);
 
             hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_WRITEONLY,
                     D3DFMT_A8R8G8B8, resources[r].pool, &texture, NULL);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for type %s.\n",
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for type %s.\n",
                     hr, resources[r].name);
         }
         if (cube_texture)
         {
             hr = IDirect3DCubeTexture9_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                     &locked_rect, NULL, 0);
-            ok(SUCCEEDED(hr), "Failed to lock texture with rect NULL, hr %#x, type %s.\n",
+            ok(SUCCEEDED(hr), "Failed to lock texture with rect NULL, hr %#lx, type %s.\n",
                     hr, resources[r].name);
             locked_rect.pBits = (BYTE *)0xdeadbeef;
             locked_rect.Pitch = 1;
             hr = IDirect3DCubeTexture9_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                     &locked_rect, NULL, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
             ok(locked_rect.pBits == (BYTE *)0xdeadbeef, "Got unexpected pBits: %p, type %s.\n",
                     locked_rect.pBits, resources[r].name);
             ok(locked_rect.Pitch == 1, "Got unexpected pitch %d, type %s.\n",
                     locked_rect.Pitch, resources[r].name);
             hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
             hr = IDirect3DCubeTexture9_UnlockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx, type %s.\n", hr, resources[r].name);
             hr = IDirect3DCubeTexture9_UnlockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0);
-            todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
 
             hr = IDirect3DCubeTexture9_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                     &locked_rect, &test_data[0].rect, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x for rect %s, type %s.\n",
+            ok(hr == D3D_OK, "Got unexpected hr %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(&test_data[0].rect), resources[r].name);
             hr = IDirect3DCubeTexture9_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                     &locked_rect, &test_data[0].rect, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for rect %s, type %s.\n",
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(&test_data[0].rect), resources[r].name);
             hr = IDirect3DCubeTexture9_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                     &locked_rect, &test_rect_2, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for rect %s, type %s.\n",
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(&test_rect_2), resources[r].name);
             hr = IDirect3DCubeTexture9_UnlockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx, type %s.\n", hr, resources[r].name);
 
             IDirect3DCubeTexture9_Release(cube_texture);
 
             hr = IDirect3DDevice9_CreateCubeTexture(device, 128, 1, D3DUSAGE_WRITEONLY, D3DFMT_A8R8G8B8,
                     resources[r].pool, &cube_texture, NULL);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for type %s.\n",
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for type %s.\n",
                     hr, resources[r].name);
         }
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8713,64 +8704,64 @@ static void test_private_data(void)
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 4,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             device, 0, D3DSPD_IUNKNOWN);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             device, 5, D3DSPD_IUNKNOWN);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             device, sizeof(IUnknown *) * 2, D3DSPD_IUNKNOWN);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     /* A failing SetPrivateData call does not clear the old data with the same tag. */
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid, device,
             sizeof(device), D3DSPD_IUNKNOWN);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid, device,
             sizeof(device) * 2, D3DSPD_IUNKNOWN);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     size = sizeof(ptr);
     hr = IDirect3DSurface9_GetPrivateData(surface, &d3d9_private_data_test_guid, &ptr, &size);
-    ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get private data, hr %#lx.\n", hr);
     IUnknown_Release(ptr);
     hr = IDirect3DSurface9_FreePrivateData(surface, &d3d9_private_data_test_guid);
-    ok(SUCCEEDED(hr), "Failed to free private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to free private data, hr %#lx.\n", hr);
 
     refcount = get_refcount((IUnknown *)device);
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             device, sizeof(IUnknown *), D3DSPD_IUNKNOWN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     expected_refcount = refcount + 1;
     refcount = get_refcount((IUnknown *)device);
-    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ok(refcount == expected_refcount, "Got unexpected refcount %lu, expected %lu.\n", refcount, expected_refcount);
     hr = IDirect3DSurface9_FreePrivateData(surface, &d3d9_private_data_test_guid);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     expected_refcount = refcount - 1;
     refcount = get_refcount((IUnknown *)device);
-    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ok(refcount == expected_refcount, "Got unexpected refcount %lu, expected %lu.\n", refcount, expected_refcount);
 
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             device, sizeof(IUnknown *), D3DSPD_IUNKNOWN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             surface, sizeof(IUnknown *), D3DSPD_IUNKNOWN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)device);
-    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ok(refcount == expected_refcount, "Got unexpected refcount %lu, expected %lu.\n", refcount, expected_refcount);
 
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid,
             device, sizeof(IUnknown *), D3DSPD_IUNKNOWN);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     size = 2 * sizeof(ptr);
     hr = IDirect3DSurface9_GetPrivateData(surface, &d3d9_private_data_test_guid, &ptr, &size);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(size == sizeof(device), "Got unexpected size %u.\n", size);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(size == sizeof(device), "Got unexpected size %lu.\n", size);
     expected_refcount = refcount + 2;
     refcount = get_refcount((IUnknown *)device);
-    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ok(refcount == expected_refcount, "Got unexpected refcount %lu, expected %lu.\n", refcount, expected_refcount);
     ok(ptr == (IUnknown *)device, "Got unexpected ptr %p, expected %p.\n", ptr, device);
     IUnknown_Release(ptr);
     expected_refcount--;
@@ -8778,26 +8769,26 @@ static void test_private_data(void)
     ptr = (IUnknown *)0xdeadbeef;
     size = 1;
     hr = IDirect3DSurface9_GetPrivateData(surface, &d3d9_private_data_test_guid, NULL, &size);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(size == sizeof(device), "Got unexpected size %u.\n", size);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(size == sizeof(device), "Got unexpected size %lu.\n", size);
     size = 2 * sizeof(ptr);
     hr = IDirect3DSurface9_GetPrivateData(surface, &d3d9_private_data_test_guid, NULL, &size);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(size == sizeof(device), "Got unexpected size %u.\n", size);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(size == sizeof(device), "Got unexpected size %lu.\n", size);
     refcount = get_refcount((IUnknown *)device);
-    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ok(refcount == expected_refcount, "Got unexpected refcount %lu, expected %lu.\n", refcount, expected_refcount);
     size = 1;
     hr = IDirect3DSurface9_GetPrivateData(surface, &d3d9_private_data_test_guid, &ptr, &size);
-    ok(hr == D3DERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
-    ok(size == sizeof(device), "Got unexpected size %u.\n", size);
+    ok(hr == D3DERR_MOREDATA, "Got unexpected hr %#lx.\n", hr);
+    ok(size == sizeof(device), "Got unexpected size %lu.\n", size);
     ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
     hr = IDirect3DSurface9_GetPrivateData(surface, &d3d9_private_data_test_guid2, NULL, NULL);
-    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     size = 0xdeadbabe;
     hr = IDirect3DSurface9_GetPrivateData(surface, &d3d9_private_data_test_guid2, &ptr, &size);
-    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
-    ok(size == 0xdeadbabe, "Got unexpected size %u.\n", size);
+    ok(size == 0xdeadbabe, "Got unexpected size %lu.\n", size);
     /* GetPrivateData with size = NULL causes an access violation on Windows if the
      * requested data exists. */
 
@@ -8805,45 +8796,45 @@ static void test_private_data(void)
     IDirect3DSurface9_Release(surface);
     expected_refcount = refcount - 2;
     refcount = get_refcount((IUnknown *)device);
-    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ok(refcount == expected_refcount, "Got unexpected refcount %lu, expected %lu.\n", refcount, expected_refcount);
 
     hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 2, 0, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH,
             &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get texture level 0, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture level 0, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 1, &surface2);
-    ok(SUCCEEDED(hr), "Failed to get texture level 1, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture level 1, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_SetPrivateData(texture, &d3d9_private_data_test_guid, data, sizeof(data), 0);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
 
     memset(data, 0, sizeof(data));
     size = sizeof(data);
     hr = IDirect3DSurface9_GetPrivateData(surface, &d3d9_private_data_test_guid, data, &size);
-    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetPrivateData(texture, &d3d9_private_data_test_guid, data, &size);
-    ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get private data, hr %#lx.\n", hr);
     ok(data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4,
-            "Got unexpected private data: %u, %u, %u, %u.\n", data[0], data[1], data[2], data[3]);
+            "Got unexpected private data: %lu, %lu, %lu, %lu.\n", data[0], data[1], data[2], data[3]);
 
     hr = IDirect3DTexture9_FreePrivateData(texture, &d3d9_private_data_test_guid);
-    ok(SUCCEEDED(hr), "Failed to free private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to free private data, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_SetPrivateData(surface, &d3d9_private_data_test_guid, data, sizeof(data), 0);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetPrivateData(surface2, &d3d9_private_data_test_guid, data, &size);
-    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_FreePrivateData(surface, &d3d9_private_data_test_guid);
-    ok(SUCCEEDED(hr), "Failed to free private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to free private data, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface2);
     IDirect3DSurface9_Release(surface);
     IDirect3DTexture9_Release(texture);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -8916,19 +8907,19 @@ static void test_getdc(void)
                     testdata[i].format, D3DPOOL_MANAGED, &texture, NULL);
             if (FAILED(hr))
             {
-                skip("Failed to create surface for format %s (hr %#x), skipping tests.\n", testdata[i].name, hr);
+                skip("Failed to create surface for format %s (hr %#lx), skipping tests.\n", testdata[i].name, hr);
                 continue;
             }
             hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-            ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
         }
 
         dc = (void *)0x1234;
         hr = IDirect3DSurface9_GetDC(surface, &dc);
         if (testdata[i].getdc_supported)
-            ok(SUCCEEDED(hr), "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+            ok(SUCCEEDED(hr), "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         else
-            ok(FAILED(hr), "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+            ok(FAILED(hr), "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -8939,10 +8930,10 @@ static void test_getdc(void)
             int size;
 
             type = GetObjectType(dc);
-            ok(type == OBJ_MEMDC, "Got unexpected object type %#x for format %s.\n", type, testdata[i].name);
+            ok(type == OBJ_MEMDC, "Got unexpected object type %#lx for format %s.\n", type, testdata[i].name);
             bitmap = GetCurrentObject(dc, OBJ_BITMAP);
             type = GetObjectType(bitmap);
-            ok(type == OBJ_BITMAP, "Got unexpected object type %#x for format %s.\n", type, testdata[i].name);
+            ok(type == OBJ_BITMAP, "Got unexpected object type %#lx for format %s.\n", type, testdata[i].name);
 
             size = GetObjectA(bitmap, sizeof(dib), &dib);
             ok(size == sizeof(dib), "Got unexpected size %d for format %s.\n", size, testdata[i].name);
@@ -8963,48 +8954,48 @@ static void test_getdc(void)
             ok(!!dib.dsBm.bmBits, "Got unexpected bits %p for format %s.\n",
                     dib.dsBm.bmBits, testdata[i].name);
 
-            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %u for format %s.\n",
+            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %lu for format %s.\n",
                     dib.dsBmih.biSize, testdata[i].name);
-            ok(dib.dsBmih.biWidth == 64, "Got unexpected width %d for format %s.\n",
+            ok(dib.dsBmih.biWidth == 64, "Got unexpected width %ld for format %s.\n",
                     dib.dsBmih.biHeight, testdata[i].name);
-            ok(dib.dsBmih.biHeight == 64, "Got unexpected height %d for format %s.\n",
+            ok(dib.dsBmih.biHeight == 64, "Got unexpected height %ld for format %s.\n",
                     dib.dsBmih.biHeight, testdata[i].name);
             ok(dib.dsBmih.biPlanes == 1, "Got unexpected plane count %u for format %s.\n",
                     dib.dsBmih.biPlanes, testdata[i].name);
             ok(dib.dsBmih.biBitCount == testdata[i].bit_count, "Got unexpected bit count %u for format %s.\n",
                     dib.dsBmih.biBitCount, testdata[i].name);
             ok(dib.dsBmih.biCompression == (testdata[i].bit_count == 16 ? BI_BITFIELDS : BI_RGB),
-                    "Got unexpected compression %#x for format %s.\n",
+                    "Got unexpected compression %#lx for format %s.\n",
                     dib.dsBmih.biCompression, testdata[i].name);
-            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %u for format %s.\n",
+            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %lu for format %s.\n",
                     dib.dsBmih.biSizeImage, testdata[i].name);
-            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %ld for format %s.\n",
                     dib.dsBmih.biXPelsPerMeter, testdata[i].name);
-            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %ld for format %s.\n",
                     dib.dsBmih.biYPelsPerMeter, testdata[i].name);
-            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %lu for format %s.\n",
                     dib.dsBmih.biClrUsed, testdata[i].name);
-            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %lu for format %s.\n",
                     dib.dsBmih.biClrImportant, testdata[i].name);
 
             if (dib.dsBmih.biCompression == BI_BITFIELDS)
             {
                 ok(dib.dsBitfields[0] == testdata[i].mask_r && dib.dsBitfields[1] == testdata[i].mask_g
                         && dib.dsBitfields[2] == testdata[i].mask_b,
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], testdata[i].name);
             }
             else
             {
                 ok(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2],
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], testdata[i].name);
             }
             ok(!dib.dshSection, "Got unexpected section %p for format %s.\n", dib.dshSection, testdata[i].name);
-            ok(!dib.dsOffset, "Got unexpected offset %u for format %s.\n", dib.dsOffset, testdata[i].name);
+            ok(!dib.dsOffset, "Got unexpected offset %lu for format %s.\n", dib.dsOffset, testdata[i].name);
 
             hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-            ok(hr == D3D_OK, "Failed to release DC, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Failed to release DC, hr %#lx.\n", hr);
         }
         else
         {
@@ -9021,142 +9012,142 @@ static void test_getdc(void)
         if (FAILED(hr = IDirect3DDevice9_CreateCubeTexture(device, 64, 0, 0,
                 testdata[i].format, D3DPOOL_MANAGED, &cube_texture, NULL)))
         {
-            skip("Failed to create cube texture for format %s (hr %#x), skipping tests.\n", testdata[i].name, hr);
+            skip("Failed to create cube texture for format %s (hr %#lx), skipping tests.\n", testdata[i].name, hr);
             continue;
         }
 
         hr = IDirect3DCubeTexture9_GetCubeMapSurface(cube_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
-        ok(SUCCEEDED(hr), "Failed to get cube surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get cube surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DCubeTexture9_GetCubeMapSurface(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_Y, 2, &surface2);
-        ok(SUCCEEDED(hr), "Failed to get cube surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get cube surface for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         dc2 = (void *)0x1234;
         hr = IDirect3DSurface9_GetDC(surface, &dc2);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         ok(dc2 == (void *)0x1234, "Got unexpected dc %p for format %s.\n", dc, testdata[i].name);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
 
         hr = IDirect3DSurface9_LockRect(surface, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_LockRect(surface, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
 
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_LockRect(surface, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_LockRect(surface, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_GetDC(surface2, &dc2);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_ReleaseDC(surface2, dc2);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_GetDC(surface, &dc2);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc2);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_LockRect(surface, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_LockRect(surface2, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_UnlockRect(surface2);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_LockRect(surface, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_LockRect(surface2, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_UnlockRect(surface2);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_LockRect(surface2, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_UnlockRect(surface2);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_LockRect(surface, &map_desc, NULL, D3DLOCK_READONLY);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
 
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
 
         hr = IDirect3DSurface9_UnlockRect(surface2);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
         hr = IDirect3DSurface9_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_UnlockRect(surface2);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", testdata[i].name, hr);
         hr = IDirect3DSurface9_UnlockRect(surface2);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for format %s.\n", hr, testdata[i].name);
 
         IDirect3DSurface9_Release(surface2);
         IDirect3DSurface9_Release(surface);
@@ -9164,7 +9155,7 @@ static void test_getdc(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     /* Backbuffer created with D3DFMT_UNKNOWN format. */
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
@@ -9177,19 +9168,19 @@ static void test_getdc(void)
     ok(!!device, "Failed to create device.\n");
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
-    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
 
     dc = NULL;
     hr = IDirect3DSurface9_GetDC(surface, &dc);
     ok(!!dc, "Unexpected DC returned.\n");
-    ok(SUCCEEDED(hr), "Failed to get backbuffer DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer DC, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release backbuffer DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release backbuffer DC, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -9217,13 +9208,13 @@ static void test_surface_dimensions(void)
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 0, 1,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 1, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -9265,65 +9256,65 @@ static void test_surface_format_null(void)
 
     hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, D3DFMT_NULL);
-    ok(hr == D3D_OK, "D3DFMT_NULL should be supported for render target textures, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "D3DFMT_NULL should be supported for render target textures, hr %#lx.\n", hr);
 
     hr = IDirect3D9_CheckDepthStencilMatch(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             D3DFMT_NULL, D3DFMT_D24S8);
-    ok(SUCCEEDED(hr), "Depth stencil match failed for D3DFMT_NULL, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Depth stencil match failed for D3DFMT_NULL, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128, D3DFMT_NULL,
             D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
-    ok(SUCCEEDED(hr), "Failed to get original render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get original render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds);
-    ok(SUCCEEDED(hr), "Failed to get original depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get original depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, NULL);
     ok(FAILED(hr), "Succeeded in setting render target 0 to NULL, should fail.\n");
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00000000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(rt);
     IDirect3DSurface9_Release(ds);
 
     hr = IDirect3DSurface9_GetDesc(surface, &desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(desc.Width == 128, "Expected width 128, got %u.\n", desc.Width);
     ok(desc.Height == 128, "Expected height 128, got %u.\n", desc.Height);
 
     hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(locked_rect.Pitch, "Expected non-zero pitch, got %u.\n", locked_rect.Pitch);
     ok(!!locked_rect.pBits, "Expected non-NULL pBits, got %p.\n", locked_rect.pBits);
 
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 0, D3DUSAGE_RENDERTARGET,
             D3DFMT_NULL, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -9361,27 +9352,27 @@ static void test_surface_double_unlock(void)
     {
         hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64,
                 D3DFMT_X8R8G8B8, pools[i], &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface in pool %#x, hr %#x.\n", pools[i], hr);
+        ok(SUCCEEDED(hr), "Failed to create surface in pool %#x, hr %#lx.\n", pools[i], hr);
 
         hr = IDirect3DSurface9_GetDesc(surface, &desc);
-        ok(hr == D3D_OK, "Pool %#x: Got unexpected hr %#x.\n", pools[i], hr);
-        ok(!desc.Usage, "Pool %#x: Got unexpected usage %#x.\n", pools[i], desc.Usage);
+        ok(hr == D3D_OK, "Pool %#x: Got unexpected hr %#lx.\n", pools[i], hr);
+        ok(!desc.Usage, "Pool %#x: Got unexpected usage %#lx.\n", pools[i], desc.Usage);
         ok(desc.Pool == pools[i], "Pool %#x: Got unexpected pool %#x.\n", pools[i], desc.Pool);
 
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, for surface in pool %#x.\n", hr, pools[i]);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, for surface in pool %#x.\n", hr, pools[i]);
         hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface in pool %#x, hr %#x.\n", pools[i], hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface in pool %#x, hr %#lx.\n", pools[i], hr);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface in pool %#x, hr %#x.\n", pools[i], hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface in pool %#x, hr %#lx.\n", pools[i], hr);
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, for surface in pool %#x.\n", hr, pools[i]);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, for surface in pool %#x.\n", hr, pools[i]);
 
         IDirect3DSurface9_Release(surface);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -9494,7 +9485,7 @@ static void test_surface_blocks(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     tex_pow2 = !!(caps.TextureCaps & D3DPTEXTURECAPS_POW2);
     if (tex_pow2)
         tex_pow2 = !(caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL);
@@ -9612,7 +9603,7 @@ static void test_surface_blocks(void)
                         may_succeed = TRUE;
 
                     ok(hr == expect_hr || ((SUCCEEDED(hr) && may_succeed)),
-                            "Got unexpected hr %#x for format %s, pool %s, type %s, size %ux%u.\n",
+                            "Got unexpected hr %#lx for format %s, pool %s, type %s, size %ux%u.\n",
                             hr, formats[i].name, create_tests[j].pool_name, create_tests[j].type_name, w, h);
                     if (FAILED(hr))
                         ok(*check_null == NULL, "Got object ptr %p, expected NULL.\n", *check_null);
@@ -9650,16 +9641,16 @@ static void test_surface_blocks(void)
                     {
                         hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
                                 formats[i].fmt, pools[j].pool, &surface, NULL);
-                        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+                        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
                     }
                     else
                     {
                         hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1,
                                 pools[j].pool == D3DPOOL_DEFAULT ? D3DUSAGE_DYNAMIC : 0,
                                 formats[i].fmt, pools[j].pool, &texture, NULL);
-                        ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+                        ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
                         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-                        ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+                        ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
                         IDirect3DTexture9_Release(texture);
                     }
                     break;
@@ -9667,7 +9658,7 @@ static void test_surface_blocks(void)
                 case D3DPOOL_SCRATCH:
                     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
                             formats[i].fmt, pools[j].pool, &surface, NULL);
-                    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
                     break;
 
                 default:
@@ -9685,7 +9676,7 @@ static void test_surface_blocks(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface9_UnlockRect(surface);
-                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
                 }
 
                 SetRect(&rect, 0, 0, formats[i].block_width >> 1, formats[i].block_height);
@@ -9697,7 +9688,7 @@ static void test_surface_blocks(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface9_UnlockRect(surface);
-                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
                 }
             }
 
@@ -9712,7 +9703,7 @@ static void test_surface_blocks(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface9_UnlockRect(surface);
-                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
                 }
 
                 SetRect(&rect, 0, 0, formats[i].block_width, formats[i].block_height >> 1);
@@ -9724,28 +9715,28 @@ static void test_surface_blocks(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface9_UnlockRect(surface);
-                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
                 }
             }
 
             for (k = 0; k < ARRAY_SIZE(invalid); ++k)
             {
                 hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &invalid[k], 0);
-                ok(FAILED(hr) == !pools[j].success, "Invalid lock %s(%#x), expected %s, format %s, pool %s, case %u.\n",
+                ok(FAILED(hr) == !pools[j].success, "Invalid lock %s(%#lx), expected %s, format %s, pool %s, case %u.\n",
                         SUCCEEDED(hr) ? "succeeded" : "failed", hr, pools[j].success ? "success" : "failure",
                         formats[i].name, pools[j].name, k);
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface9_UnlockRect(surface);
-                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
                 }
             }
 
             SetRect(&rect, 0, 0, formats[i].block_width, formats[i].block_height);
             hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &rect, 0);
-            ok(SUCCEEDED(hr), "Got unexpected hr %#x for format %s, pool %s.\n", hr, formats[i].name, pools[j].name);
+            ok(SUCCEEDED(hr), "Got unexpected hr %#lx for format %s, pool %s.\n", hr, formats[i].name, pools[j].name);
             hr = IDirect3DSurface9_UnlockRect(surface);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
             IDirect3DSurface9_Release(surface);
         }
@@ -9763,23 +9754,23 @@ static void test_surface_blocks(void)
 
         hr = IDirect3DDevice9_CreateTexture(device, formats[i].block_width, formats[i].block_height, 2,
                 D3DUSAGE_DYNAMIC, formats[i].fmt, D3DPOOL_DEFAULT, &texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, format %s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, format %s.\n", hr, formats[i].name);
 
         hr = IDirect3DTexture9_LockRect(texture, 1, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed lock texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed lock texture, hr %#lx.\n", hr);
         hr = IDirect3DTexture9_UnlockRect(texture, 1);
-        ok(SUCCEEDED(hr), "Failed lock texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed lock texture, hr %#lx.\n", hr);
 
         SetRect(&rect, 0, 0, formats[i].block_width == 1 ? 1 : formats[i].block_width >> 1,
                 formats[i].block_height == 1 ? 1 : formats[i].block_height >> 1);
         hr = IDirect3DTexture9_LockRect(texture, 1, &locked_rect, &rect, 0);
-        ok(SUCCEEDED(hr), "Failed lock texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed lock texture, hr %#lx.\n", hr);
         hr = IDirect3DTexture9_UnlockRect(texture, 1);
-        ok(SUCCEEDED(hr), "Failed lock texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed lock texture, hr %#lx.\n", hr);
 
         SetRect(&rect, 0, 0, formats[i].block_width, formats[i].block_height);
         hr = IDirect3DTexture9_LockRect(texture, 1, &locked_rect, &rect, 0);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         if (SUCCEEDED(hr))
             IDirect3DTexture9_UnlockRect(texture, 1);
 
@@ -9787,7 +9778,7 @@ static void test_surface_blocks(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -9796,7 +9787,7 @@ static void test_set_palette(void)
 {
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d9;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     HRESULT hr;
     PALETTEENTRY pal[256];
@@ -9821,10 +9812,10 @@ static void test_set_palette(void)
         pal[i].peFlags = 0xff;
     }
     hr = IDirect3DDevice9_SetPaletteEntries(device, 0, pal);
-    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     for (i = 0; i < ARRAY_SIZE(pal); i++)
     {
         pal[i].peRed = i;
@@ -9835,16 +9826,16 @@ static void test_set_palette(void)
     if (caps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE)
     {
         hr = IDirect3DDevice9_SetPaletteEntries(device, 0, pal);
-        ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#lx.\n", hr);
     }
     else
     {
         hr = IDirect3DDevice9_SetPaletteEntries(device, 0, pal);
-        ok(hr == D3DERR_INVALIDCALL, "SetPaletteEntries returned %#x, expected D3DERR_INVALIDCALL.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -9873,7 +9864,7 @@ static void test_pinned_buffers(void)
     struct vec3 *ptr, *ptr2;
     unsigned int i, test;
     IDirect3D9 *d3d;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     HRESULT hr;
 
@@ -9896,14 +9887,14 @@ static void test_pinned_buffers(void)
 
         hr = IDirect3DDevice9_CreateVertexBuffer(device, vertex_count * sizeof(*ptr),
                 tests[test].usage, 0, tests[test].pool, &buffer, NULL);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DVertexBuffer9_GetDesc(buffer, &desc);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         ok(desc.Pool == tests[test].pool, "Test %u: got unexpected pool %#x.\n", test, desc.Pool);
-        ok(desc.Usage == tests[test].usage, "Test %u: got unexpected usage %#x.\n", test, desc.Usage);
+        ok(desc.Usage == tests[test].usage, "Test %u: got unexpected usage %#lx.\n", test, desc.Usage);
 
         hr = IDirect3DVertexBuffer9_Lock(buffer, 0, vertex_count * sizeof(*ptr), (void **)&ptr, D3DLOCK_DISCARD);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         for (i = 0; i < vertex_count; ++i)
         {
             ptr[i].x = i * 1.0f;
@@ -9911,21 +9902,21 @@ static void test_pinned_buffers(void)
             ptr[i].z = i * 3.0f;
         }
         hr = IDirect3DVertexBuffer9_Unlock(buffer);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
 
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(*ptr));
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
 
         hr = IDirect3DVertexBuffer9_Lock(buffer, 0, vertex_count * sizeof(*ptr2), (void **)&ptr2, D3DLOCK_DISCARD);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
         ok(ptr2 == ptr, "Test %u: got unexpected ptr2 %p, expected %p.\n", test, ptr2, ptr);
         for (i = 0; i < vertex_count; ++i)
         {
@@ -9937,11 +9928,11 @@ static void test_pinned_buffers(void)
             }
         }
         hr = IDirect3DVertexBuffer9_Unlock(buffer);
-        ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", test, hr);
+        ok(hr == D3D_OK, "Test %u: got unexpected hr %#lx.\n", test, hr);
 
         IDirect3DVertexBuffer9_Release(buffer);
         refcount = IDirect3DDevice9_Release(device);
-        ok(!refcount, "Test %u: device has %u references left.\n", test, refcount);
+        ok(!refcount, "Test %u: device has %lu references left.\n", test, refcount);
     }
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -9984,7 +9975,7 @@ static void test_npot_textures(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     tex_pow2 = !!(caps.TextureCaps & D3DPTEXTURECAPS_POW2);
     cube_pow2 = !!(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2);
     vol_pow2 = !!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP_POW2);
@@ -10014,7 +10005,7 @@ static void test_npot_textures(void)
             {
                 expected = pools[i].hr;
             }
-            ok(hr == expected, "CreateTexture(w=h=10, %s, levels=%u) returned hr %#x, expected %#x.\n",
+            ok(hr == expected, "CreateTexture(w=h=10, %s, levels=%u) returned hr %#lx, expected %#lx.\n",
                     pools[i].pool_name, levels, hr, expected);
 
             if (SUCCEEDED(hr))
@@ -10025,12 +10016,12 @@ static void test_npot_textures(void)
                 &cube_texture, NULL);
         if (tex_pow2)
         {
-            ok(hr == pools[i].hr, "CreateCubeTexture(EdgeLength=3, %s) returned hr %#x, expected %#x.\n",
+            ok(hr == pools[i].hr, "CreateCubeTexture(EdgeLength=3, %s) returned hr %#lx, expected %#lx.\n",
                     pools[i].pool_name, hr, pools[i].hr);
         }
         else
         {
-            ok(SUCCEEDED(hr), "CreateCubeTexture(EdgeLength=3, %s) returned hr %#x, expected %#x.\n",
+            ok(SUCCEEDED(hr), "CreateCubeTexture(EdgeLength=3, %s) returned hr %#lx, expected %#lx.\n",
                     pools[i].pool_name, hr, D3D_OK);
         }
 
@@ -10041,12 +10032,12 @@ static void test_npot_textures(void)
                 &volume_texture, NULL);
         if (tex_pow2)
         {
-            ok(hr == pools[i].hr, "CreateVolumeTextur(Depth=3, %s) returned hr %#x, expected %#x.\n",
+            ok(hr == pools[i].hr, "CreateVolumeTextur(Depth=3, %s) returned hr %#lx, expected %#lx.\n",
                     pools[i].pool_name, hr, pools[i].hr);
         }
         else
         {
-            ok(SUCCEEDED(hr), "CreateVolumeTextur(Depth=3, %s) returned hr %#x, expected %#x.\n",
+            ok(SUCCEEDED(hr), "CreateVolumeTextur(Depth=3, %s) returned hr %#lx, expected %#lx.\n",
                     pools[i].pool_name, hr, D3D_OK);
         }
 
@@ -10058,7 +10049,7 @@ done:
     if (device)
     {
         refcount = IDirect3DDevice9_Release(device);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
@@ -10096,7 +10087,7 @@ static void test_vidmem_accounting(void)
         /* D3DERR_OUTOFVIDEOMEMORY is returned when the card runs out of video memory
          * E_FAIL is returned on address space or system memory exhaustion */
         ok(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY,
-                "Failed to create texture, hr %#x.\n", hr);
+                "Failed to create texture, hr %#lx.\n", hr);
     }
     vidmem_end = IDirect3DDevice9_GetAvailableTextureMem(device);
 
@@ -10112,7 +10103,7 @@ static void test_vidmem_accounting(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -10158,7 +10149,7 @@ static void test_volume_locking(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP))
     {
         skip("Volume textures not supported, skipping test.\n");
@@ -10169,18 +10160,18 @@ static void test_volume_locking(void)
     {
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 4, 1, tests[i].usage,
                 D3DFMT_A8R8G8B8, tests[i].pool, &texture, NULL);
-        ok(hr == tests[i].create_hr, "Creating volume texture pool=%u, usage=%#x returned %#x, expected %#x.\n",
+        ok(hr == tests[i].create_hr, "Creating volume texture pool=%u, usage=%#lx returned %#lx, expected %#lx.\n",
                 tests[i].pool, tests[i].usage, hr, tests[i].create_hr);
         if (FAILED(hr))
             continue;
 
         locked_box.pBits = (void *)0xdeadbeef;
         hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, NULL, 0);
-        ok(hr == tests[i].lock_hr, "Lock returned %#x, expected %#x.\n", hr, tests[i].lock_hr);
+        ok(hr == tests[i].lock_hr, "Lock returned %#lx, expected %#lx.\n", hr, tests[i].lock_hr);
         if (SUCCEEDED(hr))
         {
             hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
         }
         else
         {
@@ -10191,7 +10182,7 @@ static void test_volume_locking(void)
 
 out:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -10258,7 +10249,7 @@ static void test_update_volumetexture(void)
     d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
     ok(!!d3d9, "Failed to create a D3D object.\n");
     hr = IDirect3D9_GetAdapterIdentifier(d3d9, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     is_warp = adapter_is_warp(&identifier);
     if (!(device = create_device(d3d9, window, NULL)))
     {
@@ -10269,7 +10260,7 @@ static void test_update_volumetexture(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP))
     {
         skip("Volume textures not supported, skipping test.\n");
@@ -10283,29 +10274,29 @@ static void test_update_volumetexture(void)
 
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 1, 1, 1, src_usage,
                 D3DFMT_A8R8G8B8, tests[i].src_pool, &src, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 1, 1, 1, dst_usage,
                 D3DFMT_A8R8G8B8, tests[i].dst_pool, &dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
 
         hr = IDirect3DVolumeTexture9_LockBox(src, 0, &locked_box, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
         *((DWORD *)locked_box.pBits) = 0x11223344;
         hr = IDirect3DVolumeTexture9_UnlockBox(src, 0);
-        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)src, (IDirect3DBaseTexture9 *)dst);
-        ok(hr == tests[i].hr, "UpdateTexture returned %#x, expected %#x, src pool %x, dst pool %u.\n",
+        ok(hr == tests[i].hr, "UpdateTexture returned %#lx, expected %#lx, src pool %x, dst pool %u.\n",
                 hr, tests[i].hr, tests[i].src_pool, tests[i].dst_pool);
 
         if (SUCCEEDED(hr))
         {
-            DWORD content = *((DWORD *)locked_box.pBits);
+            unsigned int content = *((unsigned int *)locked_box.pBits);
             hr = IDirect3DVolumeTexture9_LockBox(dst, 0, &locked_box, NULL, 0);
-            ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
             ok(content == 0x11223344, "Dest texture contained %#x, expected 0x11223344.\n", content);
             hr = IDirect3DVolumeTexture9_UnlockBox(dst, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
         }
         IDirect3DVolumeTexture9_Release(src);
         IDirect3DVolumeTexture9_Release(dst);
@@ -10322,16 +10313,16 @@ static void test_update_volumetexture(void)
         hr = IDirect3DDevice9_CreateVolumeTexture(device,
                 tests2[i].src_size, tests2[i].src_size, tests2[i].src_size,
                 tests2[i].src_lvl, 0, tests2[i].src_fmt, D3DPOOL_SYSTEMMEM, &src, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x, case %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx, case %u.\n", hr, i);
         hr = IDirect3DDevice9_CreateVolumeTexture(device,
                 tests2[i].dst_size, tests2[i].dst_size, tests2[i].dst_size,
                 tests2[i].dst_lvl, 0, tests2[i].dst_fmt, D3DPOOL_DEFAULT, &dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x, case %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx, case %u.\n", hr, i);
 
         hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)src, (IDirect3DBaseTexture9 *)dst);
         todo_wine_if (FAILED(hr))
             ok(SUCCEEDED(hr) || (is_warp && (i == 6 || i == 7)), /* Fails with Win10 WARP driver */
-                    "Failed to update texture, hr %#x, case %u.\n", hr, i);
+                    "Failed to update texture, hr %#lx, case %u.\n", hr, i);
 
         IDirect3DVolumeTexture9_Release(src);
         IDirect3DVolumeTexture9_Release(dst);
@@ -10347,7 +10338,7 @@ static void test_update_volumetexture(void)
 
 out:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -10377,7 +10368,7 @@ static void test_create_rt_ds_fail(void)
     surface = (IDirect3DSurface9 *)0xdeadbeef;
     hr = IDirect3DDevice9_CreateRenderTarget(device, 4, 4, D3DFMT_D16,
             D3DMULTISAMPLE_NONE, 0, FALSE, &surface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Creating a D16 render target returned hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Creating a D16 render target returned hr %#lx.\n", hr);
     ok(surface == NULL, "Got pointer %p, expected NULL.\n", surface);
     if (SUCCEEDED(hr))
         IDirect3DSurface9_Release(surface);
@@ -10385,13 +10376,13 @@ static void test_create_rt_ds_fail(void)
     surface = (IDirect3DSurface9 *)0xdeadbeef;
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 4, 4, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Creating a A8R8G8B8 depth stencil returned hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Creating a A8R8G8B8 depth stencil returned hr %#lx.\n", hr);
     ok(surface == NULL, "Got pointer %p, expected NULL.\n", surface);
     if (SUCCEEDED(hr))
         IDirect3DSurface9_Release(surface);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -10400,7 +10391,7 @@ static void test_volume_blocks(void)
 {
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d9;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     HRESULT hr;
     D3DCAPS9 caps;
@@ -10484,7 +10475,7 @@ static void test_volume_blocks(void)
         return;
     }
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     pow2 = !!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP_POW2);
 
     for (i = 0; i < ARRAY_SIZE(formats); i++)
@@ -10537,7 +10528,7 @@ static void test_volume_blocks(void)
                             may_succeed = TRUE;
 
                         ok(hr == expect_hr || ((SUCCEEDED(hr) && may_succeed)),
-                                "Got unexpected hr %#x for format %s, pool %s, size %ux%ux%u.\n",
+                                "Got unexpected hr %#lx for format %s, pool %s, size %ux%ux%u.\n",
                                 hr, formats[i].name, create_tests[j].name, w, h, d);
 
                         if (FAILED(hr))
@@ -10554,7 +10545,7 @@ static void test_volume_blocks(void)
 
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 24, 8, 8, 1, 0,
                 formats[i].fmt, D3DPOOL_SCRATCH, &texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
 
         /* Test lockrect offset */
         for (j = 0; j < ARRAY_SIZE(offset_tests); j++)
@@ -10563,7 +10554,7 @@ static void test_volume_blocks(void)
             bytes_per_pixel = formats[i].block_size / (formats[i].block_width * formats[i].block_height);
 
             hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, NULL, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
             base = locked_box.pBits;
             if (formats[i].broken == 1)
@@ -10596,7 +10587,7 @@ static void test_volume_blocks(void)
                     locked_box.SlicePitch, formats[i].name, expected_slice_pitch);
 
             hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x, j %u.\n", hr, j);
+            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx, j %u.\n", hr, j);
 
             box.Left = offset_tests[j].x;
             box.Top = offset_tests[j].y;
@@ -10605,7 +10596,7 @@ static void test_volume_blocks(void)
             box.Bottom = offset_tests[j].y2;
             box.Back = offset_tests[j].z2;
             hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, &box, 0);
-            ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x, j %u.\n", hr, j);
+            ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx, j %u.\n", hr, j);
 
             offset = (BYTE *)locked_box.pBits - base;
             if (formats[i].broken == 1)
@@ -10630,7 +10621,7 @@ static void test_volume_blocks(void)
                     offset, formats[i].name, expected_offset, box.Left, box.Top, box.Front);
 
             hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
         }
 
         /* Test partial block locks */
@@ -10649,7 +10640,7 @@ static void test_volume_blocks(void)
             if (SUCCEEDED(hr))
             {
                 hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-                ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
             }
 
             box.Left = 0;
@@ -10663,7 +10654,7 @@ static void test_volume_blocks(void)
             if (SUCCEEDED(hr))
             {
                 hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-                ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
             }
         }
 
@@ -10680,7 +10671,7 @@ static void test_volume_blocks(void)
             if (SUCCEEDED(hr))
             {
                 hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-                ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
             }
 
             box.Left = 0;
@@ -10694,7 +10685,7 @@ static void test_volume_blocks(void)
             if (SUCCEEDED(hr))
             {
                 hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-                ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
             }
         }
 
@@ -10704,9 +10695,9 @@ static void test_volume_blocks(void)
         box.Right = formats[i].block_width;
         box.Bottom = formats[i].block_height;
         hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, &box, 0);
-        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
         hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
         IDirect3DVolumeTexture9_Release(texture);
 
@@ -10716,26 +10707,26 @@ static void test_volume_blocks(void)
         {
             hr = IDirect3DDevice9_CreateVolumeTexture(device, formats[i].block_width, formats[i].block_height,
                     2, 2, 0, formats[i].fmt, D3DPOOL_SCRATCH, &texture, NULL);
-            ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
 
             hr = IDirect3DVolumeTexture9_LockBox(texture, 1, &locked_box, NULL, 0);
-            ok(SUCCEEDED(hr), "Failed to lock volume texture mipmap, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock volume texture mipmap, hr %#lx.\n", hr);
             hr = IDirect3DVolumeTexture9_UnlockBox(texture, 1);
-            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
             box.Left = box.Top = box.Front = 0;
             box.Right = formats[i].block_width == 1 ? 1 : formats[i].block_width >> 1;
             box.Bottom = formats[i].block_height == 1 ? 1 : formats[i].block_height >> 1;
             box.Back = 1;
             hr = IDirect3DVolumeTexture9_LockBox(texture, 1, &locked_box, &box, 0);
-            ok(SUCCEEDED(hr), "Failed to lock volume texture mipmap, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock volume texture mipmap, hr %#lx.\n", hr);
             hr = IDirect3DVolumeTexture9_UnlockBox(texture, 1);
-            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
             box.Right = formats[i].block_width;
             box.Bottom = formats[i].block_height;
             hr = IDirect3DVolumeTexture9_LockBox(texture, 1, &locked_box, &box, 0);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
             if (SUCCEEDED(hr))
                 IDirect3DVolumeTexture9_UnlockBox(texture, 1);
 
@@ -10744,7 +10735,7 @@ static void test_volume_blocks(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -10797,12 +10788,12 @@ static void test_lockbox_invalid(void)
 
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 2, 1, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
     hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
     base = locked_box.pBits;
     hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -10816,7 +10807,7 @@ static void test_lockbox_invalid(void)
         hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, box, 0);
         /* Unlike surfaces, volumes properly check the box even in Windows XP */
         ok(hr == test_data[i].result,
-                "Got unexpected hr %#x with box [%u, %u, %u]->[%u, %u, %u], expected %#x.\n",
+                "Got unexpected hr %#lx with box [%u, %u, %u]->[%u, %u, %u], expected %#lx.\n",
                 hr, box->Left, box->Top, box->Front, box->Right, box->Bottom, box->Back,
                 test_data[i].result);
         if (FAILED(hr))
@@ -10829,42 +10820,42 @@ static void test_lockbox_invalid(void)
                 offset, expected_offset, box->Left, box->Top, box->Front, box->Right, box->Bottom, box->Back);
 
         hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
     }
 
     /* locked_box = NULL throws an exception on Windows */
     hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
     hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, NULL, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
     hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, &test_data[0].box, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x for rect [%u, %u, %u]->[%u, %u, %u].\n",
+    ok(hr == D3D_OK, "Got unexpected hr %#lx for rect [%u, %u, %u]->[%u, %u, %u].\n",
             hr, test_data[0].box.Left, test_data[0].box.Top, test_data[0].box.Front,
             test_data[0].box.Right, test_data[0].box.Bottom, test_data[0].box.Back);
     hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, &test_data[0].box, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for rect [%u, %u, %u]->[%u, %u, %u].\n",
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for rect [%u, %u, %u]->[%u, %u, %u].\n",
             hr, test_data[0].box.Left, test_data[0].box.Top, test_data[0].box.Front,
             test_data[0].box.Right, test_data[0].box.Bottom, test_data[0].box.Back);
     hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &locked_box, &test_boxt_2, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for rect [%u, %u, %u]->[%u, %u, %u].\n",
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx for rect [%u, %u, %u]->[%u, %u, %u].\n",
             hr, test_boxt_2.Left, test_boxt_2.Top, test_boxt_2.Front,
             test_boxt_2.Right, test_boxt_2.Bottom, test_boxt_2.Back);
     hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
     IDirect3DVolumeTexture9_Release(texture);
 
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 2, 1, D3DUSAGE_WRITEONLY,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &texture, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -10898,48 +10889,48 @@ static void test_shared_handle(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     mem = HeapAlloc(GetProcessHeap(), 0, 128 * 128 * 4);
 
     /* Windows XP returns E_NOTIMPL, Windows 7 returns INVALIDCALL, except for
      * CreateVertexBuffer, where it returns NOTAVAILABLE. */
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_DEFAULT, &texture, &handle);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, &mem);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface, &handle);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, &mem);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, 16, 0, 0, D3DPOOL_DEFAULT,
             &vertex_buffer, &handle);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexBuffer(device, 16, 0, 0, D3DPOOL_SYSTEMMEM,
             &vertex_buffer, &mem);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_NOTAVAILABLE), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_NOTAVAILABLE), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device, 16, 0, 0, D3DPOOL_DEFAULT,
             &index_buffer, &handle);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateIndexBuffer(device, 16, 0, 0, D3DPOOL_SYSTEMMEM,
             &index_buffer, &mem);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
 
     if (caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP)
     {
         IDirect3DCubeTexture9 *cube_texture = NULL;
         hr = IDirect3DDevice9_CreateCubeTexture(device, 8, 0, 0, D3DFMT_A8R8G8B8,
                 D3DPOOL_DEFAULT, &cube_texture, &handle);
-        ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+        ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateCubeTexture(device, 8, 0, 0, D3DFMT_A8R8G8B8,
                 D3DPOOL_SYSTEMMEM, &cube_texture, &mem);
-        ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+        ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
     }
 
     if (caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)
@@ -10947,23 +10938,23 @@ static void test_shared_handle(void)
         IDirect3DVolumeTexture9 *volume_texture = NULL;
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 4, 0, 0, D3DFMT_A8R8G8B8,
                 D3DPOOL_DEFAULT, &volume_texture, &handle);
-        ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+        ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 4, 0, 0, D3DFMT_A8R8G8B8,
                 D3DPOOL_SYSTEMMEM, &volume_texture, &mem);
-        ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+        ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &surface, &handle);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 128, 128, D3DFMT_D24X8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &surface, &handle);
-    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
 
     HeapFree(GetProcessHeap(), 0, mem);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -11038,37 +11029,37 @@ static void test_pixel_format(void)
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, point, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, hwnd2, NULL);
-    ok(SUCCEEDED(hr), "Present failed %#x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -11079,8 +11070,8 @@ static void test_pixel_format(void)
 cleanup:
     if (device)
     {
-        UINT refcount = IDirect3DDevice9_Release(device);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ULONG refcount = IDirect3DDevice9_Release(device);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
     if (d3d9)
         IDirect3D9_Release(d3d9);
@@ -11113,60 +11104,60 @@ static void test_begin_end_state_block(void)
     }
 
     hr = IDirect3DDevice9_BeginStateBlock(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     stateblock = (IDirect3DStateBlock9 *)0xdeadbeef;
     hr = IDirect3DDevice9_EndStateBlock(device, &stateblock);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(!!stateblock && stateblock != (IDirect3DStateBlock9 *)0xdeadbeef,
             "Got unexpected stateblock %p.\n", stateblock);
 
     stateblock2 = (IDirect3DStateBlock9 *)0xdeadbeef;
     hr = IDirect3DDevice9_EndStateBlock(device, &stateblock2);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(stateblock2 == (IDirect3DStateBlock9 *)0xdeadbeef,
             "Got unexpected stateblock %p.\n", stateblock2);
 
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == TRUE, "Got unexpected value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == TRUE, "Got unexpected value %#lx.\n", value);
 
     hr = IDirect3DDevice9_BeginStateBlock(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginStateBlock(device);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateStateBlock(device, D3DSBT_ALL, &stateblock2);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == TRUE, "Got unexpected value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == TRUE, "Got unexpected value %#lx.\n", value);
 
     hr = IDirect3DDevice9_EndStateBlock(device, &stateblock2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DStateBlock9_Apply(stateblock2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == TRUE, "Got unexpected value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == TRUE, "Got unexpected value %#lx.\n", value);
 
     IDirect3DStateBlock9_Release(stateblock);
     IDirect3DStateBlock9_Release(stateblock2);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -11198,79 +11189,79 @@ static void test_shader_constant_apply(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     vs_version = caps.VertexShaderVersion & 0xffff;
     ps_version = caps.PixelShaderVersion & 0xffff;
 
     if (vs_version)
     {
         hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, initial, 1);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, initial, 1);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 0, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, initial, sizeof(initial)),
                 "Got unexpected vertex shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
         hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 1, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, initial, sizeof(initial)),
                 "Got unexpected vertex shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
 
         hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, vs_const, 1);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#lx.\n", hr);
     }
     if (ps_version)
     {
         hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, initial, 1);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 1, initial, 1);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 0, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, initial, sizeof(initial)),
                 "Got unexpected pixel shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
         hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 1, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, initial, sizeof(initial)),
                 "Got unexpected pixel shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
 
         hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, ps_const, 1);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_BeginStateBlock(device);
-    ok(SUCCEEDED(hr), "Failed to begin stateblock, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin stateblock, hr %#lx.\n", hr);
 
     if (vs_version)
     {
         hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, vs_const, 1);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#lx.\n", hr);
     }
     if (ps_version)
     {
         hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 1, ps_const, 1);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_EndStateBlock(device, &stateblock);
-    ok(SUCCEEDED(hr), "Failed to end stateblock, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end stateblock, hr %#lx.\n", hr);
 
     if (vs_version)
     {
         hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 0, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, vs_const, sizeof(vs_const)),
                 "Got unexpected vertex shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], vs_const[0], vs_const[1], vs_const[2], vs_const[3]);
         hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 1, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, initial, sizeof(initial)),
                 "Got unexpected vertex shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
@@ -11278,12 +11269,12 @@ static void test_shader_constant_apply(void)
     if (ps_version)
     {
         hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 0, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, ps_const, sizeof(ps_const)),
                 "Got unexpected pixel shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], ps_const[0], ps_const[1], ps_const[2], ps_const[3]);
         hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 1, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, initial, sizeof(initial)),
                 "Got unexpected pixel shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
@@ -11292,17 +11283,17 @@ static void test_shader_constant_apply(void)
     /* Apply doesn't overwrite constants that aren't explicitly set on the
      * source stateblock. */
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Failed to apply stateblock, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to apply stateblock, hr %#lx.\n", hr);
 
     if (vs_version)
     {
         hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 0, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, vs_const, sizeof(vs_const)),
                 "Got unexpected vertex shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], vs_const[0], vs_const[1], vs_const[2], vs_const[3]);
         hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 1, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get vertex shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, vs_const, sizeof(vs_const)),
                 "Got unexpected vertex shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], vs_const[0], vs_const[1], vs_const[2], vs_const[3]);
@@ -11310,12 +11301,12 @@ static void test_shader_constant_apply(void)
     if (ps_version)
     {
         hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 0, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, ps_const, sizeof(ps_const)),
                 "Got unexpected pixel shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], ps_const[0], ps_const[1], ps_const[2], ps_const[3]);
         hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 1, ret, 1);
-        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get pixel shader constant, hr %#lx.\n", hr);
         ok(!memcmp(ret, ps_const, sizeof(ps_const)),
                 "Got unexpected pixel shader constant {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 ret[0], ret[1], ret[2], ret[3], ps_const[0], ps_const[1], ps_const[2], ps_const[3]);
@@ -11323,7 +11314,7 @@ static void test_shader_constant_apply(void)
 
     IDirect3DStateBlock9_Release(stateblock);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -11365,151 +11356,151 @@ static void test_vdecl_apply(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl1, &declaration1);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl2, &declaration2);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginStateBlock(device);
-    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration1);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndStateBlock(device, &stateblock);
-    ok(SUCCEEDED(hr), "EndStateBlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndStateBlock failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(declaration == declaration1, "Got unexpected vertex declaration %p, expected %p.\n",
             declaration, declaration1);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration2);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(declaration == declaration2, "Got unexpected vertex declaration %p, expected %p.\n",
             declaration, declaration2);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration2);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(declaration == declaration2, "Got unexpected vertex declaration %p, expected %p.\n",
             declaration, declaration2);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(!declaration, "Got unexpected vertex declaration %p.\n", declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration2);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(declaration == declaration2, "Got unexpected vertex declaration %p, expected %p.\n",
             declaration, declaration2);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     IDirect3DStateBlock9_Release(stateblock);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration1);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock);
-    ok(SUCCEEDED(hr), "CreateStateBlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateStateBlock failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(declaration == declaration1, "Got unexpected vertex declaration %p, expected %p.\n",
             declaration, declaration1);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration2);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(declaration == declaration2, "Got unexpected vertex declaration %p, expected %p.\n",
             declaration, declaration2);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration2);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(declaration == declaration2, "Got unexpected vertex declaration %p, expected %p.\n",
             declaration, declaration2);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(!declaration, "Got unexpected vertex declaration %p.\n", declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration2);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Capture(stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
     hr = IDirect3DStateBlock9_Apply(stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetVertexDeclaration(device, &declaration);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration failed, hr %#lx.\n", hr);
     ok(declaration == declaration2, "Got unexpected vertex declaration %p, expected %p.\n",
             declaration, declaration2);
     IDirect3DVertexDeclaration9_Release(declaration);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx.\n", hr);
     IDirect3DVertexDeclaration9_Release(declaration1);
     IDirect3DVertexDeclaration9_Release(declaration2);
     IDirect3DStateBlock9_Release(stateblock);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -11543,27 +11534,27 @@ static void test_resource_type(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 4, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     type = IDirect3DSurface9_GetType(surface);
     ok(type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n", type);
     hr = IDirect3DSurface9_GetDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#lx.\n", hr);
     ok(surface_desc.Type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n",
             surface_desc.Type);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_CreateTexture(device, 2, 8, 4, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     type = IDirect3DTexture9_GetType(texture);
     ok(type == D3DRTYPE_TEXTURE, "Expected type D3DRTYPE_TEXTURE, got %u.\n", type);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     /* The following code crashes, for the sake of completeness:
      * type = texture->lpVtbl->GetType((IDirect3DTexture9 *)surface);
      * ok(type == D3DRTYPE_PONIES, "Expected type D3DRTYPE_PONIES, got %u.\n", type);
@@ -11573,13 +11564,13 @@ static void test_resource_type(void)
     type = IDirect3DSurface9_GetType(surface);
     ok(type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n", type);
     hr = IDirect3DSurface9_GetDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#lx.\n", hr);
     ok(surface_desc.Type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n",
             surface_desc.Type);
     ok(surface_desc.Width == 2, "Expected width 2, got %u.\n", surface_desc.Width);
     ok(surface_desc.Height == 8, "Expected height 8, got %u.\n", surface_desc.Height);
     hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get level description, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get level description, hr %#lx.\n", hr);
     ok(surface_desc.Type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n",
             surface_desc.Type);
     ok(surface_desc.Width == 2, "Expected width 2, got %u.\n", surface_desc.Width);
@@ -11587,17 +11578,17 @@ static void test_resource_type(void)
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 2, &surface);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     type = IDirect3DSurface9_GetType(surface);
     ok(type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n", type);
     hr = IDirect3DSurface9_GetDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#lx.\n", hr);
     ok(surface_desc.Type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n",
             surface_desc.Type);
     ok(surface_desc.Width == 1, "Expected width 1, got %u.\n", surface_desc.Width);
     ok(surface_desc.Height == 2, "Expected height 2, got %u.\n", surface_desc.Height);
     hr = IDirect3DTexture9_GetLevelDesc(texture, 2, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get level description, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get level description, hr %#lx.\n", hr);
     ok(surface_desc.Type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n",
             surface_desc.Type);
     ok(surface_desc.Width == 1, "Expected width 1, got %u.\n", surface_desc.Width);
@@ -11609,21 +11600,21 @@ static void test_resource_type(void)
     {
         hr = IDirect3DDevice9_CreateCubeTexture(device, 1, 1, 0, D3DFMT_X8R8G8B8,
                 D3DPOOL_SYSTEMMEM, &cube_texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create cube texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create cube texture, hr %#lx.\n", hr);
         type = IDirect3DCubeTexture9_GetType(cube_texture);
         ok(type == D3DRTYPE_CUBETEXTURE, "Expected type D3DRTYPE_CUBETEXTURE, got %u.\n", type);
 
         hr = IDirect3DCubeTexture9_GetCubeMapSurface(cube_texture,
                 D3DCUBEMAP_FACE_NEGATIVE_X, 0, &surface);
-        ok(SUCCEEDED(hr), "Failed to get cube map surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get cube map surface, hr %#lx.\n", hr);
         type = IDirect3DSurface9_GetType(surface);
         ok(type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n", type);
         hr = IDirect3DSurface9_GetDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get surface description, hr %#lx.\n", hr);
         ok(surface_desc.Type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n",
                 surface_desc.Type);
         hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &surface_desc);
-        ok(SUCCEEDED(hr), "Failed to get level description, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get level description, hr %#lx.\n", hr);
         ok(surface_desc.Type == D3DRTYPE_SURFACE, "Expected type D3DRTYPE_SURFACE, got %u.\n",
                 surface_desc.Type);
         IDirect3DSurface9_Release(surface);
@@ -11636,22 +11627,22 @@ static void test_resource_type(void)
     {
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 2, 4, 8, 4, 0, D3DFMT_X8R8G8B8,
                 D3DPOOL_SYSTEMMEM, &volume_texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
         type = IDirect3DVolumeTexture9_GetType(volume_texture);
         ok(type == D3DRTYPE_VOLUMETEXTURE, "Expected type D3DRTYPE_VOLUMETEXTURE, got %u.\n", type);
 
         hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 0, &volume);
-        ok(SUCCEEDED(hr), "Failed to get volume level, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get volume level, hr %#lx.\n", hr);
         /* IDirect3DVolume9 is not an IDirect3DResource9 and has no GetType method. */
         hr = IDirect3DVolume9_GetDesc(volume, &volume_desc);
-        ok(SUCCEEDED(hr), "Failed to get volume description, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get volume description, hr %#lx.\n", hr);
         ok(volume_desc.Type == D3DRTYPE_VOLUME, "Expected type D3DRTYPE_VOLUME, got %u.\n",
                 volume_desc.Type);
         ok(volume_desc.Width == 2, "Expected width 2, got %u.\n", volume_desc.Width);
         ok(volume_desc.Height == 4, "Expected height 4, got %u.\n", volume_desc.Height);
         ok(volume_desc.Depth == 8, "Expected depth 8, got %u.\n", volume_desc.Depth);
         hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &volume_desc);
-        ok(SUCCEEDED(hr), "Failed to get level description, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get level description, hr %#lx.\n", hr);
         ok(volume_desc.Type == D3DRTYPE_VOLUME, "Expected type D3DRTYPE_VOLUME, got %u.\n",
                 volume_desc.Type);
         ok(volume_desc.Width == 2, "Expected width 2, got %u.\n", volume_desc.Width);
@@ -11660,17 +11651,17 @@ static void test_resource_type(void)
         IDirect3DVolume9_Release(volume);
 
         hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 2, &volume);
-        ok(SUCCEEDED(hr), "Failed to get volume level, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get volume level, hr %#lx.\n", hr);
         /* IDirect3DVolume9 is not an IDirect3DResource9 and has no GetType method. */
         hr = IDirect3DVolume9_GetDesc(volume, &volume_desc);
-        ok(SUCCEEDED(hr), "Failed to get volume description, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get volume description, hr %#lx.\n", hr);
         ok(volume_desc.Type == D3DRTYPE_VOLUME, "Expected type D3DRTYPE_VOLUME, got %u.\n",
                 volume_desc.Type);
         ok(volume_desc.Width == 1, "Expected width 1, got %u.\n", volume_desc.Width);
         ok(volume_desc.Height == 1, "Expected height 1, got %u.\n", volume_desc.Height);
         ok(volume_desc.Depth == 2, "Expected depth 2, got %u.\n", volume_desc.Depth);
         hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 2, &volume_desc);
-        ok(SUCCEEDED(hr), "Failed to get level description, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get level description, hr %#lx.\n", hr);
         ok(volume_desc.Type == D3DRTYPE_VOLUME, "Expected type D3DRTYPE_VOLUME, got %u.\n",
                 volume_desc.Type);
         ok(volume_desc.Width == 1, "Expected width 1, got %u.\n", volume_desc.Width);
@@ -11683,7 +11674,7 @@ static void test_resource_type(void)
         skip("Mipmapped volume maps not supported.\n");
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -11712,39 +11703,39 @@ static void test_mipmap_lock(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 2, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_DEFAULT, &texture_dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture_dst, 0, &surface_dst);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture_dst, 1, &surface_dst2);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 2, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 1, &surface2);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_LockRect(surface2, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_UpdateSurface(device, surface, NULL, surface_dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateSurface(device, surface2, NULL, surface_dst2, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     /* Apparently there's no validation on the container. */
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture,
             (IDirect3DBaseTexture9 *)texture_dst);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_UnlockRect(surface2);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface_dst2);
     IDirect3DSurface9_Release(surface_dst);
@@ -11754,7 +11745,7 @@ static void test_mipmap_lock(void)
     IDirect3DTexture9_Release(texture);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -11793,41 +11784,41 @@ static void test_writeonly_resource(void)
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad),
             D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &ptr, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(ptr, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene %#x\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene %#x\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &ptr, 0);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     ok(!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &ptr, D3DLOCK_READONLY);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     ok(!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     refcount = IDirect3DVertexBuffer9_Release(buffer);
-    ok(!refcount, "Vertex buffer has %u references left.\n", refcount);
+    ok(!refcount, "Vertex buffer has %lu references left.\n", refcount);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -11857,78 +11848,78 @@ static void test_lost_device(void)
     }
 
     hr = IDirect3DDevice9_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9_TestCooperativeLevel(device);
-    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#lx.\n", hr);
 
     ret = ShowWindow(window, SW_RESTORE);
     ok(ret, "Failed to restore window.\n");
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9_TestCooperativeLevel(device);
-    ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#lx.\n", hr);
 
     hr = reset_device(device, &device_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     device_desc.flags = 0;
     hr = reset_device(device, &device_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = ShowWindow(window, SW_RESTORE);
     ok(ret, "Failed to restore window.\n");
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirect3DDevice9_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     device_desc.flags = CREATE_DEVICE_FULLSCREEN;
     hr = reset_device(device, &device_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = reset_device(device, &device_desc);
-    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#lx.\n", hr);
     ret = ShowWindow(window, SW_RESTORE);
     ok(ret, "Failed to restore window.\n");
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = reset_device(device, &device_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -11975,30 +11966,30 @@ static void test_resource_priority(void)
     {
         hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 0, 0, D3DFMT_X8R8G8B8,
                 test_data[i].pool, &texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, pool %s.\n", hr, test_data[i].name);
+        ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, pool %s.\n", hr, test_data[i].name);
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-        ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
 
         priority = IDirect3DTexture9_GetPriority(texture);
-        ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+        ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
         priority = IDirect3DTexture9_SetPriority(texture, 1);
-        ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+        ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
         priority = IDirect3DTexture9_GetPriority(texture);
         if (test_data[i].can_set_priority)
         {
-            ok(priority == 1, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+            ok(priority == 1, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
             priority = IDirect3DTexture9_SetPriority(texture, 2);
-            ok(priority == 1, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+            ok(priority == 1, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
         }
         else
-            ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+            ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
 
         priority = IDirect3DSurface9_GetPriority(surface);
-        ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+        ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
         priority = IDirect3DSurface9_SetPriority(surface, 1);
-        ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+        ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
         priority = IDirect3DSurface9_GetPriority(surface);
-        ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+        ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
 
         IDirect3DSurface9_Release(surface);
         IDirect3DTexture9_Release(texture);
@@ -12007,14 +11998,14 @@ static void test_resource_priority(void)
         {
             hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 16, 16, D3DFMT_X8R8G8B8,
                     test_data[i].pool, &surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, pool %s.\n", hr, test_data[i].name);
+            ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, pool %s.\n", hr, test_data[i].name);
 
             priority = IDirect3DSurface9_GetPriority(surface);
-            ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+            ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
             priority = IDirect3DSurface9_SetPriority(surface, 1);
-            ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+            ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
             priority = IDirect3DSurface9_GetPriority(surface);
-            ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+            ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
 
             IDirect3DSurface9_Release(surface);
         }
@@ -12023,21 +12014,21 @@ static void test_resource_priority(void)
         {
             hr = IDirect3DDevice9_CreateVertexBuffer(device, 256, 0, 0,
                     test_data[i].pool, &buffer, NULL);
-            ok(SUCCEEDED(hr), "Failed to create buffer, hr %#x, pool %s.\n", hr, test_data[i].name);
+            ok(SUCCEEDED(hr), "Failed to create buffer, hr %#lx, pool %s.\n", hr, test_data[i].name);
 
             priority = IDirect3DVertexBuffer9_GetPriority(buffer);
-            ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+            ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
             priority = IDirect3DVertexBuffer9_SetPriority(buffer, 1);
-            ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+            ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
             priority = IDirect3DVertexBuffer9_GetPriority(buffer);
             if (test_data[i].can_set_priority)
             {
-                ok(priority == 1, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+                ok(priority == 1, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
                 priority = IDirect3DVertexBuffer9_SetPriority(buffer, 0);
-                ok(priority == 1, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+                ok(priority == 1, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
             }
             else
-                ok(priority == 0, "Got unexpected priority %u, pool %s.\n", priority, test_data[i].name);
+                ok(priority == 0, "Got unexpected priority %lu, pool %s.\n", priority, test_data[i].name);
 
             IDirect3DVertexBuffer9_Release(buffer);
         }
@@ -12046,18 +12037,18 @@ static void test_resource_priority(void)
     hr = IDirect3DDevice9_CreateRenderTarget(device, 16, 16, D3DFMT_X8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &surface, NULL);
 
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
     priority = IDirect3DSurface9_GetPriority(surface);
-    ok(priority == 0, "Got unexpected priority %u.\n", priority);
+    ok(priority == 0, "Got unexpected priority %lu.\n", priority);
     priority = IDirect3DSurface9_SetPriority(surface, 1);
-    ok(priority == 0, "Got unexpected priority %u.\n", priority);
+    ok(priority == 0, "Got unexpected priority %lu.\n", priority);
     priority = IDirect3DSurface9_GetPriority(surface);
-    ok(priority == 0, "Got unexpected priority %u.\n", priority);
+    ok(priority == 0, "Got unexpected priority %lu.\n", priority);
 
     IDirect3DSurface9_Release(surface);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -12133,7 +12124,7 @@ static void test_swapchain_parameters(void)
     }
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "Failed to get device caps, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get device caps, hr %#lx.\n", hr);
     IDirect3DDevice9_Release(device);
 
     present_parameters_windowed.BackBufferWidth = registry_mode.dmPelsWidth;
@@ -12158,16 +12149,16 @@ static void test_swapchain_parameters(void)
 
         hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
                 D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device);
-        ok(hr == tests[i].hr, "Expected hr %x, got %x, test %u.\n", tests[i].hr, hr, i);
+        ok(hr == tests[i].hr, "Expected hr %#lx, got %#lx, test %u.\n", tests[i].hr, hr, i);
         if (SUCCEEDED(hr))
         {
             UINT bb_count = tests[i].backbuffer_count ? tests[i].backbuffer_count : 1;
 
             hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-            ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x, test %u.\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx, test %u.\n", hr, i);
 
             hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &present_parameters2);
-            ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x, test %u.\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx, test %u.\n", hr, i);
             ok(present_parameters2.SwapEffect == tests[i].swap_effect, "Swap effect changed from %u to %u, test %u.\n",
                     tests[i].swap_effect, present_parameters2.SwapEffect, i);
             ok(present_parameters2.BackBufferCount == bb_count, "Backbuffer count changed from %u to %u, test %u.\n",
@@ -12181,7 +12172,7 @@ static void test_swapchain_parameters(void)
 
         hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
                 D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters_windowed, &device);
-        ok(SUCCEEDED(hr), "Failed to create device, hr %#x, test %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to create device, hr %#lx, test %u.\n", hr, i);
 
         memset(&present_parameters, 0, sizeof(present_parameters));
         present_parameters.BackBufferWidth = registry_mode.dmPelsWidth;
@@ -12194,12 +12185,12 @@ static void test_swapchain_parameters(void)
         present_parameters.BackBufferCount = tests[i].backbuffer_count;
 
         hr = IDirect3DDevice9_Reset(device, &present_parameters);
-        ok(hr == tests[i].hr, "Expected hr %x, got %x, test %u.\n", tests[i].hr, hr, i);
+        ok(hr == tests[i].hr, "Expected hr %#lx, got %#lx, test %u.\n", tests[i].hr, hr, i);
 
         if (FAILED(hr))
         {
             hr = IDirect3DDevice9_Reset(device, &present_parameters_windowed);
-            ok(SUCCEEDED(hr), "Failed to reset device, hr %#x, test %u.\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx, test %u.\n", hr, i);
         }
         IDirect3DDevice9_Release(device);
     }
@@ -12235,15 +12226,15 @@ static void test_swapchain_parameters(void)
 
         hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
                 D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device);
-        ok(hr == expected_hr, "Got unexpected hr %#x, test %u.\n", hr, i);
+        ok(hr == expected_hr, "Got unexpected hr %#lx, test %u.\n", hr, i);
         if (FAILED(hr))
             continue;
 
         hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-        ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x, test %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#lx, test %u.\n", hr, i);
 
         hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &present_parameters2);
-        ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x, test %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#lx, test %u.\n", hr, i);
         ok(present_parameters2.PresentationInterval == i,
                 "Got presentation interval %#x, expected %#x.\n",
                 present_parameters2.PresentationInterval, i);
@@ -12290,55 +12281,55 @@ static void test_check_device_format(void)
     {
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL,
                 D3DFMT_X8R8G8B8, D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_SRGBWRITE, D3DRTYPE_SURFACE, D3DFMT_A8R8G8B8);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL,
                 D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_SRGBWRITE, D3DRTYPE_SURFACE, D3DFMT_A8R8G8B8);
-        ok(FAILED(hr), "Got unexpected hr %#x.\n", hr);
+        ok(FAILED(hr), "Got unexpected hr %#lx.\n", hr);
     }
 
     for (device_type = D3DDEVTYPE_HAL; device_type <  D3DDEVTYPE_NULLREF; ++device_type)
     {
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, device_type, D3DFMT_UNKNOWN,
                 0, D3DRTYPE_SURFACE, D3DFMT_A8R8G8B8);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, device type %#x.\n", hr, device_type);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, device type %#x.\n", hr, device_type);
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, device_type, D3DFMT_UNKNOWN,
                 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, device type %#x.\n", hr, device_type);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, device type %#x.\n", hr, device_type);
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, device_type, D3DFMT_UNKNOWN,
                 0, D3DRTYPE_SURFACE, D3DFMT_X8R8G8B8);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, device type %#x.\n", hr, device_type);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, device type %#x.\n", hr, device_type);
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, device_type, D3DFMT_UNKNOWN,
                 0, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, device type %#x.\n", hr, device_type);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, device type %#x.\n", hr, device_type);
     }
 
     hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             0, D3DRTYPE_VERTEXBUFFER, D3DFMT_VERTEXDATA);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             0, D3DRTYPE_INDEXBUFFER, D3DFMT_VERTEXDATA);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             0, D3DRTYPE_INDEXBUFFER, D3DFMT_INDEX16);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             D3DUSAGE_SOFTWAREPROCESSING, D3DRTYPE_VERTEXBUFFER, D3DFMT_VERTEXDATA);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             D3DUSAGE_SOFTWAREPROCESSING, D3DRTYPE_INDEXBUFFER, D3DFMT_VERTEXDATA);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             D3DUSAGE_SOFTWAREPROCESSING, D3DRTYPE_INDEXBUFFER, D3DFMT_INDEX16);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8,
             0, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             0, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8);
     ok(hr == D3D_OK || broken(hr == D3DERR_NOTAVAILABLE) /* Testbot Windows <= 7 */,
-            "Got unexpected hr %#x.\n", hr);
+            "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(mipmap_autogen_formats); ++i)
     {
@@ -12346,30 +12337,30 @@ static void test_check_device_format(void)
 
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
                 D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, format);
-        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
         render_target_supported = hr == D3D_OK;
 
         hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
                 D3DUSAGE_RENDERTARGET | D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, format);
         if (render_target_supported)
         {
-            ok(hr == D3D_OK || hr == D3DOK_NOAUTOGEN, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK || hr == D3DOK_NOAUTOGEN, "Got unexpected hr %#lx.\n", hr);
         }
         else
         {
-            ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
         }
     }
 
     hr = IDirect3D9_CheckDepthStencilMatch(d3d, D3DADAPTER_DEFAULT,
             D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_D32);
     ok(hr == D3DERR_NOTAVAILABLE || broken(hr == D3DERR_INVALIDCALL /* Windows 10 */),
-            "Got unexpected hr %#x.\n", hr);
+            "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D9_CheckDepthStencilMatch(d3d, D3DADAPTER_DEFAULT,
             D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DFMT_R5G6B5, D3DFMT_D32);
     ok(hr == D3DERR_NOTAVAILABLE || broken(hr == D3DERR_INVALIDCALL /* Windows 10 */),
-            "Got unexpected hr %#x.\n", hr);
+            "Got unexpected hr %#lx.\n", hr);
 
     IDirect3D9_Release(d3d);
 }
@@ -12383,8 +12374,8 @@ static void test_miptree_layout(void)
     D3DLOCKED_RECT map_desc;
     BYTE *base = NULL;
     IDirect3D9 *d3d;
+    ULONG refcount;
     D3DCAPS9 caps;
-    UINT refcount;
     HWND window;
     HRESULT hr;
 
@@ -12423,7 +12414,7 @@ static void test_miptree_layout(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     base_dimension = 257;
     if (caps.TextureCaps & (D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_CUBEMAP_POW2))
@@ -12445,14 +12436,14 @@ static void test_miptree_layout(void)
         {
             hr = IDirect3DDevice9_CreateTexture(device, base_dimension, base_dimension, 0, 0,
                     formats[format_idx].format, pools[pool_idx].pool, &texture_2d, NULL);
-            ok(SUCCEEDED(hr), "Failed to create a %s %s texture, hr %#x.\n",
+            ok(SUCCEEDED(hr), "Failed to create a %s %s texture, hr %#lx.\n",
                     pools[pool_idx].name, formats[format_idx].name, hr);
 
             level_count = IDirect3DTexture9_GetLevelCount(texture_2d);
             for (i = 0, offset = 0; i < level_count; ++i)
             {
                 hr = IDirect3DTexture9_LockRect(texture_2d, i, &map_desc, NULL, 0);
-                ok(SUCCEEDED(hr), "%s, %s: Failed to lock level %u, hr %#x.\n",
+                ok(SUCCEEDED(hr), "%s, %s: Failed to lock level %u, hr %#lx.\n",
                         pools[pool_idx].name, formats[format_idx].name, i, hr);
 
                 if (!i)
@@ -12464,7 +12455,7 @@ static void test_miptree_layout(void)
                 offset += (base_dimension >> i) * map_desc.Pitch;
 
                 hr = IDirect3DTexture9_UnlockRect(texture_2d, i);
-                ok(SUCCEEDED(hr), "%s, %s Failed to unlock level %u, hr %#x.\n",
+                ok(SUCCEEDED(hr), "%s, %s Failed to unlock level %u, hr %#lx.\n",
                         pools[pool_idx].name, formats[format_idx].name, i, hr);
             }
 
@@ -12482,7 +12473,7 @@ static void test_miptree_layout(void)
         {
             hr = IDirect3DDevice9_CreateCubeTexture(device, base_dimension, 0, 0,
                     formats[format_idx].format, pools[pool_idx].pool, &texture_cube, NULL);
-            ok(SUCCEEDED(hr), "Failed to create a %s %s cube texture, hr %#x.\n",
+            ok(SUCCEEDED(hr), "Failed to create a %s %s cube texture, hr %#lx.\n",
                     pools[pool_idx].name, formats[format_idx].name, hr);
 
             level_count = IDirect3DCubeTexture9_GetLevelCount(texture_cube);
@@ -12491,7 +12482,7 @@ static void test_miptree_layout(void)
                 for (j = 0; j < level_count; ++j)
                 {
                     hr = IDirect3DCubeTexture9_LockRect(texture_cube, i, j, &map_desc, NULL, 0);
-                    ok(SUCCEEDED(hr), "%s, %s: Failed to lock face %u, level %u, hr %#x.\n",
+                    ok(SUCCEEDED(hr), "%s, %s: Failed to lock face %u, level %u, hr %#lx.\n",
                             pools[pool_idx].name, formats[format_idx].name, i, j, hr);
 
                     if (!i && !j)
@@ -12503,7 +12494,7 @@ static void test_miptree_layout(void)
                     offset += (base_dimension >> j) * map_desc.Pitch;
 
                     hr = IDirect3DCubeTexture9_UnlockRect(texture_cube, i, j);
-                    ok(SUCCEEDED(hr), "%s, %s: Failed to unlock face %u, level %u, hr %#x.\n",
+                    ok(SUCCEEDED(hr), "%s, %s: Failed to unlock face %u, level %u, hr %#lx.\n",
                             pools[pool_idx].name, formats[format_idx].name, i, j, hr);
                 }
                 offset = (offset + 15) & ~15;
@@ -12514,7 +12505,7 @@ static void test_miptree_layout(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -12525,7 +12516,7 @@ static void test_get_render_target_data(void)
     IDirect3DSurface9 *offscreen_surface, *render_target;
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     HRESULT hr;
 
@@ -12542,28 +12533,28 @@ static void test_get_render_target_data(void)
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &offscreen_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create offscreen surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create offscreen surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &render_target, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTargetData(device, NULL, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTargetData(device, render_target, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTargetData(device, NULL, offscreen_surface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTargetData(device, render_target, offscreen_surface);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(render_target);
     IDirect3DSurface9_Release(offscreen_surface);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -12573,7 +12564,7 @@ static void test_render_target_device_mismatch(void)
     IDirect3DDevice9 *device, *device2;
     IDirect3DSurface9 *surface, *rt;
     IDirect3D9 *d3d;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     HRESULT hr;
 
@@ -12589,38 +12580,38 @@ static void test_render_target_device_mismatch(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     device2 = create_device(d3d, window, NULL);
     ok(!!device2, "Failed to create a D3D device.\n");
 
     hr = IDirect3DDevice9_CreateRenderTarget(device2, 640, 480,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_GetRenderTarget(device2, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     ok(surface == rt, "Got unexpected render target %p, expected %p.\n", surface, rt);
     IDirect3DSurface9_Release(surface);
     IDirect3DSurface9_Release(rt);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirect3DDevice9_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -12629,7 +12620,7 @@ static void test_format_unknown(void)
 {
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d;
-    UINT refcount;
+    ULONG refcount;
     HWND window;
     void *iface;
     HRESULT hr;
@@ -12648,41 +12639,41 @@ static void test_format_unknown(void)
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9_CreateRenderTarget(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, 0, FALSE, (IDirect3DSurface9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, 0, TRUE, (IDirect3DSurface9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DSurface9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DTexture9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9_CreateCubeTexture(device, 64, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DCubeTexture9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 64, 64, 1, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DVolumeTexture9 **)&iface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -12712,16 +12703,16 @@ static void test_destroyed_window(void)
     }
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00000000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 }
 
 static void test_lockable_backbuffer(void)
@@ -12750,15 +12741,15 @@ static void test_lockable_backbuffer(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &lockrect, NULL, D3DLOCK_DISCARD);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     dc = (void *)0xdeadbeef;
     hr = IDirect3DSurface9_GetDC(surface, &dc);
     ok(dc == (void *)0xdeadbeef, "Unexpected DC returned.\n");
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
 
@@ -12774,19 +12765,19 @@ static void test_lockable_backbuffer(void)
     present_parameters.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
 
     hr = IDirect3DDevice9_Reset(device, &present_parameters);
-    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &lockrect, NULL, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "Failed to lock rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock rect, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     device_desc.width = 640;
@@ -12798,16 +12789,16 @@ static void test_lockable_backbuffer(void)
     ok(!!device, "Failed to create device.\n");
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &lockrect, NULL, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "Failed to lock rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock rect, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -12839,21 +12830,21 @@ static void test_clip_planes_limits(void)
         desc.flags = device_flags[i];
         if (!(device = create_device(d3d, window, &desc)))
         {
-            skip("Failed to create D3D device, flags %#x.\n", desc.flags);
+            skip("Failed to create D3D device, flags %#lx.\n", desc.flags);
             continue;
         }
 
         memset(&caps, 0, sizeof(caps));
         hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-        ok(hr == D3D_OK, "Failed to get caps, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to get caps, hr %#lx.\n", hr);
 
-        trace("Max user clip planes: %u.\n", caps.MaxUserClipPlanes);
+        trace("Max user clip planes: %lu.\n", caps.MaxUserClipPlanes);
 
         for (j = 0; j < 2 * D3DMAXUSERCLIPPLANES; ++j)
         {
             memset(plane, 0xff, sizeof(plane));
             hr = IDirect3DDevice9_GetClipPlane(device, j, plane);
-            ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#x.\n", j, hr);
+            ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#lx.\n", j, hr);
             ok(!plane[0] && !plane[1] && !plane[2] && !plane[3],
                     "Got unexpected plane %u: %.8e, %.8e, %.8e, %.8e.\n",
                     j, plane[0], plane[1], plane[2], plane[3]);
@@ -12866,32 +12857,32 @@ static void test_clip_planes_limits(void)
         {
             plane[3] = j;
             hr = IDirect3DDevice9_SetClipPlane(device, j, plane);
-            ok(hr == D3D_OK, "Failed to set clip plane %u, hr %#x.\n", j, hr);
+            ok(hr == D3D_OK, "Failed to set clip plane %u, hr %#lx.\n", j, hr);
         }
         for (j = 0; j < 2 * D3DMAXUSERCLIPPLANES; ++j)
         {
             float expected_d = j >= caps.MaxUserClipPlanes - 1 ? 2 * D3DMAXUSERCLIPPLANES - 1 : j;
             memset(plane, 0xff, sizeof(plane));
             hr = IDirect3DDevice9_GetClipPlane(device, j, plane);
-            ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#x.\n", j, hr);
+            ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#lx.\n", j, hr);
             ok(plane[0] == 2.0f && plane[1] == 8.0f && plane[2] == 5.0f && plane[3] == expected_d,
                     "Got unexpected plane %u: %.8e, %.8e, %.8e, %.8e.\n",
                     j, plane[0], plane[1], plane[2], plane[3]);
         }
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPLANEENABLE, 0xffffffff);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetRenderState(device, D3DRS_CLIPPLANEENABLE, &state);
-        ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-        ok(state == 0xffffffff, "Got unexpected state %#x.\n", state);
+        ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+        ok(state == 0xffffffff, "Got unexpected state %#lx.\n", state);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPLANEENABLE, 0x80000000);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetRenderState(device, D3DRS_CLIPPLANEENABLE, &state);
-        ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-        ok(state == 0x80000000, "Got unexpected state %#x.\n", state);
+        ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+        ok(state == 0x80000000, "Got unexpected state %#lx.\n", state);
 
         refcount = IDirect3DDevice9_Release(device);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
 
     IDirect3D9_Release(d3d);
@@ -12932,12 +12923,12 @@ static void test_swapchain_multisample_reset(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-    ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-    ok(hr == D3D_OK, "Failed to get the implicit swapchain, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get the implicit swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(hr == D3D_OK, "Failed to get present parameters, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get present parameters, hr %#lx.\n", hr);
     ok(d3dpp.MultiSampleType == D3DMULTISAMPLE_NONE,
             "Got unexpected multisample type %#x.\n", d3dpp.MultiSampleType);
     IDirect3DSwapChain9_Release(swapchain);
@@ -12945,13 +12936,13 @@ static void test_swapchain_multisample_reset(void)
     d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
     d3dpp.MultiSampleQuality = quality_levels - 1;
     hr = IDirect3DDevice9_Reset(device, &d3dpp);
-    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-    ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -12996,7 +12987,7 @@ static void test_stretch_rect(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "Failed to get caps, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get caps, hr %#lx.\n", hr);
     can_stretch_textures = caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
 
     for (i = 0; i < ARRAY_SIZE(formats); ++i)
@@ -13025,13 +13016,13 @@ static void test_stretch_rect(void)
 
             hr = IDirect3DDevice9_CreateRenderTarget(device, 32, 32, src_format,
                     D3DMULTISAMPLE_NONE, 0, FALSE, &src_rt, NULL);
-            ok(hr == D3D_OK, "Failed to create render target, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Failed to create render target, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_CreateRenderTarget(device, 32, 32, dst_format,
                     D3DMULTISAMPLE_NONE, 0, FALSE, &dst_rt, NULL);
-            ok(hr == D3D_OK, "Failed to create render target, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Failed to create render target, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_StretchRect(device, src_rt, NULL, dst_rt, NULL, D3DTEXF_NONE);
-            ok(hr == D3D_OK, "Got hr %#x (formats %#x/%#x).\n", hr, src_format, dst_format);
+            ok(hr == D3D_OK, "Got hr %#lx (formats %#x/%#x).\n", hr, src_format, dst_format);
 
             for (src_pool = D3DPOOL_DEFAULT; src_pool <= D3DPOOL_SCRATCH; ++src_pool)
             {
@@ -13039,19 +13030,19 @@ static void test_stretch_rect(void)
                 {
                     hr = IDirect3DDevice9_CreateTexture(device, 32, 32, 1, 0,
                             src_format, src_pool, &src_texture, NULL);
-                    ok(hr == D3D_OK, "Failed to create texture, hr %#x.\n", hr);
+                    ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
                     hr = IDirect3DDevice9_CreateTexture(device, 32, 32, 1, 0,
                             dst_format, dst_pool, &dst_texture, NULL);
-                    ok(hr == D3D_OK, "Failed to create texture, hr %#x.\n", hr);
+                    ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
                     hr = IDirect3DTexture9_GetSurfaceLevel(src_texture, 0, &src);
-                    ok(hr == D3D_OK, "Failed to get surface, hr %#x.\n", hr);
+                    ok(hr == D3D_OK, "Failed to get surface, hr %#lx.\n", hr);
                     hr = IDirect3DTexture9_GetSurfaceLevel(dst_texture, 0, &dst);
-                    ok(hr == D3D_OK, "Failed to get surface, hr %#x.\n", hr);
+                    ok(hr == D3D_OK, "Failed to get surface, hr %#lx.\n", hr);
                     IDirect3DTexture9_Release(src_texture);
                     IDirect3DTexture9_Release(dst_texture);
 
                     hr = IDirect3DDevice9_StretchRect(device, src, NULL, dst, NULL, D3DTEXF_NONE);
-                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#x (formats %#x/%#x, pools %#x/%#x).\n",
+                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx (formats %#x/%#x, pools %#x/%#x).\n",
                             hr, src_format, dst_format, src_pool, dst_pool);
 
                     /* render target <-> texture */
@@ -13060,10 +13051,10 @@ static void test_stretch_rect(void)
                     else
                         expected_hr = D3DERR_INVALIDCALL;
                     hr = IDirect3DDevice9_StretchRect(device, src, NULL, dst_rt, NULL, D3DTEXF_NONE);
-                    ok(hr == expected_hr, "Got hr %#x, expected hr %#x (formats %#x/%#x, pool %#x).\n",
+                    ok(hr == expected_hr, "Got hr %#lx, expected hr %#lx (formats %#x/%#x, pool %#x).\n",
                             hr, expected_hr, src_format, dst_format, src_pool);
                     hr = IDirect3DDevice9_StretchRect(device, src_rt, NULL, dst, NULL, D3DTEXF_NONE);
-                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#x (formats %#x/%#x, pool %#x).\n",
+                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx (formats %#x/%#x, pool %#x).\n",
                             hr, src_format, dst_format, dst_pool);
 
                     if (src_pool == D3DPOOL_MANAGED || dst_pool == D3DPOOL_MANAGED)
@@ -13080,32 +13071,32 @@ static void test_stretch_rect(void)
 
                     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
                             src_format, src_pool, &src_surface, NULL);
-                    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+                    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
                     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
                             dst_format, dst_pool, &dst_surface, NULL);
-                    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+                    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
                     hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL, dst_surface, NULL, D3DTEXF_NONE);
-                    ok(hr == expected_hr, "Got hr %#x, expected %#x (formats %#x/%#x, pools %#x/%#x).\n",
+                    ok(hr == expected_hr, "Got hr %#lx, expected %#lx (formats %#x/%#x, pools %#x/%#x).\n",
                             hr, expected_hr, src_format, dst_format, src_pool, dst_pool);
 
                     /* offscreen plain <-> texture */
                     hr = IDirect3DDevice9_StretchRect(device, src, NULL, dst_surface, NULL, D3DTEXF_NONE);
                     todo_wine_if(src_pool == D3DPOOL_DEFAULT && dst_pool == D3DPOOL_DEFAULT)
-                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#x (formats %#x/%#x, pools %#x/%#x).\n",
+                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx (formats %#x/%#x, pools %#x/%#x).\n",
                             hr, src_format, dst_format, src_pool, dst_pool);
                     hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL, dst, NULL, D3DTEXF_NONE);
-                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#x (formats %#x/%#x, pools %#x/%#x).\n",
+                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx (formats %#x/%#x, pools %#x/%#x).\n",
                             hr, src_format, dst_format, src_pool, dst_pool);
 
                     /* offscreen plain <-> render target */
                     expected_hr = src_pool == D3DPOOL_DEFAULT ? D3D_OK : D3DERR_INVALIDCALL;
                     hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL, dst_rt, NULL, D3DTEXF_NONE);
-                    ok(hr == expected_hr, "Got hr %#x, expected hr %#x (formats %#x/%#x, pool %#x).\n",
+                    ok(hr == expected_hr, "Got hr %#lx, expected hr %#lx (formats %#x/%#x, pool %#x).\n",
                             hr, expected_hr, src_format, dst_format, src_pool);
                     hr = IDirect3DDevice9_StretchRect(device, src_rt, NULL, dst_surface, NULL, D3DTEXF_NONE);
                     todo_wine_if(dst_pool == D3DPOOL_DEFAULT)
-                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#x (formats %#x/%#x, pool %#x).\n",
+                    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx (formats %#x/%#x, pool %#x).\n",
                             hr, src_format, dst_format, dst_pool);
 
                     IDirect3DSurface9_Release(src_surface);
@@ -13122,7 +13113,7 @@ static void test_stretch_rect(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -13186,7 +13177,7 @@ static void test_device_caps(void)
     {
         /* Test IDirect3D9_GetDeviceCaps */
         hr = IDirect3D9_GetDeviceCaps(d3d, adapter_idx, D3DDEVTYPE_HAL, &caps);
-        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Adapter %u: GetDeviceCaps failed, hr %#x.\n",
+        ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Adapter %u: GetDeviceCaps failed, hr %#lx.\n",
                 adapter_idx, hr);
         if (hr == D3DERR_NOTAVAILABLE)
         {
@@ -13204,22 +13195,22 @@ static void test_device_caps(void)
             break;
         }
         hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-        ok(SUCCEEDED(hr), "Adapter %u: Failed to get caps, hr %#x.\n", adapter_idx, hr);
+        ok(SUCCEEDED(hr), "Adapter %u: Failed to get caps, hr %#lx.\n", adapter_idx, hr);
 
         test_device_caps_adapter_group(&caps, adapter_idx, adapter_count);
         ok(!(caps.Caps & ~D3DCAPS_READ_SCANLINE),
-                "Adapter %u: Caps field has unexpected flags %#x.\n", adapter_idx, caps.Caps);
+                "Adapter %u: Caps field has unexpected flags %#lx.\n", adapter_idx, caps.Caps);
         ok(!(caps.Caps2 & ~(D3DCAPS2_FULLSCREENGAMMA | D3DCAPS2_CANCALIBRATEGAMMA | D3DCAPS2_RESERVED
                 | D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_CANAUTOGENMIPMAP
                 | D3DCAPS2_CANSHARERESOURCE)),
-                "Adapter %u: Caps2 field has unexpected flags %#x.\n", adapter_idx, caps.Caps2);
+                "Adapter %u: Caps2 field has unexpected flags %#lx.\n", adapter_idx, caps.Caps2);
         /* AMD doesn't filter all the ddraw / d3d9 caps. Consider that behavior
          * broken. */
         ok(!(caps.Caps3 & ~(D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
                 | D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION | D3DCAPS3_COPY_TO_VIDMEM
                 | D3DCAPS3_COPY_TO_SYSTEMMEM | D3DCAPS3_DXVAHD | D3DCAPS3_DXVAHD_LIMITED
                 | D3DCAPS3_RESERVED)),
-                "Adapter %u: Caps3 field has unexpected flags %#x.\n", adapter_idx, caps.Caps3);
+                "Adapter %u: Caps3 field has unexpected flags %#lx.\n", adapter_idx, caps.Caps3);
         ok(!(caps.PrimitiveMiscCaps & ~(D3DPMISCCAPS_MASKZ | D3DPMISCCAPS_LINEPATTERNREP
                 | D3DPMISCCAPS_CULLNONE | D3DPMISCCAPS_CULLCW | D3DPMISCCAPS_CULLCCW
                 | D3DPMISCCAPS_COLORWRITEENABLE | D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
@@ -13229,7 +13220,7 @@ static void test_device_caps(void)
                 | D3DPMISCCAPS_SEPARATEALPHABLEND | D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
                 | D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING | D3DPMISCCAPS_FOGVERTEXCLAMPED
                 | D3DPMISCCAPS_POSTBLENDSRGBCONVERT)),
-                "Adapter %u: PrimitiveMiscCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: PrimitiveMiscCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.PrimitiveMiscCaps);
         ok(!(caps.RasterCaps & ~(D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_ZTEST
                 | D3DPRASTERCAPS_FOGVERTEX | D3DPRASTERCAPS_FOGTABLE
@@ -13239,7 +13230,7 @@ static void test_device_caps(void)
                 | D3DPRASTERCAPS_SCISSORTEST | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
                 | D3DPRASTERCAPS_DEPTHBIAS | D3DPRASTERCAPS_MULTISAMPLE_TOGGLE))
                 || broken(!(caps.RasterCaps & ~0x0f736191)),
-                "Adapter %u: RasterCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: RasterCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.RasterCaps);
         /* D3DPBLENDCAPS_SRCCOLOR2 and D3DPBLENDCAPS_INVSRCCOLOR2 are only
          * advertised on the reference rasterizer and WARP. */
@@ -13254,7 +13245,7 @@ static void test_device_caps(void)
                 | D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA
                 | D3DPBLENDCAPS_BOTHINVSRCALPHA | D3DPBLENDCAPS_BLENDFACTOR
                 | D3DPBLENDCAPS_SRCCOLOR2 | D3DPBLENDCAPS_INVSRCCOLOR2))),
-                "Adapter %u: SrcBlendCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: SrcBlendCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.SrcBlendCaps);
         ok(!(caps.DestBlendCaps & ~(D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR
                 | D3DPBLENDCAPS_INVSRCCOLOR | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA
@@ -13267,7 +13258,7 @@ static void test_device_caps(void)
                 | D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA
                 | D3DPBLENDCAPS_BOTHINVSRCALPHA | D3DPBLENDCAPS_BLENDFACTOR
                 | D3DPBLENDCAPS_SRCCOLOR2 | D3DPBLENDCAPS_INVSRCCOLOR2))),
-                "Adapter %u: DestBlendCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: DestBlendCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.DestBlendCaps);
         ok(!(caps.TextureCaps & ~(D3DPTEXTURECAPS_PERSPECTIVE | D3DPTEXTURECAPS_POW2
                 | D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_SQUAREONLY
@@ -13277,7 +13268,7 @@ static void test_device_caps(void)
                 | D3DPTEXTURECAPS_MIPVOLUMEMAP | D3DPTEXTURECAPS_MIPCUBEMAP
                 | D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2
                 | D3DPTEXTURECAPS_NOPROJECTEDBUMPENV)),
-                "Adapter %u: TextureCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: TextureCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.TextureCaps);
         ok(!(caps.TextureFilterCaps & ~(D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR
                 | D3DPTFILTERCAPS_MINFANISOTROPIC | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD
@@ -13286,7 +13277,7 @@ static void test_device_caps(void)
                 | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR
                 | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD
                 | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD)),
-                "Adapter %u: TextureFilterCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: TextureFilterCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.TextureFilterCaps);
         ok(!(caps.CubeTextureFilterCaps & ~(D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR
                 | D3DPTFILTERCAPS_MINFANISOTROPIC | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD
@@ -13294,7 +13285,7 @@ static void test_device_caps(void)
                 | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR
                 | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD
                 | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD)),
-                "Adapter %u: CubeTextureFilterCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: CubeTextureFilterCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.CubeTextureFilterCaps);
         ok(!(caps.VolumeTextureFilterCaps & ~(D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR
                 | D3DPTFILTERCAPS_MINFANISOTROPIC | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD
@@ -13302,37 +13293,37 @@ static void test_device_caps(void)
                 | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR
                 | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD
                 | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD)),
-                "Adapter %u: VolumeTextureFilterCaps field has unexpected flags %#x.\n",
+                "Adapter %u: VolumeTextureFilterCaps field has unexpected flags %#lx.\n",
                 adapter_idx, caps.VolumeTextureFilterCaps);
         ok(!(caps.LineCaps & ~(D3DLINECAPS_TEXTURE | D3DLINECAPS_ZTEST | D3DLINECAPS_BLEND
                 | D3DLINECAPS_ALPHACMP | D3DLINECAPS_FOG | D3DLINECAPS_ANTIALIAS)),
-                "Adapter %u: LineCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: LineCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.LineCaps);
         ok(!(caps.StencilCaps & ~(D3DSTENCILCAPS_KEEP | D3DSTENCILCAPS_ZERO | D3DSTENCILCAPS_REPLACE
                 | D3DSTENCILCAPS_INCRSAT | D3DSTENCILCAPS_DECRSAT | D3DSTENCILCAPS_INVERT
                 | D3DSTENCILCAPS_INCR | D3DSTENCILCAPS_DECR | D3DSTENCILCAPS_TWOSIDED)),
-                "Adapter %u: StencilCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: StencilCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.StencilCaps);
         ok(!(caps.VertexProcessingCaps & ~(D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7
                 | D3DVTXPCAPS_DIRECTIONALLIGHTS | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER
                 | D3DVTXPCAPS_TWEENING | D3DVTXPCAPS_TEXGEN_SPHEREMAP
                 | D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER)),
-                "Adapter %u: VertexProcessingCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: VertexProcessingCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.VertexProcessingCaps);
         /* Both Nvidia and AMD give 10 here. */
         ok(caps.MaxActiveLights <= 10,
-                "Adapter %u: MaxActiveLights field has unexpected value %u.\n", adapter_idx,
+                "Adapter %u: MaxActiveLights field has unexpected value %lu.\n", adapter_idx,
                 caps.MaxActiveLights);
         /* AMD gives 6, Nvidia returns 8. */
         ok(caps.MaxUserClipPlanes <= 8,
-                "Adapter %u: MaxUserClipPlanes field has unexpected value %u.\n", adapter_idx,
+                "Adapter %u: MaxUserClipPlanes field has unexpected value %lu.\n", adapter_idx,
                 caps.MaxUserClipPlanes);
         ok(caps.MaxVertexW == 0.0f || caps.MaxVertexW >= 1e10f,
                 "Adapter %u: MaxVertexW field has unexpected value %.8e.\n", adapter_idx,
                 caps.MaxVertexW);
 
         refcount = IDirect3DDevice9_Release(device);
-        ok(!refcount, "Adapter %u: Device has %u references left.\n", adapter_idx, refcount);
+        ok(!refcount, "Adapter %u: Device has %lu references left.\n", adapter_idx, refcount);
     }
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13451,19 +13442,19 @@ static void test_resource_access(void)
         return;
     }
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     warp = adapter_is_warp(&identifier);
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetDesc(backbuffer, &surface_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     colour_format = surface_desc.Format;
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &depth_stencil);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetDesc(depth_stencil, &surface_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     depth_format = surface_desc.Format;
 
     depth_2d = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
@@ -13474,7 +13465,7 @@ static void test_resource_access(void)
             D3DFMT_X8R8G8B8, 0, D3DRTYPE_SURFACE, depth_format));
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(surface_types); ++i)
     {
@@ -13509,12 +13500,12 @@ static void test_resource_access(void)
                     todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
                         ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_2d)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
-                                "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                                "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
 
                     hr = IDirect3DTexture9_GetSurfaceLevel(texture_2d, 0, &surface);
-                    ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                    ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     IDirect3DTexture9_Release(texture_2d);
                     break;
 
@@ -13524,13 +13515,13 @@ static void test_resource_access(void)
                     todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
                         ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_cube)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
-                                "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                                "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
 
                     hr = IDirect3DCubeTexture9_GetCubeMapSurface(texture_cube,
                             D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
-                    ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                    ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     IDirect3DCubeTexture9_Release(texture_cube);
                     break;
 
@@ -13538,7 +13529,7 @@ static void test_resource_access(void)
                     hr = IDirect3DDevice9_CreateRenderTarget(device, 16, 16, format,
                             D3DMULTISAMPLE_NONE, 0, tests[j].usage & D3DUSAGE_DYNAMIC, &surface, NULL);
                     ok(hr == (tests[j].format == FORMAT_COLOUR ? D3D_OK : D3DERR_INVALIDCALL),
-                            "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                            "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -13547,7 +13538,7 @@ static void test_resource_access(void)
                     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 16, 16, format,
                             D3DMULTISAMPLE_NONE, 0, tests[j].usage & D3DUSAGE_DYNAMIC, &surface, NULL);
                     ok(hr == (tests[j].format == FORMAT_DEPTH ? D3D_OK : D3DERR_INVALIDCALL),
-                            "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                            "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -13560,7 +13551,7 @@ static void test_resource_access(void)
                         ok(hr == (tests[j].pool != D3DPOOL_MANAGED && (tests[j].format != FORMAT_DEPTH || depth_plain)
                                 && (tests[j].format != FORMAT_ATI2 || tests[j].pool == D3DPOOL_SCRATCH)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
-                                "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                                "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;
                     break;
@@ -13571,31 +13562,31 @@ static void test_resource_access(void)
             }
 
             hr = IDirect3DSurface9_GetDesc(surface, &surface_desc);
-            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
             if (surface_types[i].type == SURFACE_RT)
             {
-                ok(surface_desc.Usage == D3DUSAGE_RENDERTARGET, "Test %s %u: Got unexpected usage %#x.\n",
+                ok(surface_desc.Usage == D3DUSAGE_RENDERTARGET, "Test %s %u: Got unexpected usage %#lx.\n",
                         surface_types[i].name, j, surface_desc.Usage);
                 ok(surface_desc.Pool == D3DPOOL_DEFAULT, "Test %s %u: Got unexpected pool %#x.\n",
                         surface_types[i].name, j, surface_desc.Pool);
             }
             else if (surface_types[i].type == SURFACE_DS)
             {
-                ok(surface_desc.Usage == D3DUSAGE_DEPTHSTENCIL, "Test %s %u: Got unexpected usage %#x.\n",
+                ok(surface_desc.Usage == D3DUSAGE_DEPTHSTENCIL, "Test %s %u: Got unexpected usage %#lx.\n",
                         surface_types[i].name, j, surface_desc.Usage);
                 ok(surface_desc.Pool == D3DPOOL_DEFAULT, "Test %s %u: Got unexpected pool %#x.\n",
                         surface_types[i].name, j, surface_desc.Pool);
             }
             else if (surface_types[i].type == SURFACE_PLAIN)
             {
-                ok(!surface_desc.Usage, "Test %s %u: Got unexpected usage %#x.\n",
+                ok(!surface_desc.Usage, "Test %s %u: Got unexpected usage %#lx.\n",
                         surface_types[i].name, j, surface_desc.Usage);
                 ok(surface_desc.Pool == tests[j].pool, "Test %s %u: Got unexpected pool %#x.\n",
                         surface_types[i].name, j, surface_desc.Pool);
             }
             else
             {
-                ok(surface_desc.Usage == tests[j].usage, "Test %s %u: Got unexpected usage %#x.\n",
+                ok(surface_desc.Usage == tests[j].usage, "Test %s %u: Got unexpected usage %#lx.\n",
                         surface_types[i].name, j, surface_desc.Usage);
                 ok(surface_desc.Pool == tests[j].pool, "Test %s %u: Got unexpected pool %#x.\n",
                         surface_types[i].name, j, surface_desc.Pool);
@@ -13609,31 +13600,31 @@ static void test_resource_access(void)
                 expected_hr = D3D_OK;
             else
                 expected_hr = D3DERR_INVALIDCALL;
-            ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+            ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
             hr = IDirect3DSurface9_UnlockRect(surface);
             todo_wine_if(expected_hr != D3D_OK && surface_types[i].type == SURFACE_2D)
-                ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
 
             if (SUCCEEDED(IDirect3DSurface9_GetContainer(surface, &IID_IDirect3DBaseTexture9, (void **)&texture)))
             {
                 hr = IDirect3DDevice9_SetTexture(device, 0, texture);
-                ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                 hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-                ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
                 IDirect3DBaseTexture9_Release(texture);
             }
 
             hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface);
             ok(hr == (surface_desc.Usage & D3DUSAGE_RENDERTARGET ? D3D_OK : D3DERR_INVALIDCALL),
-                    "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                    "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
             hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
 
             hr = IDirect3DDevice9_SetDepthStencilSurface(device, surface);
             ok(hr == (surface_desc.Usage & D3DUSAGE_DEPTHSTENCIL ? D3D_OK : D3DERR_INVALIDCALL),
-                    "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+                    "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
             hr = IDirect3DDevice9_SetDepthStencilSurface(device, depth_stencil);
-            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+            ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#lx.\n", surface_types[i].name, j, hr);
 
             IDirect3DSurface9_Release(surface);
         }
@@ -13661,16 +13652,16 @@ static void test_resource_access(void)
                 && (tests[i].format != FORMAT_ATI2 || tests[i].pool == D3DPOOL_SCRATCH)
                 ? D3D_OK : D3DERR_INVALIDCALL))
                 || (tests[i].format == FORMAT_ATI2 && (hr == D3D_OK || warp)),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirect3DVolumeTexture9_GetVolumeLevel(texture, 0, &volume);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DVolume9_GetDesc(volume, &volume_desc);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(volume_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, volume_desc.Usage);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(volume_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#lx.\n", i, volume_desc.Usage);
         ok(volume_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, volume_desc.Pool);
 
         hr = IDirect3DVolume9_LockBox(volume, &lb, NULL, 0);
@@ -13679,15 +13670,15 @@ static void test_resource_access(void)
         else
             expected_hr = D3DERR_INVALIDCALL;
         ok(hr == expected_hr || (volume_desc.Pool == D3DPOOL_DEFAULT && hr == D3D_OK),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DVolume9_UnlockBox(volume);
         ok(hr == expected_hr || (volume_desc.Pool == D3DPOOL_DEFAULT && hr == D3D_OK),
-                "Test %u: Got unexpected hr %#x.\n", i, hr);
+                "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         IDirect3DVolume9_Release(volume);
         IDirect3DVolumeTexture9_Release(texture);
@@ -13702,24 +13693,24 @@ static void test_resource_access(void)
         hr = IDirect3DDevice9_CreateIndexBuffer(device, 16, tests[i].usage,
                 tests[i].format == FORMAT_COLOUR ? D3DFMT_INDEX32 : D3DFMT_INDEX16, tests[i].pool, &ib, NULL);
         ok(hr == (tests[i].pool == D3DPOOL_SCRATCH || (tests[i].usage & ~D3DUSAGE_DYNAMIC)
-                ? D3DERR_INVALIDCALL : D3D_OK), "Test %u: Got unexpected hr %#x.\n", i, hr);
+                ? D3DERR_INVALIDCALL : D3D_OK), "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirect3DIndexBuffer9_GetDesc(ib, &ib_desc);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(ib_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, ib_desc.Usage);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(ib_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#lx.\n", i, ib_desc.Usage);
         ok(ib_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, ib_desc.Pool);
 
         hr = IDirect3DIndexBuffer9_Lock(ib, 0, 0, &data, 0);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DIndexBuffer9_Unlock(ib);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_SetIndices(device, ib);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_SetIndices(device, NULL);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         IDirect3DIndexBuffer9_Release(ib);
     }
@@ -13733,24 +13724,24 @@ static void test_resource_access(void)
         hr = IDirect3DDevice9_CreateVertexBuffer(device, 16, tests[i].usage,
                 tests[i].format == FORMAT_COLOUR ? 0 : D3DFVF_XYZRHW, tests[i].pool, &vb, NULL);
         ok(hr == (tests[i].pool == D3DPOOL_SCRATCH || (tests[i].usage & ~D3DUSAGE_DYNAMIC)
-                ? D3DERR_INVALIDCALL : D3D_OK), "Test %u: Got unexpected hr %#x.\n", i, hr);
+                ? D3DERR_INVALIDCALL : D3D_OK), "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirect3DVertexBuffer9_GetDesc(vb, &vb_desc);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(vb_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, vb_desc.Usage);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(vb_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#lx.\n", i, vb_desc.Usage);
         ok(vb_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, vb_desc.Pool);
 
         hr = IDirect3DVertexBuffer9_Lock(vb, 0, 0, &data, 0);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DVertexBuffer9_Unlock(vb);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, 16);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 0, 0);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         IDirect3DVertexBuffer9_Release(vb);
     }
@@ -13758,7 +13749,7 @@ static void test_resource_access(void)
     IDirect3DSurface9_Release(depth_stencil);
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -13824,52 +13815,52 @@ static void test_multiply_transform(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice9_GetTransform(device, tests[i], &ret_mat);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", i);
 
         hr = IDirect3DDevice9_MultiplyTransform(device, tests[i], &mat2);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_GetTransform(device, tests[i], &ret_mat);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         ok(!memcmp(&ret_mat, &mat2, sizeof(mat2)), "Test %u: Got unexpected transform matrix.\n", i);
 
         /* MultiplyTransform() goes directly into the primary stateblock. */
 
         hr = IDirect3DDevice9_SetTransform(device, tests[i], &mat1);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_BeginStateBlock(device);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_MultiplyTransform(device, tests[i], &mat2);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_EndStateBlock(device, &stateblock);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_GetTransform(device, tests[i], &ret_mat);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         ok(!memcmp(&ret_mat, &mat2, sizeof(mat2)), "Test %u: Got unexpected transform matrix.\n", i);
 
         hr = IDirect3DStateBlock9_Capture(stateblock);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_SetTransform(device, tests[i], &mat1);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DStateBlock9_Apply(stateblock);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_GetTransform(device, tests[i], &ret_mat);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", i);
 
         IDirect3DStateBlock9_Release(stateblock);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -13904,73 +13895,73 @@ static void test_vertex_buffer_read_write(void)
     }
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(tri),
             D3DUSAGE_DYNAMIC, D3DFVF_XYZ, D3DPOOL_DEFAULT, &buffer, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_DISCARD);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, tri, sizeof(tri));
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Draw using the buffer to make wined3d create BO. */
     hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(*tri));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < 3; ++i)
         data[i] = 3.0f;
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < 3; ++i)
         ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i);
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < 3; ++i)
         ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i);
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < 3; ++i)
         ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i);
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < 3; ++i)
         data[i] = 4.0f;
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < 3; ++i)
         ok(data[i] == 4.0f, "Got unexpected value %.8e, i %u.\n", data[i], i);
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer9_Release(buffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -14006,20 +13997,20 @@ static void test_get_display_mode(void)
     }
 
     hr = IDirect3DDevice9_GetDisplayMode(device, 0, &mode);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(mode.Format == D3DFMT_X8R8G8B8, "Unexpected format %#x.\n", mode.Format);
     hr = IDirect3D9_GetAdapterDisplayMode(d3d, D3DADAPTER_DEFAULT, &mode);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(mode.Format == D3DFMT_X8R8G8B8, "Unexpected format %#x.\n", mode.Format);
     hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetDisplayMode(swapchain, &mode);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(mode.Format == D3DFMT_X8R8G8B8, "Unexpected format %#x.\n", mode.Format);
     IDirect3DSwapChain9_Release(swapchain);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     desc.device_window = window;
@@ -14035,26 +14026,26 @@ static void test_get_display_mode(void)
     }
 
     hr = IDirect3DDevice9_GetDisplayMode(device, 0, &mode);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(mode.Width == 640, "Unexpected width %u.\n", mode.Width);
     ok(mode.Height == 480, "Unexpected width %u.\n", mode.Height);
     ok(mode.Format == D3DFMT_X8R8G8B8, "Unexpected format %#x.\n", mode.Format);
     hr = IDirect3D9_GetAdapterDisplayMode(d3d, D3DADAPTER_DEFAULT, &mode);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(mode.Width == 640, "Unexpected width %u.\n", mode.Width);
     ok(mode.Height == 480, "Unexpected width %u.\n", mode.Height);
     ok(mode.Format == D3DFMT_X8R8G8B8, "Unexpected format %#x.\n", mode.Format);
     hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetDisplayMode(swapchain, &mode);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(mode.Width == 640, "Unexpected width %u.\n", mode.Width);
     ok(mode.Height == 480, "Unexpected width %u.\n", mode.Height);
     ok(mode.Format == D3DFMT_X8R8G8B8, "Unexpected format %#x.\n", mode.Format);
     IDirect3DSwapChain9_Release(swapchain);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 
     /* D3D9 uses adapter indices to determine which adapter to use to get the display mode */
@@ -14074,7 +14065,7 @@ static void test_get_display_mode(void)
             ok(!!monitor, "Adapter %u: GetAdapterMonitor failed.\n", adapter_idx - 1);
             monitor_info.cbSize = sizeof(monitor_info);
             ret = GetMonitorInfoW(monitor, &monitor_info);
-            ok(ret, "Adapter %u: GetMonitorInfoW failed, error %#x.\n", adapter_idx - 1,
+            ok(ret, "Adapter %u: GetMonitorInfoW failed, error %#lx.\n", adapter_idx - 1,
                     GetLastError());
             previous_monitor_rect = monitor_info.rcMonitor;
 
@@ -14112,7 +14103,7 @@ static void test_get_display_mode(void)
             ok(!!monitor, "Adapter %u test %u: GetAdapterMonitor failed.\n", adapter_idx, test_idx);
             monitor_info.cbSize = sizeof(monitor_info);
             ret = GetMonitorInfoW(monitor, &monitor_info);
-            ok(ret, "Adapter %u test %u: GetMonitorInfoW failed, error %#x.\n", adapter_idx,
+            ok(ret, "Adapter %u test %u: GetMonitorInfoW failed, error %#lx.\n", adapter_idx,
                     test_idx, GetLastError());
             width = monitor_info.rcMonitor.right - monitor_info.rcMonitor.left;
             height = monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top;
@@ -14123,12 +14114,12 @@ static void test_get_display_mode(void)
                  * position doesn't affect which adapter to use to get the display mode */
                 ret = SetWindowPos(window, 0, previous_monitor_rect.left, previous_monitor_rect.top,
                         0, 0, SWP_NOZORDER | SWP_NOSIZE);
-                ok(ret, "Adapter %u test %u: SetWindowPos failed, error %#x.\n", adapter_idx,
+                ok(ret, "Adapter %u test %u: SetWindowPos failed, error %#lx.\n", adapter_idx,
                         test_idx, GetLastError());
             }
 
             hr = IDirect3D9_GetAdapterDisplayMode(d3d, adapter_idx, &mode);
-            ok(hr == D3D_OK, "Adapter %u test %u: GetAdapterDisplayMode failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: GetAdapterDisplayMode failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
             ok(mode.Width == width, "Adapter %u test %u: Expect width %u, got %u.\n", adapter_idx,
                     test_idx, width, mode.Width);
@@ -14136,7 +14127,7 @@ static void test_get_display_mode(void)
                     adapter_idx, test_idx, height, mode.Height);
 
             hr = IDirect3DDevice9_GetDisplayMode(device, 0, &mode);
-            ok(hr == D3D_OK, "Adapter %u test %u: GetDisplayMode failed, hr %#x.\n", adapter_idx,
+            ok(hr == D3D_OK, "Adapter %u test %u: GetDisplayMode failed, hr %#lx.\n", adapter_idx,
                     test_idx, hr);
             ok(mode.Width == width, "Adapter %u test %u: Expect width %u, got %u.\n", adapter_idx,
                     test_idx, width, mode.Width);
@@ -14144,10 +14135,10 @@ static void test_get_display_mode(void)
                     adapter_idx, test_idx, height, mode.Height);
 
             hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-            ok(hr == D3D_OK, "Adapter %u test %u: GetSwapChain failed, hr %#x.\n", adapter_idx,
+            ok(hr == D3D_OK, "Adapter %u test %u: GetSwapChain failed, hr %#lx.\n", adapter_idx,
                     test_idx, hr);
             hr = IDirect3DSwapChain9_GetDisplayMode(swapchain, &mode);
-            ok(hr == D3D_OK, "Adapter %u test %u: GetDisplayMode failed, hr %#x.\n", adapter_idx,
+            ok(hr == D3D_OK, "Adapter %u test %u: GetDisplayMode failed, hr %#lx.\n", adapter_idx,
                     test_idx, hr);
             ok(mode.Width == width, "Adapter %u test %u: Expect width %u, got %u.\n", adapter_idx,
                     test_idx, width, mode.Width);
@@ -14156,7 +14147,7 @@ static void test_get_display_mode(void)
             IDirect3DSwapChain9_Release(swapchain);
 
             refcount = IDirect3DDevice9_Release(device);
-            ok(!refcount, "Adapter %u test %u: Device has %u references left.\n", adapter_idx,
+            ok(!refcount, "Adapter %u test %u: Device has %lu references left.\n", adapter_idx,
                     test_idx, refcount);
             DestroyWindow(window);
         }
@@ -14196,13 +14187,13 @@ static void test_multi_adapter(void)
 
         monitor_info.cbSize = sizeof(monitor_info);
         ret = GetMonitorInfoA(monitor, (MONITORINFO *)&monitor_info);
-        ok(ret, "Adapter %u: Failed to get monitor info, error %#x.\n", i, GetLastError());
+        ok(ret, "Adapter %u: Failed to get monitor info, error %#lx.\n", i, GetLastError());
 
         if (!i)
             ok(monitor_info.dwFlags == MONITORINFOF_PRIMARY,
-                    "Adapter %u: Got unexpected monitor flags %#x.\n", i, monitor_info.dwFlags);
+                    "Adapter %u: Got unexpected monitor flags %#lx.\n", i, monitor_info.dwFlags);
         else
-            ok(!monitor_info.dwFlags, "Adapter %u: Got unexpected monitor flags %#x.\n", i,
+            ok(!monitor_info.dwFlags, "Adapter %u: Got unexpected monitor flags %#lx.\n", i,
                     monitor_info.dwFlags);
 
         /* Test D3D adapters after they got detached */
@@ -14214,7 +14205,7 @@ static void test_multi_adapter(void)
         old_mode.dmSize = sizeof(old_mode);
         ret = EnumDisplaySettingsA(monitor_info.szDevice, ENUM_CURRENT_SETTINGS, &old_mode);
         /* Win10 TestBots may return FALSE but it's actually successful */
-        ok(ret || broken(!ret), "Adapter %u: EnumDisplaySettingsA failed for %s, error %#x.\n", i,
+        ok(ret || broken(!ret), "Adapter %u: EnumDisplaySettingsA failed for %s, error %#lx.\n", i,
                 monitor_info.szDevice, GetLastError());
 
         /* Detach */
@@ -14225,11 +14216,11 @@ static void test_multi_adapter(void)
         ret = ChangeDisplaySettingsExA(monitor_info.szDevice, &mode, NULL,
                 CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
         ok(ret == DISP_CHANGE_SUCCESSFUL,
-                "Adapter %u: ChangeDisplaySettingsExA %s returned unexpected %d.\n", i,
+                "Adapter %u: ChangeDisplaySettingsExA %s returned unexpected %ld.\n", i,
                 monitor_info.szDevice, ret);
         ret = ChangeDisplaySettingsExA(monitor_info.szDevice, NULL, NULL, 0, NULL);
         ok(ret == DISP_CHANGE_SUCCESSFUL,
-                "Adapter %u: ChangeDisplaySettingsExA %s returned unexpected %d.\n", i,
+                "Adapter %u: ChangeDisplaySettingsExA %s returned unexpected %ld.\n", i,
                 monitor_info.szDevice, ret);
 
         /* Check if it is really detached */
@@ -14237,7 +14228,7 @@ static void test_multi_adapter(void)
         mode.dmSize = sizeof(mode);
         ret = EnumDisplaySettingsA(monitor_info.szDevice, ENUM_CURRENT_SETTINGS, &mode);
         /* Win10 TestBots may return FALSE but it's actually successful */
-        ok(ret || broken(!ret) , "Adapter %u: EnumDisplaySettingsA failed for %s, error %#x.\n", i,
+        ok(ret || broken(!ret) , "Adapter %u: EnumDisplaySettingsA failed for %s, error %#lx.\n", i,
                 monitor_info.szDevice, GetLastError());
         if (mode.dmPelsWidth && mode.dmPelsHeight)
         {
@@ -14259,11 +14250,11 @@ static void test_multi_adapter(void)
         ret = ChangeDisplaySettingsExA(monitor_info.szDevice, &old_mode, NULL,
                 CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
         ok(ret == DISP_CHANGE_SUCCESSFUL,
-                "Adapter %u: ChangeDisplaySettingsExA %s returned unexpected %d.\n", i,
+                "Adapter %u: ChangeDisplaySettingsExA %s returned unexpected %ld.\n", i,
                 monitor_info.szDevice, ret);
         ret = ChangeDisplaySettingsExA(monitor_info.szDevice, NULL, NULL, 0, NULL);
         ok(ret == DISP_CHANGE_SUCCESSFUL,
-                "Adapter %u: ChangeDisplaySettingsExA %s returned unexpected %d.\n", i,
+                "Adapter %u: ChangeDisplaySettingsExA %s returned unexpected %ld.\n", i,
                 monitor_info.szDevice, ret);
     }
 
@@ -14283,7 +14274,7 @@ struct IDirect3DShaderValidator9Vtbl
     HRESULT (WINAPI *Begin)(IDirect3DShaderValidator9 *iface,
             shader_validator_cb callback, void *context, DWORD_PTR arg3);
     HRESULT (WINAPI *Instruction)(IDirect3DShaderValidator9 *iface,
-            const char *file, int line, const DWORD *tokens, DWORD token_count);
+            const char *file, int line, const DWORD *tokens, unsigned int token_count);
     HRESULT (WINAPI *End)(IDirect3DShaderValidator9 *iface);
 };
 
@@ -14325,22 +14316,22 @@ HRESULT WINAPI test_shader_validator_cb(const char *file, int line, DWORD_PTR ar
 
 static void test_shader_validator(void)
 {
-    static const unsigned int dcl_texcoord_9_9[] = {0x0200001f, 0x80090005, 0x902f0009};   /* dcl_texcoord9_pp v9 */
-    static const unsigned int dcl_texcoord_9_10[] = {0x0200001f, 0x80090005, 0x902f000a};  /* dcl_texcoord9_pp v10 */
-    static const unsigned int dcl_texcoord_10_9[] = {0x0200001f, 0x800a0005, 0x902f0009};  /* dcl_texcoord10_pp v9 */
-    static const unsigned int mov_r2_v9[] = {0x02000001, 0x80220002, 0x90ff0009};          /* mov_pp r2.y, v9.w */
-    static const unsigned int mov_r2_v10[] = {0x02000001, 0x80220002, 0x90ff000a};         /* mov_pp r2.y, v10.w */
+    static const DWORD dcl_texcoord_9_9[] = {0x0200001f, 0x80090005, 0x902f0009};   /* dcl_texcoord9_pp v9 */
+    static const DWORD dcl_texcoord_9_10[] = {0x0200001f, 0x80090005, 0x902f000a};  /* dcl_texcoord9_pp v10 */
+    static const DWORD dcl_texcoord_10_9[] = {0x0200001f, 0x800a0005, 0x902f0009};  /* dcl_texcoord10_pp v9 */
+    static const DWORD mov_r2_v9[] = {0x02000001, 0x80220002, 0x90ff0009};          /* mov_pp r2.y, v9.w */
+    static const DWORD mov_r2_v10[] = {0x02000001, 0x80220002, 0x90ff000a};         /* mov_pp r2.y, v10.w */
 
-    static const unsigned int ps_3_0 = D3DPS_VERSION(3, 0);
-    static const unsigned int end_token = 0x0000ffff;
+    static const DWORD ps_3_0 = D3DPS_VERSION(3, 0);
+    static const DWORD end_token = 0x0000ffff;
     static const char *test_file_name = "test_file";
     static const struct instruction_test
     {
-        unsigned int shader_version;
-        const unsigned int *instruction;
+        DWORD shader_version;
+        const DWORD *instruction;
         unsigned int instruction_length;
         DWORD_PTR message_id;
-        const unsigned int *decl;
+        const DWORD *decl;
         unsigned int decl_length;
     }
     instruction_tests[] =
@@ -14361,32 +14352,32 @@ static void test_shader_validator(void)
     validator = Direct3DShaderValidatorCreate9();
 
     hr = validator->vtbl->Begin(validator, test_shader_validator_cb, NULL, 0);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, NULL, 0, &simple_vs[0], 1);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, NULL, 0, &simple_vs[1], 3);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, NULL, 0, &simple_vs[4], 4);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, NULL, 0, &simple_vs[8], 4);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, NULL, 0, &simple_vs[12], 4);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, NULL, 0, &simple_vs[16], 4);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, NULL, 0, &simple_vs[20], 1);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->End(validator);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = validator->vtbl->Begin(validator, test_shader_validator_cb, &context, 0);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&context, 0, sizeof(context));
     hr = validator->vtbl->Instruction(validator, test_file_name, 28, &simple_vs[1], 3);
     todo_wine
     {
-        ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
         ok(context.call_count == 2, "Got unexpected call_count %u.\n", context.call_count);
         ok(!!context.message[0], "Got NULL message.\n");
         ok(!!context.message[1], "Got NULL message.\n");
@@ -14400,14 +14391,14 @@ static void test_shader_validator(void)
 
     memset(&context, 0, sizeof(context));
     hr = validator->vtbl->End(validator);
-    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(!context.call_count, "Got unexpected call_count %u.\n", context.call_count);
 
     memset(&context, 0, sizeof(context));
     hr = validator->vtbl->Begin(validator, test_shader_validator_cb, &context, 0);
     todo_wine
     {
-        ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
         ok(context.call_count == 1, "Got unexpected call_count %u.\n", context.call_count);
         ok(context.message_id[0] == 0xeb, "Got unexpected message_id[0] %p.\n", (void *)context.message_id[0]);
         ok(!!context.message[0], "Got NULL message.\n");
@@ -14416,42 +14407,42 @@ static void test_shader_validator(void)
     ok(!context.line[0], "Got unexpected line %d.\n", context.line[0]);
 
     hr = validator->vtbl->Begin(validator, NULL, &context, 0);
-    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = validator->vtbl->Release(validator);
-    todo_wine ok(!refcount, "Validator has %u references left.\n", refcount);
+    todo_wine ok(!refcount, "Validator has %lu references left.\n", refcount);
     validator = Direct3DShaderValidatorCreate9();
 
     hr = validator->vtbl->Begin(validator, NULL, &context, 0);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, test_file_name, 1, &ps_3_0, 1);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->Instruction(validator, test_file_name, 5, &end_token, 1);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = validator->vtbl->End(validator);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(instruction_tests); ++i)
     {
         const struct instruction_test *test = &instruction_tests[i];
 
         hr = validator->vtbl->Begin(validator, test_shader_validator_cb, &context, 0);
-        ok(hr == S_OK, "Got unexpected hr %#x, test %u.\n", hr, i);
+        ok(hr == S_OK, "Got unexpected hr %#lx, test %u.\n", hr, i);
 
         hr = validator->vtbl->Instruction(validator, test_file_name, 1, &test->shader_version, 1);
-        ok(hr == S_OK, "Got unexpected hr %#x, test %u.\n", hr, i);
+        ok(hr == S_OK, "Got unexpected hr %#lx, test %u.\n", hr, i);
 
         if (test->decl)
         {
             memset(&context, 0, sizeof(context));
             hr = validator->vtbl->Instruction(validator, test_file_name, 3, test->decl, test->decl_length);
-            ok(hr == S_OK, "Got unexpected hr %#x, test %u.\n", hr, i);
+            ok(hr == S_OK, "Got unexpected hr %#lx, test %u.\n", hr, i);
             ok(!context.call_count, "Got unexpected call_count %u, test %u.\n", context.call_count, i);
         }
 
         memset(&context, 0, sizeof(context));
         hr = validator->vtbl->Instruction(validator, test_file_name, 3, test->instruction, test->instruction_length);
-        ok(hr == S_OK, "Got unexpected hr %#x, test %u.\n", hr, i);
+        ok(hr == S_OK, "Got unexpected hr %#lx, test %u.\n", hr, i);
         if (test->message_id)
         {
             todo_wine
@@ -14470,15 +14461,15 @@ static void test_shader_validator(void)
         }
 
         hr = validator->vtbl->Instruction(validator, test_file_name, 5, &end_token, 1);
-        ok(hr == S_OK, "Got unexpected hr %#x, test %u.\n", hr, i);
+        ok(hr == S_OK, "Got unexpected hr %#lx, test %u.\n", hr, i);
 
         hr = validator->vtbl->End(validator);
         expected_hr = test->message_id ? E_FAIL : S_OK;
-        todo_wine_if(expected_hr) ok(hr == expected_hr, "Got unexpected hr %#x, test %u.\n", hr, i);
+        todo_wine_if(expected_hr) ok(hr == expected_hr, "Got unexpected hr %#lx, test %u.\n", hr, i);
     }
 
     refcount = validator->vtbl->Release(validator);
-    todo_wine ok(!refcount, "Validator has %u references left.\n", refcount);
+    todo_wine ok(!refcount, "Validator has %lu references left.\n", refcount);
 }
 
 static void test_creation_parameters(void)
@@ -14513,7 +14504,7 @@ static void test_creation_parameters(void)
 
         memset(&params, 0, sizeof(params));
         hr = IDirect3DDevice9_GetCreationParameters(device, &params);
-        ok(hr == D3D_OK, "Adapter %u: GetCreationParameters failed, hr %#x.\n", adapter_idx, hr);
+        ok(hr == D3D_OK, "Adapter %u: GetCreationParameters failed, hr %#lx.\n", adapter_idx, hr);
         ok(params.AdapterOrdinal == adapter_idx, "Adapter %u: Got unexpected adapter ordinal %u.\n",
                 adapter_idx, params.AdapterOrdinal);
         ok(params.DeviceType == D3DDEVTYPE_HAL, "Adapter %u: Expect device type %#x, got %#x.\n",
@@ -14552,7 +14543,7 @@ static void test_cursor_clipping(void)
     for (adapter_idx = 0; adapter_idx < adapter_count; ++adapter_idx)
     {
         hr = IDirect3D9_GetAdapterDisplayMode(d3d, adapter_idx, &current_mode);
-        ok(hr == D3D_OK, "Adapter %u: GetAdapterDisplayMode failed, hr %#x.\n", adapter_idx, hr);
+        ok(hr == D3D_OK, "Adapter %u: GetAdapterDisplayMode failed, hr %#lx.\n", adapter_idx, hr);
         for (mode_idx = 0; SUCCEEDED(IDirect3D9_EnumAdapterModes(d3d, adapter_idx, D3DFMT_X8R8G8B8,
                 mode_idx, &mode)); ++mode_idx)
         {
@@ -14566,11 +14557,11 @@ static void test_cursor_clipping(void)
                 current_mode.Width, current_mode.Height);
 
         ret = ClipCursor(NULL);
-        ok(ret, "Adapter %u: ClipCursor failed, error %#x.\n", adapter_idx,
+        ok(ret, "Adapter %u: ClipCursor failed, error %#lx.\n", adapter_idx,
                 GetLastError());
         get_virtual_rect(&virtual_rect);
         ret = GetClipCursor(&clip_rect);
-        ok(ret, "Adapter %u: GetClipCursor failed, error %#x.\n", adapter_idx,
+        ok(ret, "Adapter %u: GetClipCursor failed, error %#lx.\n", adapter_idx,
                 GetLastError());
         ok(EqualRect(&clip_rect, &virtual_rect), "Adapter %u: Expect clip rect %s, got %s.\n",
                 adapter_idx, wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
@@ -14586,7 +14577,7 @@ static void test_cursor_clipping(void)
         flush_events();
         get_virtual_rect(&virtual_rect);
         ret = GetClipCursor(&clip_rect);
-        ok(ret, "Adapter %u: GetClipCursor failed, error %#x.\n", adapter_idx,
+        ok(ret, "Adapter %u: GetClipCursor failed, error %#lx.\n", adapter_idx,
                 GetLastError());
         ok(EqualRect(&clip_rect, &virtual_rect), "Adapter %u: Expect clip rect %s, got %s.\n",
                 adapter_idx, wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
@@ -14595,7 +14586,7 @@ static void test_cursor_clipping(void)
         flush_events();
         get_virtual_rect(&virtual_rect);
         ret = GetClipCursor(&clip_rect);
-        ok(ret, "Adapter %u: GetClipCursor failed, error %#x.\n", adapter_idx,
+        ok(ret, "Adapter %u: GetClipCursor failed, error %#lx.\n", adapter_idx,
                 GetLastError());
         ok(EqualRect(&clip_rect, &virtual_rect), "Adapter %u: Expect clip rect %s, got %s.\n",
                 adapter_idx, wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
@@ -14628,7 +14619,7 @@ static void test_window_position(void)
         ok(!!monitor, "Adapter %u: GetAdapterMonitor failed.\n", adapter_idx);
         monitor_info.cbSize = sizeof(monitor_info);
         ret = GetMonitorInfoW(monitor, &monitor_info);
-        ok(ret, "Adapter %u: GetMonitorInfoW failed, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: GetMonitorInfoW failed, error %#lx.\n", adapter_idx, GetLastError());
 
         window = create_window();
         device_desc.adapter_ordinal = adapter_idx;
@@ -14644,7 +14635,7 @@ static void test_window_position(void)
         }
         flush_events();
         ret = GetWindowRect(window, &window_rect);
-        ok(ret, "Adapter %u: GetWindowRect failed, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: GetWindowRect failed, error %#lx.\n", adapter_idx, GetLastError());
         ok(EqualRect(&window_rect, &monitor_info.rcMonitor),
                 "Adapter %u: Expect window rect %s, got %s.\n", adapter_idx,
                 wine_dbgstr_rect(&monitor_info.rcMonitor), wine_dbgstr_rect(&window_rect));
@@ -14655,9 +14646,9 @@ static void test_window_position(void)
 
         ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
                 new_rect.bottom - new_rect.top, TRUE);
-        ok(ret, "Got unexpected ret %#x, error %#x, Adapter %u.\n", ret, GetLastError(), adapter_idx);
+        ok(ret, "Got unexpected ret %#x, error %#lx, Adapter %u.\n", ret, GetLastError(), adapter_idx);
         ret = GetWindowRect(window, &window_rect);
-        ok(ret, "Got unexpected ret %#x, error %#x, Adapter %u.\n", ret, GetLastError(), adapter_idx);
+        ok(ret, "Got unexpected ret %#x, error %#lx, Adapter %u.\n", ret, GetLastError(), adapter_idx);
         ok(EqualRect(&window_rect, &new_rect),
                 "Adapter %u: Expect window rect %s, got %s.\n", adapter_idx,
                 wine_dbgstr_rect(&monitor_info.rcMonitor), wine_dbgstr_rect(&window_rect));
@@ -14665,52 +14656,52 @@ static void test_window_position(void)
          * on the second resize remains. */
         flush_events();
         ret = GetWindowRect(window, &window_rect);
-        ok(ret, "Got unexpected ret %#x, error %#x, Adapter %u.\n", ret, GetLastError(), adapter_idx);
+        ok(ret, "Got unexpected ret %#x, error %#lx, Adapter %u.\n", ret, GetLastError(), adapter_idx);
         todo_wine ok(EqualRect(&window_rect, &monitor_info.rcMonitor),
                 "Adapter %u: Expect window rect %s, got %s.\n", adapter_idx,
                 wine_dbgstr_rect(&monitor_info.rcMonitor), wine_dbgstr_rect(&window_rect));
 
         ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
                 new_rect.bottom - new_rect.top, TRUE);
-        ok(ret, "Got unexpected ret %#x, error %#x, Adapter %u.\n", ret, GetLastError(), adapter_idx);
+        ok(ret, "Got unexpected ret %#x, error %#lx, Adapter %u.\n", ret, GetLastError(), adapter_idx);
         ret = GetWindowRect(window, &window_rect);
-        ok(ret, "Got unexpected ret %#x, error %#x, Adapter %u.\n", ret, GetLastError(), adapter_idx);
+        ok(ret, "Got unexpected ret %#x, error %#lx, Adapter %u.\n", ret, GetLastError(), adapter_idx);
         ok(EqualRect(&window_rect, &new_rect),
                 "Adapter %u: Expect window rect %s, got %s.\n", adapter_idx,
                 wine_dbgstr_rect(&monitor_info.rcMonitor), wine_dbgstr_rect(&window_rect));
         flush_events();
         ret = GetWindowRect(window, &window_rect);
-        ok(ret, "Got unexpected ret %#x, error %#x, Adapter %u.\n", ret, GetLastError(), adapter_idx);
+        ok(ret, "Got unexpected ret %#x, error %#lx, Adapter %u.\n", ret, GetLastError(), adapter_idx);
         ok(EqualRect(&window_rect, &new_rect),
                 "Adapter %u: Expect window rect %s, got %s.\n", adapter_idx,
                 wine_dbgstr_rect(&monitor_info.rcMonitor), wine_dbgstr_rect(&window_rect));
 
         /* Device resets should restore the window rectangle to fit the whole monitor */
         ret = SetWindowPos(window, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
-        ok(ret, "Adapter %u: SetWindowPos failed, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: SetWindowPos failed, error %#lx.\n", adapter_idx, GetLastError());
         hr = reset_device(device, &device_desc);
-        ok(hr == D3D_OK, "Adapter %u: Failed to reset device, hr %#x.\n", adapter_idx, hr);
+        ok(hr == D3D_OK, "Adapter %u: Failed to reset device, hr %#lx.\n", adapter_idx, hr);
         flush_events();
         ret = GetWindowRect(window, &window_rect);
-        ok(ret, "Adapter %u: GetWindowRect failed, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: GetWindowRect failed, error %#lx.\n", adapter_idx, GetLastError());
         ok(EqualRect(&window_rect, &monitor_info.rcMonitor),
                 "Adapter %u: Expect window rect %s, got %s.\n", adapter_idx,
                 wine_dbgstr_rect(&monitor_info.rcMonitor), wine_dbgstr_rect(&window_rect));
 
         /* Window activation should restore the window rectangle to fit the whole monitor */
         ret = SetWindowPos(window, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
-        ok(ret, "Adapter %u: SetWindowPos failed, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: SetWindowPos failed, error %#lx.\n", adapter_idx, GetLastError());
         ret = SetForegroundWindow(GetDesktopWindow());
-        ok(ret, "Adapter %u: SetForegroundWindow failed, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: SetForegroundWindow failed, error %#lx.\n", adapter_idx, GetLastError());
         flush_events();
         ret = ShowWindow(window, SW_RESTORE);
-        ok(ret, "Adapter %u: Failed to restore window, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: Failed to restore window, error %#lx.\n", adapter_idx, GetLastError());
         flush_events();
         ret = SetForegroundWindow(window);
-        ok(ret, "Adapter %u: SetForegroundWindow failed, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: SetForegroundWindow failed, error %#lx.\n", adapter_idx, GetLastError());
         flush_events();
         ret = GetWindowRect(window, &window_rect);
-        ok(ret, "Adapter %u: GetWindowRect failed, error %#x.\n", adapter_idx, GetLastError());
+        ok(ret, "Adapter %u: GetWindowRect failed, error %#lx.\n", adapter_idx, GetLastError());
         ok(EqualRect(&window_rect, &monitor_info.rcMonitor),
                 "Adapter %u: Expect window rect %s, got %s.\n", adapter_idx,
                 wine_dbgstr_rect(&monitor_info.rcMonitor), wine_dbgstr_rect(&window_rect));
diff --git a/dlls/d3d9/tests/stateblock.c b/dlls/d3d9/tests/stateblock.c
index 5de5d4fcc6b..f42c880c372 100644
--- a/dlls/d3d9/tests/stateblock.c
+++ b/dlls/d3d9/tests/stateblock.c
@@ -187,22 +187,22 @@ static int switch_render_target(IDirect3DDevice9 *device, struct event_data *eve
 
     /* Create new swapchain */
     hret = IDirect3DDevice9_CreateAdditionalSwapChain(device, &present_parameters, &swapchain);
-    ok (hret == D3D_OK, "CreateAdditionalSwapChain returned %#x.\n", hret);
+    ok (hret == D3D_OK, "CreateAdditionalSwapChain returned %#lx.\n", hret);
     if (hret != D3D_OK) goto error;
 
     /* Get its backbuffer */
     hret = IDirect3DSwapChain9_GetBackBuffer(swapchain, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok (hret == D3D_OK, "GetBackBuffer returned %#x.\n", hret);
+    ok (hret == D3D_OK, "GetBackBuffer returned %#lx.\n", hret);
     if (hret != D3D_OK) goto error;
 
     /* Save the current render target */
     hret = IDirect3DDevice9_GetRenderTarget(device, 0, &event_data->original_render_target);
-    ok (hret == D3D_OK, "GetRenderTarget returned %#x.\n", hret);
+    ok (hret == D3D_OK, "GetRenderTarget returned %#lx.\n", hret);
     if (hret != D3D_OK) goto error;
 
     /* Set the new swapchain's backbuffer as a render target */
     hret = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok (hret == D3D_OK, "SetRenderTarget returned %#x.\n", hret);
+    ok (hret == D3D_OK, "SetRenderTarget returned %#lx.\n", hret);
     if (hret != D3D_OK) goto error;
 
     IDirect3DSurface9_Release(backbuffer);
@@ -221,7 +221,7 @@ static int revert_render_target(IDirect3DDevice9 *device, struct event_data *eve
 
     /* Reset the old render target */
     hret = IDirect3DDevice9_SetRenderTarget(device, 0, event_data->original_render_target);
-    ok (hret == D3D_OK, "SetRenderTarget returned %#x.\n", hret);
+    ok (hret == D3D_OK, "SetRenderTarget returned %#lx.\n", hret);
     if (hret != D3D_OK) {
         IDirect3DSurface9_Release(event_data->original_render_target);
         return EVENT_ERROR;
@@ -238,7 +238,7 @@ static int create_stateblock_all(IDirect3DDevice9 *device, struct event_data *ev
     HRESULT hr;
 
     hr = IDirect3DDevice9_CreateStateBlock(device, D3DSBT_ALL, &event_data->stateblock);
-    ok(SUCCEEDED(hr), "CreateStateBlock returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateStateBlock returned %#lx.\n", hr);
     if (FAILED(hr)) return EVENT_ERROR;
     return EVENT_OK;
 }
@@ -248,7 +248,7 @@ static int create_stateblock_vertex(IDirect3DDevice9 *device, struct event_data
     HRESULT hr;
 
     hr = IDirect3DDevice9_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &event_data->stateblock);
-    ok(SUCCEEDED(hr), "CreateStateBlock returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateStateBlock returned %#lx.\n", hr);
     if (FAILED(hr)) return EVENT_ERROR;
     return EVENT_OK;
 }
@@ -258,7 +258,7 @@ static int create_stateblock_pixel(IDirect3DDevice9 *device, struct event_data *
     HRESULT hr;
 
     hr = IDirect3DDevice9_CreateStateBlock(device, D3DSBT_PIXELSTATE, &event_data->stateblock);
-    ok(SUCCEEDED(hr), "CreateStateBlock returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateStateBlock returned %#lx.\n", hr);
     if (FAILED(hr)) return EVENT_ERROR;
     return EVENT_OK;
 }
@@ -268,7 +268,7 @@ static int begin_stateblock(IDirect3DDevice9 *device, struct event_data *event_d
     HRESULT hret;
 
     hret = IDirect3DDevice9_BeginStateBlock(device);
-    ok(hret == D3D_OK, "BeginStateBlock returned %#x.\n", hret);
+    ok(hret == D3D_OK, "BeginStateBlock returned %#lx.\n", hret);
     if (hret != D3D_OK) return EVENT_ERROR;
     return EVENT_OK;
 }
@@ -278,7 +278,7 @@ static int end_stateblock(IDirect3DDevice9 *device, struct event_data *event_dat
     HRESULT hret;
 
     hret = IDirect3DDevice9_EndStateBlock(device, &event_data->stateblock);
-    ok(hret == D3D_OK, "EndStateBlock returned %#x.\n", hret);
+    ok(hret == D3D_OK, "EndStateBlock returned %#lx.\n", hret);
     if (hret != D3D_OK) return EVENT_ERROR;
     return EVENT_OK;
 }
@@ -294,7 +294,7 @@ static int apply_stateblock(IDirect3DDevice9 *device, struct event_data *event_d
     HRESULT hret;
 
     hret = IDirect3DStateBlock9_Apply(event_data->stateblock);
-    ok(hret == D3D_OK, "Apply returned %#x.\n", hret);
+    ok(hret == D3D_OK, "Apply returned %#lx.\n", hret);
     if (hret != D3D_OK) {
         IDirect3DStateBlock9_Release(event_data->stateblock);
         return EVENT_ERROR;
@@ -310,7 +310,7 @@ static int capture_stateblock(IDirect3DDevice9 *device, struct event_data *event
     HRESULT hret;
 
     hret = IDirect3DStateBlock9_Capture(event_data->stateblock);
-    ok(hret == D3D_OK, "Capture returned %#x.\n", hret);
+    ok(hret == D3D_OK, "Capture returned %#lx.\n", hret);
     if (hret != D3D_OK)
         return EVENT_ERROR;
 
@@ -523,19 +523,19 @@ static void shader_constant_apply_data(IDirect3DDevice9 *device, const struct st
 
     if (!scarg->pshader) {
         hret = IDirect3DDevice9_SetVertexShaderConstantI(device, index, scdata->int_constant, 1);
-        ok(hret == D3D_OK, "SetVertexShaderConstantI returned %#x.\n", hret);
+        ok(hret == D3D_OK, "SetVertexShaderConstantI returned %#lx.\n", hret);
         hret = IDirect3DDevice9_SetVertexShaderConstantF(device, index, scdata->float_constant, 1);
-        ok(hret == D3D_OK, "SetVertexShaderConstantF returned %#x.\n", hret);
+        ok(hret == D3D_OK, "SetVertexShaderConstantF returned %#lx.\n", hret);
         hret = IDirect3DDevice9_SetVertexShaderConstantB(device, index, scdata->bool_constant, 4);
-        ok(hret == D3D_OK, "SetVertexShaderConstantB returned %#x.\n", hret);
+        ok(hret == D3D_OK, "SetVertexShaderConstantB returned %#lx.\n", hret);
 
     } else {
         hret = IDirect3DDevice9_SetPixelShaderConstantI(device, index, scdata->int_constant, 1);
-        ok(hret == D3D_OK, "SetPixelShaderConstantI returned %#x.\n", hret);
+        ok(hret == D3D_OK, "SetPixelShaderConstantI returned %#lx.\n", hret);
         hret = IDirect3DDevice9_SetPixelShaderConstantF(device, index, scdata->float_constant, 1);
-        ok(hret == D3D_OK, "SetPixelShaderConstantF returned %#x.\n", hret);
+        ok(hret == D3D_OK, "SetPixelShaderConstantF returned %#lx.\n", hret);
         hret = IDirect3DDevice9_SetPixelShaderConstantB(device, index, scdata->bool_constant, 4);
-        ok(hret == D3D_OK, "SetPixelShaderConstantB returned %#x.\n", hret);
+        ok(hret == D3D_OK, "SetPixelShaderConstantB returned %#lx.\n", hret);
     }
 }
 
@@ -550,20 +550,20 @@ static void shader_constant_check_data(IDirect3DDevice9 *device, const struct st
     if (!scarg->pshader)
     {
         hr = IDirect3DDevice9_GetVertexShaderConstantI(device, scarg->idx, value.int_constant, 1);
-        ok(SUCCEEDED(hr), "GetVertexShaderConstantI returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetVertexShaderConstantI returned %#lx.\n", hr);
         hr = IDirect3DDevice9_GetVertexShaderConstantF(device, scarg->idx, value.float_constant, 1);
-        ok(SUCCEEDED(hr), "GetVertexShaderConstantF returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetVertexShaderConstantF returned %#lx.\n", hr);
         hr = IDirect3DDevice9_GetVertexShaderConstantB(device, scarg->idx, value.bool_constant, 4);
-        ok(SUCCEEDED(hr), "GetVertexShaderConstantB returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetVertexShaderConstantB returned %#lx.\n", hr);
     }
     else
     {
         hr = IDirect3DDevice9_GetPixelShaderConstantI(device, scarg->idx, value.int_constant, 1);
-        ok(SUCCEEDED(hr), "GetPixelShaderConstantI returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetPixelShaderConstantI returned %#lx.\n", hr);
         hr = IDirect3DDevice9_GetPixelShaderConstantF(device, scarg->idx, value.float_constant, 1);
-        ok(SUCCEEDED(hr), "GetPixelShaderConstantF returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetPixelShaderConstantF returned %#lx.\n", hr);
         hr = IDirect3DDevice9_GetPixelShaderConstantB(device, scarg->idx, value.bool_constant, 4);
-        ok(SUCCEEDED(hr), "GetPixelShaderConstantB returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetPixelShaderConstantB returned %#lx.\n", hr);
     }
 
     ok(!memcmp(scdata->int_constant, value.int_constant, sizeof(scdata->int_constant)),
@@ -737,10 +737,10 @@ static void light_apply_data(IDirect3DDevice9 *device, const struct state_test *
     unsigned int index = larg->idx;
 
     hret = IDirect3DDevice9_SetLight(device, index, &ldata->light);
-    ok(hret == D3D_OK, "SetLight returned %#x.\n", hret);
+    ok(hret == D3D_OK, "SetLight returned %#lx.\n", hret);
 
     hret = IDirect3DDevice9_LightEnable(device, index, ldata->enabled);
-    ok(hret == D3D_OK, "SetLightEnable returned %#x.\n", hret);
+    ok(hret == D3D_OK, "SetLightEnable returned %#lx.\n", hret);
 }
 
 static void light_check_data(IDirect3DDevice9 *device, const struct state_test *test,
@@ -756,10 +756,10 @@ static void light_check_data(IDirect3DDevice9 *device, const struct state_test *
     value.get_light_result = IDirect3DDevice9_GetLight(device, larg->idx, &value.light);
 
     ok(value.get_enabled_result == ldata->get_enabled_result,
-            "Chain stage %u: expected get_enabled_result %#x, got %#x.\n",
+            "Chain stage %u: expected get_enabled_result %#lx, got %#lx.\n",
             chain_stage, ldata->get_enabled_result, value.get_enabled_result);
     ok(value.get_light_result == ldata->get_light_result,
-            "Chain stage %u: expected get_light_result %#x, got %#x.\n",
+            "Chain stage %u: expected get_light_result %#lx, got %#lx.\n",
             chain_stage, ldata->get_light_result, value.get_light_result);
 
     ok(value.enabled == ldata->enabled,
@@ -981,22 +981,22 @@ static void transform_apply_data(IDirect3DDevice9 *device, const struct state_te
     HRESULT hret;
 
     hret = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &tdata->view);
-    ok(hret == D3D_OK, "SetTransform returned %#x.\n", hret);
+    ok(hret == D3D_OK, "SetTransform returned %#lx.\n", hret);
 
     hret = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &tdata->projection);
-    ok(hret == D3D_OK, "SetTransform returned %#x.\n", hret);
+    ok(hret == D3D_OK, "SetTransform returned %#lx.\n", hret);
 
     hret = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &tdata->texture0);
-    ok(hret == D3D_OK, "SetTransform returned %#x.\n", hret);
+    ok(hret == D3D_OK, "SetTransform returned %#lx.\n", hret);
 
     hret = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0 + texture_stages - 1, &tdata->texture7);
-    ok(hret == D3D_OK, "SetTransform returned %#x.\n", hret);
+    ok(hret == D3D_OK, "SetTransform returned %#lx.\n", hret);
 
     hret = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &tdata->world0);
-    ok(hret == D3D_OK, "SetTransform returned %#x.\n", hret);
+    ok(hret == D3D_OK, "SetTransform returned %#lx.\n", hret);
 
     hret = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(255), &tdata->world255);
-    ok(hret == D3D_OK, "SetTransform returned %#x.\n", hret);
+    ok(hret == D3D_OK, "SetTransform returned %#lx.\n", hret);
 }
 
 static void compare_matrix(const char *name, unsigned int chain_stage,
@@ -1036,32 +1036,32 @@ static void transform_check_data(IDirect3DDevice9 *device, const struct state_te
 
     value = transform_poison_data.view;
     hr = IDirect3DDevice9_GetTransform(device, D3DTS_VIEW, &value);
-    ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetTransform returned %#lx.\n", hr);
     compare_matrix("View", chain_stage, &value, &tdata->view);
 
     value = transform_poison_data.projection;
     hr = IDirect3DDevice9_GetTransform(device, D3DTS_PROJECTION, &value);
-    ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetTransform returned %#lx.\n", hr);
     compare_matrix("Projection", chain_stage, &value, &tdata->projection);
 
     value = transform_poison_data.texture0;
     hr = IDirect3DDevice9_GetTransform(device, D3DTS_TEXTURE0, &value);
-    ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetTransform returned %#lx.\n", hr);
     compare_matrix("Texture0", chain_stage, &value, &tdata->texture0);
 
     value = transform_poison_data.texture7;
     hr = IDirect3DDevice9_GetTransform(device, D3DTS_TEXTURE0 + texture_stages - 1, &value);
-    ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetTransform returned %#lx.\n", hr);
     compare_matrix("Texture7", chain_stage, &value, &tdata->texture7);
 
     value = transform_poison_data.world0;
     hr = IDirect3DDevice9_GetTransform(device, D3DTS_WORLD, &value);
-    ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetTransform returned %#lx.\n", hr);
     compare_matrix("World0", chain_stage, &value, &tdata->world0);
 
     value = transform_poison_data.world255;
     hr = IDirect3DDevice9_GetTransform(device, D3DTS_WORLDMATRIX(255), &value);
-    ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetTransform returned %#lx.\n", hr);
     compare_matrix("World255", chain_stage, &value, &tdata->world255);
 }
 
@@ -1230,7 +1230,7 @@ static void render_state_apply_data(IDirect3DDevice9 *device, const struct state
     for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
     {
         hret = IDirect3DDevice9_SetRenderState(device, render_state_indices[i], rsdata->states[i]);
-        ok(hret == D3D_OK, "SetRenderState returned %#x.\n", hret);
+        ok(hret == D3D_OK, "SetRenderState returned %#lx.\n", hret);
     }
 }
 
@@ -1246,8 +1246,8 @@ static void render_state_check_data(IDirect3DDevice9 *device, const struct state
     {
         DWORD value = ctx->poison_data_buffer.states[i];
         hr = IDirect3DDevice9_GetRenderState(device, render_state_indices[i], &value);
-        ok(SUCCEEDED(hr), "GetRenderState returned %#x.\n", hr);
-        ok(value == rsdata->states[i], "Chain stage %u, render state %#x: expected %#x, got %#x.\n",
+        ok(SUCCEEDED(hr), "GetRenderState returned %#lx.\n", hr);
+        ok(value == rsdata->states[i], "Chain stage %u, render state %#x: expected %#lx, got %#lx.\n",
                 chain_stage, render_state_indices[i], rsdata->states[i], value);
     }
 }
@@ -1701,16 +1701,16 @@ static void resource_apply_data(IDirect3DDevice9 *device, const struct state_tes
     HRESULT hr;
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, d->decl);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration (%p) returned %#x.\n", d->decl, hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration (%p) returned %#lx.\n", d->decl, hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, d->vs);
-    ok(SUCCEEDED(hr), "SetVertexShader (%p) returned %#x.\n", d->vs, hr);
+    ok(SUCCEEDED(hr), "SetVertexShader (%p) returned %#lx.\n", d->vs, hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, d->ps);
-    ok(SUCCEEDED(hr), "SetPixelShader (%p) returned %#x.\n", d->ps, hr);
+    ok(SUCCEEDED(hr), "SetPixelShader (%p) returned %#lx.\n", d->ps, hr);
 
     hr = IDirect3DDevice9_SetIndices(device, d->ib);
-    ok(SUCCEEDED(hr), "SetIndices (%p) returned %#x.\n", d->ib, hr);
+    ok(SUCCEEDED(hr), "SetIndices (%p) returned %#lx.\n", d->ib, hr);
 
     for (i = 0; i < arg->stream_count; ++i)
     {
@@ -1721,15 +1721,15 @@ static void resource_apply_data(IDirect3DDevice9 *device, const struct state_tes
             {
                 hr = IDirect3DDevice9_CreateVertexBuffer(device, 64, D3DUSAGE_DYNAMIC,
                         0, D3DPOOL_DEFAULT, &temp_vb, NULL);
-                ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+                ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             }
             hr = IDirect3DDevice9_SetStreamSource(device, i, temp_vb, d->stream_offset, d->stream_stride);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         }
 
         hr = IDirect3DDevice9_SetStreamSource(device, i, d->vb[i], d->stream_offset, d->stream_stride);
         ok(hr == D3D_OK, "Unexpected SetStreamSource result, i %u, vb %p, "
-                "stream_offset %u, stream_stride %u), hr %#x.\n",
+                "stream_offset %u, stream_stride %u), hr %#lx.\n",
                 i, d->vb[i], d->stream_offset, d->stream_stride, hr);
     }
     if (temp_vb)
@@ -1738,7 +1738,7 @@ static void resource_apply_data(IDirect3DDevice9 *device, const struct state_tes
     for (i = 0; i < arg->tex_count; ++i)
     {
         hr = IDirect3DDevice9_SetTexture(device, i, (IDirect3DBaseTexture9 *)d->tex[i]);
-        ok(SUCCEEDED(hr), "SetTexture (%u, %p) returned %#x.\n", i, d->tex[i], hr);
+        ok(SUCCEEDED(hr), "SetTexture (%u, %p) returned %#lx.\n", i, d->tex[i], hr);
     }
 }
 
@@ -1749,15 +1749,13 @@ static void resource_check_data(IDirect3DDevice9 *device, const struct state_tes
     const struct resource_test_data *poison = &ctx->poison_data;
     const struct resource_test_arg *arg = test->test_arg;
     const struct resource_test_data *d = expected_data;
-    unsigned int expected_offset;
-    unsigned int i;
+    unsigned int expected_offset, i, v, w;
     HRESULT hr;
     void *ptr;
-    DWORD v, w;
 
     ptr = poison->decl;
     hr = IDirect3DDevice9_GetVertexDeclaration(device, (IDirect3DVertexDeclaration9 **)&ptr);
-    ok(SUCCEEDED(hr), "GetVertexDeclaration returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexDeclaration returned %#lx.\n", hr);
     if (quirk & SB_QUIRK_RECORDED_VDECL_CAPTURE)
     {
         ok(ptr == ctx->test_data_all.decl, "Chain stage %u, expected vertex declaration %p, received %p.\n",
@@ -1775,7 +1773,7 @@ static void resource_check_data(IDirect3DDevice9 *device, const struct state_tes
 
     ptr = poison->vs;
     hr = IDirect3DDevice9_GetVertexShader(device, (IDirect3DVertexShader9 **)&ptr);
-    ok(SUCCEEDED(hr), "GetVertexShader returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetVertexShader returned %#lx.\n", hr);
     ok(ptr == d->vs, "Chain stage %u, expected vertex shader %p, received %p.\n",
             chain_stage, d->vs, ptr);
     if (SUCCEEDED(hr) && ptr)
@@ -1785,7 +1783,7 @@ static void resource_check_data(IDirect3DDevice9 *device, const struct state_tes
 
     ptr = poison->ps;
     hr = IDirect3DDevice9_GetPixelShader(device, (IDirect3DPixelShader9 **)&ptr);
-    ok(SUCCEEDED(hr), "GetPixelShader returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetPixelShader returned %#lx.\n", hr);
     ok(ptr == d->ps, "Chain stage %u, expected pixel shader %p, received %p.\n",
             chain_stage, d->ps, ptr);
     if (SUCCEEDED(hr) && ptr)
@@ -1795,7 +1793,7 @@ static void resource_check_data(IDirect3DDevice9 *device, const struct state_tes
 
     ptr = poison->ib;
     hr = IDirect3DDevice9_GetIndices(device, (IDirect3DIndexBuffer9 **)&ptr);
-    ok(SUCCEEDED(hr), "GetIndices returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetIndices returned %#lx.\n", hr);
     ok(ptr == d->ib, "Chain stage %u, expected index buffer %p, received %p.\n",
             chain_stage, d->ib, ptr);
     if (SUCCEEDED(hr) && ptr)
@@ -1808,7 +1806,7 @@ static void resource_check_data(IDirect3DDevice9 *device, const struct state_tes
     {
         ptr = poison->vb[i];
         hr = IDirect3DDevice9_GetStreamSource(device, i, (IDirect3DVertexBuffer9 **)&ptr, &v, &w);
-        ok(SUCCEEDED(hr), "GetStreamSource (%u) returned %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "GetStreamSource (%u) returned %#lx.\n", i, hr);
         ok(ptr == d->vb[i], "Chain stage %u, stream %u, expected vertex buffer %p, received %p.\n",
                 chain_stage, i, d->vb[i], ptr);
         ok(v == expected_offset, "Stream source offset %u, expected %u, stride %u.\n", v, expected_offset, w);
@@ -1823,7 +1821,7 @@ static void resource_check_data(IDirect3DDevice9 *device, const struct state_tes
     {
         ptr = poison->tex[i];
         hr = IDirect3DDevice9_GetTexture(device, i, (IDirect3DBaseTexture9 **)&ptr);
-        ok(SUCCEEDED(hr), "SetTexture (%u) returned %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "SetTexture (%u) returned %#lx.\n", i, hr);
         ok(ptr == d->tex[i], "Chain stage %u, texture stage %u, expected texture %p, received %p.\n",
                 chain_stage, i, d->tex[i], ptr);
         if (SUCCEEDED(hr) && ptr)
@@ -1889,12 +1887,12 @@ static void resource_test_data_init(IDirect3DDevice9 *device,
     HRESULT hr;
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl, &data->decl);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexDeclaration returned %#lx.\n", hr);
 
     if (arg->vs_version)
     {
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &data->vs);
-        ok(SUCCEEDED(hr), "CreateVertexShader returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateVertexShader returned %#lx.\n", hr);
     }
     else
     {
@@ -1904,7 +1902,7 @@ static void resource_test_data_init(IDirect3DDevice9 *device,
     if (arg->ps_version)
     {
         hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &data->ps);
-        ok(SUCCEEDED(hr), "CreatePixelShader returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreatePixelShader returned %#lx.\n", hr);
     }
     else
     {
@@ -1913,14 +1911,14 @@ static void resource_test_data_init(IDirect3DDevice9 *device,
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device, 64, D3DUSAGE_DYNAMIC,
             D3DFMT_INDEX32, D3DPOOL_DEFAULT, &data->ib, NULL);
-    ok(SUCCEEDED(hr), "CreateIndexBuffer returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateIndexBuffer returned %#lx.\n", hr);
 
     data->vb = HeapAlloc(GetProcessHeap(), 0, arg->stream_count * sizeof(*data->vb));
     for (i = 0; i < arg->stream_count; ++i)
     {
         hr = IDirect3DDevice9_CreateVertexBuffer(device, 64, D3DUSAGE_DYNAMIC,
                 0, D3DPOOL_DEFAULT, &data->vb[i], NULL);
-        ok(SUCCEEDED(hr), "CreateVertexBuffer (%u) returned %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "CreateVertexBuffer (%u) returned %#lx.\n", i, hr);
     }
     data->stream_offset = 4;
     data->stream_stride = 64;
@@ -1929,7 +1927,7 @@ static void resource_test_data_init(IDirect3DDevice9 *device,
     {
         hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, 0,
                 D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &data->tex[i], NULL);
-        ok(SUCCEEDED(hr), "CreateTexture (%u) returned %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "CreateTexture (%u) returned %#lx.\n", i, hr);
     }
 }
 
@@ -2078,7 +2076,7 @@ static void test_state_management(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     texture_stages = caps.MaxTextureBlendStages;
 
@@ -2121,7 +2119,7 @@ static void test_state_management(void)
     execute_test_chain_all(device, tests, tcount);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left\n", refcount);
+    ok(!refcount, "Device has %lu references left\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
diff --git a/dlls/d3d9/tests/utils.h b/dlls/d3d9/tests/utils.h
index aa6a3227d65..248e07eb521 100644
--- a/dlls/d3d9/tests/utils.h
+++ b/dlls/d3d9/tests/utils.h
@@ -33,7 +33,7 @@ static inline void wait_query_(const char *file, unsigned int line, IDirect3DQue
             break;
         Sleep(10);
     }
-    ok_(file, line)(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok_(file, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
 }
 
 #endif
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 24e28e74257..034cfeef55c 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -141,10 +141,10 @@ static DWORD getPixelColorFromSurface(IDirect3DSurface9 *surface, UINT x, UINT y
     D3DLOCKED_RECT lockedRect;
 
     hr = IDirect3DSurface9_GetDesc(surface, &desc);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &lockedRect, &rectToLock, D3DLOCK_READONLY);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     switch(desc.Format) {
         case D3DFMT_A8R8G8B8:
@@ -158,7 +158,7 @@ static DWORD getPixelColorFromSurface(IDirect3DSurface9 *surface, UINT x, UINT y
             break;
     }
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     return color;
 }
 
@@ -176,28 +176,28 @@ static void get_rt_readback(IDirect3DSurface9 *surface, struct surface_readback
 
     memset(rb, 0, sizeof(*rb));
     hr = IDirect3DSurface9_GetDevice(surface, &device);
-    ok(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetDesc(surface, &desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, desc.Width, desc.Height,
             desc.Format, D3DPOOL_SYSTEMMEM, &rb->surface, NULL);
     if (FAILED(hr) || !rb->surface)
     {
-        trace("Can't create an offscreen plain surface to read the render target data, hr %#x.\n", hr);
+        trace("Can't create an offscreen plain surface to read the render target data, hr %#lx.\n", hr);
         goto error;
     }
 
     hr = IDirect3DDevice9_GetRenderTargetData(device, surface, rb->surface);
     if (FAILED(hr))
     {
-        trace("Can't read the render target data, hr %#x.\n", hr);
+        trace("Can't read the render target data, hr %#lx.\n", hr);
         goto error;
     }
 
     hr = IDirect3DSurface9_LockRect(rb->surface, &rb->locked_rect, NULL, D3DLOCK_READONLY);
     if (FAILED(hr))
     {
-        trace("Can't lock the offscreen surface, hr %#x.\n", hr);
+        trace("Can't lock the offscreen surface, hr %#lx.\n", hr);
         goto error;
     }
     IDirect3DDevice9_Release(device);
@@ -224,7 +224,7 @@ static void release_surface_readback(struct surface_readback *rb)
     if (!rb->surface)
         return;
     if (rb->locked_rect.pBits && FAILED(hr = IDirect3DSurface9_UnlockRect(rb->surface)))
-        trace("Can't unlock the offscreen surface, hr %#x.\n", hr);
+        trace("Can't unlock the offscreen surface, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(rb->surface);
 }
 
@@ -236,7 +236,7 @@ static DWORD getPixelColor(IDirect3DDevice9 *device, UINT x, UINT y)
     HRESULT hr;
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     get_rt_readback(rt, &rb);
     /* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't
@@ -252,14 +252,14 @@ static DWORD getPixelColor(IDirect3DDevice9 *device, UINT x, UINT y)
 #define check_rt_color(a, b) check_rt_color_(__LINE__, a, b)
 static void check_rt_color_(unsigned int line, IDirect3DSurface9 *rt, D3DCOLOR expected_color)
 {
-    D3DCOLOR color = 0xdeadbeef;
+    unsigned int color = 0xdeadbeef;
     struct surface_readback rb;
     D3DSURFACE_DESC desc;
     unsigned int x, y;
     HRESULT hr;
 
     hr = IDirect3DSurface9_GetDesc(rt, &desc);
-    ok_(__FILE__, line)(hr == S_OK, "Failed to get surface desc, hr %#x.\n", hr);
+    ok_(__FILE__, line)(hr == S_OK, "Failed to get surface desc, hr %#lx.\n", hr);
 
     get_rt_readback(rt, &rb);
     for (y = 0; y < desc.Height; ++y)
@@ -310,7 +310,7 @@ static void cleanup_device(IDirect3DDevice9 *device)
         IDirect3DSwapChain9_GetPresentParameters(swapchain, &present_parameters);
         IDirect3DSwapChain9_Release(swapchain);
         ref = IDirect3DDevice9_Release(device);
-        ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+        ok(!ref, "Unexpected refcount %lu.\n", ref);
         DestroyWindow(present_parameters.hDeviceWindow);
     }
 }
@@ -318,8 +318,8 @@ static void cleanup_device(IDirect3DDevice9 *device)
 static void test_sanity(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -334,23 +334,23 @@ static void test_sanity(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     color = getPixelColor(device, 1, 1);
     ok(color == 0x00ff0000, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ddee, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     color = getPixelColor(device, 639, 479);
     ok(color == 0x0000ddee, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -362,12 +362,11 @@ static void lighting_test(void)
     DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE;
     IDirect3DDevice9 *device;
     D3DMATERIAL9 material;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    unsigned int i;
 
     static const D3DMATRIX mat =
     {{{
@@ -491,61 +490,61 @@ static void lighting_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(0), &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, fvf);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     /* No lights are defined... That means, lit vertices should be entirely black */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
             2, indices, D3DFMT_INDEX16, unlitquad, sizeof(unlitquad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
             2, indices, D3DFMT_INDEX16, litquad, sizeof(litquad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, nfvf);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
             2, indices, D3DFMT_INDEX16, unlitnquad, sizeof(unlitnquad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
             2, indices, D3DFMT_INDEX16, litnquad, sizeof(litnquad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360); /* Lower left quad - unlit without normals */
     ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08x, expected 0x00ff0000.\n", color);
@@ -559,34 +558,34 @@ static void lighting_test(void)
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice9_LightEnable(device, 0, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, tests[i].world_matrix);
-        ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
                 2, indices, D3DFMT_INDEX16, tests[i].quad, tests[i].size);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 320, 240);
         ok(color == tests[i].expected, "%s has color 0x%08x.\n", tests[i].message, color);
     }
 
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_LightEnable(device, 0, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable light 0, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable light 0, hr %#lx.\n", hr);
 
     memset(&material, 0, sizeof(material));
     material.Diffuse.r = 0.0;
@@ -607,35 +606,35 @@ static void lighting_test(void)
     material.Emissive.a = 0.0;
     material.Power = 0.0;
     hr = IDirect3DDevice9_SetMaterial(device, &material);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetMaterial returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE | D3DTA_ALPHAREPLICATE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, lighting_test, sizeof(lighting_test[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color == 0x00ffffff, "Lit vertex alpha test returned color %08x, expected 0x00ffffff\n", color);
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -715,8 +714,7 @@ static void test_specular_lighting(void)
     };
     static const struct expected_color
     {
-        unsigned int x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_directional[] =
     {
@@ -901,14 +899,13 @@ static void test_specular_lighting(void)
         {&spot, TRUE, 0.0f, expected_spot_0, ARRAY_SIZE(expected_spot_0)},
         {&point_range, FALSE, 0.0f, expected_point_range_0, ARRAY_SIZE(expected_point_range_0)},
     };
+    unsigned int color, i, j, x, y;
     IDirect3DDevice9 *device;
     D3DMATERIAL9 material;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    unsigned int i, j, x, y;
     struct
     {
         struct vec3 position;
@@ -953,33 +950,33 @@ static void test_specular_lighting(void)
     }
 
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, fvf);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_LightEnable(device, 0, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SPECULARENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice9_SetLight(device, 0, tests[i].light);
-        ok(SUCCEEDED(hr), "Failed to set light parameters, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set light parameters, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LOCALVIEWER, tests[i].local_viewer);
-        ok(SUCCEEDED(hr), "Failed to set local viewer state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set local viewer state, hr %#lx.\n", hr);
 
         memset(&material, 0, sizeof(material));
         material.Specular.r = 1.0f;
@@ -988,21 +985,21 @@ static void test_specular_lighting(void)
         material.Specular.a = 1.0f;
         material.Power = tests[i].specular_power;
         hr = IDirect3DDevice9_SetMaterial(device, &material);
-        ok(SUCCEEDED(hr), "Failed to set material, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set material, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
                 0, vertices_side * vertices_side, indices_count / 3, indices,
                 D3DFMT_INDEX16, quad, sizeof(quad[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         for (j = 0; j < tests[i].expected_count; ++j)
         {
@@ -1015,7 +1012,7 @@ static void test_specular_lighting(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -1049,12 +1046,12 @@ static void clear_test(void)
     HRESULT hr;
     D3DRECT rect[2];
     D3DRECT rect_negneg;
-    DWORD color;
     D3DVIEWPORT9 old_vp, vp;
     RECT scissor;
     DWORD oldColorWrite;
     BOOL invalid_clear_failed = FALSE, srgb_supported;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     HWND window;
@@ -1069,7 +1066,7 @@ static void clear_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Positive x, negative y */
     rect[0].x1 = 0;
@@ -1086,7 +1083,7 @@ static void clear_test(void)
      * returns D3D_OK, but ignores the rectangle silently
      */
     hr = IDirect3DDevice9_Clear(device, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     if(hr == D3DERR_INVALIDCALL) invalid_clear_failed = TRUE;
 
     /* negative x, negative y */
@@ -1095,7 +1092,7 @@ static void clear_test(void)
     rect_negneg.x2 = 320;
     rect_negneg.y2 = 0;
     hr = IDirect3DDevice9_Clear(device, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     if(hr == D3DERR_INVALIDCALL) invalid_clear_failed = TRUE;
 
     color = getPixelColor(device, 160, 360); /* lower left quad */
@@ -1123,13 +1120,13 @@ static void clear_test(void)
      * pick some obvious value
      */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xdeadbabe, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Test how the viewport affects clears */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetViewport(device, &old_vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     vp.X = 160;
     vp.Y = 120;
@@ -1138,9 +1135,9 @@ static void clear_test(void)
     vp.MinZ = 0.0;
     vp.MaxZ = 1.0;
     hr = IDirect3DDevice9_SetViewport(device, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetViewport failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     vp.X = 320;
     vp.Y = 240;
@@ -1149,16 +1146,16 @@ static void clear_test(void)
     vp.MinZ = 0.0;
     vp.MaxZ = 1.0;
     hr = IDirect3DDevice9_SetViewport(device, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetViewport failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     rect[0].x1 = 160;
     rect[0].y1 = 120;
     rect[0].x2 = 480;
     rect[0].y2 = 360;
     hr = IDirect3DDevice9_Clear(device, 1, &rect[0], D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetViewport(device, &old_vp);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetViewport failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 158, 118);
     ok(color == 0x00ffffff, "(158,118) has color %08x\n", color);
@@ -1190,21 +1187,21 @@ static void clear_test(void)
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     SetRect(&scissor, 160, 120, 480, 360);
     hr = IDirect3DDevice9_SetScissorRect(device, &scissor);
-    ok(hr == D3D_OK, "IDirect3DDevice_SetScissorRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SCISSORTESTENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice_SetScissorRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 1, &rect[1], D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SCISSORTESTENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice_SetScissorRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 158, 118);
     ok(color == 0x00ffffff, "Pixel 158/118 has color %08x\n", color);
@@ -1254,19 +1251,19 @@ static void clear_test(void)
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_COLORWRITEENABLE, &oldColorWrite);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Same nvidia windows driver trouble with white clears as earlier in the same test */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xdeadbeef, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, oldColorWrite);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Colorwriteenable does not affect the clear */
     color = getPixelColor(device, 320, 240);
@@ -1275,14 +1272,14 @@ static void clear_test(void)
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ffffff, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     rect[0].x1 = 0;
     rect[0].y1 = 0;
     rect[0].x2 = 640;
     rect[0].y2 = 480;
     hr = IDirect3DDevice9_Clear(device, 0, rect, D3DCLEAR_TARGET, 0x00ff0000, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0xff, 0xff, 0xff), 1),
@@ -1291,9 +1288,9 @@ static void clear_test(void)
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 1, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x00, 0xff, 0x00), 1),
@@ -1306,113 +1303,113 @@ static void clear_test(void)
             D3DUSAGE_QUERY_SRGBWRITE, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8));
     trace("sRGB writing to D3DFMT_A8R8G8B8 is %ssupported.\n", srgb_supported ? "" : "not ");
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f7f7f7f, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x007f7f7f, 1), "Clear has color %08x.\n", color);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable sRGB write, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable sRGB write, hr %#lx.\n", hr);
 
     /* Draw something to make sure the SRGBWRITEENABLE setting is applied. */
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world matrix, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world matrix, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f7f7f7f, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00bbbbbb, 1), "Clear has color %08x.\n", color);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable sRGB write, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable sRGB write, hr %#lx.\n", hr);
 
     /* Switching to a new render target seems to be enough to make Windows pick
      * up on the changed render state. */
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 2, D3DUSAGE_RENDERTARGET,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create the offscreen render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create the offscreen render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface0);
-    ok(SUCCEEDED(hr), "Failed to get offscreen surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get offscreen surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface0);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f7f7f7f, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, surface0, NULL, backbuffer, NULL, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "Failed to blit surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit surface, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 64, 64);
     ok(color_match(color, 0x007f7f7f, 1), "Clear has color %08x.\n", color);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable sRGB write, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable sRGB write, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface0);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f7f7f7f, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, surface0, NULL, backbuffer, NULL, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "Failed to blit surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit surface, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00bbbbbb, 1), "Clear has color %08x.\n", color);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable sRGB write, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable sRGB write, hr %#lx.\n", hr);
     /* Switching to another surface of the same texture is also enough to make
      * the setting "stick". */
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 1, &surface1);
-    ok(SUCCEEDED(hr), "Failed to get offscreen surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get offscreen surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface1);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f7f7f7f, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, surface1, NULL, backbuffer, NULL, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "Failed to blit surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit surface, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x007f7f7f, 1), "Clear has color %08x.\n", color);
@@ -1424,7 +1421,7 @@ static void clear_test(void)
     IDirect3DSurface9_Release(backbuffer);
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -1454,14 +1451,14 @@ static void test_clear_different_size_surfaces(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "Failed to get device caps, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get device caps, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 1, 1, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &rt, NULL);
-    ok(hr == D3D_OK, "Failed to create render target surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create render target surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 1, 2, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &rt2, NULL);
-    ok(hr == D3D_OK, "Failed to create render target surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create render target surface, hr %#lx.\n", hr);
 
     if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16_LOCKABLE)))
@@ -1475,16 +1472,16 @@ static void test_clear_different_size_surfaces(void)
 
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 4, 4, ds_format,
             D3DMULTISAMPLE_NONE, 0, FALSE, &ds, NULL);
-    ok(hr == D3D_OK, "Failed to create depth surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create depth surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(hr == D3D_OK, "Failed to set depth stencil surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set depth stencil surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set render target, hr %#lx.\n", hr);
     if (caps.NumSimultaneousRTs >= 2)
     {
         hr = IDirect3DDevice9_SetRenderTarget(device, 1, rt2);
-        ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to set render target, hr %#lx.\n", hr);
     }
 
     vp.X = 0;
@@ -1494,10 +1491,10 @@ static void test_clear_different_size_surfaces(void)
     vp.MinZ = 0.0f;
     vp.MaxZ = 1.0f;
     hr = IDirect3DDevice9_SetViewport(device, &vp);
-    ok(hr == D3D_OK, "Failed to set viewport, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.5f, 0);
-    ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr);
 
     check_rt_color(rt, 0x00ff0000);
 
@@ -1507,7 +1504,7 @@ static void test_clear_different_size_surfaces(void)
     if (ds_format == D3DFMT_D16_LOCKABLE)
     {
         hr = IDirect3DSurface9_LockRect(ds, &lr, NULL, D3DLOCK_READONLY);
-        ok(hr == D3D_OK, "Failed to lock rect, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to lock rect, hr %#lx.\n", hr);
         for (y = 0; y < 4; ++y)
         {
             depth = (WORD *)((BYTE *)lr.pBits + y * lr.Pitch);
@@ -1517,7 +1514,7 @@ static void test_clear_different_size_surfaces(void)
             }
         }
         hr = IDirect3DSurface9_UnlockRect(ds);
-        ok(hr == D3D_OK, "Failed to unlock rect, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to unlock rect, hr %#lx.\n", hr);
         IDirect3DSurface9_Release(ds);
     }
     else
@@ -1534,10 +1531,9 @@ done:
 
 static void color_fill_test(void)
 {
-    unsigned int fill_a, expected_a;
+    unsigned int fill_color, color, fill_a, expected_a;
     IDirect3DSurface9 *surface;
     IDirect3DTexture9 *texture;
-    D3DCOLOR fill_color, color;
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d;
     ULONG refcount;
@@ -1629,15 +1625,15 @@ static void color_fill_test(void)
     }
 
     hr = IDirect3DDevice9_ColorFill(device, NULL, NULL, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     /* Test ColorFill on a the backbuffer (should pass) */
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
-    ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     fill_color = 0x112233;
     hr = IDirect3DDevice9_ColorFill(device, surface, NULL, fill_color);
-    ok(SUCCEEDED(hr), "Color fill failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Color fill failed, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 0, 0);
     ok(color == fill_color, "Expected color %08x, got %08x\n", fill_color, color);
@@ -1647,11 +1643,11 @@ static void color_fill_test(void)
     /* Test ColorFill on a render target surface (should pass) */
     hr = IDirect3DDevice9_CreateRenderTarget(device, 32, 32, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL );
-    ok(hr == D3D_OK, "Unable to create render target surface, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     fill_color = 0x445566;
     hr = IDirect3DDevice9_ColorFill(device, surface, NULL, fill_color);
-    ok(SUCCEEDED(hr), "Color fill failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Color fill failed, hr %#lx.\n", hr);
 
     color = getPixelColorFromSurface(surface, 0, 0);
     ok(color == fill_color, "Expected color %08x, got %08x\n", fill_color, color);
@@ -1661,11 +1657,11 @@ static void color_fill_test(void)
     /* Test ColorFill on an offscreen plain surface in D3DPOOL_DEFAULT (should pass) */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL);
-    ok(hr == D3D_OK, "Unable to create offscreen plain surface, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     fill_color = 0x778899;
     hr = IDirect3DDevice9_ColorFill(device, surface, NULL, fill_color);
-    ok(SUCCEEDED(hr), "Color fill failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Color fill failed, hr %#lx.\n", hr);
 
     color = getPixelColorFromSurface(surface, 0, 0);
     ok(color == fill_color, "Expected color %08x, got %08x\n", fill_color, color);
@@ -1675,19 +1671,19 @@ static void color_fill_test(void)
     /* Try ColorFill on an offscreen surface in sysmem (should fail) */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, NULL);
-    ok(hr == D3D_OK, "Unable to create offscreen plain surface, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_ColorFill(device, surface, NULL, 0);
-    ok(hr == D3DERR_INVALIDCALL, "ColorFill on offscreen sysmem surface failed with hr = %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 32, 32, D3DFMT_D16,
             D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth stencil surface, hr = %08x.\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_ColorFill(device, surface, NULL, 0);
-    ok(hr == D3DERR_INVALIDCALL, "ColorFill on a depth stencil surface returned hr = %08x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
 
@@ -1696,12 +1692,12 @@ static void color_fill_test(void)
         texture = NULL;
         hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 1, resource_types[i].usage,
                 D3DFMT_A8R8G8B8, resource_types[i].pool, &texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, i=%u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, i=%u.\n", hr, i);
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-        ok(SUCCEEDED(hr), "Failed to get surface, hr %#x, i=%u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx, i=%u.\n", hr, i);
 
         hr = IDirect3DDevice9_ColorFill(device, surface, NULL, fill_color);
-        ok(hr == resource_types[i].hr, "Got unexpected hr %#x, expected %#x, i=%u.\n",
+        ok(hr == resource_types[i].hr, "Got unexpected hr %#lx, expected %#lx, i=%u.\n",
                 hr, resource_types[i].hr, i);
 
         IDirect3DSurface9_Release(surface);
@@ -1719,21 +1715,21 @@ static void color_fill_test(void)
 
         hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
                 formats[i].format, D3DPOOL_DEFAULT, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, fmt=%s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, fmt=%s.\n", hr, formats[i].name);
 
         hr = IDirect3DDevice9_ColorFill(device, surface, NULL, 0xdeadbeef);
-        ok(SUCCEEDED(hr), "Failed to color fill, hr %#x, fmt=%s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to color fill, hr %#lx, fmt=%s.\n", hr, formats[i].name);
 
         hr = IDirect3DDevice9_ColorFill(device, surface, &rect, 0xdeadbeef);
-        ok(SUCCEEDED(hr), "Failed to color fill, hr %#x, fmt=%s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to color fill, hr %#lx, fmt=%s.\n", hr, formats[i].name);
 
         if (SUCCEEDED(hr))
         {
             hr = IDirect3DDevice9_ColorFill(device, surface, &rect2, 0xdeadbeef);
             if (formats[i].flags & BLOCKS)
-                ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, fmt=%s.\n", hr, formats[i].name);
+                ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, fmt=%s.\n", hr, formats[i].name);
             else
-                ok(SUCCEEDED(hr), "Failed to color fill, hr %#x, fmt=%s.\n", hr, formats[i].name);
+                ok(SUCCEEDED(hr), "Failed to color fill, hr %#lx, fmt=%s.\n", hr, formats[i].name);
         }
 
         if (!(formats[i].flags & CHECK_FILL_VALUE))
@@ -1743,7 +1739,7 @@ static void color_fill_test(void)
         }
 
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, fmt=%s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, fmt=%s.\n", hr, formats[i].name);
         /* Windows drivers disagree on how to promote the 8 bit per channel
          * input argument to 16 bit for D3DFMT_G16R16. */
         if (formats[i].flags & FLOAT_VALUES)
@@ -1776,15 +1772,15 @@ static void color_fill_test(void)
         memset(locked_rect.pBits, 0x55, locked_rect.Pitch * 32);
 
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, fmt=%s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, fmt=%s.\n", hr, formats[i].name);
 
         /* Test clearing "to sysmem". Wined3d's delayed clear will perform the actual clear
          * in the lock call and try to fill the sysmem buffer instead of clearing on the
          * GPU and downloading it. */
         hr = IDirect3DDevice9_ColorFill(device, surface, NULL, 0xdeadbeef);
-        ok(SUCCEEDED(hr), "Failed to color fill, hr %#x, fmt=%s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to color fill, hr %#lx, fmt=%s.\n", hr, formats[i].name);
         hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, D3DLOCK_READONLY);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, fmt=%s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, fmt=%s.\n", hr, formats[i].name);
 
         if (formats[i].flags & FLOAT_VALUES)
         {
@@ -1813,13 +1809,13 @@ static void color_fill_test(void)
 
 
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, fmt=%s.\n", hr, formats[i].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, fmt=%s.\n", hr, formats[i].name);
 
         IDirect3DSurface9_Release(surface);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -1882,7 +1878,7 @@ static void test_mova(void)
     static const struct
     {
         float in[4];
-        DWORD out;
+        unsigned int out;
     }
     test_data[2][6] =
     {
@@ -1926,7 +1922,7 @@ static void test_mova(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
     {
         skip("No vs_2_0 support, skipping tests.\n");
@@ -1935,53 +1931,53 @@ static void test_mova(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexShader(device, mova_test, &mova_shader);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, mov_test, &mov_shader);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, mov_shader);
-    ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     for (j = 0; j < ARRAY_SIZE(test_data); ++j)
     {
         for (i = 0; i < ARRAY_SIZE(*test_data); ++i)
         {
-            DWORD color;
+            unsigned int color;
 
             hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 7, test_data[j][i].in, 1);
-            ok(SUCCEEDED(hr), "SetVertexShaderConstantF failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "BeginScene failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-            ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "EndScene failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             color = getPixelColor(device, 320, 240);
             ok(color == test_data[j][i].out, "Expected color %08x, got %08x (for input %f, instruction %s)\n",
                test_data[j][i].out, color, test_data[j][i].in[0], j == 0 ? "mov" : "mova");
 
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(SUCCEEDED(hr), "Present failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
-            ok(SUCCEEDED(hr), "Clear failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         }
         hr = IDirect3DDevice9_SetVertexShader(device, mova_shader);
-        ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     IDirect3DVertexDeclaration9_Release(vertex_declaration);
     IDirect3DVertexShader9_Release(mova_shader);
     IDirect3DVertexShader9_Release(mov_shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -1991,13 +1987,12 @@ static void fog_test(void)
 {
     float start = 0.0f, end = 1.0f;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
-    int i;
 
     /* Gets full z based fog with linear fog, no fog with specular color. */
     static const struct
@@ -2140,77 +2135,77 @@ static void fog_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Setup initial states: No lighting, fog on, fog color */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable D3DRS_ZENABLE, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable D3DRS_ZENABLE, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Turning off lighting returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
-    ok(hr == D3D_OK, "Turning on fog calculations returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0xff00ff00 /* A nice green */);
-    ok(hr == D3D_OK, "Setting fog color returned %#08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     /* Some of the tests seem to depend on the projection matrix explicitly
      * being set to an identity matrix, even though that's the default.
      * (AMD Radeon HD 6310, Windows 7) */
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &ident_mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
 
     /* First test: Both table fog and vertex fog off */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off table fog returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off vertex fog returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Start = 0, end = 1. Should be default, but set them */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, *((DWORD *) &start));
-    ok(hr == D3D_OK, "Setting fog start returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, *((DWORD *) &end));
-    ok(hr == D3D_OK, "Setting fog end returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     /* Untransformed, vertex fog = NONE, table fog = NONE:
      * Read the fog weighting from the specular color. */
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
             2 /* PrimCount */, Indices, D3DFMT_INDEX16, untransformed_1, sizeof(untransformed_1[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     /* That makes it use the Z value */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
-    ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog vertex mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog vertex mode, hr %#lx.\n", hr);
     /* Untransformed, vertex fog != none (or table fog != none):
      * Use the Z value as input into the equation. */
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
             2 /* PrimCount */, Indices, D3DFMT_INDEX16, untransformed_2, sizeof(untransformed_2[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     /* transformed verts */
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     /* Transformed, vertex fog != NONE, pixel fog == NONE:
      * Use specular color alpha component. */
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
             2 /* PrimCount */, Indices, D3DFMT_INDEX16, transformed_1, sizeof(transformed_1[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
-    ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog table mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog table mode, hr %#lx.\n", hr);
     /* Transformed, table fog != none, vertex anything:
      * Use Z value as input to the fog equation. */
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
             2 /* PrimCount */, Indices, D3DFMT_INDEX16, transformed_2, sizeof(transformed_2[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "EndScene returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color == 0x00ff0000, "Untransformed vertex with no table or vertex fog has color %08x\n", color);
@@ -2236,24 +2231,24 @@ static void fog_test(void)
 
     /* Now test the special case fogstart == fogend */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     start = 512;
     end = 512;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, *((DWORD *)&start));
-    ok(SUCCEEDED(hr), "Failed to set fog start, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fog start, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, *((DWORD *)&end));
-    ok(SUCCEEDED(hr), "Failed to set fog end, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fog end, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
-    ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog vertex mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog vertex mode, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
-    ok(SUCCEEDED(hr), "Failed to set D3DFOG_NONE fog table mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set D3DFOG_NONE fog table mode, hr %#lx.\n", hr);
 
     /* Untransformed vertex, z coord = 0.1, fogstart = 512, fogend = 512.
      * Would result in a completely fog-free primitive because start > zcoord,
@@ -2263,21 +2258,21 @@ static void fog_test(void)
      * the specular color and has fixed fogstart and fogend. */
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
             2 /* PrimCount */, Indices, D3DFMT_INDEX16, untransformed_1, sizeof(untransformed_1[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
             2 /* PrimCount */, Indices, D3DFMT_INDEX16, untransformed_2, sizeof(untransformed_2[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     /* Transformed, vertex fog != NONE, pixel fog == NONE:
      * Use specular color alpha component. */
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
             2 /* PrimCount */, Indices, D3DFMT_INDEX16, transformed_1, sizeof(transformed_1[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color_match(color, 0x0000ff00, 1), "Untransformed vertex with vertex fog and z = 0.1 has color %08x\n", color);
@@ -2293,11 +2288,11 @@ static void fog_test(void)
     end = 0.2;
     start = 0.8;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, *((DWORD *) &start));
-    ok(hr == D3D_OK, "Setting fog start returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, *((DWORD *) &end));
-    ok(hr == D3D_OK, "Setting fog end returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok( hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Test reversed fog without shaders. ATI cards have problems with reversed fog and shaders, so
      * it doesn't seem very important for games. ATI cards also have problems with reversed table fog,
@@ -2306,18 +2301,18 @@ static void fog_test(void)
     for(i = 0; i < 1 /*2 - Table fog test disabled, fails on ATI */; i++) {
         const char *mode = (i ? "table" : "vertex");
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, i == 0 ? D3DFOG_LINEAR : D3DFOG_NONE);
-        ok( hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, i == 0 ? D3DFOG_NONE : D3DFOG_LINEAR);
-        ok( hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 16 /* NumVerts */,
                 8 /* PrimCount */, Indices2, D3DFMT_INDEX16, rev_fog_quads, sizeof(rev_fog_quads[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 160, 360);
         ok(color_match(color, 0x0000ff00, 1),
@@ -2346,37 +2341,37 @@ static void fog_test(void)
     {
         /* A simple fog + non-identity world matrix test */
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(0), &world_mat1);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         start = 0.0;
         end = 1.0;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, *((DWORD *)&start));
-        ok(hr == D3D_OK, "Setting fog start returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, *((DWORD *)&end));
-        ok(hr == D3D_OK, "Setting fog end returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
-        ok(hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
-        ok(hr == D3D_OK, "Turning off vertex fog returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
                 2, Indices, D3DFMT_INDEX16, far_quad1, sizeof(far_quad1[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
                 2, Indices, D3DFMT_INDEX16, far_quad2, sizeof(far_quad2[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 160, 360);
         ok(color_match(color, D3DCOLOR_ARGB(0x00, 0xff, 0x00, 0x00), 4),
@@ -2389,28 +2384,28 @@ static void fog_test(void)
 
         /* Test fog behavior with an orthogonal (but non-identity) projection matrix */
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(0), &world_mat2);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-        ok(hr == D3D_OK, "Clear returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
                 2, Indices, D3DFMT_INDEX16, untransformed_1, sizeof(untransformed_1[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4,
                 2, Indices, D3DFMT_INDEX16, untransformed_2, sizeof(untransformed_2[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 160, 360);
         ok(color_match(color, 0x00e51900, 4), "Partially fogged quad has color %08x\n", color);
@@ -2421,9 +2416,9 @@ static void fog_test(void)
         IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(0), &ident_mat);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &ident_mat);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
     else
     {
@@ -2435,12 +2430,12 @@ static void fog_test(void)
             (D3DPRASTERCAPS_FOGTABLE | D3DPRASTERCAPS_FOGRANGE))
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetFVF failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetFVF failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_RANGEFOGENABLE, TRUE);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
 
         /* z=0.5, x = +/- 1.0, y = +/- 1.0. In case of z fog the fog coordinate is
          * 0.5. With range fog it is sqrt(x*x + y*y + z*z) = 1.5 for all vertices.
@@ -2449,22 +2444,22 @@ static void fog_test(void)
         start = 0.75f;
         end = 0.75001f;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, *((DWORD *) &start));
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, *((DWORD *) &end));
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
 
         /* Table fog: Range fog is not used */
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
-        ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog table mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog table mode, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2,
                 untransformed_3, sizeof(*untransformed_3));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 10, 10);
         ok(color == 0x00ff0000, "Rangefog with table fog returned color 0x%08x\n", color);
@@ -2476,22 +2471,22 @@ static void fog_test(void)
         ok(color == 0x00ff0000, "Rangefog with table fog returned color 0x%08x\n", color);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed, hr %#lx.\n", hr);
 
         /* Vertex fog: Rangefog is used */
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
-        ok(SUCCEEDED(hr), "Failed to set D3DFOG_NONE fog table mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set D3DFOG_NONE fog table mode, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
-        ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog vertex mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set D3DFOG_LINEAR fog vertex mode, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2,
                 untransformed_3, sizeof(*untransformed_3));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 10, 10);
         ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x00, 0xff, 0x00), 1),
@@ -2507,10 +2502,10 @@ static void fog_test(void)
                 "Rangefog with vertex fog returned color 0x%08x\n", color);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_RANGEFOGENABLE, FALSE);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
     }
     else
     {
@@ -2518,7 +2513,7 @@ static void fog_test(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -2585,7 +2580,7 @@ static void test_cube_wrap(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP))
     {
         skip("No cube texture support, skipping tests.\n");
@@ -2594,20 +2589,20 @@ static void test_cube_wrap(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, NULL);
-    ok(SUCCEEDED(hr), "CreateOffscreenPlainSurface failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateCubeTexture(device, 128, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_DEFAULT, &texture, NULL);
-    ok(SUCCEEDED(hr), "CreateCubeTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (y = 0; y < 128; ++y)
     {
@@ -2623,18 +2618,18 @@ static void test_cube_wrap(void)
     }
 
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "UnlockRect failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr= IDirect3DCubeTexture9_GetCubeMapSurface(texture, 0, 0, &face_surface);
-    ok(SUCCEEDED(hr), "GetCubeMapSurface failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_UpdateSurface(device, surface, NULL, face_surface, NULL);
-    ok(SUCCEEDED(hr), "UpdateSurface failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(face_surface);
 
     hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (y = 0; y < 128; ++y)
     {
@@ -2650,50 +2645,50 @@ static void test_cube_wrap(void)
     }
 
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "UnlockRect failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Create cube faces */
     for (face = 1; face < 6; ++face)
     {
         hr= IDirect3DCubeTexture9_GetCubeMapSurface(texture, face, 0, &face_surface);
-        ok(SUCCEEDED(hr), "GetCubeMapSurface failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_UpdateSurface(device, surface, NULL, face_surface, NULL);
-        ok(SUCCEEDED(hr), "UpdateSurface failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         IDirect3DSurface9_Release(face_surface);
     }
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
-    ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
-    ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_BORDERCOLOR, 0xff00ff00);
-    ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_BORDERCOLOR failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (x = 0; x < ARRAY_SIZE(address_modes); ++x)
     {
-        DWORD color;
+        unsigned int color;
 
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, address_modes[x].mode);
-        ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_ADDRESSU (%s) failed (0x%08x)\n", address_modes[x].name, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, address_modes[x].mode);
-        ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_ADDRESSV (%s) failed (0x%08x)\n", address_modes[x].name, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         color = getPixelColor(device, 320, 240);
         ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x00, 0x00, 0xff), 1),
@@ -2701,17 +2696,17 @@ static void test_cube_wrap(void)
                 color, address_modes[x].name);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Clear failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     IDirect3DVertexDeclaration9_Release(vertex_declaration);
     IDirect3DCubeTexture9_Release(texture);
     IDirect3DSurface9_Release(surface);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -2722,8 +2717,8 @@ static void offscreen_test(void)
     IDirect3DSurface9 *backbuffer, *offscreen;
     IDirect3DTexture9 *offscreenTexture;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -2746,17 +2741,17 @@ static void offscreen_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &offscreenTexture, NULL);
-    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Creating the offscreen render target failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     if (!offscreenTexture)
     {
         trace("Failed to create an X8R8G8B8 offscreen texture, trying R5G6B5.\n");
         hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
                 D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &offscreenTexture, NULL);
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Creating the offscreen render target failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
         if (!offscreenTexture)
         {
             skip("Cannot create an offscreen render target.\n");
@@ -2766,48 +2761,48 @@ static void offscreen_test(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(offscreenTexture, 0, &offscreen);
-    ok(hr == D3D_OK, "Can't get offscreen surface, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "SetFVF failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, offscreen);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* Draw without textures - Should result in a white quad. */
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)offscreenTexture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     /* This time with the texture. */
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Center quad - should be white */
     color = getPixelColor(device, 320, 240);
@@ -2827,7 +2822,7 @@ static void offscreen_test(void)
     IDirect3DTexture9_Release(offscreenTexture);
     IDirect3DSurface9_Release(offscreen);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -2845,11 +2840,10 @@ static void fog_with_shader_test(void)
     IDirect3DPixelShader9 *pixel_shader[3] = {NULL, NULL, NULL};
     IDirect3DVertexDeclaration9 *vertex_declaration = NULL;
     IDirect3DDevice9 *device;
-    unsigned int i, j;
+    unsigned int color, i, j;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
     union
@@ -3132,7 +3126,7 @@ static void fog_with_shader_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0) || caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
     {
         skip("No shader model 2 support, skipping tests.\n");
@@ -3149,52 +3143,52 @@ static void fog_with_shader_test(void)
      * being set to an identity matrix, even though that's the default.
      * (AMD Radeon HD 6310, Windows 7) */
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &identity);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code1, &vertex_shader[1]);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code2, &vertex_shader[2]);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code3, &vertex_shader[3]);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code2, &pixel_shader[2]);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Setup initial states: No lighting, fog on, fog color */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Turning off lighting failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
-    ok(hr == D3D_OK, "Turning on fog calculations failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0xff00ff00 /* A nice green */);
-    ok(hr == D3D_OK, "Setting fog color failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off table fog failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off vertex fog failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Use fogtart = 0.1 and end = 0.9 to test behavior outside the fog transition phase, too*/
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, start.i);
-    ok(hr == D3D_OK, "Setting fog start failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, end.i);
-    ok(hr == D3D_OK, "Setting fog end failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); i++)
     {
         hr = IDirect3DDevice9_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
-        ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, pixel_shader[test_data[i].pshader]);
-        ok(SUCCEEDED(hr), "SetPixelShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
-        ok( hr == D3D_OK, "Setting fog vertex mode to D3DFOG_LINEAR failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
-        ok( hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         for(j=0; j < 11; j++)
         {
@@ -3205,16 +3199,16 @@ static void fog_with_shader_test(void)
             quad[3].position.z = 0.001f + (float)j / 10.02f;
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff00ff, 1.0f, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_BeginScene(device);
-            ok( hr == D3D_OK, "BeginScene returned failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
-            ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_EndScene(device);
-            ok(hr == D3D_OK, "EndScene failed (%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             /* As the red and green component are the result of blending use 5% tolerance on the expected value */
             color = getPixelColor(device, 128, 240);
@@ -3232,7 +3226,7 @@ static void fog_with_shader_test(void)
     IDirect3DPixelShader9_Release(pixel_shader[2]);
     IDirect3DVertexDeclaration9_Release(vertex_declaration);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -3249,10 +3243,10 @@ static void generate_bumpmap_textures(IDirect3DDevice9 *device) {
     {
         hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, 0, i?D3DFMT_A8R8G8B8:D3DFMT_V8U8,
                                             D3DPOOL_MANAGED, &texture[i], NULL);
-        ok(SUCCEEDED(hr), "CreateTexture failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DTexture9_LockRect(texture[i], 0, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         for (y = 0; y < 128; ++y)
         {
             if(i)
@@ -3288,21 +3282,21 @@ static void generate_bumpmap_textures(IDirect3DDevice9 *device) {
             }
         }
         hr = IDirect3DTexture9_UnlockRect(texture[i], 0);
-        ok(SUCCEEDED(hr), "UnlockRect failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetTexture(device, i, (IDirect3DBaseTexture9 *)texture[i]);
-        ok(SUCCEEDED(hr), "SetTexture failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* Disable texture filtering */
         hr = IDirect3DDevice9_SetSamplerState(device, i, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-        ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, i, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-        ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetSamplerState(device, i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
-        ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_ADDRESSU failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-        ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_ADDRESSV failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 }
 
@@ -3318,13 +3312,12 @@ static void texbem_test(void)
     IDirect3DTexture9 *texture = NULL;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
-    int i;
 
     static const DWORD pixel_shader_code[] =
     {
@@ -3391,7 +3384,7 @@ static void texbem_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
     {
         skip("No ps_1_1 support, skipping tests.\n");
@@ -3405,43 +3398,43 @@ static void texbem_test(void)
     IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT01, *(LPDWORD)&bumpenvmat[1]);
     IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT10, *(LPDWORD)&bumpenvmat[2]);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT11, *(LPDWORD)&bumpenvmat[3]);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for(i=0; i<2; i++)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         if(i)
         {
             hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT4|D3DTTFF_PROJECTED);
-            ok(SUCCEEDED(hr), "SetTextureStageState D3DTSS_TEXTURETRANSFORMFLAGS failed (0x%08x)\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         }
 
         hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements[i], &vertex_declaration);
-        ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-        ok(SUCCEEDED(hr), "SetVertexDeclaration failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &pixel_shader);
-        ok(SUCCEEDED(hr), "CreatePixelShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, pixel_shader);
-        ok(SUCCEEDED(hr), "SetPixelShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         if(!i)
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
         else
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad_proj[0], sizeof(quad_proj[0]));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* The Window 8 testbot (WARP) seems to use the transposed
          * D3DTSS_BUMPENVMAT matrix. */
@@ -3459,58 +3452,58 @@ static void texbem_test(void)
                 "Got unexpected color 0x%08x.\n", color);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-        ok(SUCCEEDED(hr), "SetPixelShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         IDirect3DPixelShader9_Release(pixel_shader);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
-        ok(SUCCEEDED(hr), "SetVertexDeclaration failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         IDirect3DVertexDeclaration9_Release(vertex_declaration);
     }
 
     /* clean up */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DTSS_TEXTURETRANSFORMFLAGS failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for(i=0; i<2; i++)
     {
         hr = IDirect3DDevice9_GetTexture(device, i, (IDirect3DBaseTexture9 **) &texture);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_GetTexture failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         IDirect3DTexture9_Release(texture); /* For the GetTexture */
         hr = IDirect3DDevice9_SetTexture(device, i, NULL);
-        ok(SUCCEEDED(hr), "SetTexture failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         IDirect3DTexture9_Release(texture);
     }
 
     /* Test double texbem */
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_V8U8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_V8U8, D3DPOOL_MANAGED, &texture1, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 8, 8, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture2, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, double_texbem_code, &pixel_shader);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ((signed char *) locked_rect.pBits)[0] = (-1.0 / 8.0) * 127;
     ((signed char *) locked_rect.pBits)[1] = ( 1.0 / 8.0) * 127;
 
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_LockRect(texture1, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ((signed char *) locked_rect.pBits)[0] = (-2.0 / 8.0) * 127;
     ((signed char *) locked_rect.pBits)[1] = (-4.0 / 8.0) * 127;
     hr = IDirect3DTexture9_UnlockRect(texture1, 0);
-    ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     {
         /* Some data without any meaning, just to have an 8x8 array to see which element is picked */
@@ -3532,72 +3525,72 @@ static void texbem_test(void)
 #undef origin
 
         hr = IDirect3DTexture9_LockRect(texture2, 0, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         for(i = 0; i < 8; i++) {
             memcpy(((char *) locked_rect.pBits) + i * locked_rect.Pitch, pixel_data + 8 * i, 8 * sizeof(DWORD));
         }
         hr = IDirect3DTexture9_UnlockRect(texture2, 0);
-        ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 1, (IDirect3DBaseTexture9 *) texture2);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 2, (IDirect3DBaseTexture9 *) texture1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 3, (IDirect3DBaseTexture9 *) texture2);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, pixel_shader);
-    ok(SUCCEEDED(hr), "Direct3DDevice9_SetPixelShader failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX4);
-    ok(SUCCEEDED(hr), "Direct3DDevice9_SetPixelShader failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     bumpenvmat[0] =-1.0;  bumpenvmat[2] =  2.0;
     bumpenvmat[1] = 0.0;  bumpenvmat[3] =  0.0;
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT00, *(LPDWORD)&bumpenvmat[0]);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT01, *(LPDWORD)&bumpenvmat[1]);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT10, *(LPDWORD)&bumpenvmat[2]);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT11, *(LPDWORD)&bumpenvmat[3]);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     bumpenvmat[0] = 1.5; bumpenvmat[2] =  0.0;
     bumpenvmat[1] = 0.0; bumpenvmat[3] =  0.5;
     hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT00, *(LPDWORD)&bumpenvmat[0]);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT01, *(LPDWORD)&bumpenvmat[1]);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT10, *(LPDWORD)&bumpenvmat[2]);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT11, *(LPDWORD)&bumpenvmat[3]);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetSamplerState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetSamplerState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetSamplerState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetSamplerState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 2, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetSamplerState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 2, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetSamplerState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 3, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetSamplerState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 3, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetSamplerState returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, double_quad, sizeof(float) * 11);
-    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     /* The Window 8 testbot (WARP) seems to use the transposed
      * D3DTSS_BUMPENVMAT matrix. */
     color = getPixelColor(device, 320, 240);
@@ -3605,14 +3598,14 @@ static void texbem_test(void)
             "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DPixelShader9_Release(pixel_shader);
     IDirect3DTexture9_Release(texture);
     IDirect3DTexture9_Release(texture1);
     IDirect3DTexture9_Release(texture2);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -3622,10 +3615,10 @@ static void z_range_test(void)
 {
     IDirect3DVertexShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -3688,56 +3681,56 @@ static void z_range_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     /* Does the Present clear the depth stencil? Clear the depth buffer with some value != 0,
      * then call Present. Then clear the color buffer to make sure it has some defined content
      * after the Present with D3DSWAPEFFECT_DISCARD. After that draw a plane that is somewhere cut
      * by the depth value. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 0.75f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z writes, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z writes, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_GREATER);
-    ok(SUCCEEDED(hr), "Failed to set z function, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set z function, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     /* Test the untransformed vertex path */
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESS);
-    ok(SUCCEEDED(hr), "Failed to set z function, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set z function, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(quad2[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     /* Test the transformed vertex path */
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, sizeof(quad4[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_GREATER);
-    ok(SUCCEEDED(hr), "Failed to set z function, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set z function, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(quad3[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Do not test the exact corner pixels, but go pretty close to them */
 
@@ -3786,7 +3779,7 @@ static void z_range_test(void)
         ok(color_match(color, 0x0000ff00, 0), "Z range failed: Got color 0x%08x, expected 0x00ffffff.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Test the shader path */
     if (caps.VertexShaderVersion < D3DVS_VERSION(1, 1))
@@ -3796,33 +3789,33 @@ static void z_range_test(void)
         goto done;
     }
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code, &shader);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, color_const_1, 1);
-    ok(SUCCEEDED(hr), "Failed to set vs constant 0, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vs constant 0, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESS);
-    ok(SUCCEEDED(hr), "Failed to set z function, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set z function, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, color_const_2, 1);
-    ok(SUCCEEDED(hr), "Failed to set vs constant 0, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vs constant 0, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(quad2[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     IDirect3DVertexShader9_Release(shader);
 
@@ -3848,10 +3841,10 @@ static void z_range_test(void)
     ok(color_match(color, 0x00ffffff, 0), "Z range failed: Got color 0x%08x, expected 0x00ffffff.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -3869,7 +3862,7 @@ static void fill_surface(IDirect3DSurface9 *surface, DWORD color, DWORD flags)
     memset(&desc, 0, sizeof(desc));
     memset(&l, 0, sizeof(l));
     hr = IDirect3DSurface9_GetDesc(surface, &desc);
-    ok(hr == D3D_OK, "IDirect3DSurface9_GetDesc failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     switch(desc.Format)
     {
@@ -3890,7 +3883,7 @@ static void fill_surface(IDirect3DSurface9 *surface, DWORD color, DWORD flags)
     }
 
     hr = IDirect3DSurface9_LockRect(surface, &l, NULL, flags);
-    ok(hr == D3D_OK, "IDirect3DSurface9_LockRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(FAILED(hr)) return;
 
     for(y = 0; y < desc.Height; y++)
@@ -3905,7 +3898,7 @@ static void fill_surface(IDirect3DSurface9 *surface, DWORD color, DWORD flags)
         }
     }
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(hr == D3D_OK, "IDirect3DSurface9_UnlockRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 }
 
 static void stretchrect_test(void)
@@ -3934,9 +3927,8 @@ static void stretchrect_test(void)
     IDirect3DTexture9 *tex32, *tex64, *tex_dest64;
     IDirect3DSurface9 *surf_temp32, *surf_temp64;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -4031,70 +4023,70 @@ static void stretchrect_test(void)
     /* Create our temporary surfaces in system memory. */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surf_temp32, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64,
             D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surf_temp64, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Create offscreen plain surfaces in D3DPOOL_DEFAULT. */
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surfaces[OFFSCREEN_32], NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surfaces[OFFSCREEN_64], NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surfaces[OFFSCREEN_DST_64], NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Create render target surfaces. */
     hr = IDirect3DDevice9_CreateRenderTarget(device, 32, 32,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &surfaces[RT_32], NULL );
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 64, 64,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &surfaces[RT_64], NULL );
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 64, 64,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &surfaces[RT_DST_64], NULL );
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surfaces[BACKBUFFER]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Create render target textures. */
     hr = IDirect3DDevice9_CreateTexture(device, 32, 32, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_rt32, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_rt64, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_rt_dest64, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_rt_dest640_480, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_rt32, 0, &surfaces[TEX_RT_32]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_rt64, 0, &surfaces[TEX_RT_64]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_rt_dest64, 0, &surfaces[TEX_RT_DST_64]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_rt_dest640_480, 0, &surfaces[TEX_RT_DST_640_480]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Create regular textures in D3DPOOL_DEFAULT. */
     hr = IDirect3DDevice9_CreateTexture(device, 32, 32, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex32, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex64, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_dest64, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex32, 0, &surfaces[TEX_32]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex64, 0, &surfaces[TEX_64]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_dest64, 0, &surfaces[TEX_DST_64]);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /**********************************************************************
      * Tests for when the source parameter is an offscreen plain surface. *
@@ -4106,37 +4098,37 @@ static void stretchrect_test(void)
     /* offscreenplain ==> offscreenplain, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[OFFSCREEN_64], NULL,
             surfaces[OFFSCREEN_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[OFFSCREEN_DST_64], 32, 32);
     ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[OFFSCREEN_64], &src_rect64,
             surfaces[OFFSCREEN_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* offscreenplain ==> rendertarget texture, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[OFFSCREEN_64], NULL,
             surfaces[TEX_RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* We can't lock rendertarget textures, so copy to our temp surface first. */
     hr = IDirect3DDevice9_GetRenderTargetData(device, surfaces[TEX_RT_DST_64], surf_temp64);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surf_temp64, 32, 32);
     ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[OFFSCREEN_64], &src_rect64,
             surfaces[TEX_RT_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* offscreenplain ==> rendertarget surface, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[OFFSCREEN_64], NULL, surfaces[RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[RT_DST_64], 32, 32);
     ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[OFFSCREEN_64], &src_rect64,
             surfaces[RT_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Fill the smaller offscreen surface with red. */
     fill_surface(surfaces[OFFSCREEN_32], 0xffff0000, 0);
@@ -4144,16 +4136,16 @@ static void stretchrect_test(void)
     /* offscreenplain ==> rendertarget texture, scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[OFFSCREEN_32], NULL,
             surfaces[TEX_RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* We can't lock rendertarget textures, so copy to our temp surface first. */
     hr = IDirect3DDevice9_GetRenderTargetData(device, surfaces[TEX_RT_DST_64], surf_temp64);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surf_temp64, 48, 48);
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
     /* offscreenplain ==> rendertarget surface, scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[OFFSCREEN_32], NULL, surfaces[RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[RT_DST_64], 48, 48);
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
@@ -4165,49 +4157,49 @@ static void stretchrect_test(void)
     /* Can't fill the surf_tex directly because it's created in D3DPOOL_DEFAULT. */
     fill_surface(surf_temp64, 0xff0000ff, 0);
     hr = IDirect3DDevice9_UpdateSurface(device, surf_temp64, NULL, surfaces[TEX_64], NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* texture ==> rendertarget texture, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_64], NULL, surfaces[TEX_RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* We can't lock rendertarget textures, so copy to our temp surface first. */
     hr = IDirect3DDevice9_GetRenderTargetData(device, surfaces[TEX_RT_DST_64], surf_temp64);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surf_temp64, 32, 32);
     ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_64], &src_rect64,
             surfaces[TEX_RT_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* texture ==> rendertarget surface, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_64], NULL, surfaces[RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[RT_DST_64], 32, 32);
     ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_64], &src_rect64,
             surfaces[RT_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Fill the surface of the smaller regular texture with red. */
     /* Can't fill the surf_tex directly because it's created in D3DPOOL_DEFAULT. */
     fill_surface(surf_temp32, 0xffff0000, 0);
     hr = IDirect3DDevice9_UpdateSurface(device, surf_temp32, NULL, surfaces[TEX_32], NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* texture ==> rendertarget texture, scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_32], NULL, surfaces[TEX_RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* We can't lock rendertarget textures, so copy to our temp surface first. */
     hr = IDirect3DDevice9_GetRenderTargetData(device, surfaces[TEX_RT_DST_64], surf_temp64);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surf_temp64, 48, 48);
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
     /* texture ==> rendertarget surface, scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_32], NULL, surfaces[RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[RT_DST_64], 48, 48);
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
@@ -4219,49 +4211,49 @@ static void stretchrect_test(void)
     /* Can't fill the surf_tex_rt directly because it's created in D3DPOOL_DEFAULT. */
     fill_surface(surf_temp64, 0xffffffff, 0);
     hr = IDirect3DDevice9_UpdateSurface(device, surf_temp64, NULL, surfaces[TEX_RT_64], NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* rendertarget texture ==> rendertarget texture, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_RT_64], NULL, surfaces[TEX_RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* We can't lock rendertarget textures, so copy to our temp surface first. */
     hr = IDirect3DDevice9_GetRenderTargetData(device, surfaces[TEX_RT_DST_64], surf_temp64);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surf_temp64, 32, 32);
     ok(color == 0xffffffff, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_RT_64], &src_rect64,
             surfaces[TEX_RT_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* rendertarget texture ==> rendertarget surface, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_RT_64], NULL, surfaces[RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[RT_DST_64], 32, 32);
     ok(color == 0xffffffff, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_RT_64], &src_rect64,
             surfaces[RT_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Fill the surface of the smaller rendertarget texture with red. */
     /* Can't fill the surf_tex_rt directly because it's created in D3DPOOL_DEFAULT. */
     fill_surface(surf_temp32, 0xffff0000, 0);
     hr = IDirect3DDevice9_UpdateSurface(device, surf_temp32, NULL, surfaces[TEX_RT_32], NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* rendertarget texture ==> rendertarget texture, scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_RT_32], NULL, surfaces[TEX_RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* We can't lock rendertarget textures, so copy to our temp surface first. */
     hr = IDirect3DDevice9_GetRenderTargetData(device, surfaces[TEX_RT_DST_64], surf_temp64);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surf_temp64, 48, 48);
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
     /* rendertarget texture ==> rendertarget surface, scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[TEX_RT_32], NULL, surfaces[RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[RT_DST_64], 48, 48);
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
@@ -4274,42 +4266,42 @@ static void stretchrect_test(void)
 
     /* rendertarget surface ==> rendertarget texture, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[RT_64], NULL, surfaces[TEX_RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* We can't lock rendertarget textures, so copy to our temp surface first. */
     hr = IDirect3DDevice9_GetRenderTargetData(device, surfaces[TEX_RT_DST_64], surf_temp64);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surf_temp64, 32, 32);
     ok(color == 0xff000000, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[RT_64], &src_rect64,
             surfaces[TEX_RT_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* rendertarget surface ==> rendertarget surface, same size. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[RT_64], NULL, surfaces[RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[RT_DST_64], 32, 32);
     ok(color == 0xff000000, "Got unexpected color 0x%08x.\n", color);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[RT_64], &src_rect64,
             surfaces[RT_DST_64], &dst_rect64, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Fill the surface of the smaller rendertarget texture with red. */
     fill_surface(surfaces[RT_32], 0xffff0000, 0);
 
     /* rendertarget surface ==> rendertarget texture, scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[RT_32], NULL, surfaces[TEX_RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* We can't lock rendertarget textures, so copy to our temp surface first. */
     hr = IDirect3DDevice9_GetRenderTargetData(device, surfaces[TEX_RT_DST_64], surf_temp64);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surf_temp64, 48, 48);
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
     /* rendertarget surface ==> rendertarget surface, scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[RT_32], NULL, surfaces[RT_DST_64], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(surfaces[RT_DST_64], 48, 48);
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
@@ -4317,11 +4309,11 @@ static void stretchrect_test(void)
     /* Blit with NULL rectangles. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[BACKBUFFER], NULL,
             surfaces[TEX_RT_DST_640_480], NULL, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* Blit without scaling. */
     hr = IDirect3DDevice9_StretchRect(device, surfaces[BACKBUFFER], &src_rect,
             surfaces[TEX_RT_DST_640_480], &dst_rect, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Test error conditions. */
     for (i = 0; i < ARRAY_SIZE(error_condition_tests); ++i)
@@ -4331,7 +4323,7 @@ static void stretchrect_test(void)
         hr = IDirect3DDevice9_StretchRect(device, surfaces[test->src], test->src_rect,
                 surfaces[test->dst], test->dst_rect, test->filter);
         todo_wine_if(test->todo)
-            ok(hr == test->allowed ? D3D_OK : D3DERR_INVALIDCALL, "Test %u, got unexpected hr %#x.\n", i, hr);
+            ok(hr == test->allowed ? D3D_OK : D3DERR_INVALIDCALL, "Test %u, got unexpected hr %#lx.\n", i, hr);
     }
 
     /* TODO: Test format conversions. */
@@ -4351,7 +4343,7 @@ static void stretchrect_test(void)
     IDirect3DTexture9_Release(tex64);
     IDirect3DTexture9_Release(tex_dest64);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -4368,12 +4360,11 @@ static void test_multisample_stretch_rect(void)
     IDirect3DSurface9 *rt, *ms_rt, *ms_rt2, *rt_r5g6b5;
     struct surface_readback rb;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     DWORD quality_levels;
     IDirect3D9 *d3d;
-    unsigned int i;
     ULONG refcount;
     HWND window;
-    DWORD color;
     HRESULT hr;
     RECT rect;
 
@@ -4400,28 +4391,28 @@ static void test_multisample_stretch_rect(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, quality_levels - 1, FALSE, &ms_rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, quality_levels - 1, FALSE, &ms_rt2, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, ms_rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff00ff, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(filters); ++i)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         color = getPixelColor(device, 64, 64);
         ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color);
     }
@@ -4431,12 +4422,12 @@ static void test_multisample_stretch_rect(void)
     for (i = 0; i < ARRAY_SIZE(filters); ++i)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, rt, NULL, ms_rt2, NULL, D3DTEXF_NONE);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, &rect, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         get_rt_readback(rt, &rb);
         color = get_readback_color(&rb, 32, 32);
         ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color);
@@ -4447,9 +4438,9 @@ static void test_multisample_stretch_rect(void)
         release_surface_readback(&rb);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, ms_rt, &rect, rt, NULL, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         get_rt_readback(rt, &rb);
         color = get_readback_color(&rb, 32, 32);
         ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color);
@@ -4460,13 +4451,13 @@ static void test_multisample_stretch_rect(void)
         release_surface_readback(&rb);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 0.0f, 0);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, rt, NULL, ms_rt, &rect, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, ms_rt, &rect, rt, NULL, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         get_rt_readback(rt, &rb);
         color = get_readback_color(&rb, 32, 32);
         ok(color == 0xffffff00, "Test %u, got unexpected color 0x%08x.\n", i, color);
@@ -4477,14 +4468,14 @@ static void test_multisample_stretch_rect(void)
         release_surface_readback(&rb);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff00ff, 0.0f, 0);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, rt, NULL, ms_rt, NULL, D3DTEXF_NONE);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_StretchRect(device, ms_rt, &rect, ms_rt2, NULL, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, ms_rt2, &rect, rt, NULL, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         get_rt_readback(rt, &rb);
         color = get_readback_color(&rb, 32, 32);
         ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color);
@@ -4507,11 +4498,11 @@ static void test_multisample_stretch_rect(void)
     for (i = 0; i < ARRAY_SIZE(filters); ++i)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt_r5g6b5, NULL, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_StretchRect(device, rt_r5g6b5, NULL, rt, NULL, filters[i]);
-        ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
         color = getPixelColor(device, 64, 64);
         ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color);
     }
@@ -4523,7 +4514,7 @@ done:
     IDirect3DSurface9_Release(ms_rt);
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -4533,8 +4524,8 @@ static void maxmip_test(void)
     IDirect3DTexture9 *texture;
     IDirect3DSurface9 *surface;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -4588,7 +4579,7 @@ static void maxmip_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP))
     {
         skip("No mipmap support, skipping tests.\n");
@@ -4598,59 +4589,59 @@ static void maxmip_test(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 3, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(SUCCEEDED(hr), "IDirect3DTexture9_GetSurfaceLevel returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     fill_surface(surface, 0xffff0000, 0);
     IDirect3DSurface9_Release(surface);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 1, &surface);
-    ok(SUCCEEDED(hr), "IDirect3DTexture9_GetSurfaceLevel returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     fill_surface(surface, 0xff00ff00, 0);
     IDirect3DSurface9_Release(surface);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 2, &surface);
-    ok(SUCCEEDED(hr), "IDirect3DTexture9_GetSurfaceLevel returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     fill_surface(surface, 0xff0000ff, 0);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 0);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[0], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[1], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 2);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[2], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 3);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[3], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* With mipmapping disabled, the max mip level is ignored, only level 0 is used */
     color = getPixelColor(device, 160, 360);
@@ -4662,39 +4653,39 @@ static void maxmip_test(void)
     color = getPixelColor(device, 160, 120);
     ok(color == 0x00ff0000, "MaxMip 3, no mipfilter has color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 0);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[0], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[1], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 2);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[2], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 3);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[3], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Max Mip level 0-2 sample from the specified texture level, Max Mip
      * level 3 (> levels in texture) samples from the highest level in the
@@ -4708,54 +4699,54 @@ static void maxmip_test(void)
     color = getPixelColor(device, 160, 120);
     ok(color == 0x000000ff, "MaxMip 3, point mipfilter has color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     /* Mipmapping OFF, LOD level smaller than MAXMIPLEVEL. LOD level limits */
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 0);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     ret = IDirect3DTexture9_SetLOD(texture, 1);
-    ok(ret == 0, "Got unexpected LOD %u.\n", ret);
+    ok(ret == 0, "Got unexpected LOD %lu.\n", ret);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[0], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     /* Mipmapping ON, LOD level smaller than max mip level. LOD level limits */
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     ret = IDirect3DTexture9_SetLOD(texture, 2);
-    ok(ret == 1, "Got unexpected LOD %u.\n", ret);
+    ok(ret == 1, "Got unexpected LOD %lu.\n", ret);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[1], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     /* Mipmapping ON, LOD level bigger than max mip level. MAXMIPLEVEL limits */
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 2);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     ret = IDirect3DTexture9_SetLOD(texture, 1);
-    ok(ret == 2, "Got unexpected LOD %u.\n", ret);
+    ok(ret == 2, "Got unexpected LOD %lu.\n", ret);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[2], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     /* Mipmapping OFF, LOD level bigger than max mip level. LOD level limits */
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 2);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     ret = IDirect3DTexture9_SetLOD(texture, 1);
-    ok(ret == 1, "Got unexpected LOD %u.\n", ret);
+    ok(ret == 1, "Got unexpected LOD %lu.\n", ret);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[3], sizeof(*quads->v));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Max Mip level 0-2 sample from the specified texture level, Max Mip
      * level 3 (> levels in texture) samples from the highest level in the
@@ -4770,11 +4761,11 @@ static void maxmip_test(void)
     ok(color == 0x0000ff00, "MaxMip 2, LOD 1, none mipfilter has color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -4785,13 +4776,12 @@ static void release_buffer_test(void)
     IDirect3DVertexBuffer9 *vb;
     IDirect3DIndexBuffer9 *ib;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
     BYTE *data;
-    LONG ref;
 
     static const short indices[] = {3, 4, 5};
     static const struct
@@ -4822,46 +4812,46 @@ static void release_buffer_test(void)
     /* Index and vertex buffers should always be creatable */
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), 0,
             D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DPOOL_MANAGED, &vb, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad), (void **) &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0,
             D3DFMT_INDEX16, D3DPOOL_DEFAULT, &ib, NULL);
-    ok(SUCCEEDED(hr), "Failed to create index buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create index buffer, hr %#lx.\n", hr);
     hr = IDirect3DIndexBuffer9_Lock(ib, 0, sizeof(indices), (void **) &data, 0);
-    ok(hr == D3D_OK, "IDirect3DIndexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, indices, sizeof(indices));
     hr = IDirect3DIndexBuffer9_Unlock(ib);
-    ok(hr == D3D_OK, "IDirect3DIndexBuffer9_Unlock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetIndices(device, ib);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetIndices failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad[0]));
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSource failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     /* Now destroy the bound index buffer and draw again */
-    ref = IDirect3DIndexBuffer9_Release(ib);
-    ok(ref == 0, "Index Buffer reference count is %08d\n", ref);
+    refcount = IDirect3DIndexBuffer9_Release(ib);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     /* Deliberately using minvertexindex = 0 and numVertices = 6 to prevent
      * D3D from making assumptions about the indices or vertices. */
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 3, 3, 0, 1);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 120);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x00, 0xff, 0x00), 1), "Got unexpected color 0x%08x.\n", color);
@@ -4869,12 +4859,12 @@ static void release_buffer_test(void)
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x00, 0x00, 0xff), 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Index buffer was already destroyed as part of the test */
     IDirect3DVertexBuffer9_Release(vb);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -4884,11 +4874,11 @@ static void float_texture_test(void)
 {
     IDirect3DTexture9 *texture;
     IDirect3DDevice9 *device;
+    unsigned int color;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
     ULONG refcount;
     float *data;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -4918,42 +4908,42 @@ static void float_texture_test(void)
     }
 
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_R32F, D3DPOOL_MANAGED, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     data = lr.pBits;
     *data = 0.0;
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 240, 320);
     ok(color == 0x0000ffff, "R32F with value 0.0 has color %08x, expected 0x0000ffff\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -4963,11 +4953,11 @@ static void g16r16_texture_test(void)
 {
     IDirect3DTexture9 *texture;
     IDirect3DDevice9 *device;
+    unsigned int color;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
     ULONG refcount;
     DWORD *data;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -4997,43 +4987,43 @@ static void g16r16_texture_test(void)
     }
 
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_G16R16, D3DPOOL_MANAGED, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     data = lr.pBits;
     *data = 0x0f00f000;
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 240, 320);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0xf0, 0x0f, 0xff), 1),
        "D3DFMT_G16R16 with value 0x00ffff00 has color %08x, expected 0x00f00fff\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -5052,9 +5042,8 @@ static void check_rect_(unsigned int line, struct surface_readback *rb, RECT r,
         {r.top - 1, r.top + 1},
         {r.bottom + 1, r.bottom - 1}
     };
-    unsigned int i, j, x_side, y_side;
-    DWORD color;
-    LONG x, y;
+    unsigned int color, i, j, x_side, y_side;
+    int x, y;
 
     if (r.left < 0 && r.top < 0 && r.right < 0 && r.bottom < 0)
     {
@@ -5086,7 +5075,7 @@ static void check_rect_(unsigned int line, struct surface_readback *rb, RECT r,
             {
                 for (y_side = 0; y_side < 2; ++y_side)
                 {
-                    DWORD expected = (x_side == 1 && y_side == 1) ? 0xffffffff : 0xff000000;
+                    unsigned int expected = (x_side == 1 && y_side == 1) ? 0xffffffff : 0xff000000;
 
                     x = x_coords[i][x_side];
                     y = y_coords[j][y_side];
@@ -5141,28 +5130,28 @@ static void projected_textures_test(IDirect3DDevice9 *device,
 
     IDirect3DDevice9_GetDirect3D(device, &d3d);
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3D9_Release(d3d);
 
     if (caps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
     {
         hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader, &vs);
-        ok(SUCCEEDED(hr), "CreateVertexShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
     if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 3))
     {
         hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader, &ps);
-        ok(SUCCEEDED(hr), "CreatePixelShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff203040, 0.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -5201,7 +5190,7 @@ static void projected_textures_test(IDirect3DDevice9 *device,
         }
         else
             hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-        ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         if (tests[i].ps)
         {
             if (!ps)
@@ -5213,24 +5202,24 @@ static void projected_textures_test(IDirect3DDevice9 *device,
         }
         else
             hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-        ok(SUCCEEDED(hr), "SetPixelShader failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, tests[i].decl);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, tests[i].flags);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, &value);
-        ok(SUCCEEDED(hr) && value == tests[i].flags,
-                "GetTextureStageState returned: hr %08x, value %08x.\n", hr, value);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
+        ok(value == tests[i].flags, "Got value %#lx.\n", value);
 
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2,
                 &proj_quads[i * 4 * 7], 7 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, NULL);
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
@@ -5255,14 +5244,12 @@ static void texture_transform_flags_test(void)
     D3DCAPS9 caps;
     IDirect3DTexture9 *texture = NULL;
     IDirect3DVolumeTexture9 *volume = NULL;
+    unsigned int color, x, y, z, w, h;
     IDirect3DDevice9 *device;
-    unsigned int x, y, z;
     D3DLOCKED_RECT lr;
     D3DLOCKED_BOX lb;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
-    UINT w, h;
     IDirect3DVertexDeclaration9 *decl, *decl2, *decl3, *decl4;
 
     static const D3DVERTEXELEMENT9 decl_elements[] = {
@@ -5313,43 +5300,43 @@ static void texture_transform_flags_test(void)
         fmt = D3DFMT_A16B16G16R16;
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &decl);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements2, &decl2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements3, &decl3);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements4, &decl4);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState(D3DSAMP_SRGBTEXTURE) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState(D3DSAMP_MAGFILTER) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState(D3DSAMP_MINFILTER) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState(D3DSAMP_MIPFILTER) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState(D3DSAMP_ADDRESSU) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState(D3DSAMP_ADDRESSV) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState(D3DSAMP_ADDRESSW) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState(D3DTSS_COLOROP) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState(D3DTSS_COLORARG1) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState(D3DRS_LIGHTING) returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     w = min(1024, caps.MaxTextureWidth);
     h = min(1024, caps.MaxTextureHeight);
     hr = IDirect3DDevice9_CreateTexture(device, w, h, 1,
                                         0, fmt, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if (!texture)
     {
         skip("Failed to create the test texture.\n");
@@ -5362,7 +5349,7 @@ static void texture_transform_flags_test(void)
      * 1.0 in red and green for the x and y coords
      */
     hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     for(y = 0; y < h; y++) {
         for(x = 0; x < w; x++) {
             double r_f = (double) y / (double) h;
@@ -5388,14 +5375,14 @@ static void texture_transform_flags_test(void)
         }
     }
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(SUCCEEDED(hr))
     {
         static const float quad1[] =
@@ -5436,25 +5423,25 @@ static void texture_transform_flags_test(void)
 
         /* What happens with the texture matrix if D3DTSS_TEXTURETRANSFORMFLAGS is disabled? */
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* What happens with transforms enabled? */
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* What happens if 4 coords are used, but only 2 given ?*/
         U(mat).m[2][0] = 1.0f;
         U(mat).m[3][1] = 1.0f;
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT4);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* What happens with transformed geometry? This setup lead to 0/0 coords with untransformed
          * geometry. If the same applies to transformed vertices, the quad will be black, otherwise red,
@@ -5462,16 +5449,16 @@ static void texture_transform_flags_test(void)
          */
         memset(&mat, 0, sizeof(mat));
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_TEX1);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 6 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
     color = getPixelColor(device, 160, 360);
     ok(color_match(color, 0x00ffff00, 1), "quad 1 has color %08x, expected 0x00ffff00\n", color);
@@ -5482,15 +5469,15 @@ static void texture_transform_flags_test(void)
     color = getPixelColor(device, 480, 360);
     ok(color_match(color, 0x00ff0000, 1), "quad 4 has color %08x, expected 0x00ff0000\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(SUCCEEDED(hr))
     {
         static const float quad1[] =
@@ -5531,38 +5518,38 @@ static void texture_transform_flags_test(void)
 
         /* What happens to the default 1 in the 3rd coordinate if it is disabled? */
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* D3DTFF_COUNT1 does not work on Nvidia drivers. It behaves like D3DTTFF_DISABLE. On ATI drivers
          * it behaves like COUNT2 because normal textures require 2 coords. */
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT1);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* Just to be sure, the same as quad2 above */
         memset(&mat, 0, sizeof(mat));
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* Now, what happens to the 2nd coordinate(that is disabled in the matrix) if it is not
          * used? And what happens to the first? */
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT1);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
     color = getPixelColor(device, 160, 360);
     ok(color_match(color, 0x00ff0000, 1), "quad 1 has color %08x, expected 0x00ff0000\n", color);
@@ -5575,13 +5562,13 @@ static void texture_transform_flags_test(void)
     ok(color_match(color, 0x0033cc00, 1) || color_match(color, 0x00ff0000, 1),
        "quad 4 has color %08x, expected 0x0033cc00\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture);
 
     /* Test projected textures, without any fancy matrices */
     hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 1, 0, D3DFMT_L8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
         struct projected_textures_test_run projected_tests_1[4] =
@@ -5680,42 +5667,41 @@ static void texture_transform_flags_test(void)
         };
 
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &identity);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-        ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         for(x = 0; x < 4; x++) {
             memcpy(((BYTE *) lr.pBits) + lr.Pitch * x, proj_texdata + 4 * x, 4 * sizeof(proj_texdata[0]));
         }
         hr = IDirect3DTexture9_UnlockRect(texture, 0);
-        ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         projected_textures_test(device, projected_tests_1);
         projected_textures_test(device, projected_tests_2);
         projected_textures_test(device, projected_tests_3);
 
         hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         IDirect3DTexture9_Release(texture);
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff203040, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     /* Use a smaller volume texture than the biggest possible size for memory and performance reasons
      * Thus watch out if sampling from texels between 0 and 1.
      */
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 32, 32, 32, 1, 0, fmt, D3DPOOL_MANAGED, &volume, 0);
-    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL,
-       "IDirect3DDevice9_CreateVolumeTexture failed with %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     if(!volume) {
         skip("Failed to create a volume texture\n");
         goto out;
     }
 
     hr = IDirect3DVolumeTexture9_LockBox(volume, 0, &lb, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DVolumeTexture9_LockBox failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     for(z = 0; z < 32; z++) {
         for(y = 0; y < 32; y++) {
             for(x = 0; x < 32; x++) {
@@ -5742,13 +5728,13 @@ static void texture_transform_flags_test(void)
         }
     }
     hr = IDirect3DVolumeTexture9_UnlockBox(volume, 0);
-    ok(hr == D3D_OK, "IDirect3DVolumeTexture9_UnlockBox failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) volume);
-    ok(hr == D3D_OK, "IDirect3DVolumeTexture9_UnlockBox failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(SUCCEEDED(hr))
     {
         static const float quad1[] =
@@ -5787,17 +5773,17 @@ static void texture_transform_flags_test(void)
             0.0f, 0.0f, 0.0f, 1.0f,
         }}};
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* Draw a quad with all 3 coords enabled. Nothing fancy. v and w are swapped, but have the same
          * values
          */
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 6 * sizeof(float));
-        ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* Now disable the w coordinate. Does that change the input, or the output. The coordinates
          * are swapped by the matrix. If it changes the input, the v coord will be missing(green),
@@ -5805,35 +5791,35 @@ static void texture_transform_flags_test(void)
          * turns out that on nvidia cards the blue color is missing, so it is an output modification.
          * On ATI cards the COUNT2 is ignored, and it behaves in the same way as COUNT3. */
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 6 * sizeof(float));
-        ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* default values? Set up the identity matrix, pass in 2 vertex coords, and enable 3 */
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &identity);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 5 * sizeof(float));
-        ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* D3DTTFF_COUNT1. Set a NULL matrix, and count1, pass in all values as 1.0. Nvidia has count1 ==
          * disable. ATI extends it up to the amount of values needed for the volume texture
          */
         memset(&mat, 0, sizeof(mat));
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT1);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 6 * sizeof(float));
-        ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     color = getPixelColor(device, 160, 360);
@@ -5847,12 +5833,12 @@ static void texture_transform_flags_test(void)
     ok(color == 0x00ffffff || color == 0x0000ff00, "quad 4 has color %08x, expected 0x00ffffff\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff303030, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(SUCCEEDED(hr))
     {
         static const float quad1[] =
@@ -5891,7 +5877,7 @@ static void texture_transform_flags_test(void)
             0.0f, 0.0f, 1.0f, 0.0f,
         }}};
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* Default values? 4 coords used, 3 passed. What happens to the 4th?
          * Use COUNT3 because newer Nvidia drivers return black when there are more (output) coords
@@ -5900,30 +5886,30 @@ static void texture_transform_flags_test(void)
          * 4th *input* coordinate.
          */
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 6 * sizeof(float));
-        ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* None passed */
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &identity);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 3 * sizeof(float));
-        ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* 4 used, 1 passed */
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl2);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE0, &mat2);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 4 * sizeof(float));
-        ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
     color = getPixelColor(device, 160, 360);
     ok(color == 0x0000ff00, "quad 1 has color %08x, expected 0x0000ff00\n", color);
@@ -5934,7 +5920,7 @@ static void texture_transform_flags_test(void)
     /* Quad4: unused */
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DVolumeTexture9_Release(volume);
 
@@ -5944,7 +5930,7 @@ out:
     IDirect3DVertexDeclaration9_Release(decl3);
     IDirect3DVertexDeclaration9_Release(decl4);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -5954,10 +5940,10 @@ static void texdepth_test(void)
 {
     IDirect3DPixelShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -5996,7 +5982,7 @@ static void texdepth_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(1, 4))
     {
         skip("No ps_1_4 support, skipping tests.\n");
@@ -6005,45 +5991,45 @@ static void texdepth_test(void)
     }
 
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetFVF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Fill the depth buffer with a gradient */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Now perform the actual tests. Same geometry, but with the shader */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_GREATER);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, texdepth_test_data1, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 158, 240);
     ok(color == 0x000000ff, "Pixel 158(25%% - 2 pixel) has color %08x, expected 0x000000ff\n", color);
@@ -6051,19 +6037,19 @@ static void texdepth_test(void)
     ok(color == 0x00ffffff, "Pixel 158(25%% + 2 pixel) has color %08x, expected 0x00ffffff\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, texdepth_test_data2, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 318, 240);
     ok(color == 0x000000ff, "Pixel 318(50%% - 2 pixel) has color %08x, expected 0x000000ff\n", color);
@@ -6071,37 +6057,37 @@ static void texdepth_test(void)
     ok(color == 0x00ffff00, "Pixel 322(50%% + 2 pixel) has color %08x, expected 0x00ffff00\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, texdepth_test_data3, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 1, 240);
     ok(color == 0x00ff0000, "Pixel 1(0%% + 2 pixel) has color %08x, expected 0x00ff0000\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, texdepth_test_data4, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 318, 240);
     ok(color == 0x000000ff, "Pixel 318(50%% - 2 pixel) has color %08x, expected 0x000000ff\n", color);
@@ -6109,65 +6095,65 @@ static void texdepth_test(void)
     ok(color == 0x0000ff00, "Pixel 322(50%% + 2 pixel) has color %08x, expected 0x0000ff00\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, texdepth_test_data5, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 1, 240);
     ok(color == 0x00ffff00, "Pixel 1(0%% + 2 pixel) has color %08x, expected 0x00ffff00\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, texdepth_test_data6, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 638, 240);
     ok(color == 0x000000ff, "Pixel 638(100%% + 2 pixel) has color %08x, expected 0x000000ff\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, texdepth_test_data7, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 638, 240);
     ok(color == 0x000000ff, "Pixel 638(100%% + 2 pixel) has color %08x, expected 0x000000ff\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DPixelShader9_Release(shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -6177,10 +6163,10 @@ static void texkill_test(void)
 {
     IDirect3DPixelShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -6220,7 +6206,7 @@ static void texkill_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
     {
         skip("No ps_1_1 support, skipping tests.\n");
@@ -6229,20 +6215,20 @@ static void texkill_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_11, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEXCOORDSIZE4(0) | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 7 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 63, 46);
     ok(color == 0x0000ff00, "Pixel 63/46 has color %08x, expected 0x0000ff00\n", color);
@@ -6281,14 +6267,14 @@ static void texkill_test(void)
     ok(color == 0x00ff0000, "Pixel 575/49 has color %08x, expected 0x00ff0000\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DPixelShader9_Release(shader);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if (FAILED(IDirect3DDevice9_CreatePixelShader(device, shader_code_20, &shader)))
     {
         skip("Failed to create 2.0 test shader, most likely not supported.\n");
@@ -6297,13 +6283,13 @@ static void texkill_test(void)
     }
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, vertex, 7 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 63, 46);
     ok(color == 0x00ffff00, "Pixel 63/46 has color %08x, expected 0x00ffff00\n", color);
@@ -6342,11 +6328,11 @@ static void texkill_test(void)
     ok(color == 0x000000ff, "Pixel 575/49 has color %08x, expected 0x000000ff\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DPixelShader9_Release(shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -6368,10 +6354,9 @@ static void test_generate_mipmap(void)
     IDirect3DTexture9 *texture, *texture2;
     IDirect3DSurface9 *surface, *surface2;
     IDirect3DDevice9 *device;
-    unsigned int x, y;
+    unsigned int color, x, y;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -6386,23 +6371,23 @@ static void test_generate_mipmap(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* Make the texture big enough that a mipmap level > 0 is used. */
     hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_RENDERTARGET,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, 0);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, 0,
             D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture2, 0);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture2, 0, &surface2);
-    ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_LockRect(surface2, &lr, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to map surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to map surface, hr %#lx.\n", hr);
     for (y = 0; y < 1024; ++y)
     {
         for(x = 0; x < 1024; ++x)
@@ -6425,35 +6410,35 @@ static void test_generate_mipmap(void)
         }
     }
     hr = IDirect3DSurface9_UnlockRect(surface2);
-    ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_UpdateSurface(device, surface2, NULL, surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update surface, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface2);
     IDirect3DSurface9_Release(surface);
     IDirect3DTexture9_Release(texture2);
 
     hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_LINEAR);
-    ok(SUCCEEDED(hr), "Failed to set mipmap autogen filter type, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set mipmap autogen filter type, hr %#lx.\n", hr);
 
     IDirect3DTexture9_GenerateMipSubLevels(texture);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "Failed to set mipmap filtering, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set mipmap filtering, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     color = getPixelColor(device, 200, 200);
@@ -6473,10 +6458,10 @@ static void test_generate_mipmap(void)
     color = getPixelColor(device, 440, 270);
     ok(!color, "Unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -6487,11 +6472,10 @@ static void test_mipmap_autogen(void)
     IDirect3DSurface9 *surface, *surface2, *surface3, *backbuffer;
     IDirect3DTexture9 *texture, *texture2, *texture3;
     IDirect3DCubeTexture9 *cube_texture;
+    unsigned int color, i, x, y;
     IDirect3DDevice9 *device;
-    unsigned int i, x, y;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -6527,21 +6511,21 @@ static void test_mipmap_autogen(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Make the texture big enough that a mipmap level > 0 is used. */
     hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_AUTOGENMIPMAP,
                                         D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(hr == D3D_OK, "IDirect3DTexture9_GetSurfaceLevel returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DSurface9_LockRect returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     for(y = 0; y < 1024; y++) {
         for(x = 0; x < 1024; x++) {
             DWORD *dst = (DWORD *) (((BYTE *) lr.pBits) + y * lr.Pitch + x * 4);
@@ -6563,24 +6547,24 @@ static void test_mipmap_autogen(void)
         }
     }
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(hr == D3D_OK, "IDirect3DSurface9_UnlockRect returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     color = getPixelColor(device, 200, 200);
@@ -6600,10 +6584,10 @@ static void test_mipmap_autogen(void)
     color = getPixelColor(device, 440, 270);
     ok(color == 0x00ffffff, "pixel 440/270 has color %08x, expected 0x00ffffff\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES))
     {
         skip("Blitting from textures is not supported.\n");
@@ -6613,19 +6597,19 @@ static void test_mipmap_autogen(void)
     }
     hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 1, 0,
             D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, 0);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture2, 0);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_RENDERTARGET,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture3, 0);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to map surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to map surface, hr %#lx.\n", hr);
     for (y = 0; y < 1024; ++y)
     {
         for (x = 0; x < 1024; ++x)
@@ -6648,25 +6632,25 @@ static void test_mipmap_autogen(void)
         }
     }
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(surface);
 
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture,
             (IDirect3DBaseTexture9 *)texture2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 200, 200);
     ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color);
@@ -6686,24 +6670,24 @@ static void test_mipmap_autogen(void)
     ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture2, 0, &surface2);
-    ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture3, 0, &surface3);
-    ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, surface2, NULL, surface3, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "Failed to blit texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture3);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 200, 200);
     ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color);
@@ -6723,23 +6707,23 @@ static void test_mipmap_autogen(void)
     ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface3);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ffff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 200, 200);
     ok(color == 0x0000ffff, "Unexpected color 0x%08x.\n", color);
@@ -6759,11 +6743,11 @@ static void test_mipmap_autogen(void)
     }
     hr = IDirect3DDevice9_CreateCubeTexture(device, 1024, 0, D3DUSAGE_AUTOGENMIPMAP,
             D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &cube_texture, 0);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     for (i = 0; i < 6; ++i)
     {
         hr = IDirect3DCubeTexture9_LockRect(cube_texture, i, 0, &lr, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to map texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to map texture, hr %#lx.\n", hr);
 
         for (y = 0; y < 1024; ++y)
         {
@@ -6787,20 +6771,20 @@ static void test_mipmap_autogen(void)
             }
         }
         hr = IDirect3DCubeTexture9_UnlockRect(cube_texture, i, 0);
-        ok(SUCCEEDED(hr), "Failed to unmap texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unmap texture, hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)cube_texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     IDirect3DCubeTexture9_Release(cube_texture);
 
     color = getPixelColor(device, 200, 200);
@@ -6825,16 +6809,16 @@ static void test_mipmap_autogen(void)
             D3DFMT_X8R8G8B8, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, D3DFMT_A1R5G5B5);
     if (hr != D3DOK_NOAUTOGEN)
     {
-        skip("D3DFMT_A1R5G5B5 support is not D3DOK_NOAUTOGEN (%#x).\n", hr);
+        skip("D3DFMT_A1R5G5B5 support is not D3DOK_NOAUTOGEN (hr %#lx).\n", hr);
     }
     else
     {
         hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_AUTOGENMIPMAP,
                 D3DFMT_A1R5G5B5, D3DPOOL_MANAGED, &texture, 0);
-        ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
         hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to map texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to map texture, hr %#lx.\n", hr);
         for (y = 0; y < 1024; ++y)
         {
             for (x = 0; x < 1024; ++x)
@@ -6857,17 +6841,17 @@ static void test_mipmap_autogen(void)
             }
         }
         hr = IDirect3DTexture9_UnlockRect(texture, 0);
-        ok(SUCCEEDED(hr), "Failed to unmap texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unmap texture, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-        ok(SUCCEEDED(hr), "Failed to set texture, %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
         IDirect3DTexture9_Release(texture);
 
         color = getPixelColor(device, 200, 200);
@@ -6887,13 +6871,13 @@ static void test_mipmap_autogen(void)
         color = getPixelColor(device, 440, 270);
         ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     }
 
     IDirect3DSurface9_Release(backbuffer);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -6904,8 +6888,8 @@ static void test_constant_clamp_vs(void)
     IDirect3DVertexShader9 *shader_11, *shader_11_2, *shader_20, *shader_20_2;
     IDirect3DVertexDeclaration9 *decl;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -6997,7 +6981,7 @@ static void test_constant_clamp_vs(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(1, 1))
     {
         skip("No vs_1_1 support, skipping tests.\n");
@@ -7006,57 +6990,57 @@ static void test_constant_clamp_vs(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ffff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code_11, &shader_11);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code_11_2, &shader_11_2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code_20, &shader_20);
     if(FAILED(hr)) shader_20 = NULL;
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code_20_2, &shader_20_2);
     if(FAILED(hr)) shader_20_2 = NULL;
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &decl);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, test_data_c1, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 2, test_data_c2, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, decl);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, shader_11);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, shader_11_2);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     if (shader_20)
     {
         hr = IDirect3DDevice9_SetVertexShader(device, shader_20);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 3 * sizeof(float));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     }
 
     if (shader_20_2)
     {
         hr = IDirect3DDevice9_SetVertexShader(device, shader_20_2);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 3 * sizeof(float));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0xbf, 0xbf, 0x80), 1),
@@ -7075,7 +7059,7 @@ static void test_constant_clamp_vs(void)
            "quad 4 has color %08x, expected 0x00bfbf80\n", color);
     }
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DVertexDeclaration9_Release(decl);
     if(shader_20_2) IDirect3DVertexShader9_Release(shader_20_2);
@@ -7083,7 +7067,7 @@ static void test_constant_clamp_vs(void)
     IDirect3DVertexShader9_Release(shader_11_2);
     IDirect3DVertexShader9_Release(shader_11);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -7093,10 +7077,10 @@ static void constant_clamp_ps_test(void)
 {
     IDirect3DPixelShader9 *shader_11, *shader_12, *shader_14, *shader_20;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -7177,7 +7161,7 @@ static void constant_clamp_ps_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(1, 4))
     {
         skip("No ps_1_4 support, skipping tests.\n");
@@ -7186,52 +7170,52 @@ static void constant_clamp_ps_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ffff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_11, &shader_11);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_12, &shader_12);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_14, &shader_14);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_20, &shader_20);
     if(FAILED(hr)) shader_20 = NULL;
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 1, test_data_c1, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 2, test_data_c2, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_11);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_12);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_14);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     if (shader_20)
     {
         hr = IDirect3DDevice9_SetPixelShader(device, shader_20);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 3 * sizeof(float));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x80, 0x80, 0x00), 1),
@@ -7248,14 +7232,14 @@ static void constant_clamp_ps_test(void)
            "quad 4 has color %08x, expected 0x00bfbf80\n", color);
     }
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     if(shader_20) IDirect3DPixelShader9_Release(shader_20);
     IDirect3DPixelShader9_Release(shader_14);
     IDirect3DPixelShader9_Release(shader_12);
     IDirect3DPixelShader9_Release(shader_11);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -7266,10 +7250,10 @@ static void dp2add_ps_test(void)
     IDirect3DPixelShader9 *shader_dp2add_sat;
     IDirect3DPixelShader9 *shader_dp2add;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -7326,7 +7310,7 @@ static void dp2add_ps_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
     {
         skip("No ps_2_0 support, skipping tests.\n");
@@ -7335,51 +7319,51 @@ static void dp2add_ps_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_dp2add, &shader_dp2add);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_dp2add_sat, &shader_dp2add_sat);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_dp2add);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 360, 240);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x7f, 0x7f, 0x7f), 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present frame, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present frame, hr %#lx.\n", hr);
     IDirect3DPixelShader9_Release(shader_dp2add);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_dp2add_sat);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 360, 240);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x7f, 0x7f, 0x7f), 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present frame, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present frame, hr %#lx.\n", hr);
     IDirect3DPixelShader9_Release(shader_dp2add_sat);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -7391,11 +7375,11 @@ static void cnd_test(void)
     IDirect3DPixelShader9 *shader_11_coissue, *shader_12_coissue, *shader_13_coissue, *shader_14_coissue;
     IDirect3DPixelShader9 *shader_11, *shader_12, *shader_13, *shader_14;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
-    DWORD color;
     HRESULT hr;
 
     /* ps 1.x shaders are rather picky with writemasks and source swizzles.
@@ -7613,7 +7597,7 @@ static void cnd_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(1, 4))
     {
         skip("No ps_1_4 support, skipping tests.\n");
@@ -7622,68 +7606,68 @@ static void cnd_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ffff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_11, &shader_11);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_12, &shader_12);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_13, &shader_13);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_14, &shader_14);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_11_coissue, &shader_11_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_12_coissue, &shader_12_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_13_coissue, &shader_13_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_14_coissue, &shader_14_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_11_coissue_2, &shader_11_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_12_coissue_2, &shader_12_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_13_coissue_2, &shader_13_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_14_coissue_2, &shader_14_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 1, test_data_c1, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 2, test_data_c2, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_11);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_12);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_13);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_14);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* This is the 1.4 test. Each component(r, g, b) is tested separately against 0.5 */
     color = getPixelColor(device, 158, 118);
@@ -7726,43 +7710,43 @@ static void cnd_test(void)
     ok(color_match(color, 0x00000000, 1), "pixel 482, 122 has color 0x%08x, expected 0x00000000.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 1, test_data_c1_coi, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 2, test_data_c2_coi, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShaderConstantF returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_11_coissue);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_12_coissue);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_13_coissue);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_14_coissue);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* This is the 1.4 test. The coissue doesn't change the behavior here, but keep in mind
      * that we swapped the values in c1 and c2 to make the other tests return some color
@@ -7821,39 +7805,39 @@ static void cnd_test(void)
         "pixel 482, 122 has color %08x, expected 0x0000ff00\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Retest with the coissue flag on the alpha instruction instead. This
      * works "as expected". The Windows 8 testbot (WARP) seems to handle this
      * the same as coissue on .rgb. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_11_coissue_2);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_12_coissue_2);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_13_coissue_2);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, shader_14_coissue_2);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 6 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* 1.4 shader */
     color = getPixelColor(device, 158, 118);
@@ -7908,7 +7892,7 @@ static void cnd_test(void)
         "pixel 562, 122 has color %08x, expected 0x00000000\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DPixelShader9_Release(shader_14_coissue_2);
     IDirect3DPixelShader9_Release(shader_13_coissue_2);
@@ -7923,7 +7907,7 @@ static void cnd_test(void)
     IDirect3DPixelShader9_Release(shader_12);
     IDirect3DPixelShader9_Release(shader_11);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -7934,10 +7918,10 @@ static void nested_loop_test(void)
     IDirect3DVertexShader9 *vshader;
     IDirect3DPixelShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -7982,7 +7966,7 @@ static void nested_loop_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0) || caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No shader model 3 support, skipping tests.\n");
@@ -7991,36 +7975,36 @@ static void nested_loop_test(void)
     }
 
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vshader_code, &vshader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vshader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0000ff00, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 360, 240);
     ok(color_match(color, 0x00800000, 1),
             "Nested loop test returned color 0x%08x, expected 0x00800000.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DPixelShader9_Release(shader);
     IDirect3DVertexShader9_Release(vshader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -8122,7 +8106,7 @@ static void pretransformed_varying_test(void)
     {
         const char *name;
         const DWORD *shader_code;
-        DWORD color;
+        unsigned int color;
         BOOL todo;
         BOOL broken;
         DWORD broken_color;
@@ -8231,11 +8215,10 @@ static void pretransformed_varying_test(void)
     IDirect3DVertexDeclaration9 *decl;
     D3DADAPTER_IDENTIFIER9 identifier;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    unsigned int i;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -8249,7 +8232,7 @@ static void pretransformed_varying_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0) || caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No shader model 3 support, skipping tests.\n");
@@ -8258,7 +8241,7 @@ static void pretransformed_varying_test(void)
     }
 
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     if (adapter_is_warp(&identifier) && sizeof(UINT) == sizeof(UINT_PTR))
     {
         /* Apparently the "monster" vertex declaration used in this test
@@ -8270,29 +8253,29 @@ static void pretransformed_varying_test(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &decl);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, decl);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         IDirect3DPixelShader9 *shader;
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_CreatePixelShader(device, tests[i].shader_code, &shader);
-        ok(SUCCEEDED(hr), "Failed to create pixel shader for test %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to create pixel shader for test %s, hr %#lx.\n", tests[i].name, hr);
 
         hr = IDirect3DDevice9_SetPixelShader(device, shader);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, data, sizeof(*data));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         /* This isn't a weekend's job to fix, ignore the problem for now.
          * Needs a replacement pipeline. */
@@ -8310,16 +8293,16 @@ static void pretransformed_varying_test(void)
                     tests[i].name, color, tests[i].color);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader for test %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader for test %s, hr %#lx.\n", tests[i].name, hr);
         IDirect3DPixelShader9_Release(shader);
     }
 
     IDirect3DVertexDeclaration9_Release(decl);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -8332,8 +8315,8 @@ static void test_compare_instructions(void)
     IDirect3DVertexShader9 *shader_slt_vec;
     IDirect3DVertexShader9 *shader_sge_vec;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -8420,7 +8403,7 @@ static void test_compare_instructions(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(1, 1))
     {
         skip("No vs_1_1 support, skipping tests.\n");
@@ -8429,51 +8412,51 @@ static void test_compare_instructions(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_sge_vec_code, &shader_sge_vec);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_slt_vec_code, &shader_slt_vec);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_sge_scalar_code, &shader_sge_scalar);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_slt_scalar_code, &shader_slt_scalar);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, const0, 1);
-    ok(SUCCEEDED(hr), "SetVertexShaderConstantF failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, const1, 1);
-    ok(SUCCEEDED(hr), "SetVertexShaderConstantF failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetFVF failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, shader_sge_vec);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, shader_slt_vec);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2,  quad2, sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, shader_sge_scalar);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, const0, 1);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, shader_slt_scalar);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color == 0x00ff00ff, "Compare test: Quad 1(sge vec) returned color 0x%08x, expected 0x00ff00ff\n", color);
@@ -8485,14 +8468,14 @@ static void test_compare_instructions(void)
     ok(color == 0x000000ff, "Compare test: Quad 4(slt scalar) returned color 0x%08x, expected 0x000000ff\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DVertexShader9_Release(shader_sge_vec);
     IDirect3DVertexShader9_Release(shader_slt_vec);
     IDirect3DVertexShader9_Release(shader_sge_scalar);
     IDirect3DVertexShader9_Release(shader_slt_scalar);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -8507,11 +8490,10 @@ static void test_vshader_input(void)
     D3DADAPTER_IDENTIFIER9 identifier;
     IDirect3DPixelShader9 *ps;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
     ULONG refcount;
-    unsigned int i;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
     BOOL warp;
@@ -8767,7 +8749,7 @@ static void test_vshader_input(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No vs_3_0 support, skipping tests.\n");
@@ -8782,84 +8764,84 @@ static void test_vshader_input(void)
     }
 
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     warp = adapter_is_warp(&identifier);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_twotexcrd, &decl_twotexcrd);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_onetexcrd, &decl_onetexcrd);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_twotexcrd_wrongidx, &decl_twotex_wrongidx);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_twotexcrd_rightorder, &decl_twotexcrd_rightorder);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_texcoord_color, &decl_texcoord_color);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_color_color, &decl_color_color);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_color_ubyte, &decl_color_ubyte);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_color_float, &decl_color_float);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_nocolor, &decl_nocolor);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, ps3_code, &ps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (i = 1; i <= 3; ++i)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 1.0f, 0);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         if(i == 3) {
             hr = IDirect3DDevice9_CreateVertexShader(device, swapped_shader_code_3, &swapped_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetPixelShader(device, ps);
-            ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         } else if(i == 2){
             hr = IDirect3DDevice9_CreateVertexShader(device, swapped_shader_code_2, &swapped_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         } else if(i == 1) {
             hr = IDirect3DDevice9_CreateVertexShader(device, swapped_shader_code_1, &swapped_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         }
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexShader(device, swapped_shader);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotexcrd);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(float) * 11);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_onetexcrd);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(float) * 11);
         if (i == 3 || i == 2)
-            ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#x.\n", i, hr);
+            ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#lx.\n", i, hr);
         else if (i == 1)
             /* Succeeds or fails, depending on SW or HW vertex processing. */
-            ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotexcrd_rightorder);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, sizeof(float) * 11);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotex_wrongidx);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(float) * 11);
         if (i == 3 || i == 2)
-            ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#x.\n", i, hr);
+            ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#lx.\n", i, hr);
         else if (i == 1)
-            ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         if(i == 3 || i == 2) {
             color = getPixelColor(device, 160, 360);
@@ -8897,35 +8879,35 @@ static void test_vshader_input(void)
         }
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff808080, 0.0, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* Now find out if the whole streams are re-read, or just the last
          * active value for the vertices is used. */
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexShader(device, swapped_shader);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotexcrd);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 3, quad1_modified, sizeof(float) * 11);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_onetexcrd);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2_modified, sizeof(float) * 11);
         if (i == 3 || i == 2)
-            ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#x.\n", i, hr);
+            ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#lx.\n", i, hr);
         else if (i == 1)
             /* Succeeds or fails, depending on SW or HW vertex processing. */
-            ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 480, 350);
         /* vs_1_1 may fail, accept the clear color. Some drivers also set the undefined streams to 0, accept that
@@ -8942,7 +8924,7 @@ static void test_vshader_input(void)
                 "Got unexpected color 0x%08x for quad 2 (different colors).\n", color);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         IDirect3DDevice9_SetVertexShader(device, NULL);
         IDirect3DDevice9_SetPixelShader(device, NULL);
@@ -8954,60 +8936,60 @@ static void test_vshader_input(void)
     for (i = 1; i <= 3; ++i)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear returned %#x.\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         if(i == 3) {
             hr = IDirect3DDevice9_CreateVertexShader(device, texcoord_color_shader_code_3, &texcoord_color_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_CreateVertexShader(device, color_color_shader_code_3, &color_color_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetPixelShader(device, ps);
-            ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         } else if(i == 2){
             hr = IDirect3DDevice9_CreateVertexShader(device, texcoord_color_shader_code_2, &texcoord_color_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_CreateVertexShader(device, color_color_shader_code_2, &color_color_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         } else if(i == 1) {
             hr = IDirect3DDevice9_CreateVertexShader(device, texcoord_color_shader_code_1, &texcoord_color_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_CreateVertexShader(device, color_color_shader_code_1, &color_color_shader);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         }
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexShader(device, texcoord_color_shader);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_texcoord_color);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1_color, sizeof(quad1_color[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexShader(device, color_color_shader);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, normalize, 1);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_color_ubyte);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2_color, sizeof(quad2_color[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, no_normalize, 1);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader constant, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_color_color);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3_color, sizeof(quad3_color[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_color_float);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4_color, sizeof(float) * 7);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 160, 360);
         ok(color_match(color, D3DCOLOR_ARGB(0x00, 0xff, 0x80, 0x40), 1),
@@ -9023,20 +9005,20 @@ static void test_vshader_input(void)
            "Input test: Quad 4(color-float) returned color 0x%08x, expected 0x00ffff00\n", color);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_nocolor);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_nocolor, sizeof(quad_nocolor[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         /* WARP and r500 return a color from a previous draw. In case of WARP it is random, although most of the
          * time it is the color of the last draw, which happens to be the one with quad4_color above. AMD's r500
@@ -9068,7 +9050,7 @@ static void test_vshader_input(void)
 
     IDirect3DPixelShader9_Release(ps);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -9084,9 +9066,8 @@ static void srgbtexture_test(void)
     struct IDirect3DTexture9 *texture;
     struct IDirect3DSurface9 *surface;
     IDirect3DDevice9 *device;
+    unsigned int colour, i;
     IDirect3D9 *d3d;
-    D3DCOLOR colour;
-    unsigned int i;
     ULONG refcount;
     HWND window;
     DWORD value;
@@ -9138,187 +9119,187 @@ static void srgbtexture_test(void)
         }
 
         hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 2, 0, tests[i].format, D3DPOOL_MANAGED, &texture, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         fill_surface(surface, tests[i].fill_colour1, 0);
         IDirect3DSurface9_Release(surface);
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 1, &surface);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         fill_surface(surface, tests[i].fill_colour2, 0);
         IDirect3DSurface9_Release(surface);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* AMD uses the LSB of the D3DSAMP_SRGBTEXTURE value.
          * NVIDIA ignores any values other than 0 and 1, leaving the previous
          * D3DSAMP_SRGBTEXTURE state.
          * Intel, WARP treat the value as boolean. */
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 0x7e41882a, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].fill_colour_rb1, 2)
                 || broken(color_match(colour, tests[i].conv_colour1, 1)),
                 "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 100);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 100, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 100, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].fill_colour_rb1, 2)
                 || broken(color_match(colour, tests[i].conv_colour1, 1)),
                 "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 2);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 2, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 2, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].fill_colour_rb1, 2)
                 || broken(color_match(colour, tests[i].conv_colour1, 1)),
                 "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 3);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 3, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 3, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].fill_colour_rb1, 2)
                 || color_match(colour, tests[i].conv_colour1, 3),
                 "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, TRUE);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == TRUE, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == TRUE, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].conv_colour1, 3), "Format %s, got unexpected colour 0x%08x.\n",
                 tests[i].format_name, colour);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         /* Set the other state to verify that the sampler just inherits old
          * D3DSAMP_SRGBTEXTURE but the old sampler is not preserved entirely on
          * NVIDIA. */
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 0x7e41882a, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].conv_colour2, 1)
                 || color_match(colour, tests[i].fill_colour_rb2, 2),
                 "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 0, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 0, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].fill_colour_rb2, 2),
                 "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 0x7e41882a, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].fill_colour_rb2, 2)
                 || broken(color_match(colour, tests[i].conv_colour2, 1)),
                 "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         IDirect3DTexture9_Release(texture);
 
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -9328,17 +9309,17 @@ static void test_shademode(void)
 {
     IDirect3DVertexBuffer9 *vb_strip;
     IDirect3DVertexBuffer9 *vb_list;
+    unsigned int color0, color1, i;
     IDirect3DVertexShader9 *vs;
     IDirect3DPixelShader9 *ps;
     IDirect3DDevice9 *device;
-    DWORD color0, color1;
     void *data = NULL;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
-    UINT i;
+
     static const DWORD vs1_code[] =
     {
         0xfffe0101,                                                             /* vs_1_1          */
@@ -9428,7 +9409,7 @@ static void test_shademode(void)
         const struct test_shader *vs, *ps;
         DWORD primtype;
         DWORD shademode;
-        DWORD color0, color1;
+        unsigned int color0, color1;
         BOOL todo;
     }
     tests[] =
@@ -9461,31 +9442,31 @@ static void test_shademode(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad_strip), 0, 0, D3DPOOL_MANAGED, &vb_strip, NULL);
-    ok(hr == D3D_OK, "CreateVertexBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb_strip, 0, sizeof(quad_strip), &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, quad_strip, sizeof(quad_strip));
     hr = IDirect3DVertexBuffer9_Unlock(vb_strip);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad_list), 0, 0, D3DPOOL_MANAGED, &vb_list, NULL);
-    ok(hr == D3D_OK, "CreateVertexBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb_list, 0, sizeof(quad_list), &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, quad_list, sizeof(quad_list));
     hr = IDirect3DVertexBuffer9_Unlock(vb_list);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     /* Try it first with a TRIANGLESTRIP.  Do it with different geometry because
      * the color fixups we have to do for FLAT shading will be dependent on that. */
@@ -9497,9 +9478,9 @@ static void test_shademode(void)
             if (caps.VertexShaderVersion >= tests[i].vs->version)
             {
                 hr = IDirect3DDevice9_CreateVertexShader(device, tests[i].vs->code, &vs);
-                ok(hr == D3D_OK, "Failed to create vertex shader, hr %#x.\n", hr);
+                ok(hr == D3D_OK, "Failed to create vertex shader, hr %#lx.\n", hr);
                 hr = IDirect3DDevice9_SetVertexShader(device, vs);
-                ok(hr == D3D_OK, "Failed to set vertex shader, hr %#x.\n", hr);
+                ok(hr == D3D_OK, "Failed to set vertex shader, hr %#lx.\n", hr);
             }
             else
             {
@@ -9516,9 +9497,9 @@ static void test_shademode(void)
             if (caps.PixelShaderVersion >= tests[i].ps->version)
             {
                 hr = IDirect3DDevice9_CreatePixelShader(device, tests[i].ps->code, &ps);
-                ok(hr == D3D_OK, "Failed to create pixel shader, hr %#x.\n", hr);
+                ok(hr == D3D_OK, "Failed to create pixel shader, hr %#lx.\n", hr);
                 hr = IDirect3DDevice9_SetPixelShader(device, ps);
-                ok(hr == D3D_OK, "Failed to set pixel shader, hr %#x.\n", hr);
+                ok(hr == D3D_OK, "Failed to set pixel shader, hr %#lx.\n", hr);
             }
             else
             {
@@ -9538,20 +9519,20 @@ static void test_shademode(void)
 
         hr = IDirect3DDevice9_SetStreamSource(device, 0,
                 tests[i].primtype == D3DPT_TRIANGLESTRIP ? vb_strip : vb_list, 0, sizeof(quad_strip[0]));
-        ok(hr == D3D_OK, "Failed to set stream source, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to set stream source, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SHADEMODE, tests[i].shademode);
-        ok(hr == D3D_OK, "Failed to set shade mode, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to set shade mode, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, tests[i].primtype, 0, 2);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color0 = getPixelColor(device, 100, 100); /* Inside first triangle */
         color1 = getPixelColor(device, 500, 350); /* Inside second triangle */
@@ -9578,12 +9559,12 @@ static void test_shademode(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Failed to present, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer9_Release(vb_strip);
     IDirect3DVertexBuffer9_Release(vb_list);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -9594,8 +9575,8 @@ static void test_blend(void)
     IDirect3DSurface9 *backbuffer, *offscreen;
     IDirect3DTexture9 *offscreenTexture;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -9638,94 +9619,94 @@ static void test_blend(void)
 
     /* Clear the render target with alpha = 0.5 */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x80ff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &offscreenTexture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(offscreenTexture, 0, &offscreen);
-    ok(hr == D3D_OK, "Can't get offscreen surface, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed, hr = %#08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     /* Draw two quads, one with src alpha blending, one with dest alpha
      * blending. */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(quad1[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_DESTALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_INVDESTALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(quad2[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     /* Switch to the offscreen buffer, and redo the testing. The offscreen
      * render target doesn't have an alpha channel. DESTALPHA and INVDESTALPHA
      * "don't work" on render targets without alpha channel, they give
      * essentially ZERO and ONE blend factors. */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, offscreen);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x80ff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(quad1[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_DESTALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_INVDESTALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(quad2[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     /* Render the offscreen texture onto the frame buffer to be able to
      * compare it regularly. Disable alpha blending for the final
      * composition. */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) offscreenTexture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, composite_quad, sizeof(float) * 5);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0xbf, 0x40, 0x00), 1),
@@ -9749,7 +9730,7 @@ static void test_blend(void)
     IDirect3DTexture9_Release(offscreenTexture);
     IDirect3DSurface9_Release(offscreen);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -9760,9 +9741,9 @@ static void fixed_function_decl_test(void)
     IDirect3DVertexDeclaration9 *dcl_float = NULL, *dcl_short = NULL, *dcl_ubyte = NULL, *dcl_color = NULL;
     IDirect3DVertexDeclaration9 *dcl_color_2 = NULL, *dcl_ubyte_2 = NULL, *dcl_nocolor, *dcl_positiont;
     IDirect3DVertexBuffer9 *vb, *vb2;
+    unsigned int color, size, i;
     IDirect3DDevice9 *device;
     BOOL s_ok, ub_ok, f_ok;
-    DWORD color, size, i;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
@@ -9917,52 +9898,52 @@ static void fixed_function_decl_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "GetDeviceCaps failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-    ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_d3dcolor, &dcl_color);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_short4, &dcl_short);
-    ok(SUCCEEDED(hr) || hr == E_FAIL, "CreateVertexDeclaration failed (%08x)\n", hr);
+    ok(SUCCEEDED(hr) || hr == E_FAIL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_float, &dcl_float);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(caps.DeclTypes & D3DDTCAPS_UBYTE4N) {
         hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_ubyte4n_2streams, &dcl_ubyte_2);
-        ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_ubyte4n, &dcl_ubyte);
-        ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     } else {
         trace("D3DDTCAPS_UBYTE4N not supported\n");
         dcl_ubyte_2 = NULL;
         dcl_ubyte = NULL;
     }
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_d3dcolor_2streams, &dcl_color_2);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_nocolor, &dcl_nocolor);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_positiont, &dcl_positiont);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     size = max(sizeof(quad1), max(sizeof(quad2), max(sizeof(quad3), max(sizeof(quad4), sizeof(quads)))));
     hr = IDirect3DDevice9_CreateVertexBuffer(device, size,
                                              0, 0, D3DPOOL_MANAGED, &vb, NULL);
-    ok(hr == D3D_OK, "CreateVertexBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     f_ok = FALSE; s_ok = FALSE; ub_ok = FALSE;
     if (dcl_color)
     {
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_color);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(quad1[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     }
 
     /* Tests with non-standard fixed function types fail on the refrast. The
@@ -9972,32 +9953,32 @@ static void fixed_function_decl_test(void)
     if (dcl_ubyte)
     {
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_ubyte);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(quad2[0]));
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         ub_ok = SUCCEEDED(hr);
     }
 
     if (dcl_short)
     {
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_short);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(quad3[0]));
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         s_ok = SUCCEEDED(hr);
     }
 
     if (dcl_float)
     {
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_float);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, sizeof(quad4[0]));
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         f_ok = SUCCEEDED(hr);
     }
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     if(dcl_short) {
         color = getPixelColor(device, 480, 360);
@@ -10028,75 +10009,75 @@ static void fixed_function_decl_test(void)
      * whether the immediate mode code works. */
     f_ok = FALSE; s_ok = FALSE; ub_ok = FALSE;
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     if (dcl_color)
     {
         hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad1), &data, 0);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         memcpy(data, quad1, sizeof(quad1));
         hr = IDirect3DVertexBuffer9_Unlock(vb);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_color);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad1[0]));
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     }
 
     if (dcl_ubyte)
     {
         hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad2), &data, 0);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         memcpy(data, quad2, sizeof(quad2));
         hr = IDirect3DVertexBuffer9_Unlock(vb);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_ubyte);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad2[0]));
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         ub_ok = SUCCEEDED(hr);
     }
 
     if (dcl_short)
     {
         hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad3), &data, 0);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         memcpy(data, quad3, sizeof(quad3));
         hr = IDirect3DVertexBuffer9_Unlock(vb);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_short);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad3[0]));
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         s_ok = SUCCEEDED(hr);
     }
 
     if (dcl_float)
     {
         hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad4), &data, 0);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         memcpy(data, quad4, sizeof(quad4));
         hr = IDirect3DVertexBuffer9_Unlock(vb);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_float);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad4[0]));
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         f_ok = SUCCEEDED(hr);
     }
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     if(dcl_short) {
         color = getPixelColor(device, 480, 360);
@@ -10122,16 +10103,16 @@ static void fixed_function_decl_test(void)
 
     /* Test with no diffuse color attribute. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_nocolor);
-    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quads, sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color == 0x00ffffff, "Got unexpected color 0x%08x in the no color attribute test.\n", color);
@@ -10141,48 +10122,48 @@ static void fixed_function_decl_test(void)
     /* Test what happens with specular lighting enabled and no specular color attribute. */
     f_ok = FALSE; s_ok = FALSE; ub_ok = FALSE;
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SPECULARENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     if (dcl_color)
     {
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_color);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(quad1[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     }
     if (dcl_ubyte)
     {
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_ubyte);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(quad2[0]));
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         ub_ok = SUCCEEDED(hr);
     }
     if (dcl_short)
     {
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_short);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(quad3[0]));
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         s_ok = SUCCEEDED(hr);
     }
     if (dcl_float)
     {
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_float);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, sizeof(quad4[0]));
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         f_ok = SUCCEEDED(hr);
     }
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SPECULARENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable specular lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable specular lighting, hr %#lx.\n", hr);
 
     if (dcl_short)
     {
@@ -10211,25 +10192,25 @@ static void fixed_function_decl_test(void)
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad_transformed), &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, quad_transformed, sizeof(quad_transformed));
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_positiont);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad_transformed[0]));
-    ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 88, 108);
     ok(color == 0x000000ff,
@@ -10292,54 +10273,54 @@ static void fixed_function_decl_test(void)
     }
 
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quads), &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, quads, sizeof(quads));
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(colors),
                                              0, 0, D3DPOOL_MANAGED, &vb2, NULL);
-    ok(hr == D3D_OK, "CreateVertexBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb2, 0, sizeof(colors), &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, colors, sizeof(colors));
     hr = IDirect3DVertexBuffer9_Unlock(vb2);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for(i = 0; i < 2; i++) {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(float) * 3);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSource failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         if(i == 0) {
             hr = IDirect3DDevice9_SetStreamSource(device, 1, vb2, 0, sizeof(DWORD) * 4);
         } else {
             hr = IDirect3DDevice9_SetStreamSource(device, 1, vb2, 8, sizeof(DWORD) * 4);
         }
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSource failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_ubyte_2);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         ub_ok = SUCCEEDED(hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_color_2);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 4, 2);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, dcl_ubyte_2);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 8, 2);
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
         ub_ok = (SUCCEEDED(hr) && ub_ok);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         if(i == 0) {
             color = getPixelColor(device, 480, 360);
@@ -10383,7 +10364,7 @@ out:
     IDirect3DVertexDeclaration9_Release(dcl_nocolor);
     IDirect3DVertexDeclaration9_Release(dcl_positiont);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -10395,10 +10376,10 @@ static void test_vshader_float16(void)
     IDirect3DVertexBuffer9 *buffer = NULL;
     IDirect3DVertexShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     void *data;
     HRESULT hr;
@@ -10456,7 +10437,7 @@ static void test_vshader_float16(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No vs_3_0 support, skipping tests.\n");
@@ -10465,29 +10446,29 @@ static void test_vshader_float16(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff102030, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vdecl);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexDeclaration failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code, &shader);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vdecl);
-    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad +  0, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad +  4, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad +  8, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad + 12, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 480, 360);
     ok(color == 0x00ff0000,
@@ -10504,31 +10485,31 @@ static void test_vshader_float16(void)
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff102030, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), 0, 0,
                                              D3DPOOL_MANAGED, &buffer, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexBuffer failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(quad), &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(quad[0]));
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSource failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,  0, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,  4, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,  8, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 12, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 480, 360);
     ok(color == 0x00ff0000,
@@ -10548,7 +10529,7 @@ static void test_vshader_float16(void)
     IDirect3DVertexShader9_Release(shader);
     IDirect3DVertexBuffer9_Release(buffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -10558,14 +10539,14 @@ static void conditional_np2_repeat_test(void)
 {
     IDirect3DTexture9 *texture;
     IDirect3DDevice9 *device;
+    unsigned int color, x, y;
     D3DLOCKED_RECT rect;
-    unsigned int x, y;
-    DWORD *dst, color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
+    DWORD *dst;
 
     static const float quad[] =
     {
@@ -10586,7 +10567,7 @@ static void conditional_np2_repeat_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if (caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL)
     {
         /* NP2 conditional requires the POW2 flag. Check that while we're at it */
@@ -10607,14 +10588,14 @@ static void conditional_np2_repeat_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 10, 10, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed hr=%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     memset(&rect, 0, sizeof(rect));
     hr = IDirect3DTexture9_LockRect(texture, 0, &rect, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed hr=%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     for(y = 0; y < 10; y++) {
         for(x = 0; x < 10; x++) {
             dst = (DWORD *) ((BYTE *) rect.pBits + y * rect.Pitch + x * sizeof(DWORD));
@@ -10626,25 +10607,25 @@ static void conditional_np2_repeat_test(void)
         }
     }
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed hr=%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed hr=%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState failed hr=%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState failed hr=%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration failed, hr=%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float) * 5);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device,    1,  1);
     ok(color == 0x00ff0000, "NP2: Pixel   1,  1 has color %08x, expected 0x00ff0000\n", color);
@@ -10691,7 +10672,7 @@ static void conditional_np2_repeat_test(void)
 
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -10704,10 +10685,10 @@ static void vface_register_test(void)
     IDirect3DPixelShader9 *shader;
     IDirect3DTexture9 *texture;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -10766,7 +10747,7 @@ static void vface_register_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0) || caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No shader model 3 support, skipping tests.\n");
@@ -10775,60 +10756,60 @@ static void vface_register_test(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexShader(device, vshader_code, &vshader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(hr == D3D_OK, "IDirect3DTexture9_GetSurfaceLevel failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to set cull mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cull mode, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vshader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetBackBuffer failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     /* First, draw to the texture and the back buffer to test both offscreen and onscreen cases */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 4, quad, sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 4, quad, sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     /* Blit the texture onto the back buffer to make it visible */
     hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, blit, sizeof(float) * 5);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color == 0x00ff0000, "vFace: Onscreen rendered front facing quad has color 0x%08x, expected 0x00ff0000\n", color);
@@ -10839,7 +10820,7 @@ static void vface_register_test(void)
     color = getPixelColor(device, 480, 120);
     ok(color == 0x00ff0000, "vFace: Offscreen rendered front facing quad has color 0x%08x, expected 0x00ff0000\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
     IDirect3DPixelShader9_Release(shader);
     IDirect3DVertexShader9_Release(vshader);
@@ -10847,7 +10828,7 @@ static void vface_register_test(void)
     IDirect3DSurface9_Release(backbuffer);
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -10859,11 +10840,10 @@ static void fixed_function_bumpmap_test(void)
     IDirect3DTexture9 *texture, *tex1, *tex2;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     BOOL L6V5U5_supported;
     float scale, offset;
     IDirect3D9 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -10897,7 +10877,7 @@ static void fixed_function_bumpmap_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if (!(caps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP))
     {
         skip("D3DTEXOPCAPS_BUMPENVMAP not set, skipping bumpmap tests\n");
@@ -10923,50 +10903,50 @@ static void fixed_function_bumpmap_test(void)
     generate_bumpmap_textures(device);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT00, *(LPDWORD)&bumpenvmat[0]);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT01, *(LPDWORD)&bumpenvmat[1]);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT10, *(LPDWORD)&bumpenvmat[2]);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT11, *(LPDWORD)&bumpenvmat[3]);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 2, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff00ff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 240, 60);
     ok(color_match(color, 0x005ea000, 4), "Got unexpected color 0x%08x.\n", color);
@@ -10985,14 +10965,14 @@ static void fixed_function_bumpmap_test(void)
     color = getPixelColor(device, 400, 420);
     ok(color_match(color, 0x009e6000, 4), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for(i = 0; i < 2; i++) {
         hr = IDirect3DDevice9_GetTexture(device, i, (IDirect3DBaseTexture9 **) &texture);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_GetTexture failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         IDirect3DTexture9_Release(texture); /* For the GetTexture */
         hr = IDirect3DDevice9_SetTexture(device, i, NULL);
-        ok(SUCCEEDED(hr), "SetTexture failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         IDirect3DTexture9_Release(texture); /* To destroy it */
     }
 
@@ -11005,49 +10985,49 @@ static void fixed_function_bumpmap_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     /* This test only tests the luminance part. The bumpmapping part was already tested above and
      * would only make this test more complicated
      */
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_L6V5U5, D3DPOOL_MANAGED, &tex1, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &tex2, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     memset(&locked_rect, 0, sizeof(locked_rect));
     hr = IDirect3DTexture9_LockRect(tex1, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     *((DWORD *)locked_rect.pBits) = 0x4000; /* L = 0.25, V = 0.0, U = 0.0 */
     hr = IDirect3DTexture9_UnlockRect(tex1, 0);
-    ok(SUCCEEDED(hr), "UnlockRect failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     memset(&locked_rect, 0, sizeof(locked_rect));
     hr = IDirect3DTexture9_LockRect(tex2, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     *((DWORD *)locked_rect.pBits) = 0x00ff80c0;
     hr = IDirect3DTexture9_UnlockRect(tex2, 0);
-    ok(SUCCEEDED(hr), "UnlockRect failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) tex1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 1, (IDirect3DBaseTexture9 *) tex2);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_BUMPENVMAPLUMINANCE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     scale = 2.0;
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVLSCALE, *((DWORD *)&scale));
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     offset = 0.1;
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVLOFFSET, *((DWORD *)&offset));
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     /* red:   1.0  * (0.25 * 2.0 + 0.1) = 1.0  * 0.6 = 0.6  = 0x99
@@ -11056,53 +11036,53 @@ static void fixed_function_bumpmap_test(void)
      */
     ok(color_match(color, 0x00994c72, 5), "bumpmap failed: Got color 0x%08x, expected 0x00994c72.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Check a result scale factor > 1.0 */
     scale = 10;
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVLSCALE, *((DWORD *)&scale));
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     offset = 10;
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVLOFFSET, *((DWORD *)&offset));
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff80c0, 1), "bumpmap failed: Got color 0x%08x, expected 0x00ff80c0.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Check clamping in the scale factor calculation */
     scale = 1000;
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVLSCALE, *((DWORD *)&scale));
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     offset = -1;
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVLOFFSET, *((DWORD *)&offset));
-    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff80c0, 1), "bumpmap failed: Got color 0x%08x, expected 0x00ff80c0.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(tex1);
     IDirect3DTexture9_Release(tex2);
     IDirect3DVertexDeclaration9_Release(vertex_declaration);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -11162,8 +11142,7 @@ static void stencil_cull_test(void)
     };
     static const WORD indices_cw[]  = {0, 1, 3};
     static const WORD indices_ccw[] = {0, 2, 3};
-    unsigned int i;
-    DWORD color;
+    unsigned int color, i;
 
     window = create_window();
     d3d = Direct3DCreate9(D3D_SDK_VERSION);
@@ -11176,7 +11155,7 @@ static void stencil_cull_test(void)
         return;
     }
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if (!(caps.StencilCaps & D3DSTENCILCAPS_TWOSIDED))
     {
         skip("No two sided stencil support\n");
@@ -11184,118 +11163,118 @@ static void stencil_cull_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_STENCIL, 0x00ff0000, 0.0, 0x8);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF,hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Failed to disable Z test, %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Failed to disable lighting, %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILFAIL, D3DSTENCILOP_INCR);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILZFAIL, D3DSTENCILOP_DECR);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILREF, 0x3);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CCW_STENCILFAIL, D3DSTENCILOP_REPLACE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CCW_STENCILZFAIL, D3DSTENCILOP_DECR);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CCW_STENCILPASS, D3DSTENCILOP_INCR);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TWOSIDEDSTENCILMODE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* First pass: Fill the stencil buffer with some values... */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_CW);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_cw, D3DFMT_INDEX16, quad1, sizeof(*quad1));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_ccw, D3DFMT_INDEX16, quad1, sizeof(*quad1));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TWOSIDEDSTENCILMODE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_cw, D3DFMT_INDEX16, quad2, sizeof(*quad2));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_ccw, D3DFMT_INDEX16, quad2, sizeof(*quad2));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_CW);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_cw, D3DFMT_INDEX16, quad3, sizeof(*quad3));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_ccw, D3DFMT_INDEX16, quad3, sizeof(*quad3));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_CCW);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_cw, D3DFMT_INDEX16, quad4, sizeof(*quad4));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_ccw, D3DFMT_INDEX16, quad4, sizeof(*quad4));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TWOSIDEDSTENCILMODE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILFUNC, D3DCMP_EQUAL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILMASK, 0x000000ff);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* 2nd pass: Make the stencil values visible */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < 16; ++i)
     {
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILREF, 0x0000ff00 | i);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         painter[0].diffuse = (i * 16); /* Creates shades of blue */
         painter[1].diffuse = (i * 16);
         painter[2].diffuse = (i * 16);
         painter[3].diffuse = (i * 16);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, painter, sizeof(painter[0]));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 420);
     ok(color == 0x00000030, "CCW triangle, twoside FALSE, cull cw, replace, has color 0x%08x, expected 0x00000030\n", color);
@@ -11320,63 +11299,63 @@ static void stencil_cull_test(void)
     /* Test for reference truncation. */
     /* 1st pass: set stencil. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_STENCIL, 0x00ff0000, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILFAIL, D3DSTENCILOP_REPLACE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILZFAIL, D3DSTENCILOP_REPLACE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILREF, 0x1cc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILMASK, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_CW);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST,
             0, 4, 1, indices_cw, D3DFMT_INDEX16, quad1, sizeof(*quad1));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* 2nd pass: draw image. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILREF, 0xdb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILMASK, 0x0f);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILFUNC, D3DCMP_LESS);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, painter, sizeof(painter[0]));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = getPixelColor(device, 280, 360);
     ok(color == 0x000000f0, "Got unexpected colour 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
 cleanup:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -11387,11 +11366,11 @@ static void test_fragment_coords(void)
     IDirect3DPixelShader9 *shader, *shader_frac;
     IDirect3DVertexShader9 *vshader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
     DWORD *pos;
@@ -11446,7 +11425,7 @@ static void test_fragment_coords(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0) || caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No shader model 3 support, skipping tests.\n");
@@ -11455,30 +11434,30 @@ static void test_fragment_coords(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vshader_code, &vshader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_frac_code, &shader_frac);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vshader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetBackBuffer failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, constant, 1);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float) * 5);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* This has to be pixel exact */
     color = getPixelColor(device, 319, 239);
@@ -11493,21 +11472,21 @@ static void test_fragment_coords(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 32, 32, D3DFMT_X8R8G8B8, 0, 0, TRUE,
                                              &surface, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateRenderTarget failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     constant[2] = 16; constant[3] = 16;
     hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, constant, 1);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader constant, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float) * 5);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, D3DLOCK_READONLY);
-    ok(hr == D3D_OK, "IDirect3DSurface9_LockRect failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     pos = (DWORD *) (((BYTE *) lr.pBits) + 14 * lr.Pitch + 14 * sizeof(DWORD));
     color = *pos & 0x00ffffff;
@@ -11523,46 +11502,46 @@ static void test_fragment_coords(void)
     ok(color == 0x0000ffff, "Pixel 18/18 has color 0x%08x, expected 0x0000ffff\n", color);
 
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(hr == D3D_OK, "IDirect3DSurface9_UnlockRect failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Test the fraction value of vPos. This is tested with the offscreen target and not the backbuffer to
      * have full control over the multisampling setting inside this test
      */
     hr = IDirect3DDevice9_SetPixelShader(device, shader_frac);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float) * 5);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, D3DLOCK_READONLY);
-    ok(hr == D3D_OK, "IDirect3DSurface9_LockRect failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     pos = (DWORD *) (((BYTE *) lr.pBits) + 14 * lr.Pitch + 14 * sizeof(DWORD));
     color = *pos & 0x00ffffff;
     ok(color == 0x00000000, "vPos fraction test has color 0x%08x, expected 0x00000000\n", color);
 
     hr = IDirect3DSurface9_UnlockRect(surface);
-    ok(hr == D3D_OK, "IDirect3DSurface9_UnlockRect failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DPixelShader9_Release(shader);
     IDirect3DPixelShader9_Release(shader_frac);
     IDirect3DVertexShader9_Release(vshader);
     if(surface) IDirect3DSurface9_Release(surface);
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -11597,14 +11576,13 @@ static void test_pointsize(void)
     IDirect3DDevice9 *device;
     IDirect3DVertexShader9 *vs;
     IDirect3DPixelShader9 *ps;
+    unsigned int color, i, j;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
-    unsigned int i, j;
 
     static const RECT rect = {0, 0, 128, 128};
     static const DWORD tex1_data[4] = {0x00ff0000, 0x00ff0000, 0x00000000, 0x00000000};
@@ -11832,7 +11810,7 @@ static void test_pointsize(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(caps.MaxPointSize < 32.0) {
         skip("MaxPointSize < 32.0, skipping(MaxPointsize = %f)\n", caps.MaxPointSize);
         IDirect3DDevice9_Release(device);
@@ -11842,99 +11820,99 @@ static void test_pointsize(void)
     /* The r500 Windows driver needs a draw with regular texture coordinates at least once during the
      * device's lifetime, otherwise texture coordinate generation only works for texture 0. */
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr=%#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, vertices, sizeof(float) * 5);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &matrix);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     ptsize = 15.0f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[0], sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     ptsize = 31.0f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[3], sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     ptsize = 30.75f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[6], sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     if (caps.MaxPointSize >= 63.0f)
     {
         ptsize = 63.0f;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[9], sizeof(float) * 3);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         ptsize = 62.75f;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[15], sizeof(float) * 3);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     }
 
     ptsize = 1.0f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[12], sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_POINTSIZE_MAX, (DWORD *)&ptsizemax_orig);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_POINTSIZE_MIN, (DWORD *)&ptsizemin_orig);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
 
     /* What happens if point scaling is disabled, and POINTSIZE_MAX < POINTSIZE? */
     ptsize = 15.0f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     ptsize = 1.0f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE_MAX, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[18], sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE_MAX, *(DWORD *)&ptsizemax_orig);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     /* pointsize < pointsize_min < pointsize_max?
      * pointsize = 1.0, pointsize_min = 15.0, pointsize_max = default(usually 64.0) */
     ptsize = 1.0f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     ptsize = 15.0f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE_MIN, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[21], sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE_MIN, *(DWORD *)&ptsizemin_orig);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     ok(point_match(device, 64, 64, 7), "point_match(64, 64, 7) failed, expected point size 15.\n");
     ok(point_match(device, 128, 64, 15), "point_match(128, 64, 15) failed, expected point size 31.\n");
@@ -11962,51 +11940,51 @@ static void test_pointsize(void)
      * SW emulation is implemented in wined3d, this test will fail on GL drivers that does not support them.
      */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex1, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex2, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DTexture9_LockRect(tex1, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(lr.pBits, tex1_data, sizeof(tex1_data));
     hr = IDirect3DTexture9_UnlockRect(tex1, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DTexture9_LockRect(tex2, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(lr.pBits, tex2_data, sizeof(tex2_data));
     hr = IDirect3DTexture9_UnlockRect(tex2, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) tex1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 1, (IDirect3DBaseTexture9 *) tex2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSPRITEENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ptsize = 32.0;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *((DWORD *) (&ptsize)));
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, &vertices[0], sizeof(float) * 3);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 64-4, 64-4);
     ok(color == 0x00ff0000, "pSprite: Pixel (64-4),(64-4) has color 0x%08x, expected 0x00ff0000\n", color);
@@ -12021,25 +11999,25 @@ static void test_pointsize(void)
     U(matrix).m[0][0] =  1.0f / 64.0f;
     U(matrix).m[1][1] = -1.0f / 64.0f;
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &matrix);
-    ok(SUCCEEDED(hr), "SetTransform failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTransform failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &backbuffer);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &rt, NULL );
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSCALE_A, *(DWORD *)&a);
-    ok(SUCCEEDED(hr), "Failed setting point scale attenuation coefficient, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed setting point scale attenuation coefficient, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSCALE_B, *(DWORD *)&b);
-    ok(SUCCEEDED(hr), "Failed setting point scale attenuation coefficient, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed setting point scale attenuation coefficient, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSCALE_C, *(DWORD *)&c);
-    ok(SUCCEEDED(hr), "Failed setting point scale attenuation coefficient, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed setting point scale attenuation coefficient, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
     {
         hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, &S(U(matrix))._11, 4);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader constants, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader constants, hr %#lx.\n", hr);
     }
 
     if (caps.MaxPointSize < 63.0f)
@@ -12059,7 +12037,7 @@ static void test_pointsize(void)
         if (test_setups[i].vs->code)
         {
             hr = IDirect3DDevice9_CreateVertexShader(device, test_setups[i].vs->code, &vs);
-            ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x (case %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx (case %u).\n", hr, i);
         }
         else
         {
@@ -12068,7 +12046,7 @@ static void test_pointsize(void)
         if (test_setups[i].ps->code)
         {
             hr = IDirect3DDevice9_CreatePixelShader(device, test_setups[i].ps->code, &ps);
-            ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x (case %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx (case %u).\n", hr, i);
         }
         else
         {
@@ -12076,9 +12054,9 @@ static void test_pointsize(void)
         }
 
         hr = IDirect3DDevice9_SetVertexShader(device, vs);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, ps);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
         for (j = 0; j < ARRAY_SIZE(tests); ++j)
         {
@@ -12091,35 +12069,35 @@ static void test_pointsize(void)
 
             ptsize = tests[j].zero_size ? 0.0f : 32.0f;
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-            ok(SUCCEEDED(hr), "Failed to set pointsize, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set pointsize, hr %#lx.\n", hr);
 
             ptsize = tests[j].override_min ? 63.0f : tests[j].zero_size ? 0.0f : ptsizemin_orig;
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE_MIN, *(DWORD *)&ptsize);
-            ok(SUCCEEDED(hr), "Failed to set minimum pointsize, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set minimum pointsize, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSCALEENABLE, tests[j].scale);
-            ok(SUCCEEDED(hr), "Failed setting point scale state, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed setting point scale state, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_SetFVF(device, tests[j].fvf);
-            ok(SUCCEEDED(hr), "Failed setting FVF, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed setting FVF, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-            ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ffff, 1.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1,
                     tests[j].vertex_data, tests[j].vertex_size);
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_StretchRect(device, rt, &rect, backbuffer, &rect, D3DTEXF_NONE);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-            ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
             if (tests[j].zero_size)
             {
@@ -12187,7 +12165,7 @@ cleanup:
     IDirect3DTexture9_Release(tex1);
     IDirect3DTexture9_Release(tex2);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -12200,13 +12178,12 @@ static void multiple_rendertargets_test(void)
     IDirect3DTexture9 *tex1, *tex2;
     IDirect3DVertexShader9 *vs;
     IDirect3DDevice9 *device;
+    unsigned int color, i, j;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
-    UINT i, j;
 
     static const DWORD vshader_code[] =
     {
@@ -12262,7 +12239,7 @@ static void multiple_rendertargets_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.NumSimultaneousRTs < 2)
     {
         skip("Only 1 simultaneous render target supported, skipping MRT test.\n");
@@ -12277,70 +12254,70 @@ static void multiple_rendertargets_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 16, 16,
             D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &readback, NULL);
-    ok(SUCCEEDED(hr), "CreateOffscreenPlainSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateOffscreenPlainSurface failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex1, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex2, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vshader_code, &vs);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, pshader_code1, &ps1);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, pshader_code2, &ps2);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &backbuf);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderTarget failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex1, 0, &surf1);
-    ok(hr == D3D_OK, "IDirect3DTexture9_GetSurfaceLevel failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex2, 0, &surf2);
-    ok(hr == D3D_OK, "IDirect3DTexture9_GetSurfaceLevel failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, vs);
-    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, surf1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 1, surf2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x,\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx,\n", hr);
     hr = IDirect3DDevice9_GetRenderTargetData(device, surf1, readback);
-    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#lx.\n", hr);
     color = getPixelColorFromSurface(readback, 8, 8);
     ok(color_match(color, D3DCOLOR_ARGB(0xff, 0x00, 0x00, 0xff), 0),
             "Expected color 0x000000ff, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_GetRenderTargetData(device, surf2, readback);
-    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#lx.\n", hr);
     color = getPixelColorFromSurface(readback, 8, 8);
     ok(color_match(color, D3DCOLOR_ARGB(0xff, 0x00, 0x00, 0xff), 0),
             "Expected color 0x000000ff, got 0x%08x.\n", color);
 
     /* Render targets not written by the pixel shader should be unmodified. */
     hr = IDirect3DDevice9_SetPixelShader(device, ps1);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderTargetData(device, surf1, readback);
-    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#lx.\n", hr);
     color = getPixelColorFromSurface(readback, 8, 8);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x00, 0xff, 0x00), 0),
             "Expected color 0xff00ff00, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_GetRenderTargetData(device, surf2, readback);
-    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#lx.\n", hr);
     for (i = 6; i < 10; ++i)
     {
         for (j = 6; j < 10; ++j)
@@ -12352,52 +12329,52 @@ static void multiple_rendertargets_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x,\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx,\n", hr);
     hr = IDirect3DDevice9_GetRenderTargetData(device, surf1, readback);
-    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#lx.\n", hr);
     color = getPixelColorFromSurface(readback, 8, 8);
     ok(color_match(color, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0x00), 0),
             "Expected color 0x0000ff00, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_GetRenderTargetData(device, surf2, readback);
-    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#lx.\n", hr);
     color = getPixelColorFromSurface(readback, 8, 8);
     ok(color_match(color, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0x00), 0),
             "Expected color 0x0000ff00, got 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_SetPixelShader(device, ps2);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuf);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 1, NULL);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) tex1);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &texquad[0], 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) tex2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &texquad[20], 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 240);
     ok(color == 0x0000ff00, "Texture 1(output color 1) has color 0x%08x, expected 0x0000ff00\n", color);
@@ -12415,7 +12392,7 @@ static void multiple_rendertargets_test(void)
     IDirect3DSurface9_Release(backbuf);
     IDirect3DSurface9_Release(readback);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -12425,11 +12402,10 @@ static void pixelshader_blending_test(void)
 {
     IDirect3DSurface9 *backbuffer = NULL, *offscreen = NULL;
     IDirect3DTexture9 *offscreenTexture = NULL;
+    unsigned int fmt_index, color;
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d;
     ULONG refcount;
-    int fmt_index;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -12437,8 +12413,7 @@ static void pixelshader_blending_test(void)
     {
         const char *fmtName;
         D3DFORMAT textureFormat;
-        D3DCOLOR resultColorBlending;
-        D3DCOLOR resultColorNoBlending;
+        unsigned int resultColorBlending, resultColorNoBlending;
     }
     test_formats[] =
     {
@@ -12488,7 +12463,7 @@ static void pixelshader_blending_test(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (fmt_index = 0; fmt_index < ARRAY_SIZE(test_formats); ++fmt_index)
     {
@@ -12502,83 +12477,83 @@ static void pixelshader_blending_test(void)
         }
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-        ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET, fmt, D3DPOOL_DEFAULT, &offscreenTexture, NULL);
-        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Creating the offscreen render target failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
         if(!offscreenTexture) {
             continue;
         }
 
         hr = IDirect3DTexture9_GetSurfaceLevel(offscreenTexture, 0, &offscreen);
-        ok(hr == D3D_OK, "Can't get offscreen surface, hr = %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         if(!offscreen) {
             continue;
         }
 
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-        ok(hr == D3D_OK, "SetFVF failed, hr = %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-        ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-        ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-        ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-        ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-        ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         /* Below we will draw two quads with different colors and try to blend
          * them together. The result color is compared with the expected
          * outcome. */
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderTarget(device, 0, offscreen);
-        ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ffffff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, TRUE);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         /* Draw a quad using color 0x0010200. */
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_ONE);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_ZERO);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(quad1[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         /* Draw a quad using color 0x0020100. */
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(quad2[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         /* We don't want to blend the result on the backbuffer. */
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         /* Prepare rendering the 'blended' texture quad to the backbuffer. */
         hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-        ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)offscreenTexture);
-        ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
         /* This time with the texture. */
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
                 D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, fmt) == D3D_OK)
@@ -12614,7 +12589,7 @@ static void pixelshader_blending_test(void)
 
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -12623,8 +12598,8 @@ done:
 static void tssargtemp_test(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -12654,7 +12629,7 @@ static void tssargtemp_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(!(caps.PrimitiveMiscCaps & D3DPMISCCAPS_TSSARGTEMP)) {
         skip("D3DPMISCCAPS_TSSARGTEMP not supported\n");
         IDirect3DDevice9_Release(device);
@@ -12662,50 +12637,50 @@ static void tssargtemp_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_RESULTARG, D3DTA_TEMP);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 2, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 2, D3DTSS_COLORARG1, D3DTA_CURRENT);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 2, D3DTSS_COLORARG2, D3DTA_TEMP);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x0000ff00);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed, hr = %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color == 0x00ffff00, "TSSARGTEMP test returned color 0x%08x, expected 0x00ffff00\n", color);
     IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -12720,26 +12695,21 @@ static void stream_test(void)
     IDirect3DVertexBuffer9 *vb2 = NULL;
     IDirect3DVertexBuffer9 *vb = NULL;
     IDirect3DIndexBuffer9 *ib = NULL;
+    unsigned int color, ind, i;
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
-    unsigned i;
     HRESULT hr;
     BYTE *data;
-    DWORD ind;
 
     static const struct testdata
     {
         DWORD idxVertex; /* number of instances in the first stream */
         DWORD idxColor; /* number of instances in the second stream */
         DWORD idxInstance; /* should be 1 ?? */
-        DWORD color1; /* color 1 instance */
-        DWORD color2; /* color 2 instance */
-        DWORD color3; /* color 3 instance */
-        DWORD color4; /* color 4 instance */
+        unsigned int color1, color2, color3, color4;
         WORD strVertex; /* specify which stream to use 0-2*/
         WORD strColor;
         WORD strInstance;
@@ -12831,7 +12801,7 @@ static void stream_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No vs_3_0 support, skipping tests.\n");
@@ -12841,60 +12811,65 @@ static void stream_test(void)
 
     hr = IDirect3DDevice9_GetStreamSourceFreq(device, 0, &ind);
     ok(hr == D3D_OK && ind == 1, "IDirect3DDevice9_GetStreamSourceFreq unexpected result, "
-            "hr %#x, ind %#x.\n", hr, ind);
+            "hr %#lx, ind %#x.\n", hr, ind);
     hr = IDirect3DDevice9_GetStreamSourceFreq(device, 1, &ind);
     ok(hr == D3D_OK && ind == 1, "IDirect3DDevice9_GetStreamSourceFreq unexpected result, "
-            "hr %#x, ind %#x.\n", hr, ind);
+            "hr %#lx, ind %#x.\n", hr, ind);
 
     hr = IDirect3DDevice9_SetStreamSourceFreq(device, 1, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSourceFreq failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSourceFreq failed, hr %#lx.\n", hr);
 
     /* check for D3DSTREAMSOURCE_INDEXEDDATA at stream0 */
     hr = IDirect3DDevice9_SetStreamSourceFreq(device, 0, (D3DSTREAMSOURCE_INSTANCEDATA | 1));
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     /* check wrong cases */
     hr = IDirect3DDevice9_SetStreamSourceFreq(device, 1, 0);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetStreamSourceFreq(device, 1, &ind);
-    ok(hr == D3D_OK && ind == 1, "IDirect3DDevice9_GetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(ind == 1, "Got frequency %#x.\n", ind);
     hr = IDirect3DDevice9_SetStreamSourceFreq(device, 1, 2);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetStreamSourceFreq(device, 1, &ind);
-    ok(hr == D3D_OK && ind == 2, "IDirect3DDevice9_GetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(ind == 2, "Got frequency %#x.\n", ind);
     hr = IDirect3DDevice9_SetStreamSourceFreq(device, 1, (D3DSTREAMSOURCE_INDEXEDDATA | 0));
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetStreamSourceFreq(device, 1, &ind);
-    ok(hr == D3D_OK && ind == (D3DSTREAMSOURCE_INDEXEDDATA | 0), "IDirect3DDevice9_GetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(ind == D3DSTREAMSOURCE_INDEXEDDATA, "Got frequency %#x.\n", ind);
     hr = IDirect3DDevice9_SetStreamSourceFreq(device, 1, (D3DSTREAMSOURCE_INSTANCEDATA | 0));
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetStreamSourceFreq(device, 1, &ind);
-    ok(hr == D3D_OK && ind == (0U | D3DSTREAMSOURCE_INSTANCEDATA), "IDirect3DDevice9_GetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(ind == D3DSTREAMSOURCE_INSTANCEDATA, "Got frequency %#x.\n", ind);
     hr = IDirect3DDevice9_SetStreamSourceFreq(device, 1, (D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA | 0));
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetStreamSourceFreq(device, 1, &ind);
-    ok(hr == D3D_OK && ind == (0U | D3DSTREAMSOURCE_INSTANCEDATA), "IDirect3DDevice9_GetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(ind == D3DSTREAMSOURCE_INSTANCEDATA, "Got frequency %#x.\n", ind);
 
     /* set the default value back */
     hr = IDirect3DDevice9_SetStreamSourceFreq(device, 1, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSourceFreq failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* create all VertexBuffers*/
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), 0, 0, D3DPOOL_MANAGED, &vb, NULL);
-    ok(hr == D3D_OK, "CreateVertexBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(!vb) {
         skip("Failed to create a vertex buffer\n");
         IDirect3DDevice9_Release(device);
         goto done;
     }
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(vertcolor), 0, 0, D3DPOOL_MANAGED, &vb2, NULL);
-    ok(hr == D3D_OK, "CreateVertexBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(!vb2) {
         skip("Failed to create a vertex buffer\n");
         goto out;
     }
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(instancepos), 0, 0, D3DPOOL_MANAGED, &vb3, NULL);
-    ok(hr == D3D_OK, "CreateVertexBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(!vb3) {
         skip("Failed to create a vertex buffer\n");
         goto out;
@@ -12902,7 +12877,7 @@ static void stream_test(void)
 
     /* create IndexBuffer*/
     hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &ib, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateIndexBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(!ib) {
         skip("Failed to create an index buffer\n");
         goto out;
@@ -12910,39 +12885,39 @@ static void stream_test(void)
 
     /* copy all Buffers (Vertex + Index)*/
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad), (void **) &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb2, 0, sizeof(vertcolor), (void **) &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, vertcolor, sizeof(vertcolor));
     hr = IDirect3DVertexBuffer9_Unlock(vb2);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb3, 0, sizeof(instancepos), (void **) &data, 0);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, instancepos, sizeof(instancepos));
     hr = IDirect3DVertexBuffer9_Unlock(vb3);
-    ok(hr == D3D_OK, "IDirect3DVertexBuffer9_Unlock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DIndexBuffer9_Lock(ib, 0, sizeof(indices), (void **) &data, 0);
-    ok(hr == D3D_OK, "IDirect3DIndexBuffer9_Lock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     memcpy(data, indices, sizeof(indices));
     hr = IDirect3DIndexBuffer9_Unlock(ib);
-    ok(hr == D3D_OK, "IDirect3DIndexBuffer9_Unlock failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* create VertexShader */
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code, &shader);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if(!shader) {
         skip("Failed to create a vertex shader.\n");
         goto out;
     }
 
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShader failed hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetIndices(device, ib);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetIndices failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* run all tests */
     for( i = 0; i < ARRAY_SIZE(testcases); ++i)
@@ -12953,16 +12928,16 @@ static void stream_test(void)
         decl[2].Stream = act.strInstance;
         /* create VertexDeclarations */
         hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl, &pDecl);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexDeclaration failed hr=%08x (case %i)\n", hr, i);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x (case %i)\n", hr, i);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexDeclaration(device, pDecl);
-        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
 
         /* If stream 0 is unused, set the stream frequency regardless to show
          * that the number if instances is read from it. */
@@ -12970,48 +12945,48 @@ static void stream_test(void)
         {
             hr = IDirect3DDevice9_SetStreamSourceFreq(device, 0,
                     D3DSTREAMSOURCE_INDEXEDDATA | act.explicit_zero_freq);
-            ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#lx.\n", hr);
         }
 
         hr = IDirect3DDevice9_SetStreamSourceFreq(device, act.strVertex,
                 (D3DSTREAMSOURCE_INDEXEDDATA | act.idxVertex));
-        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, act.strVertex, vb, 0, sizeof(quad[0]));
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetStreamSourceFreq(device, act.strColor,
                 (D3DSTREAMSOURCE_INDEXEDDATA | act.idxColor));
-        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, act.strColor, vb2, 0, sizeof(vertcolor[0]));
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetStreamSourceFreq(device, act.strInstance,
                 (D3DSTREAMSOURCE_INSTANCEDATA | act.idxInstance));
-        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, act.strInstance, vb3, 0, sizeof(instancepos[0]));
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         /* set all StreamSource && StreamSourceFreq back to default */
         hr = IDirect3DDevice9_SetStreamSourceFreq(device, act.strVertex, 1);
-        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, act.strVertex, NULL, 0, 0);
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSourceFreq(device, act.idxColor, 1);
-        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, act.idxColor, NULL, 0, 0);
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSourceFreq(device, act.idxInstance, 1);
-        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source frequency, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetStreamSource(device, act.idxInstance, NULL, 0, 0);
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
 
         hr = IDirect3DVertexDeclaration9_Release(pDecl);
-        ok(hr == D3D_OK, "IDirect3DVertexDeclaration9_Release failed with %08x (case %i)\n", hr, i);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         color = getPixelColor(device, 160, 360);
         ok(color == act.color1, "has color 0x%08x, expected 0x%08x (case %i)\n", color, act.color1, i);
@@ -13023,7 +12998,7 @@ static void stream_test(void)
         ok(color == act.color4, "has color 0x%08x, expected 0x%08x (case %i)\n", color, act.color4, i);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x (case %i)\n", hr, i);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
 out:
@@ -13033,7 +13008,7 @@ out:
     if(ib)IDirect3DIndexBuffer9_Release(ib);
     if(shader)IDirect3DVertexShader9_Release(shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13044,8 +13019,8 @@ static void np2_stretch_rect_test(void)
     IDirect3DSurface9 *src = NULL, *dst = NULL, *backbuffer = NULL;
     IDirect3DTexture9 *dsttex = NULL;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -13072,12 +13047,12 @@ static void np2_stretch_rect_test(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetBackBuffer failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 100, 100, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &src, NULL );
-    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_CreateRenderTarget failed with %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 25, 25, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &dsttex, NULL);
-    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_CreateTexture failed with %08x\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     if(!src || !dsttex) {
         skip("One or more test resources could not be created\n");
@@ -13085,54 +13060,54 @@ static void np2_stretch_rect_test(void)
     }
 
     hr = IDirect3DTexture9_GetSurfaceLevel(dsttex, 0, &dst);
-    ok(hr == D3D_OK, "IDirect3DTexture9_GetSurfaceLevel failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ffff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Clear the StretchRect destination for debugging */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, dst);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, src);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 1, &r1, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 1, &r2, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 1, &r3, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 1, &r4, D3DCLEAR_TARGET, 0xff000000, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Stretchrect before setting the render target back to the backbuffer. This will make Wine use
      * the target -> texture GL blit path
      */
     hr = IDirect3DDevice9_StretchRect(device, src, NULL, dst, NULL, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "IDirect3DDevice9_StretchRect failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(dst);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) dsttex);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float) * 5);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360);
     ok(color == 0x00ff0000, "stretchrect: Pixel 160,360 has color 0x%08x, expected 0x00ff0000\n", color);
@@ -13143,14 +13118,14 @@ static void np2_stretch_rect_test(void)
     color = getPixelColor(device, 160, 120);
     ok(color == 0x00000000, "stretchrect: Pixel 160,120 has color 0x%08x, expected 0x00000000\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
 cleanup:
     if(src) IDirect3DSurface9_Release(src);
     if(backbuffer) IDirect3DSurface9_Release(backbuffer);
     if(dsttex) IDirect3DTexture9_Release(dsttex);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13162,13 +13137,12 @@ static void texop_test(void)
     IDirect3DTexture9 *texture = NULL;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
-    unsigned i;
 
     static const struct {
         float x, y, z;
@@ -13192,7 +13166,7 @@ static void texop_test(void)
         D3DTEXTUREOP op;
         const char *name;
         DWORD caps_flag;
-        D3DCOLOR result;
+        unsigned int result;
     } test_data[] = {
         {D3DTOP_SELECTARG1,                "SELECTARG1",                D3DTEXOPCAPS_SELECTARG1,                D3DCOLOR_ARGB(0x00, 0x00, 0xff, 0x00)},
         {D3DTOP_SELECTARG2,                "SELECTARG2",                D3DTEXOPCAPS_SELECTARG2,                D3DCOLOR_ARGB(0x00, 0x33, 0x33, 0x33)},
@@ -13230,42 +13204,42 @@ static void texop_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateTexture failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     *((DWORD *)locked_rect.pBits) = D3DCOLOR_ARGB(0x99, 0x00, 0xff, 0x00);
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(SUCCEEDED(hr), "UnlockRect failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG0, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0xdd333333);
-    ok(SUCCEEDED(hr), "SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA);
-    ok(SUCCEEDED(hr), "SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -13276,29 +13250,29 @@ static void texop_test(void)
         }
 
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, test_data[i].op);
-        ok(SUCCEEDED(hr), "SetTextureStageState (%s) failed with 0x%08x\n", test_data[i].name, hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed with 0x%08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed with 0x%08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed with 0x%08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
         color = getPixelColor(device, 320, 240);
         ok(color_match(color, test_data[i].result, 3), "Operation %s returned color 0x%08x, expected 0x%08x\n",
                 test_data[i].name, color, test_data[i].result);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Present failed with 0x%08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
     }
 
     IDirect3DTexture9_Release(texture);
     IDirect3DVertexDeclaration9_Release(vertex_declaration);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13308,22 +13282,21 @@ static void yuv_color_test(void)
 {
     HRESULT hr;
     IDirect3DSurface9 *surface, *target;
-    unsigned int i;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     D3DFORMAT skip_once = D3DFMT_UNKNOWN;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     D3DSURFACE_DESC desc;
     ULONG refcount;
     HWND window;
 
     static const struct
     {
-        DWORD in;
+        unsigned int in;
         D3DFORMAT format;
         const char *fmt_string;
-        D3DCOLOR left, right;
+        unsigned int left, right;
     }
     test_data[] =
     {
@@ -13376,9 +13349,9 @@ static void yuv_color_test(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &target);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetDesc(target, &desc);
-    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); i++)
     {
@@ -13411,20 +13384,20 @@ static void yuv_color_test(void)
          * second luminance value, resulting in an incorrect color in the right pixel. */
         hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 1, test_data[i].format,
                 D3DPOOL_DEFAULT, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
 
         hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         ((DWORD *)lr.pBits)[0] = test_data[i].in;
         ((DWORD *)lr.pBits)[1] = 0x00800080;
         hr = IDirect3DSurface9_UnlockRect(surface);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_StretchRect(device, surface, NULL, target, NULL, D3DTEXF_POINT);
-        ok(SUCCEEDED(hr), "Failed to draw surface onto backbuffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw surface onto backbuffer, hr %#lx.\n", hr);
 
         /* Some Windows drivers (mostly Nvidia, but also some VM drivers) insist on doing linear filtering
          * although we asked for point filtering. Be careful when reading the results and use the pixel
@@ -13441,13 +13414,13 @@ static void yuv_color_test(void)
                 "Input 0x%08x: Got color 0x%08x for pixel 2/1, expected 0x%08x, format %s.\n",
                 test_data[i].in, color, test_data[i].right, test_data[i].fmt_string);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
         IDirect3DSurface9_Release(surface);
     }
 
     IDirect3DSurface9_Release(target);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13455,15 +13428,13 @@ done:
 
 static void yuv_layout_test(void)
 {
+    unsigned int color, ref_color, fmt, i, x, y;
     HRESULT hr;
     IDirect3DSurface9 *surface, *target;
-    unsigned int fmt, i, x, y;
     D3DFORMAT format;
     const char *fmt_string;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
-    DWORD ref_color;
     BYTE *buf, *chroma_buf, *u_buf, *v_buf;
     UINT width = 20, height = 16;
     IDirect3DDevice9 *device;
@@ -13512,7 +13483,7 @@ static void yuv_layout_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#lx.\n", hr);
     if (caps.TextureCaps & D3DPTEXTURECAPS_POW2
             && !(caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL))
     {
@@ -13522,9 +13493,9 @@ static void yuv_layout_test(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &target);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderTarget failed, hr = %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DSurface9_GetDesc(target, &desc);
-    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface description, hr %#lx.\n", hr);
 
     for (fmt = 0; fmt < ARRAY_SIZE(formats); fmt++)
     {
@@ -13548,12 +13519,12 @@ static void yuv_layout_test(void)
         }
 
         hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, format, D3DPOOL_DEFAULT, &surface, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface failed, hr = %#x.\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         for (i = 0; i < ARRAY_SIZE(test_data); i++)
         {
             hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, 0);
-            ok(hr == D3D_OK, "IDirect3DSurface9_LockRect failed, hr = %#x.\n", hr);
+            ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
             buf = lr.pBits;
             chroma_buf = buf + lr.Pitch * height;
             if (format == MAKEFOURCC('Y','V','1','2'))
@@ -13601,12 +13572,12 @@ static void yuv_layout_test(void)
                 }
             }
             hr = IDirect3DSurface9_UnlockRect(surface);
-            ok(hr == D3D_OK, "IDirect3DSurface9_UnlockRect failed, hr = %#x.\n", hr);
+            ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %#x.\n", hr);
+            ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_StretchRect(device, surface, NULL, target, NULL, D3DTEXF_POINT);
-            ok(hr == D3D_OK, "IDirect3DDevice9_StretchRect failed with %#x.\n", hr);
+            ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
             /* Some Windows drivers (mostly Nvidia, but also some VM drivers) insist on doing linear filtering
              * although we asked for point filtering. To prevent running into precision problems, read at points
@@ -13628,15 +13599,14 @@ static void yuv_layout_test(void)
                 }
             }
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-
-            ok(SUCCEEDED(hr), "Present failed with %#x.\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
         }
         IDirect3DSurface9_Release(surface);
     }
 
     IDirect3DSurface9_Release(target);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13647,10 +13617,10 @@ static void texop_range_test(void)
     IDirect3DTexture9 *texture;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -13678,7 +13648,7 @@ static void texop_range_test(void)
 
     /* We need ADD and SUBTRACT operations */
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     if (!(caps.TextureOpCaps & D3DTEXOPCAPS_ADD))
     {
         skip("D3DTOP_ADD is not supported, skipping value range test.\n");
@@ -13693,86 +13663,86 @@ static void texop_range_test(void)
     }
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     /* Stage 1: result = diffuse(=1.0) + diffuse
      * stage 2: result = result - tfactor(= 0.5)
      */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x80808080);
-    ok(SUCCEEDED(hr), "SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_SUBTRACT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear device, hr %#x.\n\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear device, hr %#lx.\n\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00808080, 1), "texop Range > 1.0 returned 0x%08x, expected 0x00808080\n",
        color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateTexture failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     *((DWORD *)locked_rect.pBits) = D3DCOLOR_ARGB(0x00, 0x00, 0x00, 0x00);
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(SUCCEEDED(hr), "UnlockRect failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Stage 1: result = texture(=0.0) - tfactor(= 0.5)
      * stage 2: result = result + diffuse(1.0)
      */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x80808080);
-    ok(SUCCEEDED(hr), "SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SUBTRACT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ffffff, 1), "texop Range < 0.0 returned 0x%08x, expected 0x00ffffff\n",
        color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13781,9 +13751,9 @@ done:
 static void alphareplicate_test(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -13810,31 +13780,31 @@ static void alphareplicate_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE | D3DTA_ALPHAREPLICATE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00808080, 1), "alphareplicate test 0x%08x, expected 0x00808080\n",
        color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13843,10 +13813,10 @@ done:
 static void dp3_alpha_test(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -13874,7 +13844,7 @@ static void dp3_alpha_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.TextureOpCaps & D3DTEXOPCAPS_DOTPRODUCT3))
     {
         skip("D3DTOP_DOTPRODUCT3 not supported\n");
@@ -13883,10 +13853,10 @@ static void dp3_alpha_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* dp3_x4 r0, diffuse_bias, tfactor_bias
      * mov r0.a, diffuse.a
@@ -13897,41 +13867,41 @@ static void dp3_alpha_test(void)
      * (0.0 * 0.5 + 0.0 * 0.5 + 0.25 * 0.5) * 4 = 0.125 * 4 = 0.5, with a bunch of inprecision.
      */
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_CURRENT | D3DTA_ALPHAREPLICATE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTextureStageState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0xffffffff);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00808080, 4), "dp3 alpha test 0x%08x, expected 0x00808080\n",
        color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -13940,8 +13910,8 @@ done:
 static void zwriteenable_test(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -13976,21 +13946,21 @@ static void zwriteenable_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     /* The Z buffer is filled with 1.0. Draw a red quad with z = 0.1,
      * zenable = D3DZB_FALSE, zwriteenable = TRUE. The red color is written
      * because the z test is disabled. The question is whether the z = 0.1
@@ -14002,22 +13972,22 @@ static void zwriteenable_test(void)
      * zenable = D3DZB_FALSE and zwriteenable  = TRUE does NOT write to the z
      * buffer. */
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(*quad1));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "zwriteenable test returned 0x%08x, expected 0x0000ff00\n",
        color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -14028,9 +13998,8 @@ static void alphatest_test(void)
 #define ALPHATEST_PASSED 0x0000ff00
 #define ALPHATEST_FAILED 0x00ff0000
     IDirect3DDevice9 *device;
-    unsigned int i, j;
+    unsigned int color, i, j;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     DWORD value;
@@ -14040,9 +14009,9 @@ static void alphatest_test(void)
     static const struct
     {
         D3DCMPFUNC func;
-        D3DCOLOR color_less;
-        D3DCOLOR color_equal;
-        D3DCOLOR color_greater;
+        unsigned int color_less;
+        unsigned int color_equal;
+        unsigned int color_greater;
     }
     testdata[] =
     {
@@ -14078,14 +14047,14 @@ static void alphatest_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHATESTENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (j = 0; j < 2; ++j)
     {
@@ -14105,97 +14074,97 @@ static void alphatest_test(void)
             };
             memset(&caps, 0, sizeof(caps));
             hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-            ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             if(caps.PixelShaderVersion < D3DPS_VERSION(1, 1)) {
                 break;
             }
 
             hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &ps);
-            ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetPixelShader(device, ps);
-            ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             IDirect3DPixelShader9_Release(ps);
         }
 
         for(i = 0; i < ARRAY_SIZE(testdata); i++)
         {
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAFUNC, testdata[i].func);
-            ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAREF, 0x90);
-            ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
             color = getPixelColor(device, 320, 240);
             ok(color_match(color, testdata[i].color_less, 1), "Alphatest failed. Got color 0x%08x, expected 0x%08x. alpha < ref, func %u\n",
             color, testdata[i].color_less, testdata[i].func);
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAREF, 0x80);
-            ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
             color = getPixelColor(device, 320, 240);
             ok(color_match(color, testdata[i].color_equal, 1), "Alphatest failed. Got color 0x%08x, expected 0x%08x. alpha == ref, func %u\n",
             color, testdata[i].color_equal, testdata[i].func);
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAREF, 0x70);
-            ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
+            ok(hr == S_OK, "Got hr %#lx.\n", hr);
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
             color = getPixelColor(device, 320, 240);
             ok(color_match(color, testdata[i].color_greater, 1),
                     "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
                     color, testdata[i].color_greater, testdata[i].func);
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Present failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice9_Present failed, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAREF, 0xff70);
-            ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_GetRenderState(device, D3DRS_ALPHAREF, &value);
-            ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed, hr %#x.\n", hr);
-            ok(value == 0xff70, "Unexpected D3DRS_ALPHAREF value %#x.\n", value);
+            ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed, hr %#lx.\n", hr);
+            ok(value == 0xff70, "Unexpected D3DRS_ALPHAREF value %#lx.\n", value);
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-            ok(hr == D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed, hr %#lx.\n", hr);
             color = getPixelColor(device, 320, 240);
             ok(color_match(color, testdata[i].color_greater, 1),
                     "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
                     color, testdata[i].color_greater, testdata[i].func);
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Present failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice9_Present failed, hr %#lx.\n", hr);
 
         }
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -14250,7 +14219,7 @@ static void sincos_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
     {
         skip("No vs_2_0 support, skipping tests.\n");
@@ -14259,18 +14228,18 @@ static void sincos_test(void)
     }
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, sin_shader_code, &sin_shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, cos_shader_code, &cos_shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, sincosc1, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, sincosc2, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF failed with 0x%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Generate a point from -1 to 1 every 0.5 pixels */
     for(i = 0; i < 1280; i++) {
@@ -14280,29 +14249,29 @@ static void sincos_test(void)
     }
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, sin_shader);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1280, data, sizeof(*data));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, cos_shader);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1280, data, sizeof(*data));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Present returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     /* TODO: Find a way to properly validate the lines. Precision issues make this a kinda nasty task */
 
     IDirect3DVertexShader9_Release(sin_shader);
     IDirect3DVertexShader9_Release(cos_shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -14312,11 +14281,11 @@ static void loop_index_test(void)
 {
     IDirect3DVertexShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     float values[4];
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -14353,7 +14322,7 @@ static void loop_index_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
     {
         skip("No vs_2_0 support, skipping tests.\n");
@@ -14362,73 +14331,73 @@ static void loop_index_test(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, zero, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 2, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 3, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 4, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 5, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 6, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 7, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     values[0] = 1.0;
     values[1] = 1.0;
     values[2] = 0.0;
     values[3] = 0.0;
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 8, values, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 9, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 10, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     values[0] = -1.0;
     values[1] = 0.0;
     values[2] = 0.0;
     values[3] = 0.0;
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 11, values, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 12, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 13, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 14, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 15, one, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantF returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShaderConstantI(device, 0, i0, 1);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetVertexShaderConstantI returned %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1),
        "aL indexing test returned color 0x%08x, expected 0x0000ff00\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DVertexShader9_Release(shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -14438,10 +14407,10 @@ static void sgn_test(void)
 {
     IDirect3DVertexShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -14474,7 +14443,7 @@ static void sgn_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
     {
         skip("No vs_2_0 support, skipping tests.\n");
@@ -14483,29 +14452,29 @@ static void sgn_test(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x008000ff, 1),
        "sgn test returned color 0x%08x, expected 0x008000ff\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DVertexShader9_Release(shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -14561,15 +14530,15 @@ static void test_viewport(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* This crashes on Windows. */
     if (0)
@@ -14579,21 +14548,21 @@ static void test_viewport(void)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000,
                 tests[i].expected_z - z_eps, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetViewport(device, &tests[i].vp);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_GREATER);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-        ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
         draw_succeeded = hr == D3D_OK;
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         if (!draw_succeeded)
             continue;
@@ -14604,16 +14573,16 @@ static void test_viewport(void)
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000,
                 tests[i].expected_z + z_eps, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESS);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         get_rt_readback(backbuffer, &rb);
         check_rect(&rb, tests[i].expected_rect, tests[i].message);
@@ -14621,11 +14590,11 @@ static void test_viewport(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -14644,9 +14613,9 @@ done:
 static void depth_clamp_test(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     D3DVIEWPORT9 vp;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -14715,7 +14684,7 @@ static void depth_clamp_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     vp.X = 0;
     vp.Y = 0;
@@ -14736,56 +14705,56 @@ static void depth_clamp_test(void)
         vp.MaxZ = 1.0;
         hr = IDirect3DDevice9_SetViewport(device, &vp);
     }
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(*quad1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(*quad3));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, sizeof(*quad4));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad5, sizeof(*quad5));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad6, sizeof(*quad6));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_CLIPTLVERTS)
     {
@@ -14815,10 +14784,10 @@ static void depth_clamp_test(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -14860,8 +14829,8 @@ static void depth_bounds_test(void)
 
     IDirect3DSurface9 *offscreen_surface = NULL;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -14883,57 +14852,57 @@ static void depth_bounds_test(void)
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
             MAKEFOURCC('N','V','D','B'), D3DPOOL_DEFAULT, &offscreen_surface, NULL);
-    ok(FAILED(hr), "Able to create surface, hr %#x.\n", hr);
+    ok(FAILED(hr), "Able to create surface, hr %#lx.\n", hr);
     if (offscreen_surface) IDirect3DSurface9_Release(offscreen_surface);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(*quad1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_X, MAKEFOURCC('N','V','D','B'));
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     tmpvalue.f = 0.625;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_Z, tmpvalue.d);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     tmpvalue.f = 0.75;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_W, tmpvalue.d);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     tmpvalue.f = 0.75;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_Z, tmpvalue.d);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(*quad3));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_X, 0);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 150, 130);
     ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
@@ -14951,9 +14920,9 @@ static void depth_bounds_test(void)
     ok(color_match(color, 0x00f9e814, 1), "color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -14987,7 +14956,7 @@ static void depth_buffer_test(void)
         {{-1.0, -1.0, 0.66f}, 0xffff0000},
         {{ 1.0, -1.0, 0.66f}, 0xffff0000},
     };
-    static const DWORD expected_colors[4][4] =
+    static const unsigned int expected_colors[4][4] =
     {
         {0x000000ff, 0x000000ff, 0x0000ff00, 0x00ff0000},
         {0x000000ff, 0x000000ff, 0x0000ff00, 0x00ff0000},
@@ -14997,10 +14966,9 @@ static void depth_buffer_test(void)
 
     IDirect3DSurface9 *backbuffer, *rt1, *rt2, *rt3;
     IDirect3DDevice9 *device;
-    unsigned int i, j;
+    unsigned int color, i, j;
     D3DVIEWPORT9 vp;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -15022,69 +14990,69 @@ static void depth_buffer_test(void)
     vp.MaxZ = 1.0;
 
     hr = IDirect3DDevice9_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &backbuffer);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 320, 240, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt1, NULL);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 480, 360, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt2, NULL);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt3, NULL);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt3);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt1);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt2);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(*quad1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(*quad3));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -15099,14 +15067,14 @@ static void depth_buffer_test(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(backbuffer);
     IDirect3DSurface9_Release(rt3);
     IDirect3DSurface9_Release(rt2);
     IDirect3DSurface9_Release(rt1);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -15132,10 +15100,9 @@ static void depth_buffer2_test(void)
 
     IDirect3DSurface9 *backbuffer, *rt1, *rt2;
     IDirect3DDevice9 *device;
-    unsigned int i, j;
+    unsigned int color, i, j;
     D3DVIEWPORT9 vp;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -15157,55 +15124,55 @@ static void depth_buffer2_test(void)
     vp.MaxZ = 1.0;
 
     hr = IDirect3DDevice9_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt1, NULL);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 480, 360, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt2, NULL);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &backbuffer);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt1);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 0.5f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt2);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -15220,13 +15187,13 @@ static void depth_buffer2_test(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(backbuffer);
     IDirect3DSurface9_Release(rt2);
     IDirect3DSurface9_Release(rt1);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -15253,7 +15220,7 @@ static void depth_blit_test(void)
         {{-1.0f, -1.0f, 0.66f}, 0xff0000ff},
         {{ 1.0f, -1.0f, 0.66f}, 0xff0000ff},
     };
-    static const DWORD expected_colors[4][4] =
+    static const unsigned int expected_colors[4][4] =
     {
         {0x000000ff, 0x000000ff, 0x0000ff00, 0x00ff0000},
         {0x000000ff, 0x000000ff, 0x0000ff00, 0x00ff0000},
@@ -15263,11 +15230,10 @@ static void depth_blit_test(void)
 
     IDirect3DSurface9 *backbuffer, *ds1, *ds2, *ds3;
     IDirect3DDevice9 *device;
+    unsigned int color, i, j;
     RECT src_rect, dst_rect;
-    unsigned int i, j;
     D3DVIEWPORT9 vp;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -15289,82 +15255,82 @@ static void depth_blit_test(void)
     vp.MaxZ = 1.0;
 
     hr = IDirect3DDevice9_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &backbuffer);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds1);
-    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8, 0, 0, FALSE, &ds2, NULL);
-    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds2);
-    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 320, 240, D3DFMT_D24S8, 0, 0, FALSE, &ds3, NULL);
-    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
     SetRect(&dst_rect, 0, 0, 480, 360);
     hr = IDirect3DDevice9_Clear(device, 1, (D3DRECT *)&dst_rect, D3DCLEAR_ZBUFFER, 0, 0.5f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
     SetRect(&dst_rect, 0, 0, 320, 240);
     hr = IDirect3DDevice9_Clear(device, 1, (D3DRECT *)&dst_rect, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     /* Partial blit. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 0, 0, 320, 240);
     hr = IDirect3DDevice9_StretchRect(device, ds2, &src_rect, ds1, &dst_rect, D3DTEXF_POINT);
-    ok(hr == D3DERR_INVALIDCALL, "StretchRect returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     /* Flipped. */
     SetRect(&src_rect, 0, 0, 640, 480);
     SetRect(&dst_rect, 0, 480, 640, 0);
     hr = IDirect3DDevice9_StretchRect(device, ds2, &src_rect, ds1, &dst_rect, D3DTEXF_POINT);
-    ok(hr == D3DERR_INVALIDCALL, "StretchRect returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     /* Full, explicit. */
     SetRect(&src_rect, 0, 0, 640, 480);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirect3DDevice9_StretchRect(device, ds2, &src_rect, ds1, &dst_rect, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     /* Filtered blit. */
     hr = IDirect3DDevice9_StretchRect(device, ds2, NULL, ds1, NULL, D3DTEXF_LINEAR);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     /* Depth -> color blit.*/
     hr = IDirect3DDevice9_StretchRect(device, ds2, NULL, backbuffer, NULL, D3DTEXF_POINT);
-    ok(hr == D3DERR_INVALIDCALL, "StretchRect returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     IDirect3DSurface9_Release(backbuffer);
     /* Full surface, different sizes */
     hr = IDirect3DDevice9_StretchRect(device, ds3, NULL, ds1, NULL, D3DTEXF_POINT);
-    ok(hr == D3DERR_INVALIDCALL, "StretchRect returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, ds1, NULL, ds3, NULL, D3DTEXF_POINT);
-    ok(hr == D3DERR_INVALIDCALL, "StretchRect returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds1);
-    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, ds2, NULL, ds1, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(*quad1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -15379,13 +15345,13 @@ static void depth_blit_test(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(ds3);
     IDirect3DSurface9_Release(ds2);
     IDirect3DSurface9_Release(ds1);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -15434,8 +15400,7 @@ static void intz_test(void)
     };
     struct
     {
-        UINT x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -15478,7 +15443,7 @@ static void intz_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
     {
         skip("No pixel shader 2.0 support, skipping INTZ test.\n");
@@ -15493,82 +15458,82 @@ static void intz_test(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture, NULL);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE4(0));
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
 
     /* Render offscreen, using the INTZ texture as depth buffer */
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Setup the depth/stencil surface. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(ds);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Read the depth values back. */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     get_rt_readback(original_rt, &rb);
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
@@ -15576,53 +15541,53 @@ static void intz_test(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     /* Render onscreen while using the INTZ texture as depth buffer */
     hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture, NULL);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Setup the depth/stencil surface. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(ds);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Read the depth values back. */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     get_rt_readback(original_rt, &rb);
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
@@ -15630,66 +15595,66 @@ static void intz_test(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
 
     /* Render offscreen, then onscreen, and finally check the INTZ texture in both areas */
     hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture, NULL);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Setup the depth/stencil surface. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, half_quad_1, sizeof(*half_quad_1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, half_quad_2, sizeof(*half_quad_2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(ds);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Read the depth values back. */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     get_rt_readback(original_rt, &rb);
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
@@ -15697,14 +15662,14 @@ static void intz_test(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture);
     IDirect3DPixelShader9_Release(ps);
     IDirect3DSurface9_Release(original_rt);
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -16012,7 +15977,7 @@ static void test_fetch4(void)
         {"INTZ",          MAKEFOURCC('I','N','T','Z'), 3},
     };
 
-    D3DCOLOR colour, colour_amd, colour_intel, colour_off, colour_zround;
+    unsigned int colour, colour_amd, colour_intel, colour_off, colour_zround, i, j, k, x, y;
     IDirect3DPixelShader9 *ps[ARRAY_SIZE(shaders)];
     IDirect3DVolumeTexture9 *texture_3d;
     IDirect3DSurface9 *original_rt, *rt;
@@ -16020,7 +15985,6 @@ static void test_fetch4(void)
     struct surface_readback rb;
     IDirect3DVertexShader9 *vs;
     IDirect3DTexture9 *texture;
-    unsigned int i, j, k, x, y;
     IDirect3DDevice9 *device;
     D3DLOCKED_RECT lr;
     D3DLOCKED_BOX lb;
@@ -16046,7 +16010,7 @@ static void test_fetch4(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0))
     {
         skip("No pixel shader 3.0 support, skipping FETCH4 test.\n");
@@ -16054,22 +16018,22 @@ static void test_fetch4(void)
         goto done;
     }
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 8, 8, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 1, 0, D3DFMT_L8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < ARRAY_SIZE(fetch4_data); ++i)
         memcpy((BYTE *)lr.pBits + i * lr.Pitch, &fetch4_data[i], sizeof(fetch4_data[i]));
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vs);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < ARRAY_SIZE(shaders); ++i)
     {
         if (!shaders[i].ps_code)
@@ -16079,23 +16043,23 @@ static void test_fetch4(void)
         }
 
         hr = IDirect3DDevice9_CreatePixelShader(device, shaders[i].ps_code, &ps[i]);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code_3d, &ps_3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE4(0));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* According to the documentation, Fetch4 is enabled when
      * D3DSAMP_MIPMAPLODBIAS == GET4 and D3DSAMP_MAGFILTER == D3DTEXF_POINT.
@@ -16104,42 +16068,42 @@ static void test_fetch4(void)
      * AMD r500 hardware always uses POINT filtering with Fetch4. The driver
      * later on corrected this by adding a -0.5 texel offset. */
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPMAPLODBIAS, MAKEFOURCC('G','E','T','4'));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     /* Fetch4 should work with any texture wrapping mode, and does in Wine.
      * However, AMD RX 580 devices force clamping when fetch4 is on.
      * No other driver/hardware does this, but to avoid problems, we test with
      * CLAMP on. */
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Test basic Fetch4 sampling. */
     for (i = 0; i < ARRAY_SIZE(shaders); ++i)
     {
         hr = IDirect3DDevice9_SetVertexShader(device, ps[i] ? vs : NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, ps[i]);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, shaders[i].ttff_flags);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         get_rt_readback(original_rt, &rb);
         for (j = 0; j < ARRAY_SIZE(expected_colours.colour_amd); ++j)
@@ -16165,10 +16129,10 @@ static void test_fetch4(void)
         release_surface_readback(&rb);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Test Fetch4 format support. */
     for (i = 0; i < ARRAY_SIZE(format_tests); ++i)
@@ -16177,30 +16141,30 @@ static void test_fetch4(void)
 
         hr = IDirect3DDevice9_CreateTexture(device, format_tests[i].w, format_tests[i].h,
                 1, 0, format_tests[i].format, D3DPOOL_MANAGED, &tex, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DTexture9_LockRect(tex, 0, &lr, NULL, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memcpy(lr.pBits, &format_tests[i].data, 4);
         hr = IDirect3DTexture9_UnlockRect(tex, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         for (j = 0; j < ARRAY_SIZE(format_tests[i].colour_amd); ++j)
         {
             hr = IDirect3DDevice9_SetVertexShader(device, ps[j] ? vs : NULL);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetPixelShader(device,  ps[j]);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             get_rt_readback(original_rt, &rb);
             colour_amd = format_tests[i].colour_amd[j];
@@ -16215,15 +16179,15 @@ static void test_fetch4(void)
             release_surface_readback(&rb);
 
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         }
         IDirect3DTexture9_Release(tex);
     }
 
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 2, 1, 0, D3DFMT_L8, D3DPOOL_MANAGED, &texture_3d, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVolumeTexture9_LockBox(texture_3d, 0, &lb, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < ARRAY_SIZE(fetch4_data); ++i)
     {
         memcpy((BYTE *)lb.pBits + i * lb.RowPitch, &fetch4_data[i], sizeof(fetch4_data[i]));
@@ -16231,26 +16195,26 @@ static void test_fetch4(void)
         memcpy((BYTE *)lb.pBits + i * lb.RowPitch + lb.SlicePitch, &fetch4_data[(i + 1) % 4], sizeof(fetch4_data[i]));
     }
     hr = IDirect3DVolumeTexture9_UnlockBox(texture_3d, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture_3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Test Fetch4 with 3D textures. */
     for (i = 0; i < 2; ++i)
     {
         hr = IDirect3DDevice9_SetVertexShader(device, i ? vs : NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, i ? ps_3d : NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         get_rt_readback(original_rt, &rb);
         for (j = 0; j < ARRAY_SIZE(expected_colours.colour_amd); ++j)
         {
@@ -16273,7 +16237,7 @@ static void test_fetch4(void)
         }
         release_surface_readback(&rb);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     /* Test Fetch4 with depth textures. */
@@ -16292,63 +16256,63 @@ static void test_fetch4(void)
 
         hr = IDirect3DDevice9_CreateTexture(device, 8, 8, 1,
                 D3DUSAGE_DEPTHSTENCIL, format, D3DPOOL_DEFAULT, &depth_texture, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DTexture9_GetSurfaceLevel(depth_texture, 0, &ds);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0,
                 D3DSAMP_MIPMAPLODBIAS, MAKEFOURCC('G','E','T','1'));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* Setup the depth/stencil surface. */
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* Render to the depth surface. */
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         IDirect3DSurface9_Release(ds);
         hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)depth_texture);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* Set a shader for depth sampling, otherwise Windows does not show
          * anything. */
         hr = IDirect3DDevice9_SetVertexShader(device, vs);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, ps[1]); /* texld */
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         for (j = 0; j < 2; ++j)
         {
             hr = IDirect3DDevice9_SetSamplerState(device, 0,
                     D3DSAMP_MIPMAPLODBIAS, MAKEFOURCC('G','E','T', j ? '4' : '1' ));
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             /* Do the actual shadow mapping. */
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             get_rt_readback(original_rt, &rb);
             for (k = 0; k < ARRAY_SIZE(expected_depth[depth_tests[i].index]); ++k)
@@ -16376,11 +16340,11 @@ static void test_fetch4(void)
             release_surface_readback(&rb);
 
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         }
 
         hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         IDirect3DTexture9_Release(depth_texture);
     }
 
@@ -16396,7 +16360,7 @@ static void test_fetch4(void)
     IDirect3DSurface9_Release(rt);
     IDirect3DSurface9_Release(original_rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -16448,8 +16412,7 @@ static void shadow_test(void)
     };
     struct
     {
-        UINT x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -16484,7 +16447,7 @@ static void shadow_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
     {
         skip("No pixel shader 2.0 support, skipping shadow test.\n");
@@ -16493,37 +16456,37 @@ static void shadow_test(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &original_ds);
-    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 1024, 1024, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE4(0));
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(formats); ++i)
     {
@@ -16538,60 +16501,60 @@ static void shadow_test(void)
 
         hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 1,
                 D3DUSAGE_DEPTHSTENCIL, format, D3DPOOL_DEFAULT, &texture, NULL);
-        ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
 
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &ds);
-        ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-        ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-        ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
         /* Setup the depth/stencil surface. */
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-        ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetDepthStencilSurface failed, hr %#lx.\n", hr);
         IDirect3DSurface9_Release(ds);
 
         hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-        ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetPixelShader(device, ps);
-        ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
         /* Do the actual shadow mapping. */
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-        ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
         IDirect3DTexture9_Release(texture);
 
         get_rt_readback(original_rt, &rb);
         for (j = 0; j < ARRAY_SIZE(expected_colors); ++j)
         {
-            D3DCOLOR color = get_readback_color(&rb, expected_colors[j].x, expected_colors[j].y);
+            unsigned int color = get_readback_color(&rb, expected_colors[j].x, expected_colors[j].y);
             /* Geforce 7 on Windows returns 1.0 in alpha when the depth format is D24S8 or D24X8,
              * whereas other GPUs (all AMD, newer Nvidia) return the same value they return in .rgb.
              * Accept alpha mismatches as broken but make sure to check the color channels. */
@@ -16604,7 +16567,7 @@ static void shadow_test(void)
         release_surface_readback(&rb);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
     }
 
     IDirect3DPixelShader9_Release(ps);
@@ -16612,7 +16575,7 @@ static void shadow_test(void)
     IDirect3DSurface9_Release(original_rt);
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -16639,30 +16602,30 @@ static void clip_planes(IDirect3DDevice9 *device, const char *test_name)
         {{ 1.0f, -1.0f, 0.0f}, 0xff002b7f},
         {{ 1.0f,  1.0f, 0.0f}, 0xff002b7f},
     };
-    D3DCOLOR color;
+    unsigned int color;
     HRESULT hr;
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 1.0, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPLANEENABLE, 0);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(*quad1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPLANEENABLE, 0x1);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 1, 240);
     ok(color_match(color, 0x00002b7f, 1), "%s test: color 0x%08x.\n", test_name, color);
@@ -16708,7 +16671,7 @@ static void clip_planes_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
     {
         skip("No vs_2_0 support, skipping tests.\n");
@@ -16717,62 +16680,62 @@ static void clip_planes_test(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DDevice9_SetClipPlane(device, 0, plane0);
 
     clip_planes(device, "Onscreen FFP");
 
     hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(offscreen, 0, &offscreen_surface);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, offscreen_surface);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     clip_planes(device, "Offscreen FFP");
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, shader_code, &shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, shader);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     clip_planes(device, "Onscreen vertex shader");
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, offscreen_surface);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget failed, hr=%08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     clip_planes(device, "Offscreen vertex shader");
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DVertexShader9_Release(shader);
     IDirect3DSurface9_Release(original_rt);
     IDirect3DSurface9_Release(offscreen_surface);
     IDirect3DTexture9_Release(offscreen);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -16829,11 +16792,7 @@ static void fp_special_test(void)
         const char *name;
         const DWORD *ops;
         DWORD size;
-        D3DCOLOR r500;
-        D3DCOLOR r600;
-        D3DCOLOR nv40;
-        D3DCOLOR nv50;
-        D3DCOLOR warp;
+        unsigned int r500, r600, nv40, nv50, warp;
     }
     vs_body[] =
     {
@@ -16925,7 +16884,7 @@ static void fp_special_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0) || caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
     {
         skip("No shader model 2.0 support, skipping floating point specials test.\n");
@@ -16934,18 +16893,18 @@ static void fp_special_test(void)
     }
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE1(0));
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(vs_body); ++i)
     {
@@ -16959,23 +16918,23 @@ static void fp_special_test(void)
     {
         DWORD offset = ARRAY_SIZE(vs_header);
         IDirect3DVertexShader9 *vs;
-        D3DCOLOR color;
+        unsigned int color;
 
         memcpy(vs_code + offset, vs_body[i].ops, vs_body[i].size);
         offset += vs_body[i].size / sizeof(*vs_body[i].ops);
         memcpy(vs_code + offset, vs_footer, sizeof(vs_footer));
 
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vs);
-        ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexShader(device, vs);
-        ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 320, 240);
         ok(color_match(color, vs_body[i].r500, 1)
@@ -16987,20 +16946,20 @@ static void fp_special_test(void)
                 vs_body[i].r500, vs_body[i].r600, vs_body[i].nv40, vs_body[i].nv50, vs_body[i].name, color);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-        ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
         IDirect3DVertexShader9_Release(vs);
     }
 
     HeapFree(GetProcessHeap(), 0, vs_code);
 
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
     IDirect3DPixelShader9_Release(ps);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -17012,11 +16971,12 @@ static void srgbwrite_format_test(void)
     IDirect3DSurface9 *rt, *backbuffer;
     IDirect3DTexture9 *texture;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    int i;
-    DWORD color_rgb = 0x00808080, color_srgb = 0x00bcbcbc, color;
+
+    static const unsigned int color_rgb = 0x00808080, color_srgb = 0x00bcbcbc;
     static const struct
     {
         D3DFORMAT fmt;
@@ -17053,13 +17013,13 @@ static void srgbwrite_format_test(void)
     }
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "GetBackBuffer failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetBackBuffer failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x80808080);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     for(i = 0; i < ARRAY_SIZE(formats); i++)
     {
@@ -17073,42 +17033,42 @@ static void srgbwrite_format_test(void)
 
         hr = IDirect3DDevice9_CreateTexture(device, 8, 8, 1, D3DUSAGE_RENDERTARGET,
                 formats[i].fmt, D3DPOOL_DEFAULT, &texture, NULL);
-        ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff0000, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
         hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &rt);
-        ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, TRUE);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-        ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, FALSE);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-        ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-        ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-        ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-        ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         IDirect3DSurface9_Release(rt);
         IDirect3DTexture9_Release(texture);
@@ -17130,12 +17090,12 @@ static void srgbwrite_format_test(void)
         }
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
     }
 
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -17173,66 +17133,64 @@ static void ds_size_test(void)
     }
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 64, 64, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 32, 32, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, 0, TRUE, &ds, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &readback, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateOffscreenPlainSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateOffscreenPlainSurface failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_ValidateDevice(device, &num_passes);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_ValidateDevice failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_ValidateDevice failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &old_rt);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &old_ds);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_GetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_ValidateDevice(device, &num_passes);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_ValidateDevice failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_ValidateDevice failed, hr %#lx.\n", hr);
 
     /* The D3DCLEAR_TARGET clear works. D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER returns OK,
      * but does not change the surface's contents. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000FF, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Target clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Target clear failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 0.2f, 0);
-    ok(SUCCEEDED(hr), "Z Buffer clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Z Buffer clear failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff0000, 0.5f, 0);
-    ok(SUCCEEDED(hr), "Target and Z Buffer clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Target and Z Buffer clear failed, hr %#lx.\n", hr);
 
     /* Nvidia does not clear the surface(The color is still 0x000000ff), AMD does(the color is 0x00ff0000) */
 
     /* Turning on any depth-related state results in a ValidateDevice failure */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_ValidateDevice(device, &num_passes);
-    ok(hr == D3DERR_CONFLICTINGRENDERSTATE || hr == D3D_OK, "IDirect3DDevice9_ValidateDevice returned %#x, expected "
-        "D3DERR_CONFLICTINGRENDERSTATE.\n", hr);
+    ok(hr == D3DERR_CONFLICTINGRENDERSTATE || hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_ValidateDevice(device, &num_passes);
-    ok(hr == D3DERR_CONFLICTINGRENDERSTATE || hr == D3D_OK, "IDirect3DDevice9_ValidateDevice returned %#x, expected "
-        "D3DERR_CONFLICTINGRENDERSTATE.\n", hr);
+    ok(hr == D3DERR_CONFLICTINGRENDERSTATE || hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Try to draw with the device in an invalid state. */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Don't check the resulting draw unless we find an app that needs it. On
      * NVIDIA ValidateDevice() returns CONFLICTINGRENDERSTATE, so the result
@@ -17240,11 +17198,11 @@ static void ds_size_test(void)
      * 0.0 for all pixels, even those that are covered by the depth buffer. */
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, old_rt);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, old_ds);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_ValidateDevice(device, &num_passes);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_ValidateDevice failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_ValidateDevice failed, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(readback);
     IDirect3DSurface9_Release(ds);
@@ -17252,7 +17210,7 @@ static void ds_size_test(void)
     IDirect3DSurface9_Release(old_rt);
     IDirect3DSurface9_Release(old_ds);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -17263,10 +17221,10 @@ static void unbound_sampler_test(void)
     IDirect3DPixelShader9 *ps, *ps_cube, *ps_volume;
     IDirect3DSurface9 *rt, *old_rt;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -17321,7 +17279,7 @@ static void unbound_sampler_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
     {
         skip("No ps_2_0 support, skipping tests.\n");
@@ -17336,67 +17294,67 @@ static void unbound_sampler_test(void)
     }
 
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStage failed, %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTextureStage failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreatePixelShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code_cube, &ps_cube);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreatePixelShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code_volume, &ps_volume);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 64, 64, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &rt, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &old_rt);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_GetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 );
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x56ffffff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColorFromSurface(rt, 32, 32);
     ok(color == 0xff000000, "Unbound sampler color is %#x.\n", color);
 
     /* Now try with a cube texture */
     hr = IDirect3DDevice9_SetPixelShader(device, ps_cube);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColorFromSurface(rt, 32, 32);
     ok(color == 0xff000000, "Unbound sampler color is %#x.\n", color);
 
     /* And then with a volume texture */
     hr = IDirect3DDevice9_SetPixelShader(device, ps_volume);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColorFromSurface(rt, 32, 32);
     ok(color == 0xff000000, "Unbound sampler color is %#x.\n", color);
@@ -17407,7 +17365,7 @@ static void unbound_sampler_test(void)
     IDirect3DPixelShader9_Release(ps_cube);
     IDirect3DPixelShader9_Release(ps_volume);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -17427,8 +17385,7 @@ static void update_surface_test(void)
     };
     static const struct
     {
-        UINT x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -17494,9 +17451,9 @@ static void update_surface_test(void)
     }
 
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, 0, D3DFMT_DXT1, D3DPOOL_SYSTEMMEM, &src_tex, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, 0, D3DFMT_DXT1, D3DPOOL_DEFAULT, &dst_tex, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     count = IDirect3DTexture9_GetLevelCount(src_tex);
     ok(count == 7, "Got level count %u, expected 7.\n", count);
@@ -17509,10 +17466,10 @@ static void update_surface_test(void)
         D3DLOCKED_RECT r;
 
         hr = IDirect3DTexture9_GetLevelDesc(src_tex, i, &desc);
-        ok(SUCCEEDED(hr), "Failed to get level desc, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get level desc, hr %#lx.\n", hr);
 
         hr = IDirect3DTexture9_LockRect(src_tex, i, &r, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
 
         row_count = ((desc.Height + 3) & ~3) / 4;
         block_count = ((desc.Width + 3) & ~3) / 4;
@@ -17530,18 +17487,18 @@ static void update_surface_test(void)
         }
 
         hr = IDirect3DTexture9_UnlockRect(src_tex, i);
-        ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
     }
 
     for (i = 0; i < ARRAY_SIZE(block_size_tests); ++i)
     {
         hr = IDirect3DTexture9_GetSurfaceLevel(src_tex, block_size_tests[i].src_level, &src_surface);
-        ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#lx.\n", hr);
         hr = IDirect3DTexture9_GetSurfaceLevel(dst_tex, block_size_tests[i].dst_level, &dst_surface);
-        ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_UpdateSurface(device, src_surface, block_size_tests[i].r, dst_surface, NULL);
-        ok(hr == block_size_tests[i].hr, "Update surface returned %#x for test %u, expected %#x.\n",
+        ok(hr == block_size_tests[i].hr, "Update surface returned %#lx for test %u, expected %#lx.\n",
                 hr, i, block_size_tests[i].hr);
 
         IDirect3DSurface9_Release(dst_surface);
@@ -17551,55 +17508,55 @@ static void update_surface_test(void)
     for (i = 0; i < count; ++i)
     {
         hr = IDirect3DTexture9_GetSurfaceLevel(src_tex, i, &src_surface);
-        ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#lx.\n", hr);
         hr = IDirect3DTexture9_GetSurfaceLevel(dst_tex, i, &dst_surface);
-        ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_UpdateSurface(device, src_surface, NULL, dst_surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to update surface at level %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to update surface at level %u, hr %#lx.\n", i, hr);
 
         IDirect3DSurface9_Release(dst_surface);
         IDirect3DSurface9_Release(src_surface);
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)dst_tex);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 1, tri, sizeof(*tri));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 0),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(dst_tex);
     IDirect3DTexture9_Release(src_tex);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -17631,37 +17588,37 @@ static void multisample_get_rtdata_test(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 256, 256, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 256, 256, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &readback, NULL);
-    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &original_ds);
-    ok(SUCCEEDED(hr), "Failed to get depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderTargetData(device, rt, readback);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, original_ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to restore original render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore original render target, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(original_ds);
     IDirect3DSurface9_Release(original_rt);
     IDirect3DSurface9_Release(readback);
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -17674,10 +17631,10 @@ static void test_multisample_get_front_buffer_data(void)
     IDirect3DSurface9 *readback;
     IDirect3DTexture9 *texture;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     HWND window;
-    DWORD color;
     HRESULT hr;
 
     window = create_window();
@@ -17696,44 +17653,44 @@ static void test_multisample_get_front_buffer_data(void)
     }
 
     hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
-    ok(hr == D3D_OK, "Failed to get the implicit swapchain, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get the implicit swapchain, hr %#lx.\n", hr);
     hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
-    ok(hr == D3D_OK, "Failed to get present parameters, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get present parameters, hr %#lx.\n", hr);
     IDirect3DSwapChain9_Release(swapchain);
     d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
     d3dpp.MultiSampleQuality = 0;
     hr = IDirect3DDevice9_Reset(device, &d3dpp);
-    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00f0ff0f, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &readback, NULL);
-    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetFrontBufferData(device, 0, readback);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(readback, 320, 240);
     ok(color == 0x00f0ff0f, "Got unexpected color 0x%08x.\n", color);
     IDirect3DSurface9_Release(readback);
 
     hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1,
             0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &readback);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetFrontBufferData(device, 0, readback);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = getPixelColorFromSurface(readback, 320, 240);
     ok(color == 0x00f0ff0f, "Got unexpected color 0x%08x.\n", color);
     IDirect3DSurface9_Release(readback);
     IDirect3DTexture9_Release(texture);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -17769,8 +17726,7 @@ static void multisampled_depth_buffer_test(void)
     };
     static const struct
     {
-        UINT x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -17816,10 +17772,10 @@ static void multisampled_depth_buffer_test(void)
     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING,
             &present_parameters, &device);
-    ok(hr == D3D_OK, "Failed to create a device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create a device, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#lx.\n", hr);
     if (caps.TextureCaps & D3DPTEXTURECAPS_POW2)
     {
         skip("No unconditional NP2 texture support, skipping multisampled depth buffer test.\n");
@@ -17828,111 +17784,111 @@ static void multisampled_depth_buffer_test(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &readback, NULL);
-    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds);
-    ok(SUCCEEDED(hr), "Failed to get depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     /* Render onscreen and then offscreen */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_1, sizeof(*quad_1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, original_rt, NULL, rt, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_2, sizeof(*quad_2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, rt, NULL, readback, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
     }
 
     hr = IDirect3DDevice9_StretchRect(device, rt, NULL, original_rt, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Render offscreen and then onscreen */
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(ds);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8,
             D3DMULTISAMPLE_2_SAMPLES, 0, TRUE, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_1, sizeof(*quad_1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, rt, NULL, original_rt, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_2, sizeof(*quad_2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, original_rt, NULL, readback, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(ds);
     IDirect3DSurface9_Release(readback);
@@ -17954,88 +17910,88 @@ static void multisampled_depth_buffer_test(void)
     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING,
             &present_parameters, &device);
-    ok(hr == D3D_OK, "Failed to create a device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create a device, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ffff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear depth buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &readback, NULL);
-    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8,
             D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &ds, NULL);
-    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &original_ds);
-    ok(SUCCEEDED(hr), "Failed to get depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
 
     /* Render to a multisampled offscreen frame buffer and then blit to
      * the onscreen (not multisampled) frame buffer. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_1, sizeof(*quad_1));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, rt, NULL, original_rt, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, ds, NULL, original_ds, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, original_ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_2, sizeof(*quad_2));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, original_rt, NULL, readback, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to restore original render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore original render target, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(original_ds);
     IDirect3DSurface9_Release(original_rt);
@@ -18083,8 +18039,7 @@ static void resz_test(void)
     };
     static const struct
     {
-        UINT x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -18149,10 +18104,10 @@ static void resz_test(void)
 
     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
-    ok(hr == D3D_OK, "Failed to create a device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create a device, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
     {
         skip("No pixel shader 2.0 support, skipping INTZ test.\n");
@@ -18169,123 +18124,124 @@ static void resz_test(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8,
             D3DMULTISAMPLE_2_SAMPLES, 0, TRUE, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &readback, NULL);
-    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture, NULL);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &intz_ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, intz_ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(intz_ds);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE4(0));
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
 
     /* Render offscreen (multisampled), blit the depth buffer
      * into the INTZ texture and then check its contents */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     /* The destination depth texture has to be bound to sampler 0 */
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
 
     /* the ATI "spec" says you have to do a dummy draw to ensure correct commands ordering */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0xf);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     /* The actual multisampled depth buffer resolve happens here */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, 0x7fa05000);
-    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_POINTSIZE, &value);
-    ok(SUCCEEDED(hr) && value == 0x7fa05000, "GetRenderState failed, hr %#x, value %#x.\n", hr, value);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
+    ok(value == 0x7fa05000, "Got value %#lx.\n", value);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Read the depth values back */
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(ds);
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
     IDirect3DPixelShader9_Release(ps);
     IDirect3DSurface9_Release(readback);
     IDirect3DSurface9_Release(original_rt);
@@ -18305,225 +18261,226 @@ static void resz_test(void)
 
     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
-    ok(hr == D3D_OK, "Failed to create a device, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create a device, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds);
-    ok(SUCCEEDED(hr), "Failed to get depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &readback, NULL);
-    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture, NULL);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &intz_ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, readback);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, intz_ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(intz_ds);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE4(0));
-    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#lx.\n", hr);
 
     /* Render onscreen, blit the depth buffer into the INTZ texture
      * and then check its contents */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0xf);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     /* The actual multisampled depth buffer resolve happens here */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, 0x7fa05000);
-    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_POINTSIZE, &value);
-    ok(SUCCEEDED(hr) && value == 0x7fa05000, "GetRenderState failed, hr %#x, value %#x.\n", hr, value);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
+    ok(value == 0x7fa05000, "Got value %#lx.\n", value);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, readback);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Read the depth values back */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
 
     /* Test edge cases - try with no texture at all */
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, 0x7fa05000);
-    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#lx.\n", hr);
 
     /* With a non-multisampled depth buffer */
     IDirect3DSurface9_Release(ds);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth stencil surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, readback);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0xf);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, 0x7fa05000);
-    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Read the depth values back. */
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
-        D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
+        unsigned int color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
         ok(color_match(color, expected_colors[i].color, 1),
                 "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
                 expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     /* Without a current depth-stencil buffer set */
     hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, 0x7fa05000);
-    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth/stencil, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(ds);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(texture);
     IDirect3DPixelShader9_Release(ps);
     IDirect3DSurface9_Release(readback);
@@ -18546,16 +18503,13 @@ static void zenable_test(void)
         {{640.0f, 480.0f,  1.5f, 1.0f}, 0xff00ff00},
         {{640.0f,   0.0f,  1.5f, 1.0f}, 0xff00ff00},
     };
+    unsigned int color, x, y, i, j, test;
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
-    UINT x, y;
-    UINT i, j;
-    UINT test;
     IDirect3DSurface9 *ds;
 
     window = create_window();
@@ -18568,7 +18522,7 @@ static void zenable_test(void)
     }
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds);
-    ok(SUCCEEDED(hr), "Failed to get depth stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get depth stencil surface, hr %#lx.\n", hr);
 
     for (test = 0; test < 2; ++test)
     {
@@ -18585,28 +18539,28 @@ static void zenable_test(void)
         if (!test)
         {
             hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-            ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-            ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-            ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 0.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
         }
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
-        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, tquad, sizeof(*tquad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         for (i = 0; i < 4; ++i)
         {
@@ -18623,13 +18577,13 @@ static void zenable_test(void)
         }
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#lx.\n", hr);
     }
 
     IDirect3DSurface9_Release(ds);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 1)
             && caps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
@@ -18655,7 +18609,7 @@ static void zenable_test(void)
             { 1.0f, -1.0f,  1.5f},
             { 1.0f,  1.0f,  1.5f},
         };
-        static const D3DCOLOR expected[] =
+        static const unsigned int expected[] =
         {
             0x00ff0000, 0x0060df60, 0x009fdf9f, 0x00ff0000,
             0x00ff0000, 0x00609f60, 0x009f9f9f, 0x00ff0000,
@@ -18664,7 +18618,7 @@ static void zenable_test(void)
         };
         /* The Windows 8 testbot (WARP) appears to not clip z for regular
          * vertices either. */
-        static const D3DCOLOR expected_broken[] =
+        static const unsigned int expected_broken[] =
         {
             0x0020df20, 0x0060df60, 0x009fdf9f, 0x00dfdfdf,
             0x00209f20, 0x00609f60, 0x009f9f9f, 0x00df9fdf,
@@ -18676,24 +18630,24 @@ static void zenable_test(void)
         IDirect3DPixelShader9 *ps;
 
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vs);
-        ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-        ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetVertexShader(device, vs);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, ps);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         for (i = 0; i < 4; ++i)
         {
@@ -18709,14 +18663,14 @@ static void zenable_test(void)
         }
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#lx.\n", hr);
 
         IDirect3DPixelShader9_Release(ps);
         IDirect3DVertexShader9_Release(vs);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -18740,7 +18694,7 @@ static void fog_special_test(void)
     {
         DWORD vertexmode, tablemode;
         BOOL vs, ps;
-        D3DCOLOR color_left, color_right;
+        unsigned int color_left, color_right;
     }
     tests[] =
     {
@@ -18781,12 +18735,11 @@ static void fog_special_test(void)
         float f;
         DWORD d;
     } conv;
-    DWORD color;
     HRESULT hr;
-    unsigned int i;
     IDirect3DPixelShader9 *ps;
     IDirect3DVertexShader9 *vs;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
@@ -18802,11 +18755,11 @@ static void fog_special_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
     {
         hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code, &vs);
-        ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx.\n", hr);
     }
     else
     {
@@ -18816,7 +18769,7 @@ static void fog_special_test(void)
     if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 1))
     {
         hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &ps);
-        ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
     }
     else
     {
@@ -18828,37 +18781,37 @@ static void fog_special_test(void)
      * being set to an identity matrix, even though that's the default.
      * (AMD Radeon HD 6310, Windows 7) */
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &identity);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0xffff0000);
-    ok(SUCCEEDED(hr), "Failed to set fog color, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fog color, hr %#lx.\n", hr);
 
     conv.f = 0.5f;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, conv.d);
-    ok(SUCCEEDED(hr), "Failed to set fog start, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fog start, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, conv.d);
-    ok(SUCCEEDED(hr), "Failed to set fog end, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fog end, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); i++)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
         if (!tests[i].vs)
         {
             hr = IDirect3DDevice9_SetVertexShader(device, NULL);
-            ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         }
         else if (vs)
         {
             hr = IDirect3DDevice9_SetVertexShader(device, vs);
-            ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         }
         else
         {
@@ -18868,12 +18821,12 @@ static void fog_special_test(void)
         if (!tests[i].ps)
         {
             hr = IDirect3DDevice9_SetPixelShader(device, NULL);
-            ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
         }
         else if (ps)
         {
             hr = IDirect3DDevice9_SetPixelShader(device, ps);
-            ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
         }
         else
         {
@@ -18881,16 +18834,16 @@ static void fog_special_test(void)
         }
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, tests[i].vertexmode);
-        ok(SUCCEEDED(hr), "Failed to set fogvertexmode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set fogvertexmode, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, tests[i].tablemode);
-        ok(SUCCEEDED(hr), "Failed to set fogtablemode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set fogtablemode, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 310, 240);
         ok(color_match(color, tests[i].color_left, 1),
@@ -18900,7 +18853,7 @@ static void fog_special_test(void)
                 "Expected right color 0x%08x, got 0x%08x, case %u.\n", tests[i].color_right, color, i);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#lx.\n", hr);
     }
 
     if (vs)
@@ -18908,7 +18861,7 @@ static void fog_special_test(void)
     if (ps)
         IDirect3DPixelShader9_Release(ps);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -18917,20 +18870,19 @@ done:
 static void volume_srgb_test(void)
 {
     HRESULT hr;
-    unsigned int i, j;
     IDirect3DVolumeTexture9 *tex1, *tex2;
     D3DPOOL pool;
     D3DLOCKED_BOX locked_box;
     IDirect3DDevice9 *device;
+    unsigned int color, i, j;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
 
     static const struct
     {
         BOOL srgb;
-        DWORD color;
+        unsigned int color;
     }
     tests[] =
     {
@@ -18968,13 +18920,13 @@ static void volume_srgb_test(void)
     }
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op 0, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op 0, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "Failed to set color op 0, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op 0, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0));
-    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#lx.\n", hr);
 
     for (i = 0; i < 2; i++)
     {
@@ -18984,56 +18936,56 @@ static void volume_srgb_test(void)
             pool = D3DPOOL_MANAGED;
 
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 1, 1, 1, 0, D3DFMT_A8R8G8B8, pool, &tex1, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
         hr = IDirect3DVolumeTexture9_LockBox(tex1, 0, &locked_box, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
         *((DWORD *)locked_box.pBits) = 0x7f7f7f7f;
         hr = IDirect3DVolumeTexture9_UnlockBox(tex1, 0);
-        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
 
         if (!i)
         {
             hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 1, 1, 1, 0,
                     D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex2, NULL);
-            ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex1, (IDirect3DBaseTexture9 *)tex2);
-            ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
             IDirect3DVolumeTexture9_Release(tex1);
 
             hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex2);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
             IDirect3DVolumeTexture9_Release(tex2);
         }
         else
         {
             hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex1);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
             IDirect3DVolumeTexture9_Release(tex1);
         }
 
         for (j = 0; j < ARRAY_SIZE(tests); j++)
         {
             hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, tests[j].srgb);
-            ok(SUCCEEDED(hr), "Failed to set srgb state, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set srgb state, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             color = getPixelColor(device, 320, 240);
             ok(color_match(color, tests[j].color, 2),
                     "Expected color 0x%08x, got 0x%08x, i = %u, j = %u.\n", tests[j].color, color, i, j);
 
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to present backbuffer, hr %#lx.\n", hr);
         }
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -19043,13 +18995,12 @@ static void volume_dxtn_test(void)
 {
     IDirect3DVolumeTexture9 *texture;
     struct surface_readback rb;
+    unsigned int colour, i, j;
     IDirect3DDevice9 *device;
     IDirect3DSurface9 *rt;
     D3DLOCKED_BOX box;
-    unsigned int i, j;
     IDirect3D9 *d3d;
     ULONG refcount;
-    DWORD colour;
     HWND window;
     HRESULT hr;
 
@@ -19076,17 +19027,17 @@ static void volume_dxtn_test(void)
         0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
         0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00
     };
-    static const DWORD dxt1_expected_colours[] =
+    static const unsigned int dxt1_expected_colours[] =
     {
         0xffff0000, 0x00000000, 0xff00ff00, 0xff00ff00,
         0xff0000ff, 0xff0000ff, 0xffffffff, 0xffffffff,
     };
-    static const DWORD dxt3_expected_colours[] =
+    static const unsigned int dxt3_expected_colours[] =
     {
         0xffff0000, 0xeeff0000, 0xff00ff00, 0xdd00ff00,
         0xff0000ff, 0xcc0000ff, 0xffffffff, 0xbbffffff,
     };
-    static const DWORD dxt5_expected_colours[] =
+    static const unsigned int dxt5_expected_colours[] =
     {
         0xffff0000, 0x00ff0000, 0xff00ff00, 0xff00ff00,
         0xff0000ff, 0xff0000ff, 0xffffffff, 0xffffffff
@@ -19098,7 +19049,7 @@ static void volume_dxtn_test(void)
         D3DFORMAT format;
         const BYTE *data;
         DWORD data_size;
-        const DWORD *expected_colours;
+        const unsigned int *expected_colours;
     }
     tests[] =
     {
@@ -19136,7 +19087,7 @@ static void volume_dxtn_test(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -19148,37 +19099,37 @@ static void volume_dxtn_test(void)
         }
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 8, 4, 2, 1, 0,
                 tests[i].format, D3DPOOL_MANAGED, &texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
 
         hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &box, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
         memcpy(box.pBits, tests[i].data, tests[i].data_size);
         hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0));
-        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-        ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-        ok(SUCCEEDED(hr), "Failed to set colour op, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set colour op, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-        ok(SUCCEEDED(hr), "Failed to set colour arg, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set colour arg, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-        ok(SUCCEEDED(hr), "Failed to set colour op, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set colour op, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-        ok(SUCCEEDED(hr), "Failed to set mag filter, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set mag filter, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff00ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[0], sizeof(*quads));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[4], sizeof(*quads));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         get_rt_readback(rt, &rb);
         for (j = 0; j < ARRAY_SIZE(dxt1_expected_colours); ++j)
@@ -19190,13 +19141,13 @@ static void volume_dxtn_test(void)
         release_surface_readback(&rb);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
         IDirect3DVolumeTexture9_Release(texture);
     }
 
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -19207,13 +19158,12 @@ static void volume_v16u16_test(void)
     IDirect3DVolumeTexture9 *texture;
     IDirect3DPixelShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     D3DLOCKED_BOX box;
     IDirect3D9 *d3d;
-    unsigned int i;
     ULONG refcount;
     D3DCAPS9 caps;
     SHORT *texel;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -19254,7 +19204,7 @@ static void volume_v16u16_test(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
     {
         skip("No ps_1_1 support, skipping tests.\n");
@@ -19270,13 +19220,13 @@ static void volume_v16u16_test(void)
     }
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0));
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, shader);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "Failed to set filter, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set filter, hr %#lx.\n", hr);
 
     for (i = 0; i < 2; i++)
     {
@@ -19289,10 +19239,10 @@ static void volume_v16u16_test(void)
 
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 2, 2, 1, 0, D3DFMT_V16U16,
                 pool, &texture, NULL);
-        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
 
         hr = IDirect3DVolumeTexture9_LockBox(texture, 0, &box, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr);
 
         texel = (SHORT *)((BYTE *)box.pBits + 0 * box.RowPitch + 0 * box.SlicePitch);
         texel[0] = 32767;
@@ -19308,7 +19258,7 @@ static void volume_v16u16_test(void)
         texel[1] =  0;
 
         hr = IDirect3DVolumeTexture9_UnlockBox(texture, 0);
-        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr);
 
         if (i)
         {
@@ -19316,29 +19266,29 @@ static void volume_v16u16_test(void)
 
             hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 2, 2, 1, 0, D3DFMT_V16U16,
                     D3DPOOL_DEFAULT, &texture2, NULL);
-            ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture,
                     (IDirect3DBaseTexture9 *)texture2);
-            ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
 
             IDirect3DVolumeTexture9_Release(texture);
             texture = texture2;
         }
 
         hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
-        ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff00ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[0], sizeof(*quads));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[4], sizeof(*quads));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 120, 160);
         ok (color_match(color, 0x000080ff, 2),
@@ -19354,14 +19304,14 @@ static void volume_v16u16_test(void)
                 "Expected color 0x0040c0ff, got 0x%08x, V16U16 input -16384, 16384.\n", color);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
         IDirect3DVolumeTexture9_Release(texture);
     }
 
     IDirect3DPixelShader9_Release(shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -19384,11 +19334,11 @@ static void add_dirty_rect_test_draw(IDirect3DDevice9 *device)
     };
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 }
 
 static void add_dirty_rect_test(void)
@@ -19399,8 +19349,8 @@ static void add_dirty_rect_test(void)
     IDirect3DSurface9 *surface_dst2, *surface_src_green, *surface_src_red,
         *surface_managed0, *surface_managed1, *surface_dynamic;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    unsigned int i;
     ULONG refcount;
     DWORD *texel;
     HWND window;
@@ -19415,7 +19365,6 @@ static void add_dirty_rect_test(void)
         {300, 200, 310, 210},
         {  0,   0,   0,   0},
     };
-    DWORD color;
 
     window = create_window();
     d3d = Direct3DCreate9(D3D_SDK_VERSION);
@@ -19430,124 +19379,124 @@ static void add_dirty_rect_test(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_DEFAULT, &tex_dst1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_DEFAULT, &tex_dst2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &tex_src_red, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &tex_src_green, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 2, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_MANAGED, &tex_managed, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, D3DUSAGE_DYNAMIC,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &tex_dynamic, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_dst2, 0, &surface_dst2);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_src_green, 0, &surface_src_green);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_src_red, 0, &surface_src_red);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_managed, 0, &surface_managed0);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_managed, 1, &surface_managed1);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_dynamic, 0, &surface_dynamic);
-    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_red,
             (IDirect3DBaseTexture9 *)tex_dst2);
     fill_surface(surface_src_green, 0x00000080, D3DLOCK_NO_DIRTY_UPDATE);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00000080, 1), "Unexpected colour 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
 
     fill_surface(surface_src_red, 0x00ff0000, 0);
     fill_surface(surface_src_green, 0x0000ff00, 0);
 
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst1);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
 
     /* The second UpdateTexture call writing to tex_dst2 is ignored because tex_src_green is not dirty. */
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_red,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_dst1);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1),
             "Expected color 0x0000ff00, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1),
             "Expected color 0x00ff0000, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* AddDirtyRect on the destination is ignored. */
     hr = IDirect3DTexture9_AddDirtyRect(tex_dst2, &part_rect);
-    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1),
             "Expected color 0x00ff0000, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_AddDirtyRect(tex_dst2, NULL);
-    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1),
             "Expected color 0x00ff0000, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* AddDirtyRect on the source makes UpdateTexture work. Partial rectangle
      * tracking is supported. */
     hr = IDirect3DTexture9_AddDirtyRect(tex_src_green, &part_rect);
-    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1),
@@ -19556,13 +19505,13 @@ static void add_dirty_rect_test(void)
     ok(color_match(color, 0x00ff0000, 1),
             "Expected color 0x00ff0000, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_AddDirtyRect(tex_src_green, NULL);
-    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 1, 1);
     ok(color_match(color, 0x0000ff00, 1),
@@ -19572,70 +19521,70 @@ static void add_dirty_rect_test(void)
     fill_surface(surface_src_green, 0x00000080, D3DLOCK_NO_DIRTY_UPDATE);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1),
             "Expected color 0x0000ff00, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Manually copying the surface works, though. */
     hr = IDirect3DDevice9_UpdateSurface(device, surface_src_green, NULL, surface_dst2, NULL);
-    ok(hr == D3D_OK, "Failed to copy surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to copy surface, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00000080, 1), "Got unexpected colour 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Failed to present, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to present, hr %#lx.\n", hr);
 
     /* Readonly maps write to D3DPOOL_SYSTEMMEM, but don't record a dirty rectangle. */
     fill_surface(surface_src_green, 0x000000ff, D3DLOCK_READONLY);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00000080, 1), "Got unexpected colour 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_AddDirtyRect(tex_src_green, NULL);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x000000ff, 1),
             "Expected color 0x000000ff, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Maps without either of these flags record a dirty rectangle. */
     fill_surface(surface_src_green, 0x00ffffff, 0);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ffffff, 1),
             "Expected color 0x00ffffff, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Partial LockRect works just like a partial AddDirtyRect call. */
     hr = IDirect3DTexture9_LockRect(tex_src_green, 0, &locked_rect, &part_rect, 0);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
     texel = locked_rect.pBits;
     for (i = 0; i < 64; i++)
         texel[i] = 0x00ff00ff;
     for (i = 1; i < 64; i++)
         memcpy((BYTE *)locked_rect.pBits + i * locked_rect.Pitch, locked_rect.pBits, locked_rect.Pitch);
     hr = IDirect3DTexture9_UnlockRect(tex_src_green, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff00ff, 1),
@@ -19644,55 +19593,55 @@ static void add_dirty_rect_test(void)
     ok(color_match(color, 0x00ffffff, 1),
             "Expected color 0x00ffffff, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     fill_surface(surface_src_red, 0x00ff0000, 0);
     fill_surface(surface_src_green, 0x0000ff00, 0);
 
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_green,
             (IDirect3DBaseTexture9 *)tex_dst1);
-    ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_dst1);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1),
             "Expected color 0x0000ff00, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* UpdateSurface ignores the missing dirty marker. */
     hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)tex_src_red,
             (IDirect3DBaseTexture9 *)tex_dst2);
     hr = IDirect3DDevice9_UpdateSurface(device, surface_src_green, NULL, surface_dst2, NULL);
-    ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1),
             "Expected color 0x0000ff00, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Tests with managed textures. */
     fill_surface(surface_managed0, 0x00ff0000, 0);
     fill_surface(surface_managed1, 0x00ff0000, 0);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_managed);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1),
             "Expected color 0x00ff0000, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Managed textures also honor D3DLOCK_NO_DIRTY_UPDATE. */
     fill_surface(surface_managed0, 0x0000ff00, D3DLOCK_NO_DIRTY_UPDATE);
@@ -19702,74 +19651,74 @@ static void add_dirty_rect_test(void)
     ok(color_match(color, 0x00ff0000, 1),
             "Expected color 0x00ff0000, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 0);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* AddDirtyRect uploads the new contents.
      * Partial surface updates work, and two separate dirty rectangles are
      * tracked individually. Tested on Nvidia Kepler, other drivers untested. */
     hr = IDirect3DTexture9_AddDirtyRect(tex_managed, &part_rect);
-    ok(hr == S_OK, "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to add dirty rect, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
     color = getPixelColor(device, 1, 1);
     todo_wine ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_AddDirtyRect(tex_managed, NULL);
-    ok(hr == S_OK, "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to add dirty rect, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
     color = getPixelColor(device, 1, 1);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* So does EvictManagedResources. */
     fill_surface(surface_managed0, 0x00ffff00, D3DLOCK_NO_DIRTY_UPDATE);
     fill_surface(surface_managed1, 0x00ff00ff, D3DLOCK_NO_DIRTY_UPDATE);
     hr = IDirect3DDevice9_EvictManagedResources(device);
-    ok(SUCCEEDED(hr), "Failed to evict managed resources, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to evict managed resources, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff00ff, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 0);
-    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ffff00, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Tests with dynamic textures */
     fill_surface(surface_dynamic, 0x0000ffff, 0);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_dynamic);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ffff, 1),
             "Expected color 0x0000ffff, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Dynamic textures don't honor D3DLOCK_NO_DIRTY_UPDATE. */
     fill_surface(surface_dynamic, 0x00ffff00, D3DLOCK_NO_DIRTY_UPDATE);
@@ -19778,31 +19727,31 @@ static void add_dirty_rect_test(void)
     ok(color_match(color, 0x00ffff00, 1),
             "Expected color 0x00ffff00, got 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* AddDirtyRect on a locked texture is allowed. */
     hr = IDirect3DTexture9_LockRect(tex_src_red, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_AddDirtyRect(tex_src_red, NULL);
-    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_UnlockRect(tex_src_red, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
     /* Redundant AddDirtyRect calls are ok. */
     hr = IDirect3DTexture9_AddDirtyRect(tex_managed, NULL);
-    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_AddDirtyRect(tex_managed, NULL);
-    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add dirty rect, hr %#lx.\n", hr);
 
     /* Test out-of-bounds regions. */
     for (i = 0; i < ARRAY_SIZE(oob_rect); ++i)
     {
         hr = IDirect3DTexture9_AddDirtyRect(tex_src_red, &oob_rect[i]);
-        ok(hr == D3DERR_INVALIDCALL, "[%u] Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3DERR_INVALIDCALL, "[%u] Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DTexture9_LockRect(tex_src_red, 0, &locked_rect, &oob_rect[i], 0);
-        ok(SUCCEEDED(hr), "[%u] Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "[%u] Got unexpected hr %#lx.\n", i, hr);
         hr = IDirect3DTexture9_UnlockRect(tex_src_red, 0);
-        ok(SUCCEEDED(hr), "[%u] Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "[%u] Got unexpected hr %#lx.\n", i, hr);
     }
 
     IDirect3DSurface9_Release(surface_dst2);
@@ -19825,26 +19774,26 @@ static void add_dirty_rect_test(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_DEFAULT, &tex_dst2, NULL);
-    ok(hr == D3D_OK, "Failed to create texture, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &tex_src_green, NULL);
-    ok(hr == D3D_OK, "Failed to create texture, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_dst2, 0, &surface_dst2);
-    ok(hr == D3D_OK, "Failed to get surface level, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get surface level, hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(tex_src_green, 0, &surface_src_green);
-    ok(hr == D3D_OK, "Failed to get surface level, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to get surface level, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_dst2);
-    ok(hr == D3D_OK, "Failed to set texture, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set texture, hr %#lx.\n", hr);
     fill_surface(surface_src_green, 0x00ff0000, D3DLOCK_NO_DIRTY_UPDATE);
     hr = IDirect3DDevice9_UpdateSurface(device, surface_src_green, NULL, surface_dst2, NULL);
-    ok(hr == D3D_OK, "Failed to copy rects, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to copy rects, hr %#lx.\n", hr);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1), "Got unexpected colour 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Failed to present, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface_dst2);
     IDirect3DSurface9_Release(surface_src_green);
@@ -19852,7 +19801,7 @@ static void add_dirty_rect_test(void)
     IDirect3DTexture9_Release(tex_src_green);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -19860,8 +19809,8 @@ static void add_dirty_rect_test(void)
 static void test_per_stage_constant(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -19890,7 +19839,7 @@ static void test_per_stage_constant(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.PrimitiveMiscCaps & D3DPMISCCAPS_PERSTAGECONSTANT))
     {
         skip("Per-stage constants not supported, skipping tests.\n");
@@ -19899,98 +19848,98 @@ static void test_per_stage_constant(void)
     }
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_CONSTANT, 0x80a1b2c3);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_CONSTANT);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00a1b2c3, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_CONSTANT | D3DTA_COMPLEMENT);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x005e4d3c, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_CONSTANT | D3DTA_ALPHAREPLICATE);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00808080, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_CONSTANT);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0080007f, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -20046,14 +19995,13 @@ static void test_3dc_formats(void)
     };
     IDirect3D9 *d3d;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3DTexture9 *ati1n_texture, *ati2n_texture;
     D3DCAPS9 caps;
     D3DLOCKED_RECT rect;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    unsigned int i;
 
     window = create_window();
     d3d = Direct3DCreate9(D3D_SDK_VERSION);
@@ -20076,7 +20024,7 @@ static void test_3dc_formats(void)
         goto done;
     }
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.PrimitiveMiscCaps & D3DPMISCCAPS_TSSARGTEMP))
     {
         skip("D3DTA_TEMP not supported, skipping tests.\n");
@@ -20086,56 +20034,56 @@ static void test_3dc_formats(void)
 
     hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 1, 0, ati1n_fourcc,
             D3DPOOL_MANAGED, &ati1n_texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_LockRect(ati1n_texture, 0, &rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
     memcpy(rect.pBits, ati1n_data, sizeof(ati1n_data));
     hr = IDirect3DTexture9_UnlockRect(ati1n_texture, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 8, 4, 1, 0, ati2n_fourcc,
             D3DPOOL_MANAGED, &ati2n_texture, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_LockRect(ati2n_texture, 0, &rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
     memcpy(rect.pBits, ati2n_data, sizeof(ati2n_data));
     hr = IDirect3DTexture9_UnlockRect(ati2n_texture, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0));
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     /* The temporary register is initialized to 0. */
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TEMP);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "Failed to set mag filter, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set mag filter, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff00ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)ati1n_texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[0], sizeof(*quads));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)ati2n_texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quads[4], sizeof(*quads));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -20148,11 +20096,11 @@ static void test_3dc_formats(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     IDirect3DTexture9_Release(ati2n_texture);
     IDirect3DTexture9_Release(ati1n_texture);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D9_Release(d3d);
@@ -20163,10 +20111,11 @@ static void test_fog_interpolation(void)
 {
     HRESULT hr;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
     ULONG refcount;
     HWND window;
-    D3DCOLOR color;
+
     static const struct
     {
         struct vec3 position;
@@ -20185,7 +20134,6 @@ static void test_fog_interpolation(void)
         DWORD d;
         float f;
     } conv;
-    unsigned int i;
     static const struct
     {
         D3DFOGMODE vfog, tfog;
@@ -20226,30 +20174,30 @@ static void test_fog_interpolation(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE))
         skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests\n");
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0x0000ff00);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     conv.f = 5.0;
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGDENSITY, conv.d);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x000000ff);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     /* Some of the tests seem to depend on the projection matrix explicitly
      * being set to an identity matrix, even though that's the default.
@@ -20258,7 +20206,7 @@ static void test_fog_interpolation(void)
      * The input value is independent of the actual z and w component of
      * the vertex position. */
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &ident_mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); i++)
     {
@@ -20266,20 +20214,20 @@ static void test_fog_interpolation(void)
             continue;
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00808080, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SHADEMODE, tests[i].shade);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, tests[i].vfog);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, tests[i].tfog);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 0, 240);
         ok(color_match(color, 0x000000ff, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
@@ -20290,11 +20238,11 @@ static void test_fog_interpolation(void)
         color = getPixelColor(device, 639, 240);
         ok(color_match(color, 0x0000fd02, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -20303,10 +20251,11 @@ static void test_negative_fixedfunction_fog(void)
 {
     HRESULT hr;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
     ULONG refcount;
     HWND window;
-    D3DCOLOR color;
+
     static const struct
     {
         struct vec3 position;
@@ -20331,7 +20280,6 @@ static void test_negative_fixedfunction_fog(void)
         {{  0.0f, 480.0f, -0.5f, 1.0f}, 0xffff0000},
         {{640.0f, 480.0f, -0.5f, 1.0f}, 0xffff0000},
     };
-    unsigned int i;
     static const D3DMATRIX zero =
     {{{
         1.0f, 0.0f, 0.0f, 0.0f,
@@ -20400,20 +20348,20 @@ static void test_negative_fixedfunction_fog(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE))
         skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests.\n");
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0x0000ff00);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); i++)
     {
@@ -20421,38 +20369,38 @@ static void test_negative_fixedfunction_fog(void)
             continue;
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, tests[i].matrix);
-        ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetFVF(device, tests[i].pos_type | D3DFVF_DIFFUSE);
-        ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set fvf, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART, tests[i].start.d);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, tests[i].end.d);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, tests[i].vfog);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, tests[i].tfog);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, tests[i].quad, tests[i].stride);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 320, 240);
         ok(color_match(color, tests[i].color, 2) || broken(color_match(color, tests[i].color_broken, 2))
                 || broken(color_match(color, tests[i].color_broken2, 2)),
                 "Got unexpected color 0x%08x, case %u.\n", color, i);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -20544,12 +20492,11 @@ static void test_position_index(void)
     IDirect3DVertexDeclaration9 *vertex_declaration;
     IDirect3DVertexShader9 *vs, *vs2;
     IDirect3DPixelShader9 *ps, *ps2;
+    unsigned int color, i;
     D3DCAPS9 caps;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    unsigned int i;
 
     window = create_window();
     d3d = Direct3DCreate9(D3D_SDK_VERSION);
@@ -20561,7 +20508,7 @@ static void test_position_index(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(3, 0)
             || caps.PixelShaderVersion < D3DPS_VERSION(3, 0))
     {
@@ -20571,38 +20518,38 @@ static void test_position_index(void)
     }
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed, hr %#x\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexDeclaration failed, hr %#lx\n", hr);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#lx\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vs);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_code_2, &vs2);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, vs);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code_bad, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "CreatePixelShader returned hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "CreatePixelShader returned hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code_2, &ps2);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff00ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
@@ -20613,16 +20560,16 @@ static void test_position_index(void)
     }
 
     hr = IDirect3DDevice9_SetPixelShader(device, ps2);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff00ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
@@ -20633,16 +20580,16 @@ static void test_position_index(void)
     }
 
     hr = IDirect3DDevice9_SetVertexShader(device, vs2);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ff00ff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
     {
@@ -20652,7 +20599,7 @@ static void test_position_index(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DPixelShader9_Release(ps2);
     IDirect3DPixelShader9_Release(ps);
@@ -20660,7 +20607,7 @@ static void test_position_index(void)
     IDirect3DVertexShader9_Release(vs);
     IDirect3DVertexDeclaration9_Release(vertex_declaration);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D9_Release(d3d);
@@ -20671,10 +20618,10 @@ static void test_table_fog_zw(void)
 {
     HRESULT hr;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     HWND window;
-    D3DCOLOR color;
     D3DCAPS9 caps;
     static struct
     {
@@ -20699,7 +20646,7 @@ static void test_table_fog_zw(void)
     {
         float z, w;
         D3DZBUFFERTYPE z_test;
-        D3DCOLOR color;
+        unsigned int color;
     }
     tests[] =
     {
@@ -20727,7 +20674,7 @@ static void test_table_fog_zw(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE))
     {
         skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping POSITIONT table fog test.\n");
@@ -20735,25 +20682,25 @@ static void test_table_fog_zw(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0x0000ff00);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     /* Work around an AMD Windows driver bug. Needs a proj matrix applied redundantly. */
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &identity);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fvf, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         quad[0].position.z = tests[i].z;
         quad[1].position.z = tests[i].z;
@@ -20764,41 +20711,40 @@ static void test_table_fog_zw(void)
         quad[2].position.w = tests[i].w;
         quad[3].position.w = tests[i].w;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, tests[i].z_test);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 320, 240);
         ok(color_match(color, tests[i].color, 2),
                 "Got unexpected color 0x%08x, expected 0x%08x, case %u.\n", color, tests[i].color, i);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
     }
 
 done:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
 
 static void test_signed_formats(void)
 {
+    unsigned int expected_color, color, i, j, x, y;
     IDirect3DDevice9 *device;
     HWND window;
     HRESULT hr;
-    unsigned int i, j, x, y;
     IDirect3DTexture9 *texture, *texture_sysmem;
     IDirect3DSurface9 *src_surface, *dst_surface;
     D3DLOCKED_RECT locked_rect;
     IDirect3DPixelShader9 *shader, *shader_alpha;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     D3DCAPS9 caps;
     ULONG refcount;
 
@@ -20969,7 +20915,6 @@ static void test_signed_formats(void)
         0x00ba98a0,
         0x00c3c3c0,
     };
-    D3DCOLOR expected_color;
 
     window = create_window();
     d3d = Direct3DCreate9(D3D_SDK_VERSION);
@@ -20984,7 +20929,7 @@ static void test_signed_formats(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
     {
@@ -20993,13 +20938,13 @@ static void test_signed_formats(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_alpha, &shader_alpha);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(formats); i++)
     {
@@ -21016,10 +20961,10 @@ static void test_signed_formats(void)
             texture_sysmem = NULL;
             hr = IDirect3DDevice9_CreateTexture(device, tests[j].width, 4, 1, 0,
                     formats[i].format, tests[j].pool, &texture, NULL);
-            ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
             hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-            ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
             for (y = 0; y < 4; y++)
             {
                 memcpy((char *)locked_rect.pBits + y * locked_rect.Pitch,
@@ -21027,33 +20972,33 @@ static void test_signed_formats(void)
                         tests[j].width * formats[i].pixel_size);
             }
             hr = IDirect3DTexture9_UnlockRect(texture, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
             if (tests[j].pool == D3DPOOL_SYSTEMMEM)
             {
                 texture_sysmem = texture;
                 hr = IDirect3DDevice9_CreateTexture(device, tests[j].width, 4, 1, 0,
                         formats[i].format, D3DPOOL_DEFAULT, &texture, NULL);
-                ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
                 hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture_sysmem,
                         (IDirect3DBaseTexture9 *)texture);
-                ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
             }
 
             hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetPixelShader(device, shader_alpha);
-            ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00330033, 0.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(*quad));
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             for (y = 0; y < 4; y++)
             {
@@ -21072,19 +21017,19 @@ static void test_signed_formats(void)
                 }
             }
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_SetPixelShader(device, shader);
-            ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00330033, 0.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(*quad));
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             for (y = 0; y < 4; y++)
             {
@@ -21102,7 +21047,7 @@ static void test_signed_formats(void)
                 }
             }
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
             if (tests[j].pool != D3DPOOL_SYSTEMMEM)
             {
@@ -21111,25 +21056,25 @@ static void test_signed_formats(void)
             }
 
             hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &dst_surface);
-            ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
             IDirect3DTexture9_GetSurfaceLevel(texture_sysmem, 0, &src_surface);
-            ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_UpdateSurface(device, src_surface,
                     &tests[j].src_rect, dst_surface, &tests[j].dst_point);
-            ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to update surface, hr %#lx.\n", hr);
 
             IDirect3DSurface9_Release(dst_surface);
             IDirect3DSurface9_Release(src_surface);
 
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00003300, 0.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(*quad));
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             for (y = 0; y < 4; y++)
             {
@@ -21151,7 +21096,7 @@ static void test_signed_formats(void)
                 }
             }
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
             IDirect3DTexture9_Release(texture_sysmem);
             IDirect3DTexture9_Release(texture);
@@ -21163,7 +21108,7 @@ static void test_signed_formats(void)
 
 done:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -21171,10 +21116,10 @@ done:
 static void test_multisample_mismatch(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     HWND window;
     HRESULT hr;
-    D3DCOLOR color;
     ULONG refcount;
     IDirect3DSurface9 *rt, *rt_multi, *ds;
     static const struct
@@ -21218,40 +21163,40 @@ static void test_multisample_mismatch(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &rt_multi, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 0.1f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds);
-    ok(SUCCEEDED(hr), "Failed to set depth stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt_multi);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     /* Clear with incompatible buffers. Partial and combined clears. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 0.3f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0000ff00, 0.5f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* The color buffer is reliably cleared on AMD and Nvidia GPUs. */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, rt_multi, NULL, rt, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Check depth buffer values. AMD GPUs (r500 and evergreen tested) clear
      * the depth buffer like you'd expect in a correct framebuffer
@@ -21260,13 +21205,13 @@ static void test_multisample_mismatch(void)
      * In Wine we currently happen to allow the depth only clear case but
      * disallow the combined one. */
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 62, 240);
     ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
     color = getPixelColor(device, 64, 240);
@@ -21278,33 +21223,33 @@ static void test_multisample_mismatch(void)
     color = getPixelColor(device, 322, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Draw with incompatible buffers. AMD even performs Z testing, and the Z test
      * results appear to be correct for this simple draw. Nvidia doesn't draw unless
      * the depth test is disabled. Setting ZFUNC = ALWAYS doesn't make the geometry
      * show up either. Only test the ZENABLE = FALSE case for now. */
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt_multi);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, rt_multi, NULL, rt, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(ds);
 
@@ -21312,43 +21257,43 @@ static void test_multisample_mismatch(void)
      * Color clears work as expected, AMD also clears the depth buffer, Nvidia does not. */
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24X8,
             D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt_multi);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ffff00, 0.1f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 0.3f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0000ff00, 0.5f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt_multi);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, rt_multi, NULL, rt, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
     color = getPixelColor(device, 62, 240);
     ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
     color = getPixelColor(device, 318, 240);
@@ -21357,59 +21302,59 @@ static void test_multisample_mismatch(void)
     color = getPixelColor(device, 322, 240);
     ok(color_match(color, 0x00ffff00, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Draw with a single sampled color buffer and a multisampled depth buffer. Again
      * AMD seems to perform correct Z testing, Nvidia doesn't draw unless the Z test
      * is disabled. Again only test the ZENABLE = FALSE case. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Draw with both buffers single sampled but multisample quality set to 1 for depth buffer.
      * The difference in multisample quality parameter is ignored. */
     IDirect3DSurface9_Release(ds);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24X8,
             D3DMULTISAMPLE_NONE, 1, FALSE, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-    ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0000ff00, 0.5f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 62, 240);
     ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
     color = getPixelColor(device, 322, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(rt);
     IDirect3DSurface9_Release(ds);
     IDirect3DSurface9_Release(rt_multi);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -21438,13 +21383,13 @@ static void test_texcoordindex(void)
         {{ 1.0f,  1.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}},
     };
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d9;
     HWND window;
     HRESULT hr;
     IDirect3DTexture9 *texture1, *texture2;
     D3DLOCKED_RECT locked_rect;
     ULONG refcount;
-    D3DCOLOR color;
     DWORD *ptr;
 
     window = create_window();
@@ -21459,65 +21404,65 @@ static void test_texcoordindex(void)
     }
 
     hr = IDirect3DDevice9_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_LockRect(texture1, 0, &locked_rect, NULL, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
     ptr = locked_rect.pBits;
     ptr[0] = 0xff000000;
     ptr[1] = 0xff00ff00;
     ptr[2] = 0xff0000ff;
     ptr[3] = 0xff00ffff;
     hr = IDirect3DTexture9_UnlockRect(texture1, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_LockRect(texture2, 0, &locked_rect, NULL, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
     ptr = locked_rect.pBits;
     ptr[0] = 0xff000000;
     ptr[1] = 0xff0000ff;
     ptr[2] = 0xffff0000;
     ptr[3] = 0xffff00ff;
     hr = IDirect3DTexture9_UnlockRect(texture2, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture1);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 1, (IDirect3DBaseTexture9 *)texture2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX3);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 2, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, 1);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_TEXCOORDINDEX, 0);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 120);
     ok(color_match(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
@@ -21529,19 +21474,19 @@ static void test_texcoordindex(void)
     ok(color_match(color, 0x00ffffff, 2), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
-    ok(SUCCEEDED(hr), "Failed to set texture transform flags, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture transform flags, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_TEXTURE1, &mat);
-    ok(SUCCEEDED(hr), "Failed to set transformation matrix, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set transformation matrix, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 120);
     ok(color_match(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
@@ -21553,19 +21498,19 @@ static void test_texcoordindex(void)
     ok(color_match(color, 0x0000ffff, 2), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
-    ok(SUCCEEDED(hr), "Failed to set texture transform flags, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture transform flags, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_TEXCOORDINDEX, 2);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 120);
     ok(color_match(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
@@ -21577,13 +21522,13 @@ static void test_texcoordindex(void)
     ok(color_match(color, 0x00ffff00, 2), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture1);
     IDirect3DTexture9_Release(texture2);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -21592,13 +21537,12 @@ static void test_vertex_blending(void)
 {
     IDirect3DVertexDeclaration9 *vertex_declaration;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
     D3DCAPS9 caps;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    int i;
 
     static const D3DMATRIX view_mat =
     {{{
@@ -21760,31 +21704,31 @@ static void test_vertex_blending(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.MaxVertexBlendMatrices < 4)
     {
-        skip("Only %u vertex blend matrices supported, skipping tests.\n", caps.MaxVertexBlendMatrices);
+        skip("Only %lu vertex blend matrices supported, skipping tests.\n", caps.MaxVertexBlendMatrices);
         IDirect3DDevice9_Release(device);
         goto done;
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &view_mat);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(0), &upper_left);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(1), &lower_left);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(2), &lower_right);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(3), &upper_right);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_VERTEXBLEND, D3DVBF_3WEIGHTS);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -21793,22 +21737,22 @@ static void test_vertex_blending(void)
         if (tests[i].fvf)
         {
             hr = IDirect3DDevice9_SetFVF(device, tests[i].fvf);
-            ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
             vertex_declaration = NULL;
         }
         else
         {
             hr = IDirect3DDevice9_CreateVertexDeclaration(device, tests[i].decl_elements, &vertex_declaration);
-            ok(SUCCEEDED(hr), "Failed to create vertex declaration, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create vertex declaration, hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-            ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
         }
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0);
-        ok(SUCCEEDED(hr), "Failed to clear %08x\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         if (tests[i].fvf)
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2,
@@ -21816,16 +21760,16 @@ static void test_vertex_blending(void)
         else
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2,
                     tests[i].s.vertex_data_d3dcolor, sizeof(*tests[i].s.vertex_data_d3dcolor));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         point = tests[i].quad_points;
         while (point->x != -1 && point->y != -1)
         {
             color = getPixelColor(device, point->x, point->y);
-            ok(color_match(color, 0x00ffffff, 1), "Expected quad at %dx%d.\n", point->x, point->y);
+            ok(color_match(color, 0x00ffffff, 1), "Expected quad at (%ld,%ld).\n", point->x, point->y);
             ++point;
         }
 
@@ -21833,19 +21777,19 @@ static void test_vertex_blending(void)
         while (point->x != -1 && point->y != -1)
         {
             color = getPixelColor(device, point->x, point->y);
-            ok(color_match(color, 0x00000000, 1), "Unexpected quad at %dx%d.\n", point->x, point->y);
+            ok(color_match(color, 0x00000000, 1), "Unexpected quad at (%ld,%ld).\n", point->x, point->y);
             ++point;
         }
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
         if (vertex_declaration)
             IDirect3DVertexDeclaration9_Release(vertex_declaration);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D9_Release(d3d);
@@ -21855,14 +21799,13 @@ done:
 static void test_updatetexture(void)
 {
     BOOL r32f_supported, ati2n_supported, do_visual_test;
+    unsigned int color, t, i, f, l, x, y, z;
     IDirect3DBaseTexture9 *src, *dst;
-    unsigned int t, i, f, l, x, y, z;
     D3DLOCKED_RECT locked_rect;
     D3DLOCKED_BOX locked_box;
     IDirect3DDevice9 *device;
     IDirect3D9 *d3d9;
     ULONG refcount;
-    D3DCOLOR color;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
@@ -21969,22 +21912,22 @@ static void test_updatetexture(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
-    ok(SUCCEEDED(hr), "Failed to set texture filtering state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture filtering state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "Failed to set texture clamping state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture clamping state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "Failed to set texture clamping state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture clamping state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
-    ok(SUCCEEDED(hr), "Failed to set texture clamping state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture clamping state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set texture stage state, hr %#lx.\n", hr);
 
     for (t = 0; t < ARRAY_SIZE(texture_types); ++t)
     {
@@ -22016,7 +21959,7 @@ static void test_updatetexture(void)
         }
 
         hr = IDirect3DDevice9_SetFVF(device, texture_types[t].fvf);
-        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
         for (i = 0; i < ARRAY_SIZE(tests); ++i)
         {
@@ -22032,36 +21975,36 @@ static void test_updatetexture(void)
                             tests[i].src_width, tests[i].src_height,
                             tests[i].src_levels, 0, tests[i].src_format, D3DPOOL_SYSTEMMEM,
                             (IDirect3DTexture9 **)&src, NULL);
-                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, case %u, %u.\n", hr, t, i);
+                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, case %u, %u.\n", hr, t, i);
                     hr = IDirect3DDevice9_CreateTexture(device,
                             tests[i].dst_width, tests[i].dst_height,
                             tests[i].dst_levels, 0, tests[i].dst_format, D3DPOOL_DEFAULT,
                             (IDirect3DTexture9 **)&dst, NULL);
-                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, case %u, %u.\n", hr, t, i);
+                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, case %u, %u.\n", hr, t, i);
                     break;
                 case D3DRTYPE_CUBETEXTURE:
                     hr = IDirect3DDevice9_CreateCubeTexture(device,
                             tests[i].src_width,
                             tests[i].src_levels, 0, tests[i].src_format, D3DPOOL_SYSTEMMEM,
                             (IDirect3DCubeTexture9 **)&src, NULL);
-                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, case %u, %u.\n", hr, t, i);
+                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, case %u, %u.\n", hr, t, i);
                     hr = IDirect3DDevice9_CreateCubeTexture(device,
                             tests[i].dst_width,
                             tests[i].dst_levels, 0, tests[i].dst_format, D3DPOOL_DEFAULT,
                             (IDirect3DCubeTexture9 **)&dst, NULL);
-                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, case %u, %u.\n", hr, t, i);
+                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, case %u, %u.\n", hr, t, i);
                     break;
                 case D3DRTYPE_VOLUMETEXTURE:
                     hr = IDirect3DDevice9_CreateVolumeTexture(device,
                             tests[i].src_width, tests[i].src_height, tests[i].src_width,
                             tests[i].src_levels, 0, tests[i].src_format, D3DPOOL_SYSTEMMEM,
                             (IDirect3DVolumeTexture9 **)&src, NULL);
-                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, case %u, %u.\n", hr, t, i);
+                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, case %u, %u.\n", hr, t, i);
                     hr = IDirect3DDevice9_CreateVolumeTexture(device,
                             tests[i].dst_width, tests[i].dst_height, tests[i].dst_width,
                             tests[i].dst_levels, 0, tests[i].dst_format, D3DPOOL_DEFAULT,
                             (IDirect3DVolumeTexture9 **)&dst, NULL);
-                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, case %u, %u.\n", hr, t, i);
+                    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, case %u, %u.\n", hr, t, i);
                     break;
                 default:
                     trace("Unexpected resource type.\n");
@@ -22111,7 +22054,7 @@ static void test_updatetexture(void)
                             default:
                                 trace("Unexpected resource type.\n");
                         }
-                        ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+                        ok(SUCCEEDED(hr), "Failed to lock texture, hr %#lx.\n", hr);
 
                         for (z = 0; z < depth; ++z)
                         {
@@ -22140,7 +22083,7 @@ static void test_updatetexture(void)
                             default:
                                 trace("Unexpected resource type.\n");
                         }
-                        ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+                        ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
 
                         width >>= 1;
                         if (!width)
@@ -22159,28 +22102,28 @@ static void test_updatetexture(void)
             if (FAILED(hr))
             {
                 todo_wine ok(SUCCEEDED(hr) || broken(tests[i].broken_updatetex),
-                        "Failed to update texture, hr %#x, case %u, %u.\n", hr, t, i);
+                        "Failed to update texture, hr %#lx, case %u, %u.\n", hr, t, i);
                 IDirect3DBaseTexture9_Release(src);
                 IDirect3DBaseTexture9_Release(dst);
                 continue;
             }
-            ok(SUCCEEDED(hr), "Failed to update texture, hr %#x, case %u, %u.\n", hr, t, i);
+            ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx, case %u, %u.\n", hr, t, i);
 
             if (do_visual_test)
             {
                 hr = IDirect3DDevice9_SetTexture(device, 0, dst);
-                ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
                 hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 1.0f, 0);
-                ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
                 hr = IDirect3DDevice9_BeginScene(device);
-                ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
                 hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2,
                         texture_types[t].quad, texture_types[t].vertex_size);
-                ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
                 hr = IDirect3DDevice9_EndScene(device);
-                ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
                 color = getPixelColor(device, 320, 240);
                 ok (color_match(color, 0x007f7f00, 3) || broken(tests[i].broken_result)
@@ -22193,7 +22136,7 @@ static void test_updatetexture(void)
         }
     }
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -22201,14 +22144,13 @@ static void test_updatetexture(void)
 static void test_depthbias(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
     IDirect3DSurface9 *ds;
     D3DCAPS9 caps;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    unsigned int i;
     static const D3DFORMAT formats[] =
     {
         D3DFMT_D16, D3DFMT_D24X8, D3DFMT_D32, D3DFMT_D24S8, MAKEFOURCC('I','N','T','Z'),
@@ -22253,7 +22195,7 @@ static void test_depthbias(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.RasterCaps & D3DPRASTERCAPS_DEPTHBIAS))
     {
         IDirect3DDevice9_Release(device);
@@ -22262,15 +22204,15 @@ static void test_depthbias(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(formats); ++i)
     {
@@ -22283,46 +22225,46 @@ static void test_depthbias(void)
 
         hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, formats[i],
                 D3DMULTISAMPLE_NONE, 0, FALSE, &ds, NULL);
-        ok(SUCCEEDED(hr), "Failed to create depth stencil surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create depth stencil surface, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
-        ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 0.5f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear %08x\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x00ff0000);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         conv.f = -0.2f;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DEPTHBIAS, conv.d);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x0000ff00);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         conv.f = 0.0f;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DEPTHBIAS, conv.d);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x000000ff);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         conv.f = 0.2f;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DEPTHBIAS, conv.d);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x00ffffff);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         conv.f = 0.4f;
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DEPTHBIAS, conv.d);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 61, 240);
         ok(color_match(color, 0x00ffffff, 1), "Got unexpected color %08x at x=62, format %u.\n", color, formats[i]);
@@ -22355,15 +22297,15 @@ static void test_depthbias(void)
         ok(color_match(color, 0x00000000, 1), "Got unexpected color %08x at x=446, format %u.\n", color, formats[i]);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         IDirect3DSurface9_Release(ds);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D9_Release(d3d);
@@ -22373,13 +22315,12 @@ done:
 static void test_flip(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
     ULONG refcount;
     HWND window;
     HRESULT hr;
     IDirect3DSurface9 *back_buffers[3], *test_surface;
-    unsigned int i;
-    D3DCOLOR color;
     D3DPRESENT_PARAMETERS present_parameters = {0};
 
     window = create_window();
@@ -22406,29 +22347,29 @@ static void test_flip(void)
     for (i = 0; i < ARRAY_SIZE(back_buffers); ++i)
     {
         hr = IDirect3DDevice9_GetBackBuffer(device, 0, i, D3DBACKBUFFER_TYPE_MONO, &back_buffers[i]);
-        ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
     }
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &test_surface);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     ok(test_surface == back_buffers[0], "Expected render target %p, got %p.\n", back_buffers[0], test_surface);
     IDirect3DSurface9_Release(test_surface);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, back_buffers[2]);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_ColorFill(device, back_buffers[0], NULL, 0xffff0000);
-    ok(SUCCEEDED(hr), "Failed to color fill, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to color fill, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_ColorFill(device, back_buffers[1], NULL, 0xff00ff00);
-    ok(SUCCEEDED(hr), "Failed to color fill, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to color fill, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx\n", hr);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     /* Render target is unmodified. */
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &test_surface);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     ok(test_surface == back_buffers[2], "Expected render target %p, got %p.\n", back_buffers[2], test_surface);
     IDirect3DSurface9_Release(test_surface);
 
@@ -22436,7 +22377,7 @@ static void test_flip(void)
     for (i = 0; i < ARRAY_SIZE(back_buffers); ++i)
     {
         hr = IDirect3DDevice9_GetBackBuffer(device, 0, i, D3DBACKBUFFER_TYPE_MONO, &test_surface);
-        ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
         ok(test_surface == back_buffers[i], "Expected back buffer %u = %p, got %p.\n",
                 i, back_buffers[i], test_surface);
         IDirect3DSurface9_Release(test_surface);
@@ -22449,10 +22390,10 @@ static void test_flip(void)
     ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff808080, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx\n", hr);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     color = getPixelColorFromSurface(back_buffers[0], 1, 1);
     ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
@@ -22460,7 +22401,7 @@ static void test_flip(void)
     ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     color = getPixelColorFromSurface(back_buffers[0], 1, 1);
     ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
@@ -22469,7 +22410,7 @@ static void test_flip(void)
         IDirect3DSurface9_Release(back_buffers[i]);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     if (FAILED(IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES, NULL)))
@@ -22487,22 +22428,22 @@ static void test_flip(void)
     for (i = 0; i < present_parameters.BackBufferCount; ++i)
     {
         hr = IDirect3DDevice9_GetBackBuffer(device, 0, i, D3DBACKBUFFER_TYPE_MONO, &back_buffers[i]);
-        ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, back_buffers[1]);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff808080, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, TRUE, &test_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_StretchRect(device, back_buffers[0], NULL, test_surface, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
 
     color = getPixelColorFromSurface(test_surface, 1, 1);
     ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
@@ -22512,7 +22453,7 @@ static void test_flip(void)
         IDirect3DSurface9_Release(back_buffers[i]);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D9_Release(d3d);
@@ -22717,10 +22658,9 @@ static void test_uninitialized_varyings(void)
     struct surface_readback rb;
     IDirect3DVertexShader9 *vs;
     IDirect3DPixelShader9 *ps;
-    unsigned int i;
+    unsigned int color, i;
     ULONG refcount;
     D3DCAPS9 caps;
-    D3DCOLOR color;
     BOOL warp;
 
     window = create_window();
@@ -22735,34 +22675,34 @@ static void test_uninitialized_varyings(void)
     }
 
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     warp = adapter_is_warp(&identifier);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -22775,7 +22715,7 @@ static void test_uninitialized_varyings(void)
         if (tests[i].vs)
         {
             hr = IDirect3DDevice9_CreateVertexShader(device, tests[i].vs, &vs);
-            ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x (case %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx (case %u).\n", hr, i);
         }
         else
         {
@@ -22784,7 +22724,7 @@ static void test_uninitialized_varyings(void)
         if (tests[i].ps)
         {
             hr = IDirect3DDevice9_CreatePixelShader(device, tests[i].ps, &ps);
-            ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x (case %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx (case %u).\n", hr, i);
         }
         else
         {
@@ -22792,21 +22732,21 @@ static void test_uninitialized_varyings(void)
         }
 
         hr = IDirect3DDevice9_SetVertexShader(device, vs);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, ps);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         get_rt_readback(backbuffer, &rb);
         color = get_readback_color(&rb, 320, 240);
@@ -22824,11 +22764,11 @@ static void test_uninitialized_varyings(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -22836,13 +22776,12 @@ static void test_uninitialized_varyings(void)
 static void test_multisample_init(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color, x, y;
     IDirect3D9 *d3d;
     IDirect3DSurface9 *back, *multi;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    D3DCOLOR color;
-    unsigned int x, y;
     struct surface_readback rb;
     BOOL all_zero = TRUE;
 
@@ -22864,13 +22803,13 @@ static void test_multisample_init(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &back);
-    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &multi, NULL);
-    ok(SUCCEEDED(hr), "Failed to create multisampled render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create multisampled render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, multi, NULL, back, NULL, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "StretchRect failed, hr %#lx.\n", hr);
 
     get_rt_readback(back, &rb);
     for (y = 0; y < 480; ++y)
@@ -22894,7 +22833,7 @@ static void test_multisample_init(void)
     IDirect3DSurface9_Release(back);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D9_Release(d3d);
@@ -22934,53 +22873,53 @@ static void test_depth_stencil_init(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == S_OK, "Failed to set render state, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(hr == S_OK, "Failed to set render state, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(hr == S_OK, "Failed to set render state, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == S_OK, "Failed to set color op, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(hr == S_OK, "Failed to set color arg, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == S_OK, "Failed to set FVF, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8, 0, 0, FALSE, &ds[0], NULL);
-    ok(hr == S_OK, "Failed to create depth stencil surface, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to create depth stencil surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds[1]);
-    ok(hr == S_OK, "Failed to get depth stencil surface, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to get depth stencil surface, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(ds); ++i)
     {
         hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds[i]);
-        ok(hr == S_OK, "Failed to set depth stencil surface, hr %#x.\n", hr);
+        ok(hr == S_OK, "Failed to set depth stencil surface, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == S_OK, "Failed to clear, hr %#x.\n", hr);
+        ok(hr == S_OK, "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == S_OK, "Failed to begin scene, hr %#x.\n", hr);
+        ok(hr == S_OK, "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x000000ff);
-        ok(hr == S_OK, "Failed to set render state, hr %#x.\n", hr);
+        ok(hr == S_OK, "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(hr == S_OK, "Failed to draw, hr %#x.\n", hr);
+        ok(hr == S_OK, "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == S_OK, "Failed to end scene, hr %#x.\n", hr);
+        ok(hr == S_OK, "Failed to end scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
-        ok(hr == S_OK, "Failed to get render target, hr %#x.\n", hr);
+        ok(hr == S_OK, "Failed to get render target, hr %#lx.\n", hr);
         check_rt_color(rt, 0x000000ff);
         IDirect3DSurface9_Release(rt);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Failed to present, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to present, hr %#lx.\n", hr);
 
         IDirect3DSurface9_Release(ds[i]);
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D9_Release(d3d);
@@ -22994,12 +22933,11 @@ static void test_texture_blending(void)
 
     IDirect3DTexture9 *texture_bumpmap, *texture_red;
     IDirect3DSurface9 *backbuffer;
+    unsigned int color, i, j, k;
     struct surface_readback rb;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice9 *device;
-    unsigned int i, j, k;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -23067,7 +23005,7 @@ static void test_texture_blending(void)
     const struct test
     {
         DWORD tex_op_caps;
-        D3DCOLOR expected_color;
+        unsigned int expected_color;
         struct texture_stage stage[8];
     }
     tests[] =
@@ -23678,7 +23616,7 @@ static void test_texture_blending(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed hr %#lx.\n", hr);
 
     if(!(caps.PrimitiveMiscCaps & D3DPMISCCAPS_TSSARGTEMP))
     {
@@ -23703,31 +23641,31 @@ static void test_texture_blending(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Can't get back buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Can't get back buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_V8U8, D3DPOOL_MANAGED, &texture_bumpmap, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture_red, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr %#lx.\n", hr);
 
     memset(&locked_rect, 0, sizeof(locked_rect));
     hr = IDirect3DTexture9_LockRect(texture_bumpmap, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "LockRect failed, hr %#lx.\n", hr);
     *((WORD *)locked_rect.pBits) = 0xff00;
     hr = IDirect3DTexture9_UnlockRect(texture_bumpmap, 0);
-    ok(SUCCEEDED(hr), "UnlockRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "UnlockRect failed, hr %#lx.\n", hr);
 
     memset(&locked_rect, 0, sizeof(locked_rect));
     hr = IDirect3DTexture9_LockRect(texture_red, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "LockRect failed, hr %#lx.\n", hr);
     *((DWORD *)locked_rect.pBits) = 0x00ff0000;
     hr = IDirect3DTexture9_UnlockRect(texture_red, 0);
-    ok(SUCCEEDED(hr), "UnlockRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "UnlockRect failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Failed to disable lighting, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to disable lighting, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -23735,7 +23673,7 @@ static void test_texture_blending(void)
 
         if ((caps.TextureOpCaps & current_test->tex_op_caps) != current_test->tex_op_caps)
         {
-            skip("Texture operations %#x not supported.\n", current_test->tex_op_caps);
+            skip("Texture operations %#lx not supported.\n", current_test->tex_op_caps);
             continue;
         }
 
@@ -23747,7 +23685,7 @@ static void test_texture_blending(void)
             {
                 hr = IDirect3DDevice9_SetTextureStageState(device, j,
                         default_stage_state.state[k].name, default_stage_state.state[k].value);
-                ok(SUCCEEDED(hr), "Test %u: SetTextureStageState failed, hr %#x.\n", i, hr);
+                ok(SUCCEEDED(hr), "Test %u: SetTextureStageState failed, hr %#lx.\n", i, hr);
             }
 
             if (current_test->stage[j].texture != TEXTURE_INVALID)
@@ -23771,23 +23709,23 @@ static void test_texture_blending(void)
                 {
                     hr = IDirect3DDevice9_SetTextureStageState(device, j,
                             current_state[k].name, current_state[k].value);
-                    ok(SUCCEEDED(hr), "Test %u: SetTextureStageState failed, hr %#x.\n", i, hr);
+                    ok(SUCCEEDED(hr), "Test %u: SetTextureStageState failed, hr %#lx.\n", i, hr);
                 }
             }
 
             hr = IDirect3DDevice9_SetTexture(device, j, (IDirect3DBaseTexture9 *)current_texture);
-            ok(SUCCEEDED(hr), "Test %u: SetTexture failed, hr %#x.\n", i, hr);
+            ok(SUCCEEDED(hr), "Test %u: SetTexture failed, hr %#lx.\n", i, hr);
         }
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-        ok(hr == D3D_OK, "Test %u: IDirect3DDevice9_Clear failed, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: IDirect3DDevice9_Clear failed, hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Test %u: BeginScene failed, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: BeginScene failed, hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
-        ok(SUCCEEDED(hr), "Test %u: DrawPrimitiveUP failed, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: DrawPrimitiveUP failed, hr %#lx.\n", i, hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Test %u: EndScene failed, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: EndScene failed, hr %#lx.\n", i, hr);
 
         get_rt_readback(backbuffer, &rb);
         color = get_readback_color(&rb, 320, 240);
@@ -23795,14 +23733,14 @@ static void test_texture_blending(void)
                 "Test %u: Got color 0x%08x, expected 0x%08x.\n", i, color, current_test->expected_color);
         release_surface_readback(&rb);
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Test %u: Present failed, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Present failed, hr %#lx.\n", i, hr);
     }
 
     IDirect3DTexture9_Release(texture_bumpmap);
     IDirect3DTexture9_Release(texture_red);
     IDirect3DSurface9_Release(backbuffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -23908,10 +23846,9 @@ static void test_color_clamping(void)
     IDirect3DVertexShader9 *vs;
     IDirect3DPixelShader9 *ps;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d9;
-    unsigned int i;
     ULONG refcount;
-    D3DCOLOR color;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
@@ -23928,44 +23865,44 @@ static void test_color_clamping(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0xff404040);
-    ok(SUCCEEDED(hr), "Failed to set texture factor, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture factor, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_MODULATE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -23978,7 +23915,7 @@ static void test_color_clamping(void)
         if (tests[i].vs)
         {
             hr = IDirect3DDevice9_CreateVertexShader(device, tests[i].vs, &vs);
-            ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x (case %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx (case %u).\n", hr, i);
         }
         else
         {
@@ -23987,7 +23924,7 @@ static void test_color_clamping(void)
         if (tests[i].ps)
         {
             hr = IDirect3DDevice9_CreatePixelShader(device, tests[i].ps, &ps);
-            ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x (case %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx (case %u).\n", hr, i);
         }
         else
         {
@@ -23995,21 +23932,21 @@ static void test_color_clamping(void)
         }
 
         hr = IDirect3DDevice9_SetVertexShader(device, vs);
-        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, ps);
-        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = getPixelColor(device, 320, 240);
         ok(color_match(color, tests[i].expected, 1) || broken(color_match(color, tests[i].broken, 1)),
@@ -24022,10 +23959,10 @@ static void test_color_clamping(void)
     }
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -24033,9 +23970,9 @@ static void test_color_clamping(void)
 static void test_line_antialiasing_blending(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d9;
     ULONG refcount;
-    D3DCOLOR color;
     D3DCAPS9 caps;
     HWND window;
     HRESULT hr;
@@ -24077,111 +24014,111 @@ static void test_line_antialiasing_blending(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
-    trace("Line antialiasing support: %#x.\n", caps.LineCaps & D3DLINECAPS_ANTIALIAS);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
+    trace("Line antialiasing support: %#lx.\n", caps.LineCaps & D3DLINECAPS_ANTIALIAS);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable blending, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable blending, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_BLENDOP, D3DBLENDOP_ADD);
-    ok(SUCCEEDED(hr), "Failed to set blend op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set blend op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set src blend, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set src blend, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_DESTALPHA);
-    ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, green_quad, sizeof(*green_quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, red_quad, sizeof(*red_quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable blending, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable blending, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, green_quad, sizeof(*green_quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, red_quad, sizeof(*red_quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ANTIALIASEDLINEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable line antialiasing, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable line antialiasing, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, green_quad, sizeof(*green_quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, red_quad, sizeof(*red_quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -24225,10 +24162,10 @@ static void test_dsy(void)
     IDirect3DVertexShader9 *vs;
     IDirect3DPixelShader9 *ps;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -24242,7 +24179,7 @@ static void test_dsy(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0))
     {
         skip("No ps_3_0 support, skipping dsy tests.\n");
@@ -24251,55 +24188,55 @@ static void test_dsy(void)
     }
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create offscreen render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create offscreen render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vs);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vs);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 360, 240);
     ok(color_match(color, 0x00ff007f, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw primitive, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 360, 240);
     ok(color_match(color, 0x00ff007f, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present frame, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present frame, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(rt);
     IDirect3DSurface9_Release(backbuffer);
@@ -24307,7 +24244,7 @@ static void test_dsy(void)
     IDirect3DPixelShader9_Release(ps);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -24318,9 +24255,9 @@ static void test_evict_bound_resources(void)
     IDirect3DVertexBuffer9 *vb;
     IDirect3DIndexBuffer9 *ib;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d9;
     ULONG refcount;
-    D3DCOLOR color;
     HWND window;
     void *data;
     HRESULT hr;
@@ -24353,68 +24290,68 @@ static void test_evict_bound_resources(void)
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0,
             D3DFMT_INDEX16, D3DPOOL_MANAGED, &ib, NULL);
-    ok(SUCCEEDED(hr), "Failed to create index buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create index buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(green_quad), 0,
             D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DPOOL_MANAGED, &vb, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(green_quad), &data, 0);
-    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, green_quad, sizeof(green_quad));
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DIndexBuffer9_Lock(ib, 0, sizeof(indices), &data, 0);
-    ok(hr == D3D_OK, "Failed to lock index buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock index buffer, hr %#lx.\n", hr);
     memcpy(data, indices, sizeof(indices));
     hr = IDirect3DIndexBuffer9_Unlock(ib);
-    ok(hr == D3D_OK, "Failed to unlock index buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock index buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetIndices(device, ib);
-    ok(hr == D3D_OK, "Failed to set index buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set index buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(*green_quad));
-    ok(hr == D3D_OK, "Failed to set stream source, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set stream source, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_EvictManagedResources(device);
-    ok(hr == D3D_OK, "Failed to evict managed resources, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to evict managed resources, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
 
     IDirect3DIndexBuffer9_Release(ib);
     IDirect3DVertexBuffer9_Release(vb);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -24442,9 +24379,9 @@ static void test_max_index16(void)
     IDirect3DIndexBuffer9 *ib;
     IDirect3DDevice9 *device;
     struct vertex *vb_data;
+    unsigned int color;
     IDirect3D9 *d3d9;
     ULONG refcount;
-    D3DCOLOR color;
     D3DCAPS9 caps;
     HWND window;
     void *data;
@@ -24456,7 +24393,7 @@ static void test_max_index16(void)
     ok(!!d3d9, "Failed to create a D3D object.\n");
 
     hr = IDirect3D9_GetAdapterIdentifier(d3d9, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     warp = adapter_is_warp(&identifier);
 
     if (!(device = create_device(d3d9, window, window, TRUE)))
@@ -24468,10 +24405,10 @@ static void test_max_index16(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.MaxVertexIndex < 0xffff)
     {
-        skip("Max vertex index is lower than 0xffff (%#x).\n", caps.MaxVertexIndex);
+        skip("Max vertex index is lower than 0xffff (%#lx).\n", caps.MaxVertexIndex);
         IDirect3DDevice9_Release(device);
         IDirect3D9_Release(d3d9);
         DestroyWindow(window);
@@ -24480,50 +24417,50 @@ static void test_max_index16(void)
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, vertex_count * sizeof(*green_quad), 0,
             D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DPOOL_MANAGED, &vb, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0,
             D3DFMT_INDEX16, D3DPOOL_MANAGED, &ib, NULL);
-    ok(SUCCEEDED(hr), "Failed to create index buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create index buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(green_quad), (void **)&vb_data, 0);
-    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#lx.\n", hr);
     vb_data[0] = green_quad[0];
     vb_data[1] = green_quad[1];
     vb_data[2] = green_quad[2];
     vb_data[0xffff] = green_quad[3];
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DIndexBuffer9_Lock(ib, 0, sizeof(indices), &data, 0);
-    ok(hr == D3D_OK, "Failed to lock index buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock index buffer, hr %#lx.\n", hr);
     memcpy(data, indices, sizeof(indices));
     hr = IDirect3DIndexBuffer9_Unlock(ib);
-    ok(hr == D3D_OK, "Failed to unlock index buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock index buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetIndices(device, ib);
-    ok(hr == D3D_OK, "Failed to set index buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set index buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(struct vertex));
-    ok(hr == D3D_OK, "Failed to set stream source, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set stream source, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 0, vertex_count, 0, 2);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 20, 20);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
     color = getPixelColor(device, 320, 240);
@@ -24534,7 +24471,7 @@ static void test_max_index16(void)
     IDirect3DIndexBuffer9_Release(ib);
     IDirect3DVertexBuffer9_Release(vb);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d9);
     DestroyWindow(window);
 }
@@ -24544,8 +24481,8 @@ static void test_backbuffer_resize(void)
     D3DPRESENT_PARAMETERS present_parameters = {0};
     IDirect3DSurface9 *backbuffer;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -24575,16 +24512,16 @@ static void test_backbuffer_resize(void)
     /* Wine d3d9 implementation had a bug which was triggered by a
      * SetRenderTarget() call with an unreferenced surface. */
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     refcount = IDirect3DSurface9_Release(backbuffer);
-    ok(!refcount, "Surface has %u references left.\n", refcount);
+    ok(!refcount, "Surface has %lu references left.\n", refcount);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     color = getPixelColor(device, 1, 1);
     ok(color == 0x00ff0000, "Got unexpected color 0x%08x.\n", color);
 
@@ -24597,43 +24534,43 @@ static void test_backbuffer_resize(void)
     present_parameters.EnableAutoDepthStencil = TRUE;
     present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
     hr = IDirect3DDevice9_Reset(device, &present_parameters);
-    ok(SUCCEEDED(hr), "Failed to reset, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to reset, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     IDirect3DSurface9_Release(backbuffer);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     color = getPixelColor(device, 1, 1);
     ok(color == 0x00ffff00, "Got unexpected color 0x%08x.\n", color);
     color = getPixelColor(device, 700, 500);
     ok(color == 0x00ffff00, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 1, 1);
     ok(color == 0x0000ff00, "Got unexpected color 0x%08x.\n", color);
     color = getPixelColor(device, 700, 500);
     ok(color == 0x0000ff00, "Got unexpected color 0x%08x.\n", color);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -24662,9 +24599,9 @@ static void test_drawindexedprimitiveup(void)
     IDirect3DVertexBuffer9 *vb;
     IDirect3DDevice9 *device;
     UINT offset, stride;
+    unsigned int color;
     IDirect3D9 *d3d;
     ULONG refcount;
-    D3DCOLOR color;
     HWND window;
     HRESULT hr;
 
@@ -24681,24 +24618,24 @@ static void test_drawindexedprimitiveup(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 4, 4, 2, indices + 4, D3DFMT_INDEX16, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 120);
     ok(color_match(color, 0x0040bf00, 1), "Got unexpected color 0x%08x.\n", color);
@@ -24710,20 +24647,20 @@ static void test_drawindexedprimitiveup(void)
     ok(color_match(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_GetStreamSource(device, 0, &vb, &offset, &stride);
-    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#lx.\n", hr);
     ok(!vb, "Unexpected vb %p.\n", vb);
     ok(!offset, "Unexpected offset %u.\n", offset);
     ok(!stride, "Unexpected stride %u.\n", stride);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 0, 4, 2, indices, D3DFMT_INDEX16, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 120);
     ok(color_match(color, 0x004000bf, 1), "Got unexpected color 0x%08x.\n", color);
@@ -24735,7 +24672,7 @@ static void test_drawindexedprimitiveup(void)
     ok(color_match(color, 0x00bf0040, 1), "Got unexpected color 0x%08x.\n", color);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -24779,9 +24716,9 @@ static void test_vertex_texture(void)
     IDirect3DVertexShader9 *vs;
     IDirect3DPixelShader9 *ps;
     IDirect3DDevice9 *device;
+    unsigned int color;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -24800,7 +24737,7 @@ static void test_vertex_texture(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(3, 0) || caps.PixelShaderVersion < D3DPS_VERSION(3, 0))
     {
         skip("SM3 is not supported.\n");
@@ -24809,51 +24746,51 @@ static void test_vertex_texture(void)
     if (!(caps.VertexTextureFilterCaps & D3DPTFILTERCAPS_MAGFPOINT)
             || !(caps.VertexTextureFilterCaps & D3DPTFILTERCAPS_MINFPOINT))
     {
-        skip("Vertex texture point filtering is not supported, caps %#x.\n", caps.VertexTextureFilterCaps);
+        skip("Vertex texture point filtering is not supported, caps %#lx.\n", caps.VertexTextureFilterCaps);
         goto done;
     }
     hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             D3DUSAGE_QUERY_VERTEXTEXTURE, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8);
     if (hr != D3D_OK)
     {
-        skip("No vertex texture fetch support for D3DFMT_A8R8G8B8, hr %#x.\n", hr);
+        skip("No vertex texture fetch support for D3DFMT_A8R8G8B8, hr %#lx.\n", hr);
         goto done;
     }
 
     hr = IDirect3DDevice9_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
-    ok(hr == D3D_OK, "Failed to create texture, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "Failed to lock texture, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock texture, hr %#lx.\n", hr);
     memcpy(lr.pBits, texture_data, sizeof(texture_data));
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "Failed to unlock texture, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, D3DVERTEXTEXTURESAMPLER0, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "Failed to set texture, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &declaration);
-    ok(SUCCEEDED(hr), "Failed to create vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex declaration, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vs);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, declaration);
-    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vs);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = getPixelColor(device, 160, 360);
     ok(color == texture_data[0], "Got unexpected color 0x%08x.\n", color);
 
@@ -24863,7 +24800,7 @@ static void test_vertex_texture(void)
     IDirect3DVertexDeclaration9_Release(declaration);
 done:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -24874,12 +24811,11 @@ static void test_mvp_software_vertex_shaders(void)
     D3DPRESENT_PARAMETERS present_parameters = {0};
     IDirect3DVertexShader9 *pure_sw_shader = NULL;
     IDirect3DVertexShader9 *reladdr_shader = NULL;
+    unsigned int color, expected_color;
     IDirect3DDevice9 *device;
-    DWORD expected_color;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -24946,7 +24882,7 @@ static void test_mvp_software_vertex_shaders(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
     {
         skip("No vs_2_0 support, skipping tests.\n");
@@ -24955,31 +24891,31 @@ static void test_mvp_software_vertex_shaders(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSoftwareVertexProcessing(device, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexShader(device, reladdr_shader_code, &reladdr_shader);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, pure_sw_shader_code, &pure_sw_shader);
     todo_wine
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShader(device, pure_sw_shader);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
     todo_wine
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     expected_color = 0; /* Nothing rendered. */
     color = getPixelColor(device, 5, 5);
@@ -24988,16 +24924,16 @@ static void test_mvp_software_vertex_shaders(void)
             expected_color, color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     expected_color = 0x00ff0000; /* Color from vertex data and not from the shader. */
     color = getPixelColor(device, 5, 5);
@@ -25005,18 +24941,18 @@ static void test_mvp_software_vertex_shaders(void)
             expected_color, color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSoftwareVertexProcessing(device, 1);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     expected_color = 0x00ffffff;
     color = getPixelColor(device, 5, 5);
@@ -25025,27 +24961,27 @@ static void test_mvp_software_vertex_shaders(void)
             expected_color, color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSoftwareVertexProcessing(device, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, reladdr_shader);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, c_index, 1);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShaderConstantF(device, (unsigned int)c_index[0], c_color, 1);
     todo_wine
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Index 256 is out of bounds for selected shader in HW mode. c[256] is 0 most of the time. It
        is not guaranteed across all the adapters though, so disabling test. */
@@ -25057,17 +24993,17 @@ static void test_mvp_software_vertex_shaders(void)
 #endif
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetSoftwareVertexProcessing(device, 1);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     expected_color = 0x0000ffff; /* c[256] is c_color for SW shader. */
     color = getPixelColor(device, 5, 5);
@@ -25080,7 +25016,7 @@ static void test_mvp_software_vertex_shaders(void)
     if (pure_sw_shader)
         IDirect3DVertexShader9_Release(pure_sw_shader);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -25121,8 +25057,7 @@ static void test_null_format(void)
     };
     static const struct
     {
-        unsigned int x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -25159,9 +25094,8 @@ static void test_null_format(void)
     IDirect3DSurface9 *original_ds, *small_ds;
     struct surface_readback rb;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     HWND window;
     HRESULT hr;
 
@@ -25186,98 +25120,98 @@ static void test_null_format(void)
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &original_rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 400, 300, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, 0, FALSE, &small_rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, null_fourcc,
             D3DMULTISAMPLE_NONE, 0, FALSE, &null_rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 400, 300, null_fourcc,
             D3DMULTISAMPLE_NONE, 0, FALSE, &small_null_rt, NULL);
-    ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDepthStencilSurface(device, &original_ds);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 400, 300, D3DFMT_D24S8, 0, 0, FALSE,
             &small_ds, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable depth test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable depth test, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "Failed to set depth function, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set depth function, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable depth write, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable depth write, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* Clear extends to viewport size > RT size even if format is not
      * "NULL". */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, small_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetViewport(device, &vp_full);
-    ok(hr == D3D_OK, "Failed to set viewport, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.2f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, null_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#lx.\n", hr);
 
     /* Draw only extends to viewport size > RT size if format is "NULL". */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, small_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetViewport(device, &vp_lower);
-    ok(hr == D3D_OK, "Failed to set viewport, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, small_null_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetViewport(device, &vp_560);
-    ok(hr == D3D_OK, "Failed to set viewport, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, original_rt);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_partial, sizeof(*quad_partial));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_far, sizeof(*quad_far));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     get_rt_readback(original_rt, &rb);
     for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
@@ -25292,33 +25226,33 @@ static void test_null_format(void)
     /* Clears and draws on a depth buffer smaller than the "NULL" RT work just
      * fine. */
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, null_rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, small_ds);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetViewport(device, &vp_full);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.6f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetViewport(device, &vp_part_400);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_partial, sizeof(*quad_partial));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, small_rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     get_rt_readback(small_rt, &rb);
     for (i = 0; i < ARRAY_SIZE(expected_small); ++i)
@@ -25331,9 +25265,9 @@ static void test_null_format(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice9_StretchRect(device, small_rt, NULL, original_rt, NULL, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(small_ds);
     IDirect3DSurface9_Release(original_ds);
@@ -25347,14 +25281,13 @@ static void test_null_format(void)
 
 static void test_map_synchronisation(void)
 {
+    unsigned int colour, i, j, tri_count, size;
     LARGE_INTEGER frequency, diff, ts[3];
-    unsigned int i, j, tri_count, size;
     D3DADAPTER_IDENTIFIER9 identifier;
     IDirect3DVertexBuffer9 *buffer;
     IDirect3DDevice9 *device;
     BOOL unsynchronised, ret;
     IDirect3D9 *d3d;
-    D3DCOLOR colour;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -25415,7 +25348,7 @@ static void test_map_synchronisation(void)
     }
 
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     /* Maps are always synchronised on WARP. */
     if (adapter_is_warp(&identifier))
     {
@@ -25424,12 +25357,12 @@ static void test_map_synchronisation(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     tri_count = 0x1000;
     if (tri_count > caps.MaxPrimitiveCount)
     {
-        skip("Device supports only %u primitives, skipping test.\n", caps.MaxPrimitiveCount);
+        skip("Device supports only %lu primitives, skipping test.\n", caps.MaxPrimitiveCount);
         goto done;
     }
     size = (tri_count + 2) * sizeof(*quad1.strip);
@@ -25439,32 +25372,32 @@ static void test_map_synchronisation(void)
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, size,
             D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(buffer, 0, size, (void **)&quads, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     for (j = 0; j < size / sizeof(*quads); ++j)
     {
         quads[j] = quad1;
     }
     hr = IDirect3DVertexBuffer9_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(*quads->strip));
-    ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
 
     /* Initial draw to initialise states, compile shaders, etc. */
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, tri_count);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     /* Read the result to ensure the GPU has finished drawing. */
     colour = getPixelColor(device, 320, 240);
 
@@ -25472,25 +25405,25 @@ static void test_map_synchronisation(void)
     ret = QueryPerformanceCounter(&ts[0]);
     ok(ret, "Failed to read performance counter.\n");
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, tri_count);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     colour = getPixelColor(device, 320, 240);
     /* Time drawing a single triangle. */
     ret = QueryPerformanceCounter(&ts[1]);
     ok(ret, "Failed to read performance counter.\n");
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 1);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     colour = getPixelColor(device, 320, 240);
     ret = QueryPerformanceCounter(&ts[2]);
     ok(ret, "Failed to read performance counter.\n");
@@ -25503,7 +25436,7 @@ static void test_map_synchronisation(void)
     tri_count = ((tri_count + 2 + 3) & ~3) - 2;
     if (tri_count > caps.MaxPrimitiveCount)
     {
-        skip("Would need to draw %u triangles, but the device only supports %u primitives.\n",
+        skip("Would need to draw %u triangles, but the device only supports %lu primitives.\n",
                 tri_count, caps.MaxPrimitiveCount);
         goto done;
     }
@@ -25513,36 +25446,36 @@ static void test_map_synchronisation(void)
     {
         hr = IDirect3DDevice9_CreateVertexBuffer(device, size,
                 D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &buffer, NULL);
-        ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
         hr = IDirect3DVertexBuffer9_Lock(buffer, 0, size, (void **)&quads, D3DLOCK_DISCARD);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         for (j = 0; j < size / sizeof(*quads); ++j)
         {
             quads[j] = quad1;
         }
         hr = IDirect3DVertexBuffer9_Unlock(buffer);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(*quads->strip));
-        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set stream source, hr %#lx.\n", hr);
 
         /* Start a draw operation. */
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, tri_count);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         /* Map the last quad while the draw is in progress. */
         hr = IDirect3DVertexBuffer9_Lock(buffer, size - sizeof(quad2),
                 sizeof(quad2), (void **)&quads, tests[i].flags);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         *quads = quad2;
         hr = IDirect3DVertexBuffer9_Unlock(buffer);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
         colour = getPixelColor(device, 320, 240);
         unsynchronised = color_match(colour, D3DCOLOR_ARGB(0x00, 0xff, 0xff, 0x00), 1);
@@ -25550,14 +25483,14 @@ static void test_map_synchronisation(void)
                 tests[i].unsynchronised ? "unsynchronised" : "synchronised", tests[i].flags);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
         IDirect3DVertexBuffer9_Release(buffer);
     }
 
 done:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -25565,10 +25498,9 @@ done:
 static void test_color_vertex(void)
 {
     IDirect3DDevice9 *device;
+    unsigned int colour, i;
     D3DMATERIAL9 material;
     IDirect3D9 *d3d;
-    D3DCOLOR colour;
-    unsigned int i;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -25582,7 +25514,8 @@ static void test_color_vertex(void)
      * in the struct will be fed into the specular vertex colour slot. */
     static const struct
     {
-        DWORD fvf, color_vertex, ambient, emissive, result;
+        DWORD fvf, color_vertex, ambient, emissive;
+        unsigned int result;
     }
     tests[] =
     {
@@ -25632,36 +25565,36 @@ static void test_color_vertex(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_AMBIENT, 0xffffffff);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     memset(&material, 0, sizeof(material));
     material.Ambient.b = 0.5f;
     material.Emissive.b = 0.25f;
     hr = IDirect3DDevice9_SetMaterial(device, &material);
-    ok(SUCCEEDED(hr), "Failed to set material, hr %#x\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material, hr %#lx\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORVERTEX, tests[i].color_vertex);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_AMBIENTMATERIALSOURCE, tests[i].ambient);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_EMISSIVEMATERIALSOURCE, tests[i].emissive);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | tests[i].fvf);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].result, 1),
@@ -25670,7 +25603,7 @@ static void test_color_vertex(void)
     }
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -25679,14 +25612,13 @@ static void test_sysmem_draw(void)
 {
     IDirect3DVertexBuffer9 *vb, *vb_s0, *vb_s1, *dst_vb, *get_vb;
     IDirect3DVertexDeclaration9 *vertex_declaration;
-    unsigned int i, offset, stride;
+    unsigned int colour, i, offset, stride;
     IDirect3DTexture9 *texture;
     IDirect3DIndexBuffer9 *ib;
     IDirect3DDevice9 *device;
     struct vec4 *dst_data;
     D3DLOCKED_RECT lr;
     IDirect3D9 *d3d;
-    D3DCOLOR colour;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -25751,41 +25683,41 @@ static void test_sysmem_draw(void)
     }
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), 0, 0, D3DPOOL_SYSTEMMEM, &vb, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(*quad));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = getPixelColor(device, 320, 240);
     ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, ARRAY_SIZE(quad) * sizeof(*dst_data),
             0, D3DFVF_XYZRHW, D3DPOOL_SYSTEMMEM, &dst_vb, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_ProcessVertices(device, 0, 0, ARRAY_SIZE(quad), dst_vb, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(dst_vb, 0, 0, (void **)&dst_data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < ARRAY_SIZE(quad); ++i)
     {
         ok(compare_vec4(&dst_data[i], quad[i].position.x * 320.0f + 320.0f,
@@ -25794,158 +25726,158 @@ static void test_sysmem_draw(void)
                 i, dst_data[i].x, dst_data[i].y, dst_data[i].z, dst_data[i].w);
     }
     hr = IDirect3DVertexBuffer9_Unlock(dst_vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0,
             D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DIndexBuffer9_Lock(ib, 0, sizeof(indices), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, indices, sizeof(indices));
     hr = IDirect3DIndexBuffer9_Unlock(ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetIndices(device, ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 0, 4, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = getPixelColor(device, 320, 240);
     ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad_s0), 0, 0, D3DPOOL_SYSTEMMEM, &vb_s0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb_s0, 0, sizeof(quad_s0), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad_s0, sizeof(quad_s0));
     hr = IDirect3DVertexBuffer9_Unlock(vb_s0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad_s1), 0, 0, D3DPOOL_SYSTEMMEM, &vb_s1, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb_s1, 0, sizeof(quad_s1), (void **)&data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad_s1, sizeof(quad_s1));
     hr = IDirect3DVertexBuffer9_Unlock(vb_s1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb_s0, 0, sizeof(*quad_s0));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 1, vb_s1, 0, sizeof(*quad_s1));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 0, 4, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = getPixelColor(device, 320, 240);
     ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 4, 0, 5, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = getPixelColor(device, 320, 240);
     ok(color_match(colour, 0x00443322, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     /* Test that releasing but not unbinding a vertex buffer doesn't break. */
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(*quad));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetIndices(device, ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DVertexBuffer9_Release(vb_s1);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
     hr = IDirect3DDevice9_GetStreamSource(device, 1, &get_vb, &offset, &stride);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     ok(get_vb == vb_s1, "Got unexpected vertex buffer %p.\n", get_vb);
     refcount = IDirect3DVertexBuffer9_Release(get_vb);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 0, 4, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = getPixelColor(device, 320, 240);
     ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb_s0, 0, sizeof(*quad_s0));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 0, 4, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = getPixelColor(device, 320, 240);
     ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
 
     hr = IDirect3DDevice9_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(lr.pBits, texture_data, sizeof(texture_data));
     hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-    ok(hr == D3D_OK || hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DTexture9_Release(texture);
     IDirect3DVertexBuffer9_Release(vb_s0);
@@ -25954,7 +25886,7 @@ static void test_sysmem_draw(void)
     IDirect3DVertexBuffer9_Release(dst_vb);
     IDirect3DVertexBuffer9_Release(vb);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -25964,11 +25896,9 @@ static void test_nrm_instruction(void)
     IDirect3DVertexDeclaration9 *vertex_declaration;
     IDirect3DVertexShader9 *vertex_shader;
     IDirect3DPixelShader9 *pixel_shader;
+    unsigned int body_size, colour, i;
     IDirect3DDevice9 *device;
-    unsigned int body_size;
     IDirect3D9 *d3d;
-    D3DCOLOR colour;
-    unsigned int i;
     DWORD *ps_code;
     ULONG refcount;
     D3DCAPS9 caps;
@@ -26085,7 +26015,7 @@ static void test_nrm_instruction(void)
         const DWORD *ops;
         DWORD body_size;
         struct vec4 c0;
-        D3DCOLOR expected_colour;
+        unsigned int expected_colour;
     }
     tests[] =
     {
@@ -26117,7 +26047,7 @@ static void test_nrm_instruction(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0) || caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No shader model 3 support, skipping tests.\n");
@@ -26135,17 +26065,17 @@ static void test_nrm_instruction(void)
     memcpy(ps_code, ps_header, sizeof(ps_header));
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vertex_shader);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vertex_shader);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -26153,19 +26083,19 @@ static void test_nrm_instruction(void)
         memcpy(ps_code + ARRAY_SIZE(ps_header) + tests[i].body_size, ps_footer, sizeof(ps_footer));
 
         hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &pixel_shader);
-        ok(hr == D3D_OK, "Got unexpected hr %#x, test %s.\n", hr, tests[i].name);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx, test %s.\n", hr, tests[i].name);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x80808080, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, pixel_shader);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, &tests[i].c0.x, 1);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         colour = getPixelColor(device, 320, 240);
         ok(color_match(colour, tests[i].expected_colour, 1),
@@ -26175,13 +26105,13 @@ static void test_nrm_instruction(void)
         IDirect3DPixelShader9_Release(pixel_shader);
     }
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     heap_free(ps_code);
     IDirect3DVertexShader9_Release(vertex_shader);
     IDirect3DVertexDeclaration9_Release(vertex_declaration);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -26190,8 +26120,8 @@ static void test_desktop_window(void)
 {
     IDirect3DVertexShader9 *shader;
     IDirect3DDevice9 *device;
+    unsigned int color;
     IDirect3D9 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -26224,22 +26154,22 @@ static void test_desktop_window(void)
     ok(!!device, "Failed to create a D3D device.\n");
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     color = getPixelColor(device, 1, 1);
     ok(color == 0x00ff0000, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     /* test device with NULL HWND */
     device = create_device(d3d, NULL, NULL, TRUE);
     ok(device != NULL, "Failed to create a D3D device\n");
 
     hr = IDirect3DDevice9_CreateVertexShader(device, simple_vs, &shader);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#lx.\n", hr);
     IDirect3DVertexShader9_Release(shader);
 
     IDirect3DDevice9_Release(device);
@@ -26280,9 +26210,8 @@ static void test_mismatched_sample_types(void)
     D3DLOCKED_RECT locked_rect;
     D3DLOCKED_BOX locked_box;
     IDirect3DDevice9 *device;
+    unsigned int colour, i;
     IDirect3D9 *d3d;
-    D3DCOLOR colour;
-    unsigned int i;
     ULONG refcount;
     D3DCAPS9 caps;
     HWND window;
@@ -26355,9 +26284,9 @@ static void test_mismatched_sample_types(void)
         const char *name;
         IDirect3DBaseTexture9 **texture;
         IDirect3DPixelShader9 **pixel_shader;
-        D3DCOLOR expected_colour;
-        D3DCOLOR expected_broken;
-        D3DCOLOR expected_broken2;
+        unsigned int expected_colour;
+        unsigned int expected_broken;
+        unsigned int expected_broken2;
     }
     tests[] =
     {
@@ -26381,7 +26310,7 @@ static void test_mismatched_sample_types(void)
     }
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (caps.PixelShaderVersion < D3DPS_VERSION(3, 0) || caps.VertexShaderVersion < D3DVS_VERSION(3, 0))
     {
         skip("No shader model 3 support, skipping tests.\n");
@@ -26395,36 +26324,36 @@ static void test_mismatched_sample_types(void)
 
     hr = IDirect3DDevice9_CreateVolumeTexture(device, 2, 2, 2, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_MANAGED, &volume, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVolumeTexture9_LockBox(volume, 0, &locked_box, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     test_mismatched_sample_types_fill_texture(locked_box.pBits, locked_box.RowPitch, 0x20202020, 2);
     test_mismatched_sample_types_fill_texture((DWORD *)((BYTE *)locked_box.pBits + locked_box.SlicePitch),
             locked_box.RowPitch, 0x40404040, 2);
     hr = IDirect3DVolumeTexture9_UnlockBox(volume, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_MANAGED, &tex_2d, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_LockRect(tex_2d, 0, &locked_rect, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     test_mismatched_sample_types_fill_texture(locked_rect.pBits, locked_rect.Pitch, 0x70707070, 2);
     hr = IDirect3DTexture9_UnlockRect(tex_2d, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vertex_shader);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetVertexShader(device, vertex_shader);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memcpy(ps_code, ps_header, sizeof(ps_header));
     memcpy(ps_code + ARRAY_SIZE(ps_header) + TEST_MISMATCHED_SAMPLE_BODY_WORDS, ps_footer, sizeof(ps_footer));
@@ -26432,32 +26361,32 @@ static void test_mismatched_sample_types(void)
     memcpy(ps_code + ARRAY_SIZE(ps_header), ps_tex_2d,
             sizeof(*ps_code) * TEST_MISMATCHED_SAMPLE_BODY_WORDS);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps_2d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memcpy(ps_code + ARRAY_SIZE(ps_header), ps_tex_3d,
             sizeof(*ps_code) * TEST_MISMATCHED_SAMPLE_BODY_WORDS);
     hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps_3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x80808080, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_SetTexture(device, 0, *tests[i].texture);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_SetPixelShader(device, *tests[i].pixel_shader);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         colour = getPixelColor(device, 320, 240);
 
@@ -26468,7 +26397,7 @@ static void test_mismatched_sample_types(void)
                 tests[i].name, tests[i].expected_colour, colour);
     }
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DPixelShader9_Release(ps_2d);
     IDirect3DPixelShader9_Release(ps_3d);
@@ -26480,7 +26409,7 @@ static void test_mismatched_sample_types(void)
 
 done:
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -26490,9 +26419,8 @@ static void test_draw_mapped_buffer(void)
     IDirect3DVertexBuffer9 *vb;
     IDirect3DIndexBuffer9 *ib;
     IDirect3DDevice9 *device;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     ULONG refcount;
     BOOL test_pass;
     HWND window;
@@ -26538,40 +26466,40 @@ static void test_draw_mapped_buffer(void)
     }
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0,
             D3DFMT_INDEX16, D3DPOOL_DEFAULT, &ib, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DIndexBuffer9_Lock(ib, 0, sizeof(indices), &data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, indices, sizeof(indices));
 
     hr = IDirect3DDevice9_SetIndices(device, ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), tests[i].usage,
                 D3DFVF_XYZ | D3DFVF_DIFFUSE, tests[i].pool, &vb, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad), &data, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memcpy(data, quad, sizeof(quad));
 
         hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad[0]));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 0, ARRAY_SIZE(quad), 0, 1);
-        ok(hr == D3D_OK, "Got unexpected hr %#x, test %u.\n", hr, i);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx, test %u.\n", hr, i);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = getPixelColor(device, 160, 120);
         ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x, test %u.\n", color, i);
@@ -26579,24 +26507,24 @@ static void test_draw_mapped_buffer(void)
         ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x, test %u.\n", color, i);
 
         hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer9_Unlock(vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* One more time now when buffer object in wined3d is already created. */
         hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad), &data, D3DLOCK_DISCARD);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memcpy(data, quad, sizeof(quad));
 
         hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 0, ARRAY_SIZE(quad), 0, 1);
-        ok(hr == D3D_OK, "Got unexpected hr %#x, test %u.\n", hr, i);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx, test %u.\n", hr, i);
         hr = IDirect3DDevice9_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = getPixelColor(device, 160, 120);
 
@@ -26608,16 +26536,16 @@ static void test_draw_mapped_buffer(void)
         ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x, test %u.\n", color, i);
 
         hr = IDirect3DVertexBuffer9_Unlock(vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         IDirect3DVertexBuffer9_Release(vb);
     }
 
     hr = IDirect3DIndexBuffer9_Unlock(ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DIndexBuffer9_Release(ib);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -26632,10 +26560,9 @@ static void test_sample_attached_rendertarget(void)
     IDirect3DPixelShader9 *ps;
     IDirect3DDevice9 *device;
     IDirect3DSurface9 *rt;
+    unsigned int color, i;
     IDirect3D9 *d3d;
-    unsigned int i;
     ULONG refcount;
-    D3DCOLOR color;
     BOOL is_warp;
     HWND window;
     HRESULT hr;
@@ -26674,7 +26601,7 @@ static void test_sample_attached_rendertarget(void)
     ok(!!d3d, "Failed to create a D3D object.\n");
 
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     is_warp = adapter_is_warp(&identifier);
 
     if (!(device = create_device(d3d, window, window, TRUE)))
@@ -26698,70 +26625,70 @@ static void test_sample_attached_rendertarget(void)
    }
 
     hr = IDirect3DDevice9_CreateQuery(device, D3DQUERYTYPE_EVENT, &event_query);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DQuery9_Issue(event_query, D3DISSUE_END);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), D3DUSAGE_DYNAMIC,
             D3DFVF_XYZ | D3DFVF_TEX1, D3DPOOL_DEFAULT, &vb, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(quad), &data, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer9_Unlock(vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad[0]));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x01010101, 0.0, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     check_rt_color(rt, 0x00010101);
 
     hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &ps);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetPixelShader(device, ps);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < 3; ++i)
     {
         wait_query(event_query);
 
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DQuery9_Issue(event_query, D3DISSUE_END);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = getPixelColor(device, 0, 0);
     if (is_warp || color == 0x00010101)
@@ -26778,7 +26705,7 @@ static void test_sample_attached_rendertarget(void)
     IDirect3DTexture9_Release(texture);
 
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
@@ -26806,10 +26733,10 @@ static void test_alpha_to_coverage(void)
     IDirect3DStateBlock9 *sb;
     IDirect3DDevice9 *device;
     DWORD quality_levels;
+    unsigned int colour;
     BOOL nvidia_mode;
     IDirect3D9 *d3d;
     ULONG refcount;
-    DWORD colour;
     HWND window;
     HRESULT hr;
 
@@ -26836,7 +26763,7 @@ static void test_alpha_to_coverage(void)
 
 
     hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     if (adapter_is_amd(&identifier))
     {
@@ -26851,7 +26778,7 @@ static void test_alpha_to_coverage(void)
         {
             win_skip("Alpha to coverage is not supported.\n");
             refcount = IDirect3DDevice9_Release(device);
-            ok(!refcount, "Device has %u references left.\n", refcount);
+            ok(!refcount, "Device has %lu references left.\n", refcount);
             IDirect3D9_Release(d3d);
             DestroyWindow(window);
             return;
@@ -26861,70 +26788,70 @@ static void test_alpha_to_coverage(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &ms_rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, ms_rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8,
             D3DPOOL_DEFAULT, &texture, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     fill_surface(surface, 0xff2000ff, 0);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     if (nvidia_mode)
     {
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_Y, MAKEFOURCC('A','T','O','C'));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* While undocumented, Nvidia also requires to enable alpha test to enable
          * alpha to coverage. Intel does not. */
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHATESTENABLE, TRUE);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
     else
     {
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, MAKEFOURCC('A','2','M','1'));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &sb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     fill_surface(surface, 0x40608000, 0);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     get_rt_readback(rt, &rb);
     colour = get_readback_color(&rb, 64, 64);
 
@@ -26936,35 +26863,35 @@ static void test_alpha_to_coverage(void)
     if (nvidia_mode)
     {
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_Y, D3DFMT_UNKNOWN);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
     else
     {
         hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, MAKEFOURCC('A','2','M','0'));
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     get_rt_readback(rt, &rb);
     colour = get_readback_color(&rb, 64, 64);
     ok(colour == 0x40608000, "Got unexpected colour %08x.\n", colour);
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff2000ff, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DStateBlock9_Apply(sb);
     IDirect3DStateBlock9_Release(sb);
 
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     get_rt_readback(rt, &rb);
     colour = get_readback_color(&rb, 64, 64);
     ok(color_match(colour, 0x9f404080, 1) || color_match(colour, 0x9f485cbc, 1) /* Nvidia */,
@@ -26972,16 +26899,16 @@ static void test_alpha_to_coverage(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(surface);
     IDirect3DTexture9_Release(texture);
     IDirect3DSurface9_Release(ms_rt);
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -26991,9 +26918,9 @@ static void test_sample_mask(void)
     IDirect3DSurface9 *rt, *ms_rt;
     struct surface_readback rb;
     IDirect3DDevice9 *device;
+    unsigned int colour;
     IDirect3D9 *d3d;
     ULONG refcount;
-    DWORD colour;
     HWND window;
     HRESULT hr;
 
@@ -27033,33 +26960,33 @@ static void test_sample_mask(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &ms_rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderTarget(device, 0, ms_rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_MULTISAMPLEMASK, 0x5);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, D3DTEXF_POINT);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     get_rt_readback(rt, &rb);
     colour = get_readback_color(&rb, 64, 64);
     /* Multiple generations of Nvidia cards return broken results.
@@ -27074,12 +27001,12 @@ static void test_sample_mask(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface9_Release(ms_rt);
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -27131,62 +27058,62 @@ static void test_dynamic_map_synchronization(void)
 
     hr = IDirect3DDevice9_CreateVertexBuffer(device, 200 * 4 * sizeof(struct dynamic_vb_vertex),
             D3DUSAGE_DYNAMIC, D3DFVF_XYZ, D3DPOOL_DEFAULT, &buffer, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(struct dynamic_vb_vertex));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (y = 0; y < 200; ++y)
     {
         hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &data, D3DLOCK_DISCARD);
-        ok(hr == D3D_OK, "Failed to map buffer, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to map buffer, hr %#lx.\n", hr);
 
         fill_dynamic_vb_quad(data, 0, y);
 
         hr = IDirect3DVertexBuffer9_Unlock(buffer);
-        ok(hr == D3D_OK, "Failed to map buffer, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to map buffer, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         for (x = 1; x < 200; ++x)
         {
             hr = IDirect3DVertexBuffer9_Lock(buffer, 4 * sizeof(struct dynamic_vb_vertex) * x,
                     4 * sizeof(struct dynamic_vb_vertex), &data, D3DLOCK_NOOVERWRITE);
-            ok(hr == D3D_OK, "Failed to map buffer, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Failed to map buffer, hr %#lx.\n", hr);
 
             fill_dynamic_vb_quad(data, x, y);
 
             hr = IDirect3DVertexBuffer9_Unlock(buffer);
-            ok(hr == D3D_OK, "Failed to map buffer, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Failed to map buffer, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 4 * x, 2);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         }
     }
 
     hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
-    ok(hr == S_OK, "Failed to get render target, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to get render target, hr %#lx.\n", hr);
     check_rt_color(rt, 0x0000ff00);
     IDirect3DSurface9_Release(rt);
 
     hr = IDirect3DDevice9_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer9_Release(buffer);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -27198,12 +27125,11 @@ static void test_filling_convention(void)
     static const DWORD colour_right = 0x00000000;
     static const DWORD colour_left = 0x00ff0000;
     static const DWORD colour_top = 0x0000ff00;
+    unsigned int colour, expected, i, j, x, y;
     IDirect3DSurface9 *rt, *backbuffer, *cur;
     IDirect3DVertexShader9 *shader = NULL;
     struct surface_readback rb;
     IDirect3DDevice9 *device;
-    unsigned int i, j, x, y;
-    DWORD colour, expected;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCAPS9 caps;
@@ -27572,24 +27498,24 @@ static void test_filling_convention(void)
 
     hr = IDirect3DDevice9_CreateRenderTarget(device, vp_size, vp_size,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (caps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
     {
         hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &shader);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
     else
         skip("Skipping vertex shader codepath in filling convention test.\n");
 
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     if (device_is_d3d10(device))
         eps = 1.0f / 512.0f;
@@ -27607,7 +27533,7 @@ static void test_filling_convention(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice9_SetFVF(device, tests[i].fvf);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* Run tests with shader and fixed function vertex processing if shaders are
          * supported. There's no point in running the XYZRHW tests with a VS though. */
@@ -27621,21 +27547,21 @@ static void test_filling_convention(void)
             cur = (j & 1) ? rt : backbuffer;
 
             hr = IDirect3DDevice9_SetVertexShader(device, (j & 2) ? NULL : shader);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_SetRenderTarget(device, 0, cur);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, colour_clear, 0.0f, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_SetViewport(device, &vp);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice9_BeginScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 4, tests[i].geometry, tests[i].stride);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice9_EndScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             get_rt_readback(cur, &rb);
             for (y = 0; y < 8; y++)
@@ -27684,10 +27610,10 @@ static void test_filling_convention(void)
             if (cur != backbuffer)
             {
                 hr = IDirect3DDevice9_StretchRect(device, rt, NULL, backbuffer, NULL, D3DTEXF_POINT);
-                ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+                ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             }
             hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         }
     }
 
@@ -27696,7 +27622,7 @@ static void test_filling_convention(void)
     IDirect3DSurface9_Release(backbuffer);
     IDirect3DSurface9_Release(rt);
     refcount = IDirect3DDevice9_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
@@ -27715,7 +27641,7 @@ START_TEST(visual)
 
     memset(&identifier, 0, sizeof(identifier));
     hr = IDirect3D9_GetAdapterIdentifier(d3d, 0, 0, &identifier);
-    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#lx.\n", hr);
     trace("Driver string: \"%s\"\n", identifier.Driver);
     trace("Description string: \"%s\"\n", identifier.Description);
     /* Only Windows XP's default VGA driver should have an empty description */
-- 
GitLab

https://gitlab.winehq.org/wine/wine/-/merge_requests/386



More information about the wine-devel mailing list