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

Zebediah Figura wine at gitlab.winehq.org
Wed Jul 6 22:46:05 CDT 2022


From: Zebediah Figura <zfigura at codeweavers.com>

---
 dlls/d3d8/tests/Makefile.in  |    1 -
 dlls/d3d8/tests/device.c     | 2538 +++++++++++++-------------
 dlls/d3d8/tests/stateblock.c |  118 +-
 dlls/d3d8/tests/visual.c     | 3262 +++++++++++++++++-----------------
 dlls/d3d9/tests/d3d9ex.c     |    3 +-
 5 files changed, 2934 insertions(+), 2988 deletions(-)

diff --git a/dlls/d3d8/tests/Makefile.in b/dlls/d3d8/tests/Makefile.in
index 39b7e8021a7..9b288b967a9 100644
--- a/dlls/d3d8/tests/Makefile.in
+++ b/dlls/d3d8/tests/Makefile.in
@@ -1,4 +1,3 @@
-EXTRADEFS = -DWINE_NO_LONG_TYPES
 TESTDLL   = d3d8.dll
 IMPORTS   = d3d8 user32 gdi32
 
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index cb1e83b64b3..d7c149f8154 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -267,7 +267,7 @@ static HRESULT reset_device(IDirect3DDevice8 *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) \
@@ -303,8 +303,8 @@ static HRESULT reset_device(IDirect3DDevice8 *device, const struct device_desc *
     { \
         void *container_ptr = (void *)0x1337c0d3; \
         hr = IDirect3DSurface8_GetContainer(obj, &iid, &container_ptr); \
-        ok(SUCCEEDED(hr) && container_ptr == expected, "GetContainer returned: hr %#08x, container_ptr %p. " \
-            "Expected hr %#08x, container_ptr %p\n", hr, container_ptr, S_OK, expected); \
+        ok(SUCCEEDED(hr) && container_ptr == expected, "GetContainer returned: hr %#08lx, container_ptr %p. " \
+            "Expected hr %#08lx, container_ptr %p\n", hr, container_ptr, S_OK, expected); \
         if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr); \
     }
 
@@ -316,9 +316,9 @@ static void check_mipmap_levels(IDirect3DDevice8 *device, UINT width, UINT heigh
 
     if (SUCCEEDED(hr)) {
         DWORD levels = IDirect3DBaseTexture8_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) IDirect3DBaseTexture8_Release( texture );
 }
@@ -346,7 +346,7 @@ static void test_mipmap_levels(void)
     check_mipmap_levels(device, 1, 1, 1);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -381,24 +381,24 @@ static void test_swapchain(void)
     backbuffer = (void *)0xdeadbeef;
     /* IDirect3DDevice8::GetBackBuffer crashes if a NULL output pointer is passed. */
     hr = IDirect3DDevice8_GetBackBuffer(device, 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);
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 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);
     IDirect3DSurface8_Release(backbuffer);
 
     /* The back buffer type value is ignored. */
     hr = IDirect3DDevice8_GetBackBuffer(device, 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);
     IDirect3DSurface8_Release(stereo_buffer);
     hr = IDirect3DDevice8_GetBackBuffer(device, 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);
     IDirect3DSurface8_Release(stereo_buffer);
     hr = IDirect3DDevice8_GetBackBuffer(device, 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);
     IDirect3DSurface8_Release(stereo_buffer);
 
@@ -410,56 +410,56 @@ static void test_swapchain(void)
     /* Create a bunch of swapchains */
     d3dpp.BackBufferCount = 0;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 */
         hr = IDirect3DSwapChain8_GetBackBuffer(swapchain3, 0, 0, NULL);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
         backbuffer = (void *) 0xdeadbeef;
         hr = IDirect3DSwapChain8_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) IDirect3DSurface8_Release(backbuffer);
 
         /* The back buffer type value is ignored. */
         hr = IDirect3DSwapChain8_GetBackBuffer(swapchain3, 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);
         IDirect3DSurface8_Release(stereo_buffer);
         hr = IDirect3DSwapChain8_GetBackBuffer(swapchain3, 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);
         IDirect3DSurface8_Release(stereo_buffer);
         hr = IDirect3DSwapChain8_GetBackBuffer(swapchain3, 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);
         IDirect3DSurface8_Release(stereo_buffer);
 
         backbuffer = (void *) 0xdeadbeef;
         hr = IDirect3DSwapChain8_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) IDirect3DSurface8_Release(backbuffer);
 
         backbuffer = (void *) 0xdeadbeef;
         hr = IDirect3DSwapChain8_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) IDirect3DSurface8_Release(backbuffer);
 
         backbuffer = (void *) 0xdeadbeef;
         hr = IDirect3DSwapChain8_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) IDirect3DSurface8_Release(backbuffer);
     }
@@ -467,32 +467,32 @@ static void test_swapchain(void)
     /* Check the back buffers of the swapchains */
     /* Swapchain 1, created with backbuffercount 0 */
     hr = IDirect3DSwapChain8_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, "Expected a non-NULL backbuffer.\n");
     if(backbuffer) IDirect3DSurface8_Release(backbuffer);
 
     backbuffer = (void *) 0xdeadbeef;
     hr = IDirect3DSwapChain8_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) IDirect3DSurface8_Release(backbuffer);
 
     /* Swapchain 2 - created with backbuffercount 1 */
     backbuffer = (void *) 0xdeadbeef;
     hr = IDirect3DSwapChain8_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) IDirect3DSurface8_Release(backbuffer);
 
     backbuffer = (void *) 0xdeadbeef;
     hr = IDirect3DSwapChain8_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) IDirect3DSurface8_Release(backbuffer);
 
     backbuffer = (void *) 0xdeadbeef;
     hr = IDirect3DSwapChain8_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) IDirect3DSurface8_Release(backbuffer);
 
@@ -504,34 +504,34 @@ static void test_swapchain(void)
     d3dpp.hDeviceWindow = window;
     d3dpp.BackBufferCount = 1;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window2);
@@ -589,7 +589,7 @@ static void test_refcount(void)
     IDirect3DDevice8_GetDeviceCaps(device, &caps);
 
     refcount = get_refcount((IUnknown *)device);
-    ok(refcount == 1, "Invalid device RefCount %d\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     CHECK_REFCOUNT(d3d, 2);
 
@@ -842,13 +842,13 @@ static void test_refcount(void)
         BYTE *data;
         /* Vertex buffers can be locked multiple times */
         hr = IDirect3DVertexBuffer8_Lock(pVertexBuffer, 0, 0, &data, 0);
-        ok(hr == D3D_OK, "IDirect3DVertexBuffer8::Lock failed with %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DVertexBuffer8_Lock(pVertexBuffer, 0, 0, &data, 0);
-        ok(hr == D3D_OK, "IDirect3DVertexBuffer8::Lock failed with %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DVertexBuffer8_Unlock(pVertexBuffer);
-        ok(hr == D3D_OK, "IDirect3DVertexBuffer8::Unlock failed with %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DVertexBuffer8_Unlock(pVertexBuffer);
-        ok(hr == D3D_OK, "IDirect3DVertexBuffer8::Unlock failed with %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     }
 
     /* The implicit render target is not freed if refcount reaches 0.
@@ -916,34 +916,34 @@ static void test_checkdevicemultisampletype(void)
 
     hr = IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_UNKNOWN, TRUE, D3DMULTISAMPLE_NONE);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             65536, TRUE, D3DMULTISAMPLE_NONE);
-    todo_wine ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_NONE);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, FALSE, D3DMULTISAMPLE_NONE);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* We assume D3DMULTISAMPLE_15_SAMPLES is never supported in practice. */
     hr = IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_15_SAMPLES);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, TRUE, 65536);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_DXT5, TRUE, D3DMULTISAMPLE_2_SAMPLES);
-    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
 
 cleanup:
     IDirect3D8_Release(d3d);
@@ -978,12 +978,12 @@ static void test_invalid_multisample(void)
             D3DFMT_X8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, FALSE, &rt);
     if (available)
     {
-        ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
         IDirect3DSurface8_Release(rt);
     }
     else
     {
-        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
     }
 
     /* We assume D3DMULTISAMPLE_15_SAMPLES is never supported in practice. */
@@ -993,16 +993,16 @@ static void test_invalid_multisample(void)
             D3DFMT_X8R8G8B8, D3DMULTISAMPLE_15_SAMPLES, FALSE, &rt);
     if (available)
     {
-        ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
         IDirect3DSurface8_Release(rt);
     }
     else
     {
-        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -1055,7 +1055,7 @@ static void test_cursor(void)
     }
 
     hr = IDirect3DDevice8_CreateImageSurface(device, 32, 32, D3DFMT_A8R8G8B8, &cursor);
-    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 = IDirect3DDevice8_ShowCursor(device, TRUE);
@@ -1067,10 +1067,10 @@ static void test_cursor(void)
 
     /* Fails */
     hr = IDirect3DDevice8_SetCursorProperties(device, 0, 0, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_SetCursorProperties returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetCursorProperties(device, 0, 0, cursor);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetCursorProperties returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(cursor);
 
@@ -1085,7 +1085,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 */
@@ -1099,7 +1099,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 */
@@ -1108,19 +1108,19 @@ static void test_cursor(void)
         width = cursor_sizes[test_idx].cx;
         height = cursor_sizes[test_idx].cy;
         hr = IDirect3DDevice8_CreateImageSurface(device, width, height, D3DFMT_A8R8G8B8, &cursor);
-        ok(hr == D3D_OK, "Test %u: CreateImageSurface failed, hr %#x.\n", test_idx, hr);
+        ok(hr == D3D_OK, "Test %u: CreateImageSurface failed, hr %#lx.\n", test_idx, hr);
         hr = IDirect3DDevice8_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);
         IDirect3DSurface8_Release(cursor);
     }
 
     refcount = IDirect3DDevice8_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;
@@ -1141,7 +1141,7 @@ static void test_cursor(void)
             }
 
             hr = IDirect3D8_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 */
@@ -1153,35 +1153,31 @@ static void test_cursor(void)
                 height *= 2;
 
             hr = IDirect3DDevice8_CreateImageSurface(device, width, height, D3DFMT_A8R8G8B8, &cursor);
-            ok(hr == D3D_OK, "Adapter %u test %u: CreateImageSurface failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: CreateImageSurface failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
             hr = IDirect3DDevice8_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);
             IDirect3DSurface8_Release(cursor);
 
             hr = IDirect3DDevice8_CreateImageSurface(device, width * 2, height, D3DFMT_A8R8G8B8,
                     &cursor);
-            ok(hr == D3D_OK, "Adapter %u test %u: CreateImageSurface failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: CreateImageSurface failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
             hr = IDirect3DDevice8_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);
             IDirect3DSurface8_Release(cursor);
 
             hr = IDirect3DDevice8_CreateImageSurface(device, width, height * 2, D3DFMT_A8R8G8B8,
                     &cursor);
-            ok(hr == D3D_OK, "Adapter %u test %u: CreateImageSurface failed, hr %#x.\n",
+            ok(hr == D3D_OK, "Adapter %u test %u: CreateImageSurface failed, hr %#lx.\n",
                     adapter_idx, test_idx, hr);
             hr = IDirect3DDevice8_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);
             IDirect3DSurface8_Release(cursor);
 
             refcount = IDirect3DDevice8_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:
@@ -1258,7 +1254,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;
     }
 
@@ -1278,9 +1274,9 @@ static void test_cursor_pos(void)
     }
 
     hr = IDirect3DDevice8_CreateImageSurface(device, 32, 32, D3DFMT_A8R8G8B8, &cursor);
-    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 = IDirect3DDevice8_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);
     IDirect3DSurface8_Release(cursor);
     ret = IDirect3DDevice8_ShowCursor(device, TRUE);
     ok(!ret, "Failed to show cursor, hr %#x.\n", ret);
@@ -1322,7 +1318,7 @@ 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 = IDirect3DDevice8_Release(device);
@@ -1352,12 +1348,12 @@ static void test_states(void)
     }
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZVISIBLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState(D3DRS_ZVISIBLE, TRUE) returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZVISIBLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState(D3DRS_ZVISIBLE, FALSE) returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -1373,7 +1369,7 @@ static void test_shader_versions(void)
     ok(!!d3d, "Failed to create a D3D object.\n");
 
     hr = IDirect3D8_GetDeviceCaps(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);
-    ok(SUCCEEDED(hr) || hr == D3DERR_NOTAVAILABLE, "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == D3DERR_NOTAVAILABLE, "Failed to get device caps, hr %#lx.\n", hr);
     IDirect3D8_Release(d3d);
     if (FAILED(hr))
     {
@@ -1382,9 +1378,9 @@ static void test_shader_versions(void)
     }
 
     ok(caps.VertexShaderVersion <= D3DVS_VERSION(1,1),
-            "Got unexpected VertexShaderVersion %#x.\n", caps.VertexShaderVersion);
+            "Got unexpected VertexShaderVersion %#lx.\n", caps.VertexShaderVersion);
     ok(caps.PixelShaderVersion <= D3DPS_VERSION(1,4),
-            "Got unexpected PixelShaderVersion %#x.\n", caps.PixelShaderVersion);
+            "Got unexpected PixelShaderVersion %#lx.\n", caps.PixelShaderVersion);
 }
 
 static void test_display_formats(void)
@@ -1455,7 +1451,7 @@ static void test_display_formats(void)
                 hr = IDirect3D8_CheckDeviceType(d3d8, 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);
             }
         }
@@ -1483,7 +1479,7 @@ static void test_display_modes(void)
     for (i = 0; i < max_modes; ++i)
     {
         res = IDirect3D8_EnumAdapterModes(d3d, D3DADAPTER_DEFAULT, i, &dmode);
-        ok(res==D3D_OK, "EnumAdapterModes returned %#08x for mode %u!\n", res, i);
+        ok(res==D3D_OK, "EnumAdapterModes returned %#08lx for mode %u!\n", res, i);
         if(res != D3D_OK)
             continue;
 
@@ -1555,7 +1551,7 @@ static void test_reset(void)
     ok(!!d3d8, "Failed to create a D3D object.\n");
 
     hr = IDirect3D8_GetAdapterDisplayMode(d3d8, D3DADAPTER_DEFAULT, &d3ddm);
-    ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
     adapter_mode_count = IDirect3D8_GetAdapterModeCount(d3d8, D3DADAPTER_DEFAULT);
     modes = HeapAlloc(GetProcessHeap(), 0, sizeof(*modes) * adapter_mode_count);
     for (i = 0; i < adapter_mode_count; ++i)
@@ -1564,7 +1560,7 @@ static void test_reset(void)
 
         memset(&d3ddm2, 0, sizeof(d3ddm2));
         hr = IDirect3D8_EnumAdapterModes(d3d8, D3DADAPTER_DEFAULT, i, &d3ddm2);
-        ok(SUCCEEDED(hr), "EnumAdapterModes failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "EnumAdapterModes failed, hr %#lx.\n", hr);
 
         if (d3ddm2.Format != d3ddm.Format)
             continue;
@@ -1620,10 +1616,10 @@ static void test_reset(void)
         skip("Device is lost.\n");
         goto cleanup;
     }
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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);
@@ -1631,11 +1627,11 @@ static void test_reset(void)
     ok(height == modes[i].h, "Screen height is %u, expected %u.\n", height, modes[i].h);
 
     hr = IDirect3DDevice8_GetViewport(device1, &vp);
-    ok(SUCCEEDED(hr), "GetViewport failed, hr %#x.\n", hr);
-    ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X);
-    ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\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(SUCCEEDED(hr), "GetViewport failed, hr %#lx.\n", hr);
+    ok(vp.X == 0, "D3DVIEWPORT->X = %lu, expected 0.\n", vp.X);
+    ok(vp.Y == 0, "D3DVIEWPORT->Y = %lu, expected 0.\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 = %.8e, expected 0.\n", vp.MinZ);
     ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ);
 
@@ -1647,13 +1643,13 @@ static void test_reset(void)
     vp.MinZ = 0.2f;
     vp.MaxZ = 0.3f;
     hr = IDirect3DDevice8_SetViewport(device1, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
@@ -1662,21 +1658,21 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = modes[i].h;
     d3dpp.BackBufferFormat = d3ddm.Format;
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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);
 
     memset(&vp, 0, sizeof(vp));
     hr = IDirect3DDevice8_GetViewport(device1, &vp);
-    ok(SUCCEEDED(hr), "GetViewport failed, hr %#x.\n", hr);
-    ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X);
-    ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\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(SUCCEEDED(hr), "GetViewport failed, hr %#lx.\n", hr);
+    ok(vp.X == 0, "D3DVIEWPORT->X = %lu, expected 0.\n", vp.X);
+    ok(vp.Y == 0, "D3DVIEWPORT->Y = %lu, expected 0.\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 = %.8e, expected 0.\n", vp.MinZ);
     ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ);
 
@@ -1686,9 +1682,9 @@ static void test_reset(void)
     ok(height == modes[i].h, "Screen height is %u, expected %u.\n", height, modes[i].h);
 
     hr = IDirect3DDevice8_GetRenderTarget(device1, &surface);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DSurface8_GetDesc(surface, &surface_desc);
-    ok(hr == D3D_OK, "GetDesc failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "GetDesc failed, hr %#lx.\n", hr);
     ok(surface_desc.Width == modes[i].w, "Back buffer width is %u, expected %u.\n",
             surface_desc.Width, modes[i].w);
     ok(surface_desc.Height == modes[i].h, "Back buffer height is %u, expected %u.\n",
@@ -1702,17 +1698,17 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 300;
     d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&vp, 0, sizeof(vp));
     hr = IDirect3DDevice8_GetViewport(device1, &vp);
-    ok(SUCCEEDED(hr), "GetViewport failed, hr %#x.\n", hr);
-    ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X);
-    ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y);
-    ok(vp.Width == 400, "D3DVIEWPORT->Width = %u, expected 400.\n", vp.Width);
-    ok(vp.Height == 300, "D3DVIEWPORT->Height = %u, expected 300.\n", vp.Height);
+    ok(SUCCEEDED(hr), "GetViewport failed, hr %#lx.\n", hr);
+    ok(vp.X == 0, "D3DVIEWPORT->X = %lu, expected 0.\n", vp.X);
+    ok(vp.Y == 0, "D3DVIEWPORT->Y = %lu, expected 0.\n", vp.Y);
+    ok(vp.Width == 400, "D3DVIEWPORT->Width = %lu, expected 400.\n", vp.Width);
+    ok(vp.Height == 300, "D3DVIEWPORT->Height = %lu, expected 300.\n", vp.Height);
     ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %.8e, expected 0.\n", vp.MinZ);
     ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ);
 
@@ -1722,9 +1718,9 @@ static void test_reset(void)
     ok(height == orig_height, "Screen height is %u, expected %u.\n", height, orig_height);
 
     hr = IDirect3DDevice8_GetRenderTarget(device1, &surface);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DSurface8_GetDesc(surface, &surface_desc);
-    ok(hr == D3D_OK, "GetDesc failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "GetDesc failed, hr %#lx.\n", hr);
     ok(surface_desc.Width == 400, "Back buffer width is %u, expected 400.\n",
             surface_desc.Width);
     ok(surface_desc.Height == 300, "Back buffer height is %u, expected 300.\n",
@@ -1737,7 +1733,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);
@@ -1747,9 +1743,9 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 400;
     d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
 
     width = GetSystemMetrics(SM_CXSCREEN);
     height = GetSystemMetrics(SM_CYSCREEN);
@@ -1758,18 +1754,18 @@ static void test_reset(void)
 
     ZeroMemory(&vp, sizeof(vp));
     hr = IDirect3DDevice8_GetViewport(device1, &vp);
-    ok(SUCCEEDED(hr), "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(SUCCEEDED(hr), "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 = IDirect3DDevice8_GetRenderTarget(device1, &surface);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DSurface8_GetDesc(surface, &surface_desc);
-    ok(hr == D3D_OK, "GetDesc failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "GetDesc failed, hr %#lx.\n", hr);
     ok(surface_desc.Width == 500, "Back buffer width is %u, expected 500.\n",
             surface_desc.Width);
     ok(surface_desc.Height == 400, "Back buffer height is %u, expected 400.\n",
@@ -1780,7 +1776,7 @@ 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);
@@ -1807,9 +1803,9 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 0;
     d3dpp.BackBufferFormat = d3ddm.Format;
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
 
     ok(!d3dpp.BackBufferWidth, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth);
     ok(!d3dpp.BackBufferHeight, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight);
@@ -1822,7 +1818,7 @@ static void test_reset(void)
     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.FullScreen_PresentationInterval, "Got unexpected FullScreen_PresentationInterval %#x.\n",
@@ -1830,30 +1826,30 @@ static void test_reset(void)
 
     memset(&vp, 0, sizeof(vp));
     hr = IDirect3DDevice8_GetViewport(device1, &vp);
-    ok(SUCCEEDED(hr), "GetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetViewport failed, hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
-        ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X);
-        ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y);
-        ok(vp.Width == client_rect.right, "D3DVIEWPORT->Width = %d, expected %d\n",
+        ok(vp.X == 0, "D3DVIEWPORT->X = %lu, expected 0.\n", vp.X);
+        ok(vp.Y == 0, "D3DVIEWPORT->Y = %lu, expected 0.\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 = %.8e, expected 0.\n", vp.MinZ);
         ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ);
     }
 
     hr = IDirect3DDevice8_GetRenderTarget(device1, &surface);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DSurface8_GetDesc(surface, &surface_desc);
-    ok(hr == D3D_OK, "GetDesc failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "GetDesc failed, hr %#lx.\n", hr);
     ok(surface_desc.Format == d3ddm.Format, "Got unexpected Format %#x, expected %#x.\n",
             surface_desc.Format, d3ddm.Format);
     ok(!surface_desc.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType);
     ok(surface_desc.Width == client_rect.right,
-            "Back buffer width is %u, expected %d.\n", surface_desc.Width, client_rect.right);
+            "Back buffer width is %u, expected %ld.\n", surface_desc.Width, client_rect.right);
     ok(surface_desc.Height == client_rect.bottom,
-            "Back buffer height is %u, expected %d.\n", surface_desc.Height, client_rect.bottom);
+            "Back buffer height is %u, expected %ld.\n", surface_desc.Height, client_rect.bottom);
     IDirect3DSurface8_Release(surface);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
@@ -1865,17 +1861,17 @@ static void test_reset(void)
 
     /* Reset fails if there is a resource in the default pool. */
     hr = IDirect3DDevice8_CreateTexture(device1, 16, 16, 1, 0, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(hr == D3DERR_DEVICELOST, "Reset returned %#x, expected %#x.\n", hr, D3DERR_DEVICELOST);
+    ok(hr == D3DERR_DEVICELOST, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n", hr, D3DERR_DEVICENOTRESET);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
     IDirect3DTexture8_Release(texture);
     /* Reset again to get the device out of the lost state. */
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
 
     if (caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)
     {
@@ -1883,17 +1879,16 @@ static void test_reset(void)
 
         hr = IDirect3DDevice8_CreateVolumeTexture(device1, 16, 16, 4, 1, 0,
                 D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &volume_texture);
-        ok(SUCCEEDED(hr), "CreateVolumeTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateVolumeTexture failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-        ok(hr == D3DERR_DEVICELOST, "Reset returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+        ok(hr == D3DERR_DEVICELOST, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-        ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n",
-                hr, D3DERR_DEVICENOTRESET);
+        ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
         IDirect3DVolumeTexture8_Release(volume_texture);
         hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-        ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-        ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
     }
     else
     {
@@ -1903,151 +1898,151 @@ static void test_reset(void)
     /* Test with DEFAULT pool resources bound but otherwise not referenced. */
     hr = IDirect3DDevice8_CreateVertexBuffer(device1, 16, 0,
             D3DFVF_XYZ, D3DPOOL_DEFAULT, &vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetStreamSource(device1, 0, vb, 16);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     refcount = IDirect3DVertexBuffer8_Release(vb);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
     hr = IDirect3DDevice8_CreateIndexBuffer(device1, 16, 0,
             D3DFMT_INDEX16, D3DPOOL_DEFAULT, &ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetIndices(device1, ib, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     refcount = IDirect3DIndexBuffer8_Release(ib);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
     hr = IDirect3DDevice8_CreateTexture(device1, 16, 16, 0, 0,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device1, i, (IDirect3DBaseTexture8 *)texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#lx.\n", hr);
 
     /* Crashes on Windows. */
     if (0)
     {
         hr = IDirect3DDevice8_GetIndices(device1, &ib, &i);
-        todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
     refcount = IDirect3DTexture8_Release(texture);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
 
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Scratch, sysmem and managed pool resources are fine. */
     hr = IDirect3DDevice8_CreateTexture(device1, 16, 16, 1, 0, D3DFMT_R5G6B5, D3DPOOL_SCRATCH, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
     IDirect3DTexture8_Release(texture);
 
     hr = IDirect3DDevice8_CreateTexture(device1, 16, 16, 1, 0, D3DFMT_R5G6B5, D3DPOOL_SYSTEMMEM, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
     IDirect3DTexture8_Release(texture);
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device1, 16, 0,
             D3DFVF_XYZ, D3DPOOL_SYSTEMMEM, &vb);
-    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 = IDirect3DDevice8_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);
     IDirect3DVertexBuffer8_Release(vb);
 
     hr = IDirect3DDevice8_CreateIndexBuffer(device1, 16, 0,
             D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib);
-    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 = IDirect3DDevice8_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);
     IDirect3DIndexBuffer8_Release(ib);
 
     /* The depth stencil should get reset to the auto depth stencil when present. */
     hr = IDirect3DDevice8_SetRenderTarget(device1, NULL, NULL);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device1, &surface);
-    ok(hr == D3DERR_NOTFOUND, "GetDepthStencilSurface returned %#x, expected %#x.\n", hr, D3DERR_NOTFOUND);
+    ok(hr == D3DERR_NOTFOUND, "Got hr %#lx.\n", hr);
     ok(!surface, "Depth / stencil buffer should be NULL.\n");
 
     d3dpp.EnableAutoDepthStencil = TRUE;
     d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device1, &surface);
-    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#lx.\n", hr);
     ok(!!surface, "Depth / stencil buffer should not be NULL.\n");
     if (surface) IDirect3DSurface8_Release(surface);
 
     d3dpp.EnableAutoDepthStencil = FALSE;
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device1, &surface);
-    ok(hr == D3DERR_NOTFOUND, "GetDepthStencilSurface returned %#x, expected %#x.\n", hr, D3DERR_NOTFOUND);
+    ok(hr == D3DERR_NOTFOUND, "Got hr %#lx.\n", hr);
     ok(!surface, "Depth / stencil buffer should be NULL.\n");
 
     /* Will a sysmem or scratch resource survive while locked? */
     hr = IDirect3DDevice8_CreateTexture(device1, 16, 16, 1, 0, D3DFMT_R5G6B5, D3DPOOL_SYSTEMMEM, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_LockRect(texture, 0, &lockrect, NULL, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "LockRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "LockRect failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
     IDirect3DTexture8_UnlockRect(texture, 0);
     IDirect3DTexture8_Release(texture);
 
     hr = IDirect3DDevice8_CreateTexture(device1, 16, 16, 1, 0, D3DFMT_R5G6B5, D3DPOOL_SCRATCH, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_LockRect(texture, 0, &lockrect, NULL, D3DLOCK_DISCARD);
-    ok(SUCCEEDED(hr), "LockRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "LockRect failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
     IDirect3DTexture8_UnlockRect(texture, 0);
     IDirect3DTexture8_Release(texture);
 
     hr = IDirect3DDevice8_CreateTexture(device1, 16, 16, 1, 0, D3DFMT_R5G6B5, D3DPOOL_MANAGED, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
     IDirect3DTexture8_Release(texture);
 
     /* A reference held to an implicit surface causes failures as well. */
     hr = IDirect3DDevice8_GetBackBuffer(device1, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
-    ok(SUCCEEDED(hr), "GetBackBuffer failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetBackBuffer failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(hr == D3DERR_DEVICELOST, "Reset returned %#x, expected %#x.\n", hr, D3DERR_DEVICELOST);
+    ok(hr == D3DERR_DEVICELOST, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n", hr, D3DERR_DEVICENOTRESET);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
     IDirect3DSurface8_Release(surface);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
 
     /* Shaders are fine as well. */
     hr = IDirect3DDevice8_CreateVertexShader(device1, decl, simple_vs, &shader, 0);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Reset(device1, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DeleteVertexShader(device1, shader);
-    ok(SUCCEEDED(hr), "DeleteVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DeleteVertexShader failed, hr %#lx.\n", hr);
 
     /* Try setting invalid modes. */
     memset(&d3dpp, 0, sizeof(d3dpp));
@@ -2057,9 +2052,9 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 32;
     d3dpp.BackBufferFormat = d3ddm.Format;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n", hr, D3DERR_DEVICENOTRESET);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
@@ -2068,9 +2063,9 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 600;
     d3dpp.BackBufferFormat = d3ddm.Format;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n", hr, D3DERR_DEVICENOTRESET);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
@@ -2079,12 +2074,12 @@ static void test_reset(void)
     d3dpp.BackBufferHeight = 0;
     d3dpp.BackBufferFormat = d3ddm.Format;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_TestCooperativeLevel(device1);
-    ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n", hr, D3DERR_DEVICENOTRESET);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got hr %#lx.\n", hr);
 
     hr = IDirect3D8_GetAdapterDisplayMode(d3d8, D3DADAPTER_DEFAULT, &d3ddm);
-    ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
 
     memset(&d3dpp, 0, sizeof(d3dpp));
     d3dpp.Windowed = TRUE;
@@ -2097,12 +2092,12 @@ static void test_reset(void)
             window, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &device2);
     if (FAILED(hr))
     {
-        skip("Failed to create device, hr %#x.\n", hr);
+        skip("Failed to create device, hr %#lx.\n", hr);
         goto cleanup;
     }
 
     hr = IDirect3DDevice8_TestCooperativeLevel(device2);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#lx.\n", hr);
 
     d3dpp.Windowed = TRUE;
     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
@@ -2113,12 +2108,12 @@ static void test_reset(void)
     d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
 
     hr = IDirect3DDevice8_Reset(device2, &d3dpp);
-    ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Reset failed, hr %#lx.\n", hr);
     if (FAILED(hr))
         goto cleanup;
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device2, &surface);
-    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#lx.\n", hr);
     ok(!!surface, "Depth / stencil buffer should not be NULL.\n");
     if (surface)
         IDirect3DSurface8_Release(surface);
@@ -2153,32 +2148,32 @@ static void test_scene(void)
 
     /* Test an EndScene without BeginScene. Should return an error */
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_EndScene returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     /* Test a normal BeginScene / EndScene pair, this should work */
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Test another EndScene without having begun a new scene. Should return an error */
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_EndScene returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     /* Two nested BeginScene and EndScene calls */
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_BeginScene returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_EndScene returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     /* StretchRect does not exit in Direct3D8, so no equivalent to the d3d9 stretchrect tests */
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -2244,140 +2239,137 @@ static void test_shader(void)
 
     /* Test setting and retrieving a FVF */
     hr = IDirect3DDevice8_SetVertexShader(device, fvf);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetVertexShader(device, &hTempHandle);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
-    ok(hTempHandle == fvf, "Vertex shader %#08x is set, expected %#08x\n", hTempHandle, fvf);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
+    ok(hTempHandle == fvf, "Got vertex shader %#lx, expected %#lx.\n", hTempHandle, fvf);
 
     /* First create a vertex shader */
     hr = IDirect3DDevice8_SetVertexShader(device, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateVertexShader(device, dwVertexDecl, simple_vs, &hVertexShader, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     /* Msdn says that the new vertex shader is set immediately. This is wrong, apparently */
     hr = IDirect3DDevice8_GetVertexShader(device, &hTempHandle);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
-    ok(hTempHandle == 0, "Vertex Shader %d is set, expected shader %d\n", hTempHandle, 0);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(!hTempHandle, "Got vertex shader %#lx.\n", hTempHandle);
     /* Assign the shader, then verify that GetVertexShader works */
     hr = IDirect3DDevice8_SetVertexShader(device, hVertexShader);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetVertexShader(device, &hTempHandle);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
-    ok(hTempHandle == hVertexShader, "Vertex Shader %d is set, expected shader %d\n", hTempHandle, hVertexShader);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(hTempHandle == hVertexShader, "Got vertex shader %#lx, expected %#lx.\n", hTempHandle, hVertexShader);
     /* Verify that we can retrieve the declaration */
     hr = IDirect3DDevice8_GetVertexShaderDeclaration(device, hVertexShader, NULL, &data_size);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShaderDeclaration returned %#08x\n", hr);
-    ok(data_size == vertex_decl_size, "Got data_size %u, expected %u\n", data_size, vertex_decl_size);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(data_size == vertex_decl_size, "Got data_size %lu, expected %lu.\n", data_size, vertex_decl_size);
     data = HeapAlloc(GetProcessHeap(), 0, vertex_decl_size);
     data_size = 1;
     hr = IDirect3DDevice8_GetVertexShaderDeclaration(device, hVertexShader, data, &data_size);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_GetVertexShaderDeclaration returned (%#08x), "
-            "expected D3DERR_INVALIDCALL\n", hr);
-    ok(data_size == 1, "Got data_size %u, expected 1\n", data_size);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
+    ok(data_size == 1, "Got data_size %lu.\n", data_size);
     data_size = vertex_decl_size;
     hr = IDirect3DDevice8_GetVertexShaderDeclaration(device, hVertexShader, data, &data_size);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShaderDeclaration returned %#08x\n", hr);
-    ok(data_size == vertex_decl_size, "Got data_size %u, expected %u\n", data_size, vertex_decl_size);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(data_size == vertex_decl_size, "Got data_size %lu, expected %lu.\n", data_size, vertex_decl_size);
     ok(!memcmp(data, dwVertexDecl, vertex_decl_size), "data not equal to shader declaration\n");
     HeapFree(GetProcessHeap(), 0, data);
     /* Verify that we can retrieve the shader function */
     hr = IDirect3DDevice8_GetVertexShaderFunction(device, hVertexShader, NULL, &data_size);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShaderFunction returned %#08x\n", hr);
-    ok(data_size == simple_vs_size, "Got data_size %u, expected %u\n", data_size, simple_vs_size);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(data_size == simple_vs_size, "Got data_size %lu, expected %lu.\n", data_size, simple_vs_size);
     data = HeapAlloc(GetProcessHeap(), 0, simple_vs_size);
     data_size = 1;
     hr = IDirect3DDevice8_GetVertexShaderFunction(device, hVertexShader, data, &data_size);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_GetVertexShaderFunction returned (%#08x), "
-            "expected D3DERR_INVALIDCALL\n", hr);
-    ok(data_size == 1, "Got data_size %u, expected 1\n", data_size);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
+    ok(data_size == 1, "Got data_size %lu.\n", data_size);
     data_size = simple_vs_size;
     hr = IDirect3DDevice8_GetVertexShaderFunction(device, hVertexShader, data, &data_size);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShaderFunction returned %#08x\n", hr);
-    ok(data_size == simple_vs_size, "Got data_size %u, expected %u\n", data_size, simple_vs_size);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(data_size == simple_vs_size, "Got data_size %lu, expected %lu.\n", data_size, simple_vs_size);
     ok(!memcmp(data, simple_vs, simple_vs_size), "data not equal to shader function\n");
     HeapFree(GetProcessHeap(), 0, data);
     /* Delete the assigned shader. This is supposed to work */
     hr = IDirect3DDevice8_DeleteVertexShader(device, hVertexShader);
-    ok(hr == D3D_OK, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     /* The shader should be unset now */
     hr = IDirect3DDevice8_GetVertexShader(device, &hTempHandle);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
-    ok(hTempHandle == 0, "Vertex Shader %d is set, expected shader %d\n", hTempHandle, 0);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(!hTempHandle, "Got vertex shader %#lx.\n", hTempHandle);
 
     /* Test a broken declaration. 3DMark2001 tries to use normals with 2 components
      * First try the fixed function shader function, then a custom one
      */
     hr = IDirect3DDevice8_CreateVertexShader(device, decl_normal_float2, 0, &hVertexShader, 0);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateVertexShader(device, decl_normal_float4, 0, &hVertexShader, 0);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateVertexShader(device, decl_normal_d3dcolor, 0, &hVertexShader, 0);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateVertexShader(device, decl_normal_float2, simple_vs, &hVertexShader, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     IDirect3DDevice8_DeleteVertexShader(device, hVertexShader);
 
     if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 0))
     {
         /* The same with a pixel shader */
         hr = IDirect3DDevice8_CreatePixelShader(device, simple_ps, &hPixelShader);
-        ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         /* Msdn says that the new pixel shader is set immediately. This is wrong, apparently */
         hr = IDirect3DDevice8_GetPixelShader(device, &hTempHandle);
-        ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShader returned %#08x\n", hr);
-        ok(hTempHandle == 0, "Pixel Shader %d is set, expected shader %d\n", hTempHandle, 0);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+        ok(!hTempHandle, "Got pixel shader %#lx.\n", hTempHandle);
         /* Assign the shader, then verify that GetPixelShader works */
         hr = IDirect3DDevice8_SetPixelShader(device, hPixelShader);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_GetPixelShader(device, &hTempHandle);
-        ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShader returned %#08x\n", hr);
-        ok(hTempHandle == hPixelShader, "Pixel Shader %d is set, expected shader %d\n", hTempHandle, hPixelShader);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+        ok(hTempHandle == hPixelShader, "Got pixel shader %#lx, expected %#lx.\n", hTempHandle, hPixelShader);
         /* Verify that we can retrieve the shader function */
         hr = IDirect3DDevice8_GetPixelShaderFunction(device, hPixelShader, NULL, &data_size);
-        ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShaderFunction returned %#08x\n", hr);
-        ok(data_size == simple_ps_size, "Got data_size %u, expected %u\n", data_size, simple_ps_size);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+        ok(data_size == simple_ps_size, "Got data_size %lu, expected %lu.\n", data_size, simple_ps_size);
         data = HeapAlloc(GetProcessHeap(), 0, simple_ps_size);
         data_size = 1;
         hr = IDirect3DDevice8_GetPixelShaderFunction(device, hPixelShader, data, &data_size);
-        ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_GetPixelShaderFunction returned (%#08x), "
-                "expected D3DERR_INVALIDCALL\n", hr);
-        ok(data_size == 1, "Got data_size %u, expected 1\n", data_size);
+        ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
+        ok(data_size == 1, "Got data_size %lu.\n", data_size);
         data_size = simple_ps_size;
         hr = IDirect3DDevice8_GetPixelShaderFunction(device, hPixelShader, data, &data_size);
-        ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShaderFunction returned %#08x\n", hr);
-        ok(data_size == simple_ps_size, "Got data_size %u, expected %u\n", data_size, simple_ps_size);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+        ok(data_size == simple_ps_size, "Got data_size %lu, expected %lu.\n", data_size, simple_ps_size);
         ok(!memcmp(data, simple_ps, simple_ps_size), "data not equal to shader function\n");
         HeapFree(GetProcessHeap(), 0, data);
         /* Delete the assigned shader. This is supposed to work */
         hr = IDirect3DDevice8_DeletePixelShader(device, hPixelShader);
-        ok(hr == D3D_OK, "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         /* The shader should be unset now */
         hr = IDirect3DDevice8_GetPixelShader(device, &hTempHandle);
-        ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShader returned %#08x\n", hr);
-        ok(hTempHandle == 0, "Pixel Shader %d is set, expected shader %d\n", hTempHandle, 0);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+        ok(!hTempHandle, "Got pixel shader %#lx.\n", hTempHandle);
 
         /* What happens if a non-bound shader is deleted? */
         hr = IDirect3DDevice8_CreatePixelShader(device, simple_ps, &hPixelShader);
-        ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_CreatePixelShader(device, simple_ps, &hPixelShader2);
-        ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_SetPixelShader(device, hPixelShader);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_DeletePixelShader(device, hPixelShader2);
-        ok(hr == D3D_OK, "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_GetPixelShader(device, &hTempHandle);
-        ok(hr == D3D_OK, "IDirect3DDevice8_GetPixelShader returned %#08x\n", hr);
-        ok(hTempHandle == hPixelShader, "Pixel Shader %d is set, expected shader %d\n", hTempHandle, hPixelShader);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+        ok(hTempHandle == hPixelShader, "Got pixel shader %#lx, expected %#lx.\n", hTempHandle, hPixelShader);
         hr = IDirect3DDevice8_DeletePixelShader(device, hPixelShader);
-        ok(hr == D3D_OK, "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         /* Check for double delete. */
         hr = IDirect3DDevice8_DeletePixelShader(device, hPixelShader2);
-        ok(hr == D3DERR_INVALIDCALL || broken(hr == D3D_OK), "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
+        ok(hr == D3DERR_INVALIDCALL || broken(hr == D3D_OK), "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_DeletePixelShader(device, hPixelShader);
-        ok(hr == D3DERR_INVALIDCALL || broken(hr == D3D_OK), "IDirect3DDevice8_DeletePixelShader returned %#08x\n", hr);
+        ok(hr == D3DERR_INVALIDCALL || broken(hr == D3D_OK), "Got hr %#lx.\n", hr);
     }
     else
     {
@@ -2386,28 +2378,28 @@ static void test_shader(void)
 
     /* What happens if a non-bound shader is deleted? */
     hr = IDirect3DDevice8_CreateVertexShader(device, dwVertexDecl, NULL, &hVertexShader, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateVertexShader(device, dwVertexDecl, NULL, &hVertexShader2, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, hVertexShader);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DeleteVertexShader(device, hVertexShader2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetVertexShader(device, &hTempHandle);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetVertexShader returned %#08x\n", hr);
-    ok(hTempHandle == hVertexShader, "Vertex Shader %d is set, expected shader %d\n", hTempHandle, hVertexShader);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
+    ok(hTempHandle == hVertexShader, "Got vertex shader %#lx, expected %#lx.\n", hTempHandle, hVertexShader);
     hr = IDirect3DDevice8_DeleteVertexShader(device, hVertexShader);
-    ok(hr == D3D_OK, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Check for double delete. */
     hr = IDirect3DDevice8_DeleteVertexShader(device, hVertexShader2);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DeleteVertexShader(device, hVertexShader);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -2434,17 +2426,17 @@ static void test_limits(void)
     }
 
     hr = IDirect3DDevice8_CreateTexture(device, 16, 16, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreateTexture failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* There are 8 texture stages. We should be able to access all of them */
     for (i = 0; i < 8; ++i)
     {
         hr = IDirect3DDevice8_SetTexture(device, i, (IDirect3DBaseTexture8 *)texture);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture for sampler %d failed with %#08x\n", i, hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_SetTexture(device, i, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture for sampler %d failed with %#08x\n", i, hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_SetTextureStageState(device, i, D3DTSS_COLOROP, D3DTOP_ADD);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetTextureStageState for texture %d failed with %#08x\n", i, hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     }
 
     /* Investigations show that accessing higher textures stage states does
@@ -2453,7 +2445,7 @@ static void test_limits(void)
      * there is no bounds checking. */
     IDirect3DTexture8_Release(texture);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -2482,33 +2474,32 @@ static void test_lights(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetDeviceCaps failed with %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     for(i = 1; i <= caps.MaxActiveLights; i++) {
         hr = IDirect3DDevice8_LightEnable(device, i, TRUE);
-        ok(hr == D3D_OK, "Enabling light %u failed with %08x\n", i, hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_GetLightEnable(device, i, &enabled);
-        ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL),
-            "GetLightEnable on light %u failed with %08x\n", i, hr);
+        ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL), "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 = IDirect3DDevice8_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 = IDirect3DDevice8_GetLightEnable(device, i + 1, &enabled);
-    ok(hr == D3D_OK, "GetLightEnable on light %u failed with %08x\n", i + 1, hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(enabled, "Light %d is %s\n", i + 1, enabled ? "enabled" : "disabled");
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_LightEnable(device, i, FALSE);
-        ok(hr == D3D_OK, "Disabling light %u failed with %08x\n", i, hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
@@ -2535,29 +2526,29 @@ static void test_set_stream_source(void)
     }
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device, 512, 0, 0, D3DPOOL_DEFAULT, &vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetStreamSource(device, 0, vb, 32);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetStreamSource(device, 0, NULL, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetStreamSource(device, 0, &current_vb, &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(stride == 32, "Got unexpected stride %u.\n", stride);
 
     hr = IDirect3DDevice8_SetStreamSource(device, 0, vb, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetStreamSource(device, 0, &current_vb, &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);
     IDirect3DVertexBuffer8_Release(current_vb);
     ok(!stride, "Got unexpected stride %u.\n", stride);
 
     IDirect3DVertexBuffer8_Release(vb);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
@@ -2596,20 +2587,20 @@ static void test_render_zero_triangles(void)
     }
 
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 0 /* NumVerts */,
             0 /* PrimCount */, NULL, 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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 cleanup:
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
@@ -2644,45 +2635,45 @@ static void test_depth_stencil_reset(void)
             D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device);
     if(FAILED(hr))
     {
-        skip("could not create device, IDirect3D8_CreateDevice returned %#x\n", hr);
+        skip("Failed to create device, hr %#lx.\n", hr);
         goto cleanup;
     }
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &orig_rt);
-    ok(hr == D3D_OK, "GetRenderTarget failed with 0x%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(SUCCEEDED(hr), "TestCooperativeLevel failed with %#x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, NULL, NULL);
-    ok(hr == D3D_OK, "SetRenderTarget failed with 0x%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &surface);
-    ok(hr == D3D_OK, "GetRenderTarget failed with 0x%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(surface == orig_rt, "Render target is %p, should be %p\n", surface, orig_rt);
     if (surface) IDirect3DSurface8_Release(surface);
     IDirect3DSurface8_Release(orig_rt);
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &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");
 
     present_parameters.EnableAutoDepthStencil = TRUE;
     present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
     hr = IDirect3DDevice8_Reset(device, &present_parameters);
-    ok(hr == D3D_OK, "Reset failed with 0x%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surface);
-    ok(hr == D3D_OK, "GetDepthStencilSurface failed with 0x%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(surface != NULL, "Depth stencil should not be NULL\n");
     if (surface) IDirect3DSurface8_Release(surface);
 
     present_parameters.EnableAutoDepthStencil = FALSE;
     hr = IDirect3DDevice8_Reset(device, &present_parameters);
-    ok(hr == D3D_OK, "Reset failed with 0x%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &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");
 
     refcount = IDirect3DDevice8_Release(device);
@@ -2703,12 +2694,12 @@ static void test_depth_stencil_reset(void)
 
     if(FAILED(hr))
     {
-        skip("could not create device, IDirect3D8_CreateDevice returned %#x\n", hr);
+        skip("Failed to create device, hr %#lx.\n", hr);
         goto cleanup;
     }
 
     hr = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_TestCooperativeLevel after creation returned %#x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     present_parameters.SwapEffect       = D3DSWAPEFFECT_DISCARD;
     present_parameters.Windowed         = TRUE;
@@ -2718,12 +2709,12 @@ static void test_depth_stencil_reset(void)
     present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
 
     hr = IDirect3DDevice8_Reset(device, &present_parameters);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Reset failed with 0x%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     if (FAILED(hr)) goto cleanup;
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surface);
-    ok(hr == D3D_OK, "GetDepthStencilSurface failed with 0x%08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(surface != NULL, "Depth stencil should not be NULL\n");
     if (surface) IDirect3DSurface8_Release(surface);
 
@@ -2801,7 +2792,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)
@@ -2815,7 +2806,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);
             }
 
@@ -2847,7 +2838,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 (;;)
     {
@@ -2858,7 +2849,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;
         }
     }
@@ -2870,6 +2861,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;
@@ -2881,10 +2873,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;
@@ -3020,7 +3010,7 @@ static void test_wndproc(void)
     for (i = 0; i < adapter_mode_count; ++i)
     {
         hr = IDirect3D8_EnumAdapterModes(d3d8, D3DADAPTER_DEFAULT, 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.Format != D3DFMT_X8R8G8B8)
             continue;
@@ -3075,9 +3065,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);
@@ -3085,23 +3075,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("d3d8_test_wndproc_wc", "d3d8_test",
             WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, user32_width, user32_height, 0, 0, 0, 0);
     device_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_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",
@@ -3148,25 +3138,25 @@ 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", (LONG_PTR)test_proc);
+    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. */
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     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 = IDirect3DDevice8_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);
 
     expect_messages = focus_loss_messages;
     focus_test_device = device;
@@ -3186,16 +3176,16 @@ static void test_wndproc(void)
 
     /* The Present call is necessary to make native realize the device is lost. */
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_TestCooperativeLevel(device);
     /* Focus-follows-mouse WMs prematurely reactivate our window. */
     todo_wine_if (hr == D3DERR_DEVICENOTRESET)
-        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);
 
     /* I have to minimize and restore the focus window, otherwise native d3d8 fails
@@ -3214,16 +3204,16 @@ static void test_wndproc(void)
     expect_messages = NULL;
 
     hr = IDirect3DDevice8_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)
@@ -3243,8 +3233,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). */
@@ -3257,7 +3247,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.\n",
             expect_messages->message, expect_messages->window);
-    ok(syscommand_received == 1, "Got unexpected number of WM_SYSCOMMAND messages: %d.\n", syscommand_received);
+    ok(syscommand_received == 1, "Got %lu WM_SYSCOMMAND messages.\n", syscommand_received);
     expect_messages = NULL;
     flush_events();
 
@@ -3284,18 +3274,18 @@ static void test_wndproc(void)
 
     /* Releasing a device in lost state breaks follow-up tests on native. */
     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 = focus_window;
     ref = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
 
     /* 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.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* Hide the device window. It prevents WM_ACTIVATEAPP messages from being sent
@@ -3329,14 +3319,14 @@ static void test_wndproc(void)
     ok(IsIconic(focus_window), "The focus window is not iconic.\n");
 
     hr = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#lx.\n", hr);
 
     syscommand_received = 0;
     expect_messages = sc_restore_messages;
     SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0);
     ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
             expect_messages->message, expect_messages->window);
-    ok(syscommand_received == 1, "Got unexpected number of WM_SYSCOMMAND messages: %d.\n", syscommand_received);
+    ok(syscommand_received == 1, "Got %lu WM_SYSCOMMAND messages.\n", syscommand_received);
     expect_messages = NULL;
     flush_events();
 
@@ -3377,14 +3367,14 @@ static void test_wndproc(void)
 
     filter_messages = focus_window;
     hr = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#lx.\n", hr);
 
     filter_messages = NULL;
     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 = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
     filter_messages = NULL;
 
     ShowWindow(device_window, SW_RESTORE);
@@ -3407,7 +3397,7 @@ static void test_wndproc(void)
     expect_messages = 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;
 
     flush_events();
@@ -3427,7 +3417,7 @@ static void test_wndproc(void)
     expect_messages = 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();
@@ -3446,13 +3436,13 @@ static void test_wndproc(void)
     ok(device_style & WS_VISIBLE, "Expected the device window to be visible.\n");
 
     proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    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 = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got 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:
@@ -3470,7 +3460,7 @@ done:
     DestroyWindow(focus_window);
     UnregisterClassA("d3d8_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)
@@ -3498,9 +3488,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("d3d8_test_wndproc_wc", "d3d8_test",
             WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
@@ -3509,16 +3499,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",
@@ -3555,42 +3545,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 = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
 
     filter_messages = device_window;
 
@@ -3605,31 +3595,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 = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
 
     device_desc.device_window = device_window;
     if (!(device = create_device(d3d8, focus_window, &device_desc)))
@@ -3642,31 +3632,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 = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
 
 done:
     filter_messages = NULL;
@@ -3768,7 +3758,7 @@ static void test_fpu_setup(void)
     ok(!!d3d8, "Failed to create a D3D object.\n");
 
     hr = IDirect3D8_GetAdapterDisplayMode(d3d8, D3DADAPTER_DEFAULT, &d3ddm);
-    ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
 
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     device_desc.device_window = window;
@@ -3791,12 +3781,12 @@ static void test_fpu_setup(void)
     ok(cw == 0x7f, "cw is %#x, expected 0x7f.\n", cw);
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 == 0x7f, "Callback cw is %#x, expected 0x7f.\n", callback_cw);
     ok(callback_tid == GetCurrentThreadId(), "Got unexpected thread id.\n");
     cw = get_fpu_cw();
@@ -3805,7 +3795,7 @@ static void test_fpu_setup(void)
     callback_cw = 0;
     hr = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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");
 
@@ -3833,13 +3823,13 @@ static void test_fpu_setup(void)
     ok(cw == 0xf60, "cw is %#x, expected 0xf60.\n", cw);
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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();
@@ -3883,19 +3873,19 @@ static void test_ApplyStateBlock(void)
     IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
 
     hr = IDirect3DDevice8_GetRenderState(device, D3DRS_ZENABLE, &received);
-    ok(hr == D3D_OK, "Expected D3D_OK, received %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(!received, "Expected = FALSE, received TRUE.\n");
 
     hr = IDirect3DDevice8_ApplyStateBlock(device, 0);
-    ok(hr == D3D_OK, "Expected D3D_OK, received %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetRenderState(device, D3DRS_ZENABLE, &received);
-    ok(hr == D3D_OK, "Expected D3D_OK, received %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(!received, "Expected FALSE, received TRUE.\n");
 
     hr = IDirect3DDevice8_ApplyStateBlock(device, token);
-    ok(hr == D3D_OK, "Expected D3D_OK, received %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetRenderState(device, D3DRS_ZENABLE, &received);
-    ok(hr == D3D_OK, "Expected D3D_OK, received %#x.\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     ok(received, "Expected TRUE, received FALSE.\n");
 
     IDirect3DDevice8_DeleteStateBlock(device, token);
@@ -3927,38 +3917,38 @@ static void test_depth_stencil_size(void)
     }
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, 64, 64, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &rt);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 32, 32, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, &ds);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 128, 128, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, &ds_bigger);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 128, 128, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, &ds_bigger2);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_SetRenderTarget returned %#x, expected D3DERR_INVALIDCALL.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds_bigger);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice8_SetRenderTarget failed, hr %#lx.\n", hr);
 
     /* try to set the small ds without changing the render target at the same time */
     hr = IDirect3DDevice8_SetRenderTarget(device, NULL, ds);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_SetRenderTarget returned %#x, expected D3DERR_INVALIDCALL.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderTarget(device, NULL, ds_bigger2);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice8_SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &surf);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetRenderTarget failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice8_GetRenderTarget failed, hr %#lx.\n", hr);
     ok(surf == rt, "The render target is %p, expected %p\n", surf, rt);
     IDirect3DSurface8_Release(surf);
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surf);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice8_GetDepthStencilSurface failed, hr %#lx.\n", hr);
     ok(surf == ds_bigger2, "The depth stencil is %p, expected %p\n", surf, ds_bigger2);
     IDirect3DSurface8_Release(surf);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, NULL, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice8_SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surf);
-    ok(FAILED(hr), "IDirect3DDevice8_GetDepthStencilSurface should have failed, hr %#x.\n", hr);
+    ok(FAILED(hr), "IDirect3DDevice8_GetDepthStencilSurface should have failed, hr %#lx.\n", hr);
     ok(surf == NULL, "The depth stencil is %p, expected NULL\n", surf);
     if (surf) IDirect3DSurface8_Release(surf);
 
@@ -4014,19 +4004,19 @@ static void test_window_style(void)
     style = GetWindowLongA(device_window, GWL_STYLE);
     expected_style = device_style | WS_VISIBLE;
     todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_OVERLAPPEDWINDOW)) /* w1064v1809 */,
-            "Expected device window style %#x, got %#x.\n",
+            "Expected device window style %#lx, got %#lx.\n",
             expected_style, style);
     style = GetWindowLongA(device_window, GWL_EXSTYLE);
     expected_style = device_exstyle | WS_EX_TOPMOST;
     todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
-            "Expected device window extended style %#x, got %#x.\n",
+            "Expected device window extended style %#lx, got %#lx.\n",
             expected_style, style);
 
     style = GetWindowLongA(focus_window, GWL_STYLE);
-    ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+    ok(style == focus_style, "Expected focus window style %#lx, got %#lx.\n",
             focus_style, style);
     style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-    ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+    ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx.\n",
             focus_exstyle, style);
 
     GetWindowRect(device_window, &r);
@@ -4041,44 +4031,44 @@ 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 | WS_VISIBLE;
-    ok(style == expected_style, "Expected device window style %#x, got %#x.\n",
+    ok(style == expected_style, "Expected device window style %#lx, got %#lx.\n",
             expected_style, style);
     style = GetWindowLongA(device_window, GWL_EXSTYLE);
     expected_style = device_exstyle | WS_EX_TOPMOST;
-    ok(style == expected_style, "Expected device window extended style %#x, got %#x.\n",
+    ok(style == expected_style, "Expected device window extended style %#lx, got %#lx.\n",
             expected_style, style);
 
     style = GetWindowLongA(focus_window, GWL_STYLE);
-    ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+    ok(style == focus_style, "Expected focus window style %#lx, got %#lx.\n",
             focus_style, style);
     style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-    ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+    ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx.\n",
             focus_exstyle, style);
 
     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 | WS_MINIMIZE | WS_VISIBLE;
-    todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x.\n",
+    todo_wine ok(style == expected_style, "Expected device window style %#lx, got %#lx.\n",
             expected_style, style);
     style = GetWindowLongA(device_window, GWL_EXSTYLE);
     expected_style = device_exstyle | WS_EX_TOPMOST;
-    todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x.\n",
+    todo_wine ok(style == expected_style, "Expected device window extended style %#lx, got %#lx.\n",
             expected_style, style);
 
     style = GetWindowLongA(focus_window, GWL_STYLE);
-    ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+    ok(style == focus_style, "Expected focus window style %#lx, got %#lx.\n",
             focus_style, style);
     style = GetWindowLongA(focus_window, GWL_EXSTYLE);
-    ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+    ok(style == focus_exstyle, "Expected focus window extended style %#lx, got %#lx.\n",
             focus_exstyle, style);
 
     /* Follow-up tests fail on native if the device is destroyed while lost. */
@@ -4088,10 +4078,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 = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
 
 done:
     IDirect3D8_Release(d3d8);
@@ -4180,47 +4170,47 @@ static void test_unsupported_shaders(void)
     }
 
     hr = IDirect3DDevice8_CreateVertexShader(device, decl, simple_ps, &vs, 0);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreatePixelShader(device, simple_vs, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreatePixelShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateVertexShader(device, decl, vs_2_0, &vs, 0);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreateVertexShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreatePixelShader(device, ps_2_0, &ps);
-    ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_CreatePixelShader returned %#08x\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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.MaxVertexShaderConst < 256)
     {
         hr = IDirect3DDevice8_CreateVertexShader(device, decl, vs_1_255, &vs, 0);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
     else
     {
         hr = IDirect3DDevice8_CreateVertexShader(device, decl, vs_1_255, &vs, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice8_DeleteVertexShader(device, vs);
-        ok(hr == D3D_OK, "IDirect3DDevice8_DeleteVertexShader returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_CreateVertexShader(device, decl, vs_1_256, &vs, 0);
-        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
 
 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];
     IDirect3DDevice8 *device, *device2;
-    unsigned int display_count = 0;
     RECT d3d_rect, focus_rect, r;
     IDirect3DSurface8 *backbuffer;
     MONITORINFOEXW monitor_info;
@@ -4233,15 +4223,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");
 
     d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
@@ -4251,7 +4240,7 @@ static void test_mode_change(void)
     for (i = 0; i < adapter_mode_count; ++i)
     {
         hr = IDirect3D8_EnumAdapterModes(d3d8, D3DADAPTER_DEFAULT, 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.Format != D3DFMT_X8R8G8B8)
             continue;
@@ -4307,7 +4296,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);
 
     /* Make the windows visible, otherwise device::release does not restore the mode if
      * the application is not in foreground like on the testbot. */
@@ -4333,12 +4322,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);
@@ -4349,9 +4338,9 @@ static void test_mode_change(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DSurface8_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",
@@ -4359,17 +4348,17 @@ static void test_mode_change(void)
     IDirect3DSurface8_Release(backbuffer);
 
     refcount = IDirect3DDevice8_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. */
 
@@ -4384,10 +4373,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 = IDirect3DDevice8_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);
@@ -4395,14 +4384,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;
@@ -4412,17 +4401,17 @@ static void test_mode_change(void)
     device = create_device(d3d8, device_window, &device_desc);
     ok(!!device, "Failed to create a D3D device.\n");
     refcount = IDirect3DDevice8_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;
@@ -4432,13 +4421,13 @@ static void test_mode_change(void)
     device = create_device(d3d8, device_window, &device_desc);
     ok(!!device, "Failed to create a D3D device.\n");
     refcount = IDirect3DDevice8_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");
@@ -4446,7 +4435,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;
@@ -4459,21 +4448,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 = IDirect3DDevice8_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");
@@ -4487,13 +4476,13 @@ static void test_mode_change(void)
     second_monitor = IDirect3D8_GetAdapterMonitor(d3d8, 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;
@@ -4536,37 +4525,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 = IDirect3DDevice8_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 = IDirect3D8_GetAdapterDisplayMode(d3d8, 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 = IDirect3DDevice8_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");
 
@@ -4580,22 +4569,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 = IDirect3DDevice8_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 = IDirect3D8_GetAdapterDisplayMode(d3d8, 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");
@@ -4606,25 +4595,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 = IDirect3DDevice8_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 = IDirect3D8_GetAdapterDisplayMode(d3d8, 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");
@@ -4642,28 +4631,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 = IDirect3D8_GetAdapterDisplayMode(d3d8, 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 = IDirect3DDevice8_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirect3DDevice8_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");
 
@@ -4675,25 +4664,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 = IDirect3DDevice8_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 = IDirect3D8_GetAdapterDisplayMode(d3d8, 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 = IDirect3DDevice8_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     DestroyWindow(device_window);
@@ -4733,10 +4722,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;
@@ -4758,10 +4747,10 @@ static void test_device_window_reset(void)
             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);
@@ -4775,13 +4764,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 = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
 
 done:
     IDirect3D8_Release(d3d8);
@@ -4813,41 +4802,41 @@ static void depth_blit_test(void)
     }
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &backbuffer);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &ds1);
-    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, &ds2);
-    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, &ds3);
-    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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);
 
     /* Partial blit. */
     SetRect(&src_rect, 0, 0, 320, 240);
     hr = IDirect3DDevice8_CopyRects(device, ds1, &src_rect, 1, ds2, &dst_point);
-    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     /* Flipped. */
     SetRect(&src_rect, 0, 480, 640, 0);
     hr = IDirect3DDevice8_CopyRects(device, ds1, &src_rect, 1, ds2, &dst_point);
-    ok(hr == D3DERR_INVALIDCALL, "CopyRects 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);
     hr = IDirect3DDevice8_CopyRects(device, ds1, &src_rect, 1, ds2, &dst_point);
-    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     /* Depth -> color blit.*/
     hr = IDirect3DDevice8_CopyRects(device, ds1, &src_rect, 1, backbuffer, &dst_point);
-    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     /* Full, NULL rects, current depth stencil -> unbound depth stencil */
     hr = IDirect3DDevice8_CopyRects(device, ds1, NULL, 0, ds2, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     /* Full, NULL rects, unbound depth stencil -> current depth stencil */
     hr = IDirect3DDevice8_CopyRects(device, ds2, NULL, 0, ds1, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
     /* Full, NULL rects, unbound depth stencil -> unbound depth stencil */
     hr = IDirect3DDevice8_CopyRects(device, ds2, NULL, 0, ds3, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(backbuffer);
     IDirect3DSurface8_Release(ds3);
@@ -4882,17 +4871,17 @@ static void test_reset_resources(void)
 
     hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 128, 128, D3DFMT_D24S8,
             D3DMULTISAMPLE_NONE, &surface);
-    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 = IDirect3DDevice8_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture);
-    ok(SUCCEEDED(hr), "Failed to create render target texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create render target texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &rt);
-    ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
     IDirect3DTexture8_Release(texture);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, rt, surface);
-    ok(SUCCEEDED(hr), "Failed to set render target surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target surface, hr %#lx.\n", hr);
     IDirect3DSurface8_Release(rt);
     IDirect3DSurface8_Release(surface);
 
@@ -4900,15 +4889,15 @@ static void test_reset_resources(void)
     ok(SUCCEEDED(hr), "Failed to reset device.\n");
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DDevice8_GetRenderTarget(device, &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);
     IDirect3DSurface8_Release(surface);
     IDirect3DSurface8_Release(rt);
 
     ref = IDirect3DDevice8_Release(device);
-    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
 
 done:
     IDirect3D8_Release(d3d8);
@@ -4939,39 +4928,39 @@ static void test_set_rt_vp_scissor(void)
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, FALSE, &rt);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt, 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 = IDirect3DDevice8_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);
     hr = IDirect3DDevice8_DeleteStateBlock(device, stateblock);
-    ok(SUCCEEDED(hr), "Failed to delete stateblock, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to delete stateblock, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt, 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);
 
     vp.X = 10;
     vp.Y = 20;
@@ -4980,17 +4969,17 @@ static void test_set_rt_vp_scissor(void)
     vp.MinZ = 0.25f;
     vp.MaxZ = 0.75f;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt, 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 = IDirect3DDevice8_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);
 
@@ -5036,65 +5025,65 @@ static void test_validate_vs(void)
     };
 
     hr = ValidateVertexShader(NULL, NULL, NULL, FALSE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = ValidateVertexShader(NULL, NULL, NULL, TRUE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = ValidateVertexShader(NULL, NULL, NULL, FALSE, &errors);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(!*errors, "Got unexpected string \"%s\".\n", errors);
     heap_free(errors);
     hr = ValidateVertexShader(NULL, NULL, NULL, TRUE, &errors);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(!!*errors, "Got unexpected empty string.\n");
     heap_free(errors);
 
     hr = ValidateVertexShader(vs_code, NULL, NULL, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = ValidateVertexShader(vs_code, NULL, NULL, TRUE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = ValidateVertexShader(vs_code, NULL, NULL, TRUE, &errors);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(!*errors, "Got unexpected string \"%s\".\n", errors);
     heap_free(errors);
 
     hr = ValidateVertexShader(vs_code, declaration_valid1, NULL, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = ValidateVertexShader(vs_code, declaration_valid2, NULL, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = ValidateVertexShader(vs_code, declaration_invalid, NULL, FALSE, NULL);
-    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
 
     memset(&caps, 0, sizeof(caps));
     caps.VertexShaderVersion = D3DVS_VERSION(1, 1);
     caps.MaxVertexShaderConst = 4;
     hr = ValidateVertexShader(vs_code, NULL, &caps, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     caps.VertexShaderVersion = D3DVS_VERSION(1, 0);
     hr = ValidateVertexShader(vs_code, NULL, &caps, FALSE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     caps.VertexShaderVersion = D3DVS_VERSION(1, 2);
     hr = ValidateVertexShader(vs_code, NULL, &caps, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     caps.VertexShaderVersion = D3DVS_VERSION(8, 8);
     hr = ValidateVertexShader(vs_code, NULL, &caps, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     caps.VertexShaderVersion = D3DVS_VERSION(1, 1);
     caps.MaxVertexShaderConst = 3;
     hr = ValidateVertexShader(vs_code, NULL, &caps, FALSE, NULL);
-    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
 
     *vs_code = D3DVS_VERSION(1, 0);
     hr = ValidateVertexShader(vs_code, NULL, NULL, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     *vs_code = D3DVS_VERSION(1, 2);
     hr = ValidateVertexShader(vs_code, NULL, NULL, TRUE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = ValidateVertexShader(vs_code, NULL, NULL, FALSE, &errors);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(!*errors, "Got unexpected string \"%s\".\n", errors);
     heap_free(errors);
     hr = ValidateVertexShader(vs_code, NULL, NULL, TRUE, &errors);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(!!*errors, "Got unexpected empty string.\n");
     heap_free(errors);
 }
@@ -5121,58 +5110,58 @@ static void test_validate_ps(void)
     HRESULT hr;
 
     hr = ValidatePixelShader(NULL, NULL, FALSE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = ValidatePixelShader(NULL, NULL, TRUE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     errors = (void *)0xcafeface;
     hr = ValidatePixelShader(NULL, NULL, FALSE, &errors);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(errors == (void *)0xcafeface, "Got unexpected errors %p.\n", errors);
     errors = (void *)0xcafeface;
     hr = ValidatePixelShader(NULL, NULL, TRUE, &errors);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(errors == (void *)0xcafeface, "Got unexpected errors %p.\n", errors);
 
     hr = ValidatePixelShader(ps_1_1_code, NULL, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = ValidatePixelShader(ps_1_1_code, NULL, TRUE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = ValidatePixelShader(ps_1_1_code, NULL, TRUE, &errors);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     ok(!*errors, "Got unexpected string \"%s\".\n", errors);
     heap_free(errors);
 
     memset(&caps, 0, sizeof(caps));
     caps.PixelShaderVersion = D3DPS_VERSION(1, 1);
     hr = ValidatePixelShader(ps_1_1_code, &caps, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     caps.PixelShaderVersion = D3DPS_VERSION(1, 0);
     hr = ValidatePixelShader(ps_1_1_code, &caps, FALSE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     caps.PixelShaderVersion = D3DPS_VERSION(1, 2);
     hr = ValidatePixelShader(ps_1_1_code, &caps, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     caps.PixelShaderVersion = D3DPS_VERSION(8, 8);
     hr = ValidatePixelShader(ps_1_1_code, &caps, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
 
     *ps_1_1_code = D3DPS_VERSION(1, 0);
     hr = ValidatePixelShader(ps_1_1_code, NULL, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     *ps_1_1_code = D3DPS_VERSION(1, 4);
     hr = ValidatePixelShader(ps_1_1_code, NULL, FALSE, NULL);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
     hr = ValidatePixelShader(ps_2_0_code, NULL, FALSE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     *ps_1_1_code = D3DPS_VERSION(1, 5);
     hr = ValidatePixelShader(ps_1_1_code, NULL, TRUE, NULL);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = ValidatePixelShader(ps_1_1_code, NULL, FALSE, &errors);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(!*errors, "Got unexpected string \"%s\".\n", errors);
     heap_free(errors);
     hr = ValidatePixelShader(ps_1_1_code, NULL, TRUE, &errors);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     ok(!!*errors, "Got unexpected empty string.\n");
     heap_free(errors);
 }
@@ -5201,7 +5190,7 @@ static void test_volume_get_container(void)
     }
 
     hr = IDirect3DDevice8_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");
@@ -5213,47 +5202,47 @@ static void test_volume_get_container(void)
 
     hr = IDirect3DDevice8_CreateVolumeTexture(device, 128, 128, 128, 1, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture);
-    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 = IDirect3DVolumeTexture8_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 = IDirect3DVolume8_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 = IDirect3DVolume8_GetContainer(volume, &IID_IDirect3DResource8, (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 = IDirect3DVolume8_GetContainer(volume, &IID_IDirect3DBaseTexture8, (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 = IDirect3DVolume8_GetContainer(volume, &IID_IDirect3DVolumeTexture8, (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 = IDirect3DVolume8_GetContainer(volume, &IID_IDirect3DVolume8, (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);
 
     IDirect3DVolume8_Release(volume);
     IDirect3DVolumeTexture8_Release(texture);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -5299,24 +5288,24 @@ static void test_vb_lock_flags(void)
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device, 1024, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
             0, D3DPOOL_DEFAULT, &buffer);
-    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)
     {
         hr = IDirect3DVertexBuffer8_Lock(buffer, 0, 0, &data, test_data[i].flags);
-        ok(hr == test_data[i].result, "Got unexpected hr %#x for %s.\n",
+        ok(hr == test_data[i].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 = IDirect3DVertexBuffer8_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);
         }
     }
 
     IDirect3DVertexBuffer8_Release(buffer);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -5345,68 +5334,68 @@ static void test_texture_stage_states(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -5433,35 +5422,35 @@ static void test_cube_textures(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture);
-        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);
         IDirect3DCubeTexture8_Release(texture);
         hr = IDirect3DDevice8_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture);
-        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);
         IDirect3DCubeTexture8_Release(texture);
         hr = IDirect3DDevice8_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture);
-        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);
         IDirect3DCubeTexture8_Release(texture);
     }
     else
     {
         hr = IDirect3DDevice8_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture);
-        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 = IDirect3DDevice8_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture);
-        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 = IDirect3DDevice8_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture);
-        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 = IDirect3DDevice8_CreateCubeTexture(device, 512, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_SCRATCH, &texture);
-    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);
     IDirect3DCubeTexture8_Release(texture);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -5489,30 +5478,30 @@ static void test_get_set_texture(void)
 
     texture = (IDirect3DBaseTexture8 *)0xdeadbeef;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateTexture(device, 16, 16, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_MANAGED, (IDirect3DTexture8 **)&texture);
-    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 = (IDirect3DBaseTexture8Vtbl *)0xdeadbeef;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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;
     IDirect3DBaseTexture8_Release(texture);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -5555,14 +5544,14 @@ static void test_image_surface_pool(void)
     }
 
     hr = IDirect3DDevice8_CreateImageSurface(device, 128, 128, D3DFMT_A8R8G8B8, &surface);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DSurface8_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.Pool == D3DPOOL_SYSTEMMEM, "Got unexpected pool %#x.\n", desc.Pool);
     IDirect3DSurface8_Release(surface);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -5591,47 +5580,47 @@ static void test_surface_get_container(void)
 
     hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 1, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture);
-    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 = IDirect3DTexture8_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 = IDirect3DSurface8_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 = IDirect3DSurface8_GetContainer(surface, &IID_IDirect3DResource8, (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 = IDirect3DSurface8_GetContainer(surface, &IID_IDirect3DBaseTexture8, (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 = IDirect3DSurface8_GetContainer(surface, &IID_IDirect3DTexture8, (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 = IDirect3DSurface8_GetContainer(surface, &IID_IDirect3DSurface8, (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);
 
     IDirect3DSurface8_Release(surface);
     IDirect3DTexture8_Release(texture);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -5708,23 +5697,23 @@ static void test_lockrect_invalid(void)
         {
             case D3DRTYPE_SURFACE:
                 hr = IDirect3DDevice8_CreateImageSurface(device, 128, 128, D3DFMT_A8R8G8B8, &surface);
-                ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, type %s.\n", hr, resources[r].name);
                 break;
 
             case D3DRTYPE_TEXTURE:
                 hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
                         resources[r].pool, &texture);
-                ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx, type %s.\n", hr, resources[r].name);
                 hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &surface);
-                ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx, type %s.\n", hr, resources[r].name);
                 break;
 
             case D3DRTYPE_CUBETEXTURE:
                 hr = IDirect3DDevice8_CreateCubeTexture(device, 128, 1, 0, D3DFMT_A8R8G8B8,
                         resources[r].pool, &cube_texture);
-                ok(SUCCEEDED(hr), "Failed to create cube texture, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to create cube texture, hr %#lx, type %s.\n", hr, resources[r].name);
                 hr = IDirect3DCubeTexture8_GetCubeMapSurface(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0, &surface);
-                ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to get surface level, hr %#lx, type %s.\n", hr, resources[r].name);
                 break;
 
             default:
@@ -5732,13 +5721,13 @@ static void test_lockrect_invalid(void)
         }
 
         hr = IDirect3DSurface8_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 = IDirect3DSurface8_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 = IDirect3DSurface8_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(valid); ++i)
         {
@@ -5748,7 +5737,7 @@ static void test_lockrect_invalid(void)
             locked_rect.Pitch = 0xdeadbeef;
 
             hr = IDirect3DSurface8_LockRect(surface, &locked_rect, rect, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface with rect %s, hr %#x, type %s.\n",
+            ok(SUCCEEDED(hr), "Failed to lock surface with rect %s, hr %#lx, type %s.\n",
                     wine_dbgstr_rect(rect), hr, resources[r].name);
 
             offset = (BYTE *)locked_rect.pBits - base;
@@ -5758,12 +5747,12 @@ static void test_lockrect_invalid(void)
                     offset, expected_offset, wine_dbgstr_rect(rect), resources[r].name);
 
             hr = IDirect3DSurface8_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 = IDirect3DTexture8_LockRect(texture, 0, &locked_rect, rect, 0);
-                ok(SUCCEEDED(hr), "Failed to lock surface with rect %s, hr %#x, type %s.\n",
+                ok(SUCCEEDED(hr), "Failed to lock surface with rect %s, hr %#lx, type %s.\n",
                         wine_dbgstr_rect(rect), hr, resources[r].name);
 
                 offset = (BYTE *)locked_rect.pBits - base;
@@ -5772,12 +5761,12 @@ static void test_lockrect_invalid(void)
                         offset, expected_offset, wine_dbgstr_rect(rect), resources[r].name);
 
                 hr = IDirect3DTexture8_UnlockRect(texture, 0);
-                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 (cube_texture)
             {
                 hr = IDirect3DCubeTexture8_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0, &locked_rect, rect, 0);
-                ok(SUCCEEDED(hr), "Failed to lock surface with rect %s, hr %#x, type %s.\n",
+                ok(SUCCEEDED(hr), "Failed to lock surface with rect %s, hr %#lx, type %s.\n",
                         wine_dbgstr_rect(rect), hr, resources[r].name);
 
                 offset = (BYTE *)locked_rect.pBits - base;
@@ -5786,7 +5775,7 @@ static void test_lockrect_invalid(void)
                         offset, expected_offset, wine_dbgstr_rect(rect), resources[r].name);
 
                 hr = IDirect3DCubeTexture8_UnlockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0);
-                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);
             }
         }
 
@@ -5798,10 +5787,10 @@ static void test_lockrect_invalid(void)
             locked_rect.Pitch = 1;
             hr = IDirect3DSurface8_LockRect(surface, &locked_rect, rect, 0);
             if (resources[r].validate)
-                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(rect), resources[r].name);
             else
-                ok(SUCCEEDED(hr), "Got unexpected hr %#x for rect %s, type %s.\n",
+                ok(SUCCEEDED(hr), "Got unexpected hr %#lx for rect %s, type %s.\n",
                         hr, wine_dbgstr_rect(rect), resources[r].name);
 
             if (SUCCEEDED(hr))
@@ -5813,7 +5802,7 @@ static void test_lockrect_invalid(void)
                         offset, expected_offset,wine_dbgstr_rect(rect), resources[r].name);
 
                 hr = IDirect3DSurface8_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);
             }
             else
             {
@@ -5825,12 +5814,12 @@ static void test_lockrect_invalid(void)
         }
 
         hr = IDirect3DSurface8_LockRect(surface, &locked_rect, NULL, 0);
-        ok(SUCCEEDED(hr), "Failed to lock surface with rect NULL, hr %#x, type %s.\n",
+        ok(SUCCEEDED(hr), "Failed to lock surface with rect NULL, hr %#lx, type %s.\n",
                 hr, resources[r].name);
         locked_rect.pBits = (void *)0xdeadbeef;
         locked_rect.Pitch = 1;
         hr = IDirect3DSurface8_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);
         if (resources[r].clear)
         {
             ok(!locked_rect.pBits, "Got unexpected pBits %p, type %s.\n",
@@ -5846,58 +5835,58 @@ static void test_lockrect_invalid(void)
                     locked_rect.Pitch, resources[r].name);
         }
         hr = IDirect3DSurface8_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 = IDirect3DSurface8_LockRect(surface, &locked_rect, &valid[0], 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(&valid[0]), resources[r].name);
         hr = IDirect3DSurface8_LockRect(surface, &locked_rect, &valid[0], 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(&valid[0]), resources[r].name);
         hr = IDirect3DSurface8_LockRect(surface, &locked_rect, &valid[1], 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(&valid[1]), resources[r].name);
         hr = IDirect3DSurface8_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);
 
         IDirect3DSurface8_Release(surface);
         if (texture)
         {
             hr = IDirect3DTexture8_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 = (void *)0xdeadbeef;
             locked_rect.Pitch = 1;
             hr = IDirect3DTexture8_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 == (void *)0xdeadbeef, "Got unexpected pBits %p, type %s.\n",
                     locked_rect.pBits, resources[r].name);
             ok(locked_rect.Pitch == 1, "Got unexpected Pitch %u, type %s.\n",
                     locked_rect.Pitch, resources[r].name);
             hr = IDirect3DSurface8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_LockRect(texture, 0, &locked_rect, &valid[0], 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(&valid[0]), resources[r].name);
             hr = IDirect3DTexture8_LockRect(texture, 0, &locked_rect, &valid[0], 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(&valid[0]), resources[r].name);
             hr = IDirect3DTexture8_LockRect(texture, 0, &locked_rect, &valid[1], 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(&valid[1]), resources[r].name);
             hr = IDirect3DTexture8_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);
 
             IDirect3DTexture8_Release(texture);
 
             hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 1, D3DUSAGE_WRITEONLY,
                     D3DFMT_A8R8G8B8, resources[r].pool, &texture);
-            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);
         }
 
@@ -5905,50 +5894,50 @@ static void test_lockrect_invalid(void)
         {
             hr = IDirect3DCubeTexture8_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 = (void *)0xdeadbeef;
             locked_rect.Pitch = 1;
             hr = IDirect3DCubeTexture8_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, "Got unexpected pBits %p, type %s.\n",
                     locked_rect.pBits, resources[r].name);
             ok(!locked_rect.Pitch, "Got unexpected Pitch %u, type %s.\n",
                     locked_rect.Pitch, resources[r].name);
             hr = IDirect3DSurface8_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 = IDirect3DCubeTexture8_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 = IDirect3DCubeTexture8_UnlockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 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 = IDirect3DCubeTexture8_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                     &locked_rect, &valid[0], 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(&valid[0]), resources[r].name);
             hr = IDirect3DCubeTexture8_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                     &locked_rect, &valid[0], 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(&valid[0]), resources[r].name);
             hr = IDirect3DCubeTexture8_LockRect(cube_texture, D3DCUBEMAP_FACE_NEGATIVE_X, 0,
                     &locked_rect, &valid[1], 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(&valid[1]), resources[r].name);
             hr = IDirect3DCubeTexture8_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);
 
             IDirect3DTexture8_Release(cube_texture);
 
             hr = IDirect3DDevice8_CreateCubeTexture(device, 128, 1, D3DUSAGE_WRITEONLY, D3DFMT_A8R8G8B8,
                     resources[r].pool, &cube_texture);
-            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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -5985,64 +5974,64 @@ static void test_private_data(void)
     }
 
     hr = IDirect3DDevice8_CreateImageSurface(device, 4, 4, D3DFMT_A8R8G8B8, &surface);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_GetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_FreePrivateData(surface, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_FreePrivateData(surface, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_GetPrivateData(surface, &d3d8_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--;
@@ -6050,26 +6039,26 @@ static void test_private_data(void)
     ptr = (IUnknown *)0xdeadbeef;
     size = 1;
     hr = IDirect3DSurface8_GetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_GetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_GetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_GetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_GetPrivateData(surface, &d3d8_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. */
 
@@ -6077,43 +6066,43 @@ static void test_private_data(void)
     IDirect3DSurface8_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 = IDirect3DDevice8_CreateTexture(device, 4, 4, 2, 0, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &texture);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_SetPrivateData(texture, &d3d8_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 = IDirect3DSurface8_GetPrivateData(surface, &d3d8_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 = IDirect3DTexture8_GetPrivateData(texture, &d3d8_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 = IDirect3DTexture8_FreePrivateData(texture, &d3d8_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 = IDirect3DSurface8_SetPrivateData(surface, &d3d8_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 = IDirect3DSurface8_GetPrivateData(surface2, &d3d8_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 = IDirect3DSurface8_FreePrivateData(surface, &d3d8_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);
 
     IDirect3DSurface8_Release(surface2);
     IDirect3DSurface8_Release(surface);
     IDirect3DTexture8_Release(texture);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -6139,12 +6128,12 @@ static void test_surface_dimensions(void)
     }
 
     hr = IDirect3DDevice8_CreateImageSurface(device, 0, 1, D3DFMT_A8R8G8B8, &surface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateImageSurface(device, 1, 0, D3DFMT_A8R8G8B8, &surface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -6186,56 +6175,56 @@ static void test_surface_format_null(void)
 
     hr = IDirect3D8_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 = IDirect3D8_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 = IDirect3DDevice8_CreateRenderTarget(device, 128, 128, D3DFMT_NULL,
             D3DMULTISAMPLE_NONE, TRUE, &surface);
-    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 = IDirect3DDevice8_GetRenderTarget(device, &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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, surface, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(rt);
     IDirect3DSurface8_Release(ds);
 
     hr = IDirect3DSurface8_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 = IDirect3DSurface8_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 = IDirect3DSurface8_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(surface);
 
     hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 0, D3DUSAGE_RENDERTARGET,
             D3DFMT_NULL, D3DPOOL_DEFAULT, &texture);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     IDirect3DTexture8_Release(texture);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -6282,12 +6271,12 @@ static void test_surface_double_unlock(void)
 
                 hr = IDirect3DDevice8_CreateRenderTarget(device, 64, 64, D3DFMT_X8R8G8B8,
                         D3DMULTISAMPLE_NONE, TRUE, &surface);
-                ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx.\n", hr);
                 break;
 
             case D3DPOOL_SYSTEMMEM:
                 hr = IDirect3DDevice8_CreateImageSurface(device, 64, 64, D3DFMT_X8R8G8B8, &surface);
-                ok(SUCCEEDED(hr), "Failed to create image surface, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to create image surface, hr %#lx.\n", hr);
                 break;
 
             default:
@@ -6295,19 +6284,19 @@ static void test_surface_double_unlock(void)
         }
 
         hr = IDirect3DSurface8_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 = IDirect3DSurface8_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 = IDirect3DSurface8_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 = IDirect3DSurface8_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]);
 
         IDirect3DSurface8_Release(surface);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -6422,7 +6411,7 @@ static void test_surface_blocks(void)
     }
 
     hr = IDirect3DDevice8_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);
@@ -6540,7 +6529,7 @@ static void test_surface_blocks(void)
                      * on an r200 GPU creates scratch ATI2N texture even though the card doesn't
                      * support it. */
                     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))
@@ -6564,9 +6553,9 @@ static void test_surface_blocks(void)
             hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 1,
                     pools[j].pool == D3DPOOL_DEFAULT ? D3DUSAGE_DYNAMIC : 0,
                     formats[i].fmt, pools[j].pool, &texture);
-            ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
             hr = IDirect3DTexture8_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);
             IDirect3DTexture8_Release(texture);
 
             if (formats[i].block_width > 1)
@@ -6580,7 +6569,7 @@ static void test_surface_blocks(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface8_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);
@@ -6592,7 +6581,7 @@ static void test_surface_blocks(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface8_UnlockRect(surface);
-                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
                 }
             }
 
@@ -6607,7 +6596,7 @@ static void test_surface_blocks(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface8_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);
@@ -6619,28 +6608,27 @@ static void test_surface_blocks(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface8_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 = IDirect3DSurface8_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",
-                        SUCCEEDED(hr) ? "succeeded" : "failed", hr, pools[j].success ? "success" : "failure",
-                        formats[i].name, pools[j].name, k);
+                ok(FAILED(hr) == !pools[j].success, "Got hr %#lx, format %s, pool %s, case %u.\n",
+                        hr, formats[i].name, pools[j].name, k);
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirect3DSurface8_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 = IDirect3DSurface8_LockRect(surface, &locked_rect, &rect, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x for format %s, pool %s.\n", hr, formats[i].name, pools[j].name);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx for format %s, pool %s.\n", hr, formats[i].name, pools[j].name);
             hr = IDirect3DSurface8_UnlockRect(surface);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
             IDirect3DSurface8_Release(surface);
         }
@@ -6652,26 +6640,26 @@ static void test_surface_blocks(void)
 
         hr = IDirect3DDevice8_CreateTexture(device, formats[i].block_width, formats[i].block_height, 2,
                 D3DUSAGE_DYNAMIC, formats[i].fmt, D3DPOOL_DEFAULT, &texture);
-        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 = IDirect3DTexture8_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 = IDirect3DTexture8_UnlockRect(texture, 1);
-        ok(SUCCEEDED(hr), "Failed lock texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed lock texture, hr %#lx.\n", hr);
 
         rect.left = 0;
         rect.top = 0;
         rect.right = formats[i].block_width == 1 ? 1 : formats[i].block_width >> 1;
         rect.bottom = formats[i].block_height == 1 ? 1 : formats[i].block_height >> 1;
         hr = IDirect3DTexture8_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 = IDirect3DTexture8_UnlockRect(texture, 1);
-        ok(SUCCEEDED(hr), "Failed lock texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed lock texture, hr %#lx.\n", hr);
 
         rect.right = formats[i].block_width;
         rect.bottom = formats[i].block_height;
         hr = IDirect3DTexture8_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))
             IDirect3DTexture8_UnlockRect(texture, 1);
 
@@ -6679,7 +6667,7 @@ static void test_surface_blocks(void)
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -6714,10 +6702,10 @@ static void test_set_palette(void)
         pal[i].peFlags = 0xff;
     }
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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;
@@ -6728,12 +6716,12 @@ static void test_set_palette(void)
     if (caps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE)
     {
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
@@ -6787,14 +6775,14 @@ static void test_pinned_buffers(void)
 
         hr = IDirect3DDevice8_CreateVertexBuffer(device, vertex_count * sizeof(*ptr),
                 tests[test].usage, 0, tests[test].pool, &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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_Lock(buffer, 0, vertex_count * sizeof(*ptr), (BYTE **)&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;
@@ -6802,21 +6790,21 @@ static void test_pinned_buffers(void)
             ptr[i].z = i * 3.0f;
         }
         hr = IDirect3DVertexBuffer8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_SetStreamSource(device, 0, buffer, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DVertexBuffer8_Lock(buffer, 0, vertex_count * sizeof(*ptr2), (BYTE **)&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)
         {
@@ -6828,7 +6816,7 @@ static void test_pinned_buffers(void)
             }
         }
         hr = IDirect3DVertexBuffer8_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);
 
         IDirect3DVertexBuffer8_Release(buffer);
         refcount = IDirect3DDevice8_Release(device);
@@ -6875,7 +6863,7 @@ static void test_npot_textures(void)
     }
 
     hr = IDirect3DDevice8_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);
@@ -6905,7 +6893,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))
@@ -6916,13 +6904,11 @@ static void test_npot_textures(void)
                 pools[i].pool, &cube_texture);
         if (tex_pow2)
         {
-            ok(hr == pools[i].hr, "CreateCubeTexture(EdgeLength=3, %s) returned hr %#x, expected %#x.\n",
-                    pools[i].pool_name, hr, pools[i].hr);
+            ok(hr == pools[i].hr, "CreateCubeTexture(EdgeLength=3, %s) returned hr %#lx.\n", pools[i].pool_name, hr);
         }
         else
         {
-            ok(SUCCEEDED(hr), "CreateCubeTexture(EdgeLength=3, %s) returned hr %#x, expected %#x.\n",
-                    pools[i].pool_name, hr, D3D_OK);
+            ok(SUCCEEDED(hr), "CreateCubeTexture(EdgeLength=3, %s) returned hr %#lx.\n", pools[i].pool_name, hr);
         }
 
         if (SUCCEEDED(hr))
@@ -6932,13 +6918,11 @@ static void test_npot_textures(void)
                 pools[i].pool, &volume_texture);
         if (tex_pow2)
         {
-            ok(hr == pools[i].hr, "CreateVolumeTextur(Depth=3, %s) returned hr %#x, expected %#x.\n",
-                    pools[i].pool_name, hr, pools[i].hr);
+            ok(hr == pools[i].hr, "CreateVolumeTextur(Depth=3, %s) returned hr %#lx.\n", pools[i].pool_name, hr);
         }
         else
         {
-            ok(SUCCEEDED(hr), "CreateVolumeTextur(Depth=3, %s) returned hr %#x, expected %#x.\n",
-                    pools[i].pool_name, hr, D3D_OK);
+            ok(SUCCEEDED(hr), "CreateVolumeTextur(Depth=3, %s) returned hr %#lx.\n", pools[i].pool_name, hr);
         }
 
         if (SUCCEEDED(hr))
@@ -6949,7 +6933,7 @@ done:
     if (device)
     {
         refcount = IDirect3DDevice8_Release(device);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
@@ -6997,7 +6981,7 @@ static void test_volume_locking(void)
     }
 
     hr = IDirect3DDevice8_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");
@@ -7008,18 +6992,18 @@ static void test_volume_locking(void)
     {
         hr = IDirect3DDevice8_CreateVolumeTexture(device, 4, 4, 4, 1, tests[i].usage,
                 D3DFMT_A8R8G8B8, tests[i].pool, &texture);
-        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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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
         {
@@ -7030,7 +7014,7 @@ static void test_volume_locking(void)
 
 out:
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -7097,7 +7081,7 @@ static void test_update_volumetexture(void)
     d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
     ok(!!d3d8, "Failed to create a D3D object.\n");
     hr = IDirect3D8_GetAdapterIdentifier(d3d8, 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(d3d8, window, NULL)))
     {
@@ -7108,7 +7092,7 @@ static void test_update_volumetexture(void)
     }
 
     hr = IDirect3DDevice8_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");
@@ -7122,29 +7106,29 @@ static void test_update_volumetexture(void)
 
         hr = IDirect3DDevice8_CreateVolumeTexture(device, 1, 1, 1, 1, src_usage,
                 D3DFMT_A8R8G8B8, tests[i].src_pool, &src);
-        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 = IDirect3DDevice8_CreateVolumeTexture(device, 1, 1, 1, 1, dst_usage,
                 D3DFMT_A8R8G8B8, tests[i].dst_pool, &dst);
-        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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)src, (IDirect3DBaseTexture8 *)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 %#x.\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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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);
         }
         IDirect3DVolumeTexture8_Release(src);
         IDirect3DVolumeTexture8_Release(dst);
@@ -7161,16 +7145,16 @@ static void test_update_volumetexture(void)
         hr = IDirect3DDevice8_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);
-        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 = IDirect3DDevice8_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);
-        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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)src, (IDirect3DBaseTexture8 *)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);
 
         IDirect3DVolumeTexture8_Release(src);
         IDirect3DVolumeTexture8_Release(dst);
@@ -7186,7 +7170,7 @@ static void test_update_volumetexture(void)
 
 out:
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -7216,7 +7200,7 @@ static void test_create_rt_ds_fail(void)
     surface = (IDirect3DSurface8 *)0xdeadbeef;
     hr = IDirect3DDevice8_CreateRenderTarget(device, 4, 4, D3DFMT_D16,
             D3DMULTISAMPLE_NONE, FALSE, &surface);
-    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))
         IDirect3DSurface8_Release(surface);
@@ -7224,13 +7208,13 @@ static void test_create_rt_ds_fail(void)
     surface = (IDirect3DSurface8 *)0xdeadbeef;
     hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 4, 4, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, &surface);
-    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))
         IDirect3DSurface8_Release(surface);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -7323,7 +7307,7 @@ static void test_volume_blocks(void)
         return;
     }
     hr = IDirect3DDevice8_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++)
@@ -7376,7 +7360,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))
@@ -7393,7 +7377,7 @@ static void test_volume_blocks(void)
 
         hr = IDirect3DDevice8_CreateVolumeTexture(device, 24, 8, 8, 1, 0,
                 formats[i].fmt, D3DPOOL_SCRATCH, &texture);
-        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++)
@@ -7402,7 +7386,7 @@ static void test_volume_blocks(void)
             bytes_per_pixel = formats[i].block_size / (formats[i].block_width * formats[i].block_height);
 
             hr = IDirect3DVolumeTexture8_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)
@@ -7435,7 +7419,7 @@ static void test_volume_blocks(void)
                     locked_box.SlicePitch, formats[i].name, expected_slice_pitch);
 
             hr = IDirect3DVolumeTexture8_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;
@@ -7444,7 +7428,7 @@ static void test_volume_blocks(void)
             box.Bottom = offset_tests[j].y2;
             box.Back = offset_tests[j].z2;
             hr = IDirect3DVolumeTexture8_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)
@@ -7469,7 +7453,7 @@ static void test_volume_blocks(void)
                     offset, formats[i].name, expected_offset, box.Left, box.Top, box.Front);
 
             hr = IDirect3DVolumeTexture8_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 */
@@ -7488,7 +7472,7 @@ static void test_volume_blocks(void)
             if (SUCCEEDED(hr))
             {
                 hr = IDirect3DVolumeTexture8_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;
@@ -7502,7 +7486,7 @@ static void test_volume_blocks(void)
             if (SUCCEEDED(hr))
             {
                 hr = IDirect3DVolumeTexture8_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);
             }
         }
 
@@ -7519,7 +7503,7 @@ static void test_volume_blocks(void)
             if (SUCCEEDED(hr))
             {
                 hr = IDirect3DVolumeTexture8_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;
@@ -7533,7 +7517,7 @@ static void test_volume_blocks(void)
             if (SUCCEEDED(hr))
             {
                 hr = IDirect3DVolumeTexture8_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);
             }
         }
 
@@ -7543,9 +7527,9 @@ static void test_volume_blocks(void)
         box.Right = formats[i].block_width;
         box.Bottom = formats[i].block_height;
         hr = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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);
 
         IDirect3DVolumeTexture8_Release(texture);
 
@@ -7556,25 +7540,25 @@ static void test_volume_blocks(void)
             hr = IDirect3DDevice8_CreateVolumeTexture(device, formats[i].block_width, formats[i].block_height,
                     2, 2, 0, formats[i].fmt, D3DPOOL_SCRATCH, &texture);
 
-            ok(SUCCEEDED(hr), "CreateVolumeTexture failed, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "CreateVolumeTexture failed, hr %#lx.\n", hr);
             hr = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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))
                 IDirect3DVolumeTexture8_UnlockBox(texture, 1);
 
@@ -7636,12 +7620,12 @@ static void test_lockbox_invalid(void)
 
     hr = IDirect3DDevice8_CreateVolumeTexture(device, 4, 4, 2, 1, 0,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &texture);
-    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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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)
     {
@@ -7655,7 +7639,7 @@ static void test_lockbox_invalid(void)
         hr = IDirect3DVolumeTexture8_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))
@@ -7668,42 +7652,42 @@ static void test_lockbox_invalid(void)
                 offset, expected_offset, box->Left, box->Top, box->Front, box->Right, box->Bottom, box->Back);
 
         hr = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_UnlockBox(texture, 0);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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);
 
     IDirect3DVolumeTexture8_Release(texture);
 
     hr = IDirect3DDevice8_CreateVolumeTexture(device, 4, 4, 2, 1, D3DUSAGE_WRITEONLY,
             D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &texture);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -7778,37 +7762,37 @@ static void test_pixel_format(void)
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice8_SetVertexShader(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);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed %#x\n", hr);
+    ok(SUCCEEDED(hr), "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 = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1, point, 3 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed %#x\n", hr);
+    ok(SUCCEEDED(hr), "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 = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed %#x\n", hr);
+    ok(SUCCEEDED(hr), "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 = IDirect3DDevice8_Present(device, NULL, NULL, hwnd2, NULL);
-    ok(SUCCEEDED(hr), "Present failed %#x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -7853,56 +7837,56 @@ static void test_begin_end_state_block(void)
     }
 
     hr = IDirect3DDevice8_BeginStateBlock(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = 0xdeadbeef;
     hr = IDirect3DDevice8_EndStateBlock(device, &stateblock);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!stateblock && stateblock != 0xdeadbeef, "Got unexpected stateblock %#x.\n", stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!stateblock && stateblock != 0xdeadbeef, "Got unexpected stateblock %#lx.\n", stateblock);
 
     stateblock2 = 0xdeadbeef;
     hr = IDirect3DDevice8_EndStateBlock(device, &stateblock2);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
-    ok(stateblock2 == 0xdeadbeef, "Got unexpected stateblock %#x.\n", stateblock2);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
+    ok(stateblock2 == 0xdeadbeef, "Got unexpected stateblock %#lx.\n", stateblock2);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginStateBlock(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginStateBlock(device);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_ApplyStateBlock(device, stateblock);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CaptureStateBlock(device, stateblock);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_EndStateBlock(device, &stateblock2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_ApplyStateBlock(device, stateblock2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -7934,79 +7918,79 @@ static void test_shader_constant_apply(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShaderConstant(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 = IDirect3DDevice8_SetVertexShaderConstant(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 = IDirect3DDevice8_GetVertexShaderConstant(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 = IDirect3DDevice8_GetVertexShaderConstant(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 = IDirect3DDevice8_SetVertexShaderConstant(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 = IDirect3DDevice8_SetPixelShaderConstant(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 = IDirect3DDevice8_SetPixelShaderConstant(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 = IDirect3DDevice8_GetPixelShaderConstant(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 = IDirect3DDevice8_GetPixelShaderConstant(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 = IDirect3DDevice8_SetPixelShaderConstant(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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShaderConstant(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 = IDirect3DDevice8_SetPixelShaderConstant(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 = IDirect3DDevice8_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 = IDirect3DDevice8_GetVertexShaderConstant(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 = IDirect3DDevice8_GetVertexShaderConstant(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]);
@@ -8014,12 +7998,12 @@ static void test_shader_constant_apply(void)
     if (ps_version)
     {
         hr = IDirect3DDevice8_GetPixelShaderConstant(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 = IDirect3DDevice8_GetPixelShaderConstant(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]);
@@ -8028,17 +8012,17 @@ static void test_shader_constant_apply(void)
     /* Apply doesn't overwrite constants that aren't explicitly set on the
      * source stateblock. */
     hr = IDirect3DDevice8_ApplyStateBlock(device, 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 = IDirect3DDevice8_GetVertexShaderConstant(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 = IDirect3DDevice8_GetVertexShaderConstant(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]);
@@ -8046,12 +8030,12 @@ static void test_shader_constant_apply(void)
     if (ps_version)
     {
         hr = IDirect3DDevice8_GetPixelShaderConstant(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 = IDirect3DDevice8_GetPixelShaderConstant(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]);
@@ -8059,7 +8043,7 @@ static void test_shader_constant_apply(void)
 
     IDirect3DDevice8_DeleteStateBlock(device, stateblock);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -8093,32 +8077,32 @@ static void test_resource_type(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_CreateImageSurface(device, 4, 4, D3DFMT_X8R8G8B8, &surface);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DSurface8_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);
     IDirect3DSurface8_Release(surface);
 
     hr = IDirect3DDevice8_CreateTexture(device, 2, 8, 4, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     type = IDirect3DTexture8_GetType(texture);
     ok(type == D3DRTYPE_TEXTURE, "Expected type D3DRTYPE_TEXTURE, got %u.\n", type);
 
     hr = IDirect3DTexture8_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 = IDirect3DSurface8_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 = IDirect3DTexture8_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);
@@ -8126,15 +8110,15 @@ static void test_resource_type(void)
     IDirect3DSurface8_Release(surface);
 
     hr = IDirect3DTexture8_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);
     hr = IDirect3DSurface8_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 = IDirect3DTexture8_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);
@@ -8146,19 +8130,19 @@ static void test_resource_type(void)
     {
         hr = IDirect3DDevice8_CreateCubeTexture(device, 1, 1, 0, D3DFMT_X8R8G8B8,
                 D3DPOOL_SYSTEMMEM, &cube_texture);
-        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 = IDirect3DCubeTexture8_GetType(cube_texture);
         ok(type == D3DRTYPE_CUBETEXTURE, "Expected type D3DRTYPE_CUBETEXTURE, got %u.\n", type);
 
         hr = IDirect3DCubeTexture8_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);
         hr = IDirect3DSurface8_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 = IDirect3DCubeTexture8_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);
         IDirect3DSurface8_Release(surface);
@@ -8171,22 +8155,22 @@ static void test_resource_type(void)
     {
         hr = IDirect3DDevice8_CreateVolumeTexture(device, 2, 4, 8, 4, 0, D3DFMT_X8R8G8B8,
                 D3DPOOL_SYSTEMMEM, &volume_texture);
-        ok(SUCCEEDED(hr), "CreateVolumeTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateVolumeTexture failed, hr %#lx.\n", hr);
         type = IDirect3DVolumeTexture8_GetType(volume_texture);
         ok(type == D3DRTYPE_VOLUMETEXTURE, "Expected type D3DRTYPE_VOLUMETEXTURE, got %u.\n", type);
 
         hr = IDirect3DVolumeTexture8_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);
         /* IDirect3DVolume8 is not an IDirect3DResource8 and has no GetType method. */
         hr = IDirect3DVolume8_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 = IDirect3DVolumeTexture8_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);
@@ -8195,16 +8179,16 @@ static void test_resource_type(void)
         IDirect3DVolume8_Release(volume);
 
         hr = IDirect3DVolumeTexture8_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);
         hr = IDirect3DVolume8_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 = IDirect3DVolumeTexture8_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);
@@ -8217,7 +8201,7 @@ static void test_resource_type(void)
         skip("Mipmapped volume maps not supported.\n");
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -8246,39 +8230,39 @@ static void test_mipmap_lock(void)
 
     hr = IDirect3DDevice8_CreateTexture(device, 4, 4, 2, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_DEFAULT, &texture_dst);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_CreateTexture(device, 4, 4, 2, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DSurface8_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 = IDirect3DSurface8_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 = IDirect3DSurface8_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 = IDirect3DDevice8_CopyRects(device, surface, NULL, 0, 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 = IDirect3DDevice8_CopyRects(device, surface2, NULL, 0, surface_dst2, NULL);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     /* Apparently there's no validation on the container. */
     hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)texture,
             (IDirect3DBaseTexture8 *)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 = IDirect3DSurface8_UnlockRect(surface2);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(surface_dst2);
     IDirect3DSurface8_Release(surface_dst);
@@ -8288,7 +8272,7 @@ static void test_mipmap_lock(void)
     IDirect3DTexture8_Release(texture);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -8327,41 +8311,41 @@ static void test_writeonly_resource(void)
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device, sizeof(quad),
             D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &buffer);
-    ok(SUCCEEDED(hr), "Failed to create buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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 = IDirect3DDevice8_SetStreamSource(device, 0, buffer, 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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene %#x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene %#x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_Release(buffer);
-    ok(!refcount, "Vertex buffer has %u references left.\n", refcount);
+    ok(!refcount, "Vertex buffer has %lu references left.\n", refcount);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -8381,7 +8365,7 @@ static void test_lost_device(void)
     d3d = Direct3DCreate8(D3D_SDK_VERSION);
     ok(!!d3d, "Failed to create a D3D object.\n");
     hr = IDirect3D8_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);
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
     device_desc.device_window = window;
     device_desc.width = registry_mode.dmPelsWidth;
@@ -8407,78 +8391,78 @@ static void test_lost_device(void)
         goto done;
     }
 
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
     /* The device is not lost on Windows 10. */
-    ok(hr == D3DERR_DEVICELOST || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST || broken(hr == D3D_OK), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3DERR_DEVICELOST || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST || broken(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 = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3DERR_DEVICENOTRESET || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICENOTRESET || broken(hr == D3D_OK), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3DERR_DEVICELOST || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST || broken(hr == D3D_OK), "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 = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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");
     hr = IDirect3DDevice8_TestCooperativeLevel(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_TestCooperativeLevel(device);
     /* The device is not lost on Windows 10. */
-    todo_wine ok(hr == D3DERR_DEVICELOST || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_DEVICELOST || broken(hr == D3D_OK), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    todo_wine ok(hr == D3DERR_DEVICELOST || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_DEVICELOST || broken(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 || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_DEVICELOST || broken(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 = 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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -8524,21 +8508,21 @@ static void test_resource_priority(void)
     {
         hr = IDirect3DDevice8_CreateTexture(device, 16, 16, 0, 0, D3DFMT_X8R8G8B8,
                 test_data[i].pool, &texture);
-        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);
 
         priority = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_SetPriority(texture, 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);
 
         IDirect3DTexture8_Release(texture);
 
@@ -8546,28 +8530,28 @@ static void test_resource_priority(void)
         {
             hr = IDirect3DDevice8_CreateVertexBuffer(device, 256, 0, 0,
                     test_data[i].pool, &buffer);
-            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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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);
 
             IDirect3DVertexBuffer8_Release(buffer);
         }
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -8643,7 +8627,7 @@ static void test_swapchain_parameters(void)
         return;
     }
     hr = IDirect3DDevice8_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);
     IDirect3DDevice8_Release(device);
 
     present_parameters_windowed.BackBufferWidth = registry_mode.dmPelsWidth;
@@ -8670,24 +8654,24 @@ static void test_swapchain_parameters(void)
 
         hr = IDirect3D8_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))
         {
             for (j = 0; j < bb_count; ++j)
             {
                 hr = IDirect3DDevice8_GetBackBuffer(device, j, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-                ok(SUCCEEDED(hr), "Failed to get backbuffer %u, hr %#x, test %u.\n", j, hr, i);
+                ok(SUCCEEDED(hr), "Failed to get backbuffer %u, hr %#lx, test %u.\n", j, hr, i);
                 IDirect3DSurface8_Release(backbuffer);
             }
             hr = IDirect3DDevice8_GetBackBuffer(device, j, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %x, test %u.\n", hr, i);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, test %u.\n", hr, i);
 
             IDirect3DDevice8_Release(device);
         }
 
         hr = IDirect3D8_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;
@@ -8700,12 +8684,12 @@ static void test_swapchain_parameters(void)
         present_parameters.BackBufferCount = tests[i].backbuffer_count;
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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);
         }
         else
         {
@@ -8713,12 +8697,12 @@ static void test_swapchain_parameters(void)
             {
                 hr = IDirect3DDevice8_GetBackBuffer(device, j, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
                 todo_wine_if (j)
-                    ok(SUCCEEDED(hr), "Failed to get backbuffer %u, hr %#x, test %u.\n", j, hr, i);
+                    ok(SUCCEEDED(hr), "Failed to get backbuffer %u, hr %#lx, test %u.\n", j, hr, i);
                 if (SUCCEEDED(hr))
                     IDirect3DSurface8_Release(backbuffer);
             }
             hr = IDirect3DDevice8_GetBackBuffer(device, j, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %x, test %u.\n", hr, i);
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, test %u.\n", hr, i);
         }
         IDirect3DDevice8_Release(device);
     }
@@ -8754,7 +8738,7 @@ static void test_swapchain_parameters(void)
 
         hr = IDirect3D8_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 (SUCCEEDED(hr))
             IDirect3DDevice8_Release(device);
     }
@@ -8776,54 +8760,54 @@ static void test_check_device_format(void)
     {
         hr = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, 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 = IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
             0, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8);
-    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);
 
     hr = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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);
 
     IDirect3D8_Release(d3d);
 }
@@ -8877,7 +8861,7 @@ static void test_miptree_layout(void)
     }
 
     hr = IDirect3DDevice8_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))
@@ -8899,14 +8883,14 @@ static void test_miptree_layout(void)
         {
             hr = IDirect3DDevice8_CreateTexture(device, base_dimension, base_dimension, 0, 0,
                     formats[format_idx].format, pools[pool_idx].pool, &texture_2d);
-            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 = IDirect3DTexture8_GetLevelCount(texture_2d);
             for (i = 0, offset = 0; i < level_count; ++i)
             {
                 hr = IDirect3DTexture8_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)
@@ -8918,7 +8902,7 @@ static void test_miptree_layout(void)
                 offset += (base_dimension >> i) * map_desc.Pitch;
 
                 hr = IDirect3DTexture8_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);
             }
 
@@ -8936,7 +8920,7 @@ static void test_miptree_layout(void)
         {
             hr = IDirect3DDevice8_CreateCubeTexture(device, base_dimension, 0, 0,
                     formats[format_idx].format, pools[pool_idx].pool, &texture_cube);
-            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 = IDirect3DCubeTexture8_GetLevelCount(texture_cube);
@@ -8945,7 +8929,7 @@ static void test_miptree_layout(void)
                 for (j = 0; j < level_count; ++j)
                 {
                     hr = IDirect3DCubeTexture8_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)
@@ -8957,7 +8941,7 @@ static void test_miptree_layout(void)
                     offset += (base_dimension >> j) * map_desc.Pitch;
 
                     hr = IDirect3DCubeTexture8_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;
@@ -8995,30 +8979,30 @@ static void test_render_target_device_mismatch(void)
     }
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &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 = IDirect3DDevice8_CreateRenderTarget(device2, 640, 480,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &surface);
-    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 = IDirect3DDevice8_SetRenderTarget(device, surface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(surface);
 
     hr = IDirect3DDevice8_GetRenderTarget(device2, &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 = IDirect3DDevice8_SetRenderTarget(device, surface, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(surface);
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &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);
     IDirect3DSurface8_Release(surface);
     IDirect3DSurface8_Release(rt);
@@ -9061,68 +9045,68 @@ static void test_format_unknown(void)
         iface = (void *)0xdeadbeef;
         hr = IDirect3DDevice8_CreateRenderTarget(device, 64, 64,
                 D3DFMT_P8, D3DMULTISAMPLE_NONE, FALSE, (IDirect3DSurface8 **)&iface);
-        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 = IDirect3DDevice8_CreateDepthStencilSurface(device, 64, 64,
                 D3DFMT_P8, D3DMULTISAMPLE_NONE, (IDirect3DSurface8 **)&iface);
-        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 = IDirect3DDevice8_CreateTexture(device, 64, 64, 1, 0,
                 D3DFMT_P8, D3DPOOL_DEFAULT, (IDirect3DTexture8 **)&iface);
-        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 = IDirect3DDevice8_CreateCubeTexture(device, 64, 1, 0,
                 D3DFMT_P8, D3DPOOL_DEFAULT, (IDirect3DCubeTexture8 **)&iface);
-        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 = IDirect3DDevice8_CreateVolumeTexture(device, 64, 64, 1, 1, 0,
                 D3DFMT_P8, D3DPOOL_DEFAULT, (IDirect3DVolumeTexture8 **)&iface);
-        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 = IDirect3DDevice8_CreateRenderTarget(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, FALSE, (IDirect3DSurface8 **)&iface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(iface == (void *)0xdeadbeef, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, (IDirect3DSurface8 **)&iface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(iface == (void *)0xdeadbeef, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice8_CreateImageSurface(device, 64, 64,
             D3DFMT_UNKNOWN, (IDirect3DSurface8 **)&iface);
-    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 = IDirect3DDevice8_CreateTexture(device, 64, 64, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DTexture8 **)&iface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(iface == (void *)0xdeadbeef, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice8_CreateCubeTexture(device, 64, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DCubeTexture8 **)&iface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(iface == (void *)0xdeadbeef, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice8_CreateVolumeTexture(device, 64, 64, 1, 1, 0,
             D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, (IDirect3DVolumeTexture8 **)&iface);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
     ok(iface == (void *)0xdeadbeef, "Got unexpected iface %p.\n", iface);
 
     refcount = IDirect3DDevice8_Release(device);
@@ -9156,16 +9140,16 @@ static void test_destroyed_window(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice8_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)
@@ -9193,10 +9177,10 @@ static void test_lockable_backbuffer(void)
     }
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DSurface8_LockRect(surface, &lockrect, NULL, D3DLOCK_READONLY);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(surface);
 
@@ -9212,19 +9196,19 @@ static void test_lockable_backbuffer(void)
     present_parameters.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DSurface8_LockRect(surface, &lockrect, NULL, D3DLOCK_READONLY);
-    ok(SUCCEEDED(hr), "Failed to lock rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock rect, hr %#lx.\n", hr);
     hr = IDirect3DSurface8_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(surface);
     refcount = IDirect3DDevice8_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;
@@ -9236,16 +9220,16 @@ static void test_lockable_backbuffer(void)
     ok(!!device, "Failed to create device.\n");
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DSurface8_LockRect(surface, &lockrect, NULL, D3DLOCK_READONLY);
-    ok(SUCCEEDED(hr), "Failed to lock rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock rect, hr %#lx.\n", hr);
     hr = IDirect3DSurface8_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(surface);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -9277,21 +9261,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 = IDirect3DDevice8_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 < caps.MaxUserClipPlanes; ++j)
         {
             memset(plane, 0xff, sizeof(plane));
             hr = IDirect3DDevice8_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]);
@@ -9304,31 +9288,31 @@ static void test_clip_planes_limits(void)
         {
             plane[3] = j;
             hr = IDirect3DDevice8_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 < caps.MaxUserClipPlanes; ++j)
         {
             memset(plane, 0xff, sizeof(plane));
             hr = IDirect3DDevice8_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] == j,
                     "Got unexpected plane %u: %.8e, %.8e, %.8e, %.8e.\n",
                     j, plane[0], plane[1], plane[2], plane[3]);
         }
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-        ok(!refcount, "Device has %u references left.\n", refcount);
+        ok(!refcount, "Device has %lu references left.\n", refcount);
     }
 
     IDirect3D8_Release(d3d);
@@ -9367,7 +9351,7 @@ static void test_swapchain_multisample_reset(void)
     }
 
     hr = IDirect3DDevice8_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);
 
     memset(&present_parameters, 0, sizeof(present_parameters));
     present_parameters.BackBufferWidth = 640;
@@ -9378,13 +9362,13 @@ static void test_swapchain_multisample_reset(void)
     present_parameters.Windowed = TRUE;
     present_parameters.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
     hr = IDirect3DDevice8_Reset(device, &present_parameters);
-    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 = IDirect3DDevice8_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);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -9414,7 +9398,7 @@ static void test_device_caps(void)
     {
         /* Test IDirect3D8_GetDeviceCaps */
         hr = IDirect3D8_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)
         {
@@ -9433,30 +9417,30 @@ static void test_device_caps(void)
             break;
         }
         hr = IDirect3DDevice8_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);
 
         ok(caps.AdapterOrdinal == adapter_idx, "Adapter %u: Got unexpected adapter ordinal %u.\n",
                 adapter_idx, caps.AdapterOrdinal);
         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_CANCALIBRATEGAMMA | D3DCAPS2_CANRENDERWINDOWED
                 | D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_FULLSCREENGAMMA
                 | D3DCAPS2_NO2DDURING3DSCENE | D3DCAPS2_RESERVED)),
-                "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);
         /* Nvidia returns that 0x400 flag, which is probably Vista+
          * D3DCAPS3_DXVAHD from d3d9caps.h */
         /* AMD doesn't filter all the ddraw / d3d9 caps. Consider that behavior
          * broken. */
         ok(!(caps.Caps3 & ~(D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD | D3DCAPS3_RESERVED | 0x400))
                 || broken(!(caps.Caps3 & ~(D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD | 0x80))),
-                "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
                 | D3DPMISCCAPS_CLIPTLVERTS | D3DPMISCCAPS_TSSARGTEMP | D3DPMISCCAPS_BLENDOP
                 | D3DPMISCCAPS_NULLREFERENCE))
                 || broken(!(caps.PrimitiveMiscCaps & ~0x003fdff6)),
-                "Adapter %u: PrimitiveMiscCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: PrimitiveMiscCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.PrimitiveMiscCaps);
         /* AMD includes an unknown 0x2 flag. */
         ok(!(caps.RasterCaps & ~(D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_PAT | D3DPRASTERCAPS_ZTEST
@@ -9466,21 +9450,21 @@ static void test_device_caps(void)
                 | D3DPRASTERCAPS_WFOG | D3DPRASTERCAPS_ZFOG | D3DPRASTERCAPS_COLORPERSPECTIVE
                 | D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE))
                 || broken(!(caps.RasterCaps & ~0x0ff7f19b)),
-                "Adapter %u: RasterCaps field has unexpected flags %#x.\n", adapter_idx,
+                "Adapter %u: RasterCaps field has unexpected flags %#lx.\n", adapter_idx,
                 caps.RasterCaps);
         ok(!(caps.SrcBlendCaps & ~(D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR
                 | D3DPBLENDCAPS_INVSRCCOLOR | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA
                 | D3DPBLENDCAPS_DESTALPHA | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR
                 | D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA
                 | D3DPBLENDCAPS_BOTHINVSRCALPHA)),
-                "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
                 | D3DPBLENDCAPS_DESTALPHA | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR
                 | D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA
                 | D3DPBLENDCAPS_BOTHINVSRCALPHA)),
-                "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
@@ -9489,7 +9473,7 @@ static void test_device_caps(void)
                 | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_VOLUMEMAP | D3DPTEXTURECAPS_MIPMAP
                 | D3DPTEXTURECAPS_MIPVOLUMEMAP | D3DPTEXTURECAPS_MIPCUBEMAP
                 | D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2)),
-                "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_MIPFPOINT
@@ -9497,50 +9481,50 @@ static void test_device_caps(void)
                 | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFAFLATCUBIC
                 | D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC))
                 || broken(!(caps.TextureFilterCaps & ~0x0703073f)),
-                "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_MIPFPOINT
                 | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR
                 | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFAFLATCUBIC
                 | D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC)),
-                "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_MIPFPOINT
                 | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR
                 | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFAFLATCUBIC
                 | D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC)),
-                "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)),
-                "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)),
-                "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_NO_VSDT_UBYTE4)),
-                "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 = IDirect3DDevice8_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);
     }
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -9569,19 +9553,19 @@ static void test_get_info(void)
 
     /* As called by Chessmaster 9000 (bug 42118). */
     hr = IDirect3DDevice8_GetInfo(device, 4, info, 16);
-    ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
+    ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < 256; ++i)
     {
         hr = IDirect3DDevice8_GetInfo(device, i, info, sizeof(info));
         if (i <= 4)
-            ok(hr == (i < 4 ? E_FAIL : S_FALSE), "info_id %u, unexpected hr %#x.\n", i, hr);
+            ok(hr == (i < 4 ? E_FAIL : S_FALSE), "info_id %u, unexpected hr %#lx.\n", i, hr);
         else
-            ok(hr == E_FAIL || hr == S_FALSE, "info_id %u, unexpected hr %#x.\n", i, hr);
+            ok(hr == E_FAIL || hr == S_FALSE, "info_id %u, unexpected hr %#lx.\n", i, hr);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -9686,7 +9670,7 @@ static void test_resource_access(void)
     d3d = Direct3DCreate8(D3D_SDK_VERSION);
     ok(!!d3d, "Failed to create a D3D object.\n");
     hr = IDirect3D8_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);
 
     device_desc.adapter_ordinal = D3DADAPTER_DEFAULT;
@@ -9703,15 +9687,15 @@ static void test_resource_access(void)
     }
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DSurface8_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 = IDirect3DDevice8_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 = IDirect3DSurface8_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(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
@@ -9722,7 +9706,7 @@ static void test_resource_access(void)
             D3DFMT_X8R8G8B8, 0, D3DRTYPE_SURFACE, depth_format));
 
     hr = IDirect3DDevice8_SetVertexShader(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)
     {
@@ -9757,12 +9741,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 = IDirect3DTexture8_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);
                     IDirect3DTexture8_Release(texture_2d);
                     break;
 
@@ -9772,13 +9756,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 = IDirect3DCubeTexture8_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);
                     IDirect3DCubeTexture8_Release(texture_cube);
                     break;
 
@@ -9786,7 +9770,7 @@ static void test_resource_access(void)
                     hr = IDirect3DDevice8_CreateRenderTarget(device, 16, 16, format,
                             D3DMULTISAMPLE_NONE, tests[j].usage & D3DUSAGE_DYNAMIC, &surface);
                     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;
@@ -9798,7 +9782,7 @@ static void test_resource_access(void)
                         ok(hr == (tests[j].format == FORMAT_DEPTH ? D3D_OK
                                 : tests[j].format == FORMAT_COLOUR ? D3DERR_INVALIDCALL : E_INVALIDARG)
                                 || (tests[j].format == FORMAT_ATI2 && hr == D3D_OK),
-                                "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;
@@ -9806,7 +9790,7 @@ static void test_resource_access(void)
                 case SURFACE_IMAGE:
                     hr = IDirect3DDevice8_CreateImageSurface(device, 16, 16, format, &surface);
                     ok(hr == ((tests[j].format != FORMAT_DEPTH || depth_plain) ? 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;
@@ -9817,31 +9801,31 @@ static void test_resource_access(void)
             }
 
             hr = IDirect3DSurface8_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_IMAGE)
             {
-                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 == D3DPOOL_SYSTEMMEM, "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);
@@ -9855,31 +9839,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 = IDirect3DSurface8_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(IDirect3DSurface8_GetContainer(surface, &IID_IDirect3DBaseTexture8, (void **)&texture)))
             {
                 hr = IDirect3DDevice8_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 = IDirect3DDevice8_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);
                 IDirect3DBaseTexture8_Release(texture);
             }
 
             hr = IDirect3DDevice8_SetRenderTarget(device, surface, depth_stencil);
             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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, 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);
 
             hr = IDirect3DDevice8_SetRenderTarget(device, backbuffer, 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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, 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);
 
             IDirect3DSurface8_Release(surface);
         }
@@ -9907,16 +9891,16 @@ static void test_resource_access(void)
                 || (tests[i].pool == D3DPOOL_SCRATCH && !tests[i].usage)
                 ? 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 = IDirect3DVolumeTexture8_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 = IDirect3DVolume8_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 = IDirect3DVolume8_LockBox(volume, &lb, NULL, 0);
@@ -9925,15 +9909,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 = IDirect3DVolume8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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);
 
         IDirect3DVolume8_Release(volume);
         IDirect3DVolumeTexture8_Release(texture);
@@ -9948,24 +9932,24 @@ static void test_resource_access(void)
         hr = IDirect3DDevice8_CreateIndexBuffer(device, 16, tests[i].usage,
                 tests[i].format == FORMAT_COLOUR ? D3DFMT_INDEX32 : D3DFMT_INDEX16, tests[i].pool, &ib);
         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 = IDirect3DIndexBuffer8_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 = IDirect3DIndexBuffer8_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 = IDirect3DIndexBuffer8_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 = IDirect3DDevice8_SetIndices(device, ib, 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 = IDirect3DDevice8_SetIndices(device, NULL, 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);
 
         IDirect3DIndexBuffer8_Release(ib);
     }
@@ -9979,24 +9963,24 @@ static void test_resource_access(void)
         hr = IDirect3DDevice8_CreateVertexBuffer(device, 16, tests[i].usage,
                 tests[i].format == FORMAT_COLOUR ? 0 : D3DFVF_XYZRHW, tests[i].pool, &vb);
         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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_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 = IDirect3DDevice8_SetStreamSource(device, 0, vb, 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 = IDirect3DDevice8_SetStreamSource(device, 0, NULL, 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);
 
         IDirect3DVertexBuffer8_Release(vb);
     }
@@ -10004,7 +9988,7 @@ static void test_resource_access(void)
     IDirect3DSurface8_Release(depth_stencil);
     IDirect3DSurface8_Release(backbuffer);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -10070,52 +10054,52 @@ static void test_multiply_transform(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_CaptureStateBlock(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 = IDirect3DDevice8_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 = IDirect3DDevice8_ApplyStateBlock(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 = IDirect3DDevice8_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);
 
         IDirect3DDevice8_DeleteStateBlock(device, stateblock);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -10161,147 +10145,147 @@ static void test_draw_primitive(void)
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device, sizeof(quad), 0, 0,
             D3DPOOL_DEFAULT, &vertex_buffer);
-    ok(SUCCEEDED(hr), "CreateVertexBuffer failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateVertexBuffer failed, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_Unlock(vertex_buffer);
-    ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetStreamSource(device, 0, vertex_buffer, sizeof(*quad));
-    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateIndexBuffer(device, sizeof(indices), 0, D3DFMT_INDEX16,
             D3DPOOL_DEFAULT, &index_buffer);
-    ok(SUCCEEDED(hr), "CreateIndexBuffer failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateIndexBuffer failed, hr %#lx.\n", hr);
     hr = IDirect3DIndexBuffer8_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 = IDirect3DIndexBuffer8_Unlock(index_buffer);
-    ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_GetStreamSource(device, 0, &current_vb, &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(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
     IDirect3DVertexBuffer8_Release(current_vb);
 
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, quad, 0);
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "DrawPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, quad, sizeof(*quad));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "DrawPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_GetStreamSource(device, 0, &current_vb, &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(!stride, "Unexpected stride %u.\n", stride);
 
     /* NULL index buffer, NULL stream source. */
     hr = IDirect3DDevice8_SetIndices(device, NULL, 0);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 4, 0, 2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Valid index buffer, NULL stream source. */
     hr = IDirect3DDevice8_SetIndices(device, index_buffer, 1);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 4, 0, 2);
-    ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetIndices(device, &current_ib, &base_vertex_index);
-    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);
     ok(base_vertex_index == 1, "Unexpected base vertex index %u.\n", base_vertex_index);
     IDirect3DIndexBuffer8_Release(current_ib);
 
     hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 0,
             indices, D3DFMT_INDEX16, quad, 0);
-    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0, 4, 2,
             indices, D3DFMT_INDEX16, quad, 0);
-    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawIndexedPrimitiveUP failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_GetIndices(device, &current_ib, &base_vertex_index);
-    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);
     ok(!base_vertex_index, "Unexpected base vertex index %u.\n", base_vertex_index);
 
     /* Resetting of stream source and index buffer is not recorded in stateblocks. */
 
     hr = IDirect3DDevice8_SetStreamSource(device, 0, vertex_buffer, sizeof(*quad));
-    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetIndices(device, index_buffer, 1);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginStateBlock(device);
-    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndStateBlock(device, &stateblock);
-    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginStateBlock failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetStreamSource(device, 0, &current_vb, &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(!stride, "Unexpected stride %u.\n", stride);
     hr = IDirect3DDevice8_GetIndices(device, &current_ib, &base_vertex_index);
-    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);
     ok(!base_vertex_index, "Unexpected base vertex index %u.\n", base_vertex_index);
 
     hr = IDirect3DDevice8_CaptureStateBlock(device, stateblock);
-    ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetStreamSource(device, 0, vertex_buffer, sizeof(*quad));
-    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetStreamSource failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetIndices(device, index_buffer, 1);
-    ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetIndices failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_ApplyStateBlock(device, stateblock);
-    ok(SUCCEEDED(hr), "Apply failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetStreamSource(device, 0, &current_vb, &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(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
     IDirect3DVertexBuffer8_Release(current_vb);
     hr = IDirect3DDevice8_GetIndices(device, &current_ib, &base_vertex_index);
-    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);
     ok(base_vertex_index == 1, "Unexpected base vertex index %u.\n", base_vertex_index);
     IDirect3DIndexBuffer8_Release(current_ib);
 
     hr = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
     IDirect3DDevice8_DeleteStateBlock(device, stateblock);
     IDirect3DVertexBuffer8_Release(vertex_buffer);
     IDirect3DIndexBuffer8_Release(index_buffer);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -10336,14 +10320,14 @@ static void test_get_display_mode(void)
     }
 
     hr = IDirect3DDevice8_GetDisplayMode(device, &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 = IDirect3D8_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);
 
     refcount = IDirect3DDevice8_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;
@@ -10359,18 +10343,18 @@ static void test_get_display_mode(void)
     }
 
     hr = IDirect3DDevice8_GetDisplayMode(device, &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 = IDirect3D8_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);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 
     /* D3D8 uses adapter indices to determine which adapter to use to get the display mode */
@@ -10390,7 +10374,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;
 
@@ -10430,7 +10414,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;
@@ -10441,12 +10425,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 = IDirect3D8_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);
@@ -10454,7 +10438,7 @@ static void test_get_display_mode(void)
                     adapter_idx, test_idx, height, mode.Height);
 
             hr = IDirect3DDevice8_GetDisplayMode(device, &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);
@@ -10462,7 +10446,7 @@ static void test_get_display_mode(void)
                     adapter_idx, test_idx, height, mode.Height);
 
             refcount = IDirect3DDevice8_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);
         }
@@ -10502,13 +10486,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 */
@@ -10520,7 +10504,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 */
@@ -10531,11 +10515,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 */
@@ -10543,7 +10527,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)
         {
@@ -10565,11 +10549,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);
     }
 
@@ -10608,7 +10592,7 @@ static void test_creation_parameters(void)
 
         memset(&params, 0, sizeof(params));
         hr = IDirect3DDevice8_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",
@@ -10647,7 +10631,7 @@ static void test_cursor_clipping(void)
     for (adapter_idx = 0; adapter_idx < adapter_count; ++adapter_idx)
     {
         hr = IDirect3D8_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(IDirect3D8_EnumAdapterModes(d3d, adapter_idx, mode_idx, &mode));
                 ++mode_idx)
         {
@@ -10663,11 +10647,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));
@@ -10683,7 +10667,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));
@@ -10692,7 +10676,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));
@@ -10725,7 +10709,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;
@@ -10741,37 +10725,37 @@ 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));
 
         /* 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/d3d8/tests/stateblock.c b/dlls/d3d8/tests/stateblock.c
index 83f153a2897..4a27738d5d4 100644
--- a/dlls/d3d8/tests/stateblock.c
+++ b/dlls/d3d8/tests/stateblock.c
@@ -183,22 +183,22 @@ static int switch_render_target(IDirect3DDevice8* device, struct event_data *eve
 
     /* Create new swapchain */
     hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &present_parameters, &swapchain);
-    ok(SUCCEEDED(hr), "CreateAdditionalSwapChain returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateAdditionalSwapChain returned %#lx.\n", hr);
     if (FAILED(hr)) goto error;
 
     /* Get its backbuffer */
     hr = IDirect3DSwapChain8_GetBackBuffer(swapchain, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(SUCCEEDED(hr), "GetBackBuffer returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetBackBuffer returned %#lx.\n", hr);
     if (FAILED(hr)) goto error;
 
     /* Save the current render target */
     hr = IDirect3DDevice8_GetRenderTarget(device, &event_data->original_render_target);
-    ok(SUCCEEDED(hr), "GetRenderTarget returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget returned %#lx.\n", hr);
     if (FAILED(hr)) goto error;
 
     /* Set the new swapchain's backbuffer as a render target */
     hr = IDirect3DDevice8_SetRenderTarget(device, backbuffer, NULL);
-    ok(SUCCEEDED(hr), "SetRenderTarget returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget returned %#lx.\n", hr);
     if (FAILED(hr)) goto error;
 
     IDirect3DSurface8_Release(backbuffer);
@@ -217,7 +217,7 @@ static int revert_render_target(IDirect3DDevice8 *device, struct event_data *eve
 
     /* Reset the old render target */
     hr = IDirect3DDevice8_SetRenderTarget(device, event_data->original_render_target, NULL);
-    ok(SUCCEEDED(hr), "SetRenderTarget returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget returned %#lx.\n", hr);
     if (FAILED(hr))
     {
         IDirect3DSurface8_Release(event_data->original_render_target);
@@ -234,7 +234,7 @@ static int create_stateblock_all(IDirect3DDevice8 *device, struct event_data *ev
     HRESULT hr;
 
     hr = IDirect3DDevice8_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;
 }
@@ -244,7 +244,7 @@ static int create_stateblock_vertex(IDirect3DDevice8 *device, struct event_data
     HRESULT hr;
 
     hr = IDirect3DDevice8_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;
 }
@@ -254,7 +254,7 @@ static int create_stateblock_pixel(IDirect3DDevice8 *device, struct event_data *
     HRESULT hr;
 
     hr = IDirect3DDevice8_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;
 }
@@ -264,7 +264,7 @@ static int begin_stateblock(IDirect3DDevice8 *device, struct event_data *event_d
     HRESULT hr;
 
     hr = IDirect3DDevice8_BeginStateBlock(device);
-    ok(SUCCEEDED(hr), "BeginStateBlock returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginStateBlock returned %#lx.\n", hr);
     if (FAILED(hr)) return EVENT_ERROR;
     return EVENT_OK;
 }
@@ -274,7 +274,7 @@ static int end_stateblock(IDirect3DDevice8 *device, struct event_data *event_dat
     HRESULT hr;
 
     hr = IDirect3DDevice8_EndStateBlock(device, &event_data->stateblock);
-    ok(SUCCEEDED(hr), "EndStateBlock returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndStateBlock returned %#lx.\n", hr);
     if (FAILED(hr)) return EVENT_ERROR;
     return EVENT_OK;
 }
@@ -290,7 +290,7 @@ static int apply_stateblock(IDirect3DDevice8 *device, struct event_data *event_d
     HRESULT hr;
 
     hr = IDirect3DDevice8_ApplyStateBlock(device, event_data->stateblock);
-    ok(SUCCEEDED(hr), "Apply returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Apply returned %#lx.\n", hr);
 
     IDirect3DDevice8_DeleteStateBlock(device, event_data->stateblock);
     if (FAILED(hr)) return EVENT_ERROR;
@@ -302,7 +302,7 @@ static int capture_stateblock(IDirect3DDevice8 *device, struct event_data *event
     HRESULT hr;
 
     hr = IDirect3DDevice8_CaptureStateBlock(device, event_data->stateblock);
-    ok(SUCCEEDED(hr), "Capture returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Capture returned %#lx.\n", hr);
     if (FAILED(hr)) return EVENT_ERROR;
 
     return EVENT_OK;
@@ -497,12 +497,12 @@ static void shader_constant_apply_data(IDirect3DDevice8 *device, const struct st
     if (!scarg->pshader)
     {
         hr = IDirect3DDevice8_SetVertexShaderConstant(device, index, scdata->float_constant, 1);
-        ok(SUCCEEDED(hr), "SetVertexShaderConstant returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetVertexShaderConstant returned %#lx.\n", hr);
     }
     else
     {
         hr = IDirect3DDevice8_SetPixelShaderConstant(device, index, scdata->float_constant, 1);
-        ok(SUCCEEDED(hr), "SetPixelShaderConstant returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetPixelShaderConstant returned %#lx.\n", hr);
     }
 }
 
@@ -519,12 +519,12 @@ static void shader_constant_check_data(IDirect3DDevice8 *device, const struct st
     if (!scarg->pshader)
     {
         hr = IDirect3DDevice8_GetVertexShaderConstant(device, scarg->idx, value.float_constant, 1);
-        ok(SUCCEEDED(hr), "GetVertexShaderConstant returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetVertexShaderConstant returned %#lx.\n", hr);
     }
     else
     {
         hr = IDirect3DDevice8_GetPixelShaderConstant(device, scarg->idx, value.float_constant, 1);
-        ok(SUCCEEDED(hr), "GetPixelShaderConstant returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetPixelShaderConstant returned %#lx.\n", hr);
     }
 
     ok(!memcmp(value.float_constant, scdata->float_constant, sizeof(scdata->float_constant)),
@@ -675,10 +675,10 @@ static void light_apply_data(IDirect3DDevice8 *device, const struct state_test *
     HRESULT hr;
 
     hr = IDirect3DDevice8_SetLight(device, index, &ldata->light);
-    ok(SUCCEEDED(hr), "SetLight returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetLight returned %#lx.\n", hr);
 
     hr = IDirect3DDevice8_LightEnable(device, index, ldata->enabled);
-    ok(SUCCEEDED(hr), "SetLightEnable returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetLightEnable returned %#lx.\n", hr);
 }
 
 static void light_check_data(IDirect3DDevice8 *device, const struct state_test *test,
@@ -694,10 +694,10 @@ static void light_check_data(IDirect3DDevice8 *device, const struct state_test *
     value.get_light_result = IDirect3DDevice8_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,
@@ -921,22 +921,22 @@ static void transform_apply_data(IDirect3DDevice8 *device, const struct state_te
     HRESULT hr;
 
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, &tdata->view);
-    ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTransform returned %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &tdata->projection);
-    ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTransform returned %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_TEXTURE0, &tdata->texture0);
-    ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTransform returned %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_TEXTURE0 + texture_stages - 1, &tdata->texture7);
-    ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTransform returned %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLD, &tdata->world0);
-    ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTransform returned %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLDMATRIX(255), &tdata->world255);
-    ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTransform returned %#lx.\n", hr);
 }
 
 static void compare_matrix(const char *name, unsigned int chain_stage,
@@ -976,32 +976,32 @@ static void transform_check_data(IDirect3DDevice8 *device, const struct state_te
 
     value = transform_poison_data.view;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
 }
 
@@ -1135,7 +1135,7 @@ static void render_state_apply_data(IDirect3DDevice8 *device, const struct state
     for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
     {
         hr = IDirect3DDevice8_SetRenderState(device, render_state_indices[i], rsdata->states[i]);
-        ok(SUCCEEDED(hr), "SetRenderState returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetRenderState returned %#lx.\n", hr);
     }
 }
 
@@ -1151,8 +1151,8 @@ static void render_state_check_data(IDirect3DDevice8 *device, const struct state
     {
         DWORD value = ctx->poison_data_buffer.states[i];
         hr = IDirect3DDevice8_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);
     }
 }
@@ -1500,25 +1500,25 @@ static void resource_apply_data(IDirect3DDevice8 *device, const struct state_tes
     HRESULT hr;
 
     hr = IDirect3DDevice8_SetVertexShader(device, d->vs);
-    ok(SUCCEEDED(hr), "SetVertexShader (%u) returned %#x.\n", d->vs, hr);
+    ok(SUCCEEDED(hr), "SetVertexShader (%lu) returned %#lx.\n", d->vs, hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, d->ps);
-    ok(SUCCEEDED(hr), "SetPixelShader (%u) returned %#x.\n", d->ps, hr);
+    ok(SUCCEEDED(hr), "SetPixelShader (%lu) returned %#lx.\n", d->ps, hr);
 
     hr = IDirect3DDevice8_SetIndices(device, d->ib, 0);
-    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)
     {
         hr = IDirect3DDevice8_SetStreamSource(device, i, d->vb[i], 64);
-        ok(SUCCEEDED(hr), "SetStreamSource (%u, %p, 64) returned %#x.\n",
+        ok(SUCCEEDED(hr), "SetStreamSource (%u, %p, 64) returned %#lx.\n",
                 i, d->vb[i], hr);
     }
 
     for (i = 0; i < arg->tex_count; ++i)
     {
         hr = IDirect3DDevice8_SetTexture(device, i, (IDirect3DBaseTexture8 *)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);
     }
 }
 
@@ -1529,26 +1529,26 @@ static void resource_check_data(IDirect3DDevice8 *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 i;
+    unsigned int i, base_index;
     HRESULT hr;
     void *ptr;
     DWORD v;
 
     v = poison->vs;
     hr = IDirect3DDevice8_GetVertexShader(device, &v);
-    ok(SUCCEEDED(hr), "GetVertexShader returned %#x.\n", hr);
-    ok(v == d->vs, "Chain stage %u, expected vertex shader %#x, received %#x.\n",
+    ok(SUCCEEDED(hr), "GetVertexShader returned %#lx.\n", hr);
+    ok(v == d->vs, "Chain stage %u, expected vertex shader %#lx, received %#lx.\n",
             chain_stage, d->vs, v);
 
     v = poison->ps;
     hr = IDirect3DDevice8_GetPixelShader(device, &v);
-    ok(SUCCEEDED(hr), "GetPixelShader returned %#x.\n", hr);
-    ok(v == d->ps, "Chain stage %u, expected pixel shader %#x, received %#x.\n",
+    ok(SUCCEEDED(hr), "GetPixelShader returned %#lx.\n", hr);
+    ok(v == d->ps, "Chain stage %u, expected pixel shader %#lx, received %#lx.\n",
             chain_stage, d->ps, v);
 
     ptr = poison->ib;
-    hr = IDirect3DDevice8_GetIndices(device, (IDirect3DIndexBuffer8 **)&ptr, &v);
-    ok(SUCCEEDED(hr), "GetIndices returned %#x.\n", hr);
+    hr = IDirect3DDevice8_GetIndices(device, (IDirect3DIndexBuffer8 **)&ptr, &base_index);
+    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)
@@ -1559,8 +1559,8 @@ static void resource_check_data(IDirect3DDevice8 *device, const struct state_tes
     for (i = 0; i < arg->stream_count; ++i)
     {
         ptr = poison->vb[i];
-        hr = IDirect3DDevice8_GetStreamSource(device, i, (IDirect3DVertexBuffer8 **)&ptr, &v);
-        ok(SUCCEEDED(hr), "GetStreamSource (%u) returned %#x.\n", i, hr);
+        hr = IDirect3DDevice8_GetStreamSource(device, i, (IDirect3DVertexBuffer8 **)&ptr, &base_index);
+        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);
         if (SUCCEEDED(hr) && ptr)
@@ -1573,7 +1573,7 @@ static void resource_check_data(IDirect3DDevice8 *device, const struct state_tes
     {
         ptr = poison->tex[i];
         hr = IDirect3DDevice8_GetTexture(device, i, (IDirect3DBaseTexture8 **)&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)
@@ -1638,24 +1638,24 @@ static void resource_test_data_init(IDirect3DDevice8 *device,
     if (arg->vs_version)
     {
         hr = IDirect3DDevice8_CreateVertexShader(device, decl, vs_code, &data->vs, 0);
-        ok(SUCCEEDED(hr), "CreateVertexShader returned hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateVertexShader returned hr %#lx.\n", hr);
     }
 
     if (arg->ps_version)
     {
         hr = IDirect3DDevice8_CreatePixelShader(device, ps_code, &data->ps);
-        ok(SUCCEEDED(hr), "CreatePixelShader returned hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreatePixelShader returned hr %#lx.\n", hr);
     }
 
     hr = IDirect3DDevice8_CreateIndexBuffer(device, 64, D3DUSAGE_DYNAMIC, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &data->ib);
-    ok(SUCCEEDED(hr), "CreateIndexBuffer returned hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateIndexBuffer returned hr %#lx.\n", hr);
 
     data->vb = HeapAlloc(GetProcessHeap(), 0, arg->stream_count * sizeof(*data->vb));
     for (i = 0; i < arg->stream_count; ++i)
     {
         hr = IDirect3DDevice8_CreateVertexBuffer(device, 64, D3DUSAGE_DYNAMIC,
                 0, D3DPOOL_DEFAULT, &data->vb[i]);
-        ok(SUCCEEDED(hr), "CreateVertexBuffer (%u) returned hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "CreateVertexBuffer (%u) returned hr %#lx.\n", i, hr);
     }
 
     data->tex = HeapAlloc(GetProcessHeap(), 0, arg->tex_count * sizeof(*data->tex));
@@ -1663,7 +1663,7 @@ static void resource_test_data_init(IDirect3DDevice8 *device,
     {
         hr = IDirect3DDevice8_CreateTexture(device, 64, 64, 0, 0,
                 D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &data->tex[i]);
-        ok(SUCCEEDED(hr), "CreateTexture (%u) returned hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "CreateTexture (%u) returned hr %#lx.\n", i, hr);
     }
 }
 
@@ -1727,13 +1727,13 @@ static void resource_test_cleanup(IDirect3DDevice8 *device, struct state_test *t
     if (ctx->test_data_all.vs)
     {
         hr = IDirect3DDevice8_DeleteVertexShader(device, ctx->test_data_all.vs);
-        ok(SUCCEEDED(hr), "DeleteVertexShader (%u) returned %#x.\n", ctx->test_data_all.vs, hr);
+        ok(SUCCEEDED(hr), "DeleteVertexShader (%lu) returned %#lx.\n", ctx->test_data_all.vs, hr);
     }
 
     if (ctx->test_data_all.ps)
     {
         hr = IDirect3DDevice8_DeletePixelShader(device, ctx->test_data_all.ps);
-        ok(SUCCEEDED(hr), "DeletePixelShader (%u) returned %#x.\n", ctx->test_data_all.ps, hr);
+        ok(SUCCEEDED(hr), "DeletePixelShader (%lu) returned %#lx.\n", ctx->test_data_all.ps, hr);
     }
 
     IDirect3DIndexBuffer8_Release(ctx->test_data_all.ib);
@@ -1819,7 +1819,7 @@ static void test_state_management(void)
     }
 
     hr = IDirect3DDevice8_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;
 
@@ -1858,7 +1858,7 @@ static void test_state_management(void)
     execute_test_chain_all(device, tests, tcount);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index afcda103844..a2c762f9556 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -110,17 +110,17 @@ static void get_rt_readback(IDirect3DSurface8 *surface, struct surface_readback
 
     memset(rb, 0, sizeof(*rb));
     hr = IDirect3DSurface8_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 = IDirect3DSurface8_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 = IDirect3DDevice8_CreateTexture(device, desc.Width, desc.Height, 1, 0, desc.Format, D3DPOOL_SYSTEMMEM, &tex);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DTexture8_GetSurfaceLevel(tex, 0, &rb->surface);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CopyRects(device, surface, NULL, 0, rb->surface, NULL);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DSurface8_LockRect(rb->surface, &rb->locked_rect, NULL, D3DLOCK_READONLY);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DTexture8_Release(tex);
     IDirect3DDevice8_Release(device);
 }
@@ -135,7 +135,7 @@ static void release_surface_readback(struct surface_readback *rb)
     HRESULT hr;
 
     hr = IDirect3DSurface8_UnlockRect(rb->surface);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(hr == S_OK, "Got hr %#lx.\n", hr);
     IDirect3DSurface8_Release(rb->surface);
 }
 
@@ -147,7 +147,7 @@ static DWORD getPixelColor(IDirect3DDevice8 *device, UINT x, UINT y)
     HRESULT hr;
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &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
@@ -169,10 +169,10 @@ static D3DCOLOR get_surface_color(IDirect3DSurface8 *surface, UINT x, UINT y)
     D3DLOCKED_RECT lockedRect;
 
     hr = IDirect3DSurface8_GetDesc(surface, &desc);
-    ok(SUCCEEDED(hr), "Failed to get surface description, hr=%#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DSurface8_LockRect(surface, &lockedRect, &rectToLock, D3DLOCK_READONLY);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr=%#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     switch(desc.Format)
     {
@@ -187,7 +187,7 @@ static D3DCOLOR get_surface_color(IDirect3DSurface8 *surface, UINT x, UINT y)
     }
 
     hr = IDirect3DSurface8_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr=%#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     return color;
 }
@@ -204,8 +204,7 @@ static void check_rect(struct surface_readback *rb, RECT r, const char *message)
         {r.top - 1, r.top + 1},
         {r.bottom + 1, r.bottom - 1}
     };
-    unsigned int i, j, x_side, y_side;
-    DWORD color;
+    unsigned int i, j, x_side, y_side, color;
     LONG x, y;
 
     for (i = 0; i < 2; ++i)
@@ -216,14 +215,14 @@ static void check_rect(struct surface_readback *rb, RECT r, const char *message)
             {
                 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];
                     if (x < 0 || x >= 640 || y < 0 || y >= 480)
                         continue;
                     color = get_readback_color(rb, x, y);
-                    ok(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x.\n",
+                    ok(color == expected, "%s: Pixel (%ld, %ld) has color %08x, expected %08x.\n",
                             message, x, y, color, expected);
                 }
             }
@@ -234,14 +233,14 @@ static void check_rect(struct surface_readback *rb, RECT r, const char *message)
 #define check_rt_color(a, b) check_rt_color_(__LINE__, a, b)
 static void check_rt_color_(unsigned int line, IDirect3DSurface8 *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 = IDirect3DSurface8_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)
@@ -283,8 +282,8 @@ static IDirect3DDevice8 *create_device(IDirect3D8 *d3d, HWND device_window, HWND
 static void test_sanity(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -299,23 +298,23 @@ static void test_sanity(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ddee, 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, 639, 479);
     ok(color == 0x0000ddee, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -326,12 +325,11 @@ static void lighting_test(void)
     DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL;
     DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE;
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    unsigned int i;
 
     static const struct
     {
@@ -455,61 +453,61 @@ static void lighting_test(void)
     }
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLDMATRIX(0), &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, fvf);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, nfvf);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -523,25 +521,25 @@ static void lighting_test(void)
     IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 || broken(color == tests[i].broken),
@@ -549,7 +547,7 @@ static void lighting_test(void)
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -629,8 +627,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[] =
     {
@@ -814,14 +811,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;
     IDirect3DDevice8 *device;
     D3DMATERIAL8 material;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    unsigned int i, j, x, y;
     struct
     {
         struct vec3 position;
@@ -866,33 +862,33 @@ static void test_specular_lighting(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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;
@@ -901,21 +897,21 @@ static void test_specular_lighting(void)
         material.Specular.a = 1.0f;
         material.Power = tests[i].specular_power;
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
         {
@@ -928,7 +924,7 @@ static void test_specular_lighting(void)
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -941,8 +937,8 @@ static void clear_test(void)
     /* Tests the correctness of clearing parameters */
     D3DRECT rect_negneg, rect[2];
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -957,7 +953,7 @@ static void clear_test(void)
     }
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Positive x, negative y */
     rect[0].x1 = 0;
@@ -974,7 +970,7 @@ static void clear_test(void)
      * is ignored, the positive is still cleared afterwards
      */
     hr = IDirect3DDevice8_Clear(device, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* negative x, negative y */
     rect_negneg.x1 = 640;
@@ -982,7 +978,7 @@ static void clear_test(void)
     rect_negneg.x2 = 320;
     rect_negneg.y2 = 0;
     hr = IDirect3DDevice8_Clear(device, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 160, 360); /* lower left quad */
     ok(color == 0x00ffffff, "Clear rectangle 3(pos, neg) has color %08x\n", color);
@@ -996,14 +992,14 @@ static void clear_test(void)
     IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_Clear failed with %#08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     rect[0].x1 = 0;
     rect[0].y1 = 0;
     rect[0].x2 = 640;
     rect[0].y2 = 480;
     hr = IDirect3DDevice8_Clear(device, 0, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_Clear failed with %#08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0xff, 0xff, 0xff), 1),
@@ -1012,9 +1008,9 @@ static void clear_test(void)
     IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_Clear failed with %#08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Clear(device, 1, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_Clear failed with %#08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x00, 0xff, 0x00), 1),
@@ -1023,7 +1019,7 @@ static void clear_test(void)
     IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -1033,8 +1029,8 @@ static void fog_test(void)
 {
     float start = 0.0f, end = 1.0f;
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
@@ -1141,76 +1137,76 @@ static void fog_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetDeviceCaps returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Setup initial states: No lighting, fog on, fog color */
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Turning off lighting returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
-    ok(hr == D3D_OK, "Turning on fog calculations returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, 0xFF00FF00 /* A nice green */);
-    ok(hr == D3D_OK, "Setting fog color returned %#08x\n", hr);
+    ok(hr == D3D_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off table fog returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off vertex fog returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Start = 0, end = 1. Should be default, but set them */
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGSTART, *((DWORD *) &start));
-    ok(hr == D3D_OK, "Setting fog start returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGEND, *((DWORD *) &end));
-    ok(hr == D3D_OK, "Setting fog start returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     /* Untransformed, vertex fog = NONE, table fog = NONE:
      * Read the fog weighting from the specular color. */
     hr = IDirect3DDevice8_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);
 
     /* This makes it use the Z value. */
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, 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);
     /* Untransformed, vertex fog != none (or table fog != none):
      * Use the Z value as input into the equation. */
     hr = IDirect3DDevice8_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 vertices. */
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
     /* Transformed, vertex fog != NONE, pixel fog == NONE:
      * Use specular color alpha component. */
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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);
     /* Transformed, table fog != none, vertex anything:
      * Use Z value as input to the fog equation. */
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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), 1),
@@ -1231,28 +1227,28 @@ static void fog_test(void)
     {
         /* A simple fog + non-identity world matrix test */
         hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLDMATRIX(0), &world_mat1);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
-        ok(hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
-        ok(hr == D3D_OK, "Turning off vertex fog returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice8_Clear returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-        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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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, 0x00ff0000, 4), "Unfogged quad has color %08x\n", color);
@@ -1264,25 +1260,25 @@ static void fog_test(void)
 
         /* Test fog behavior with an orthogonal (but not identity) projection matrix */
         hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLDMATRIX(0), &world_mat2);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-        ok(hr == D3D_OK, "Clear returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
-        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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -1298,7 +1294,7 @@ static void fog_test(void)
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -1316,9 +1312,8 @@ static void fog_with_shader_test(void)
     DWORD vertex_shader[3] = {D3DFVF_XYZ | D3DFVF_DIFFUSE, 0, 0};
     DWORD pixel_shader[2] = {0, 0};
     IDirect3DDevice8 *device;
-    unsigned int i, j;
+    unsigned int color, i, j;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
@@ -1520,7 +1515,7 @@ static void fog_with_shader_test(void)
     }
 
     hr = IDirect3DDevice8_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) || caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
     {
         skip("No vs_1_1 / ps_1_1 support, skipping tests.\n");
@@ -1537,50 +1532,50 @@ 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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateVertexShader(device, decl, vertex_shader_code1, &vertex_shader[1], 0);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateVertexShader(device, decl, vertex_shader_code2, &vertex_shader[2], 0);
-    ok(SUCCEEDED(hr), "CreateVertexShader failed (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     /* Set shader constant value */
     hr = IDirect3DDevice8_SetVertexShader(device, vertex_shader[2]);
-    ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShaderConstant(device, 0, vs_constant, 1);
-    ok(hr == D3D_OK, "Setting vertex shader constant failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Setup initial states: No lighting, fog on, fog color */
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Turning off lighting failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
-    ok(hr == D3D_OK, "Turning on fog calculations failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, 0xFF00FF00 /* A nice green */);
-    ok(hr == D3D_OK, "Setting fog color failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off table fog failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off vertex fog failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Use fogtart = 0.1 and end = 0.9 to test behavior outside the fog transition phase, too */
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGSTART, start.i);
-    ok(hr == D3D_OK, "Setting fog start failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGEND, end.i);
-    ok(hr == D3D_OK, "Setting fog end failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DDevice8_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
-        ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_SetPixelShader(device, pixel_shader[test_data[i].pshader]);
-        ok(SUCCEEDED(hr), "SetPixelShader failed (%08x)\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_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 == D3D_OK, "Got hr %#lx.\n", hr);
         hr = IDirect3DDevice8_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 == D3D_OK, "Got hr %#lx.\n", hr);
 
         for(j = 0; j < 11; ++j)
         {
@@ -1591,16 +1586,16 @@ static void fog_with_shader_test(void)
             quad[3].position.z = 0.001f + j / 10.02f;
 
             hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff00ff, 1.0f, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed (%08x)\n", hr);
+            ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice8_BeginScene(device);
-            ok( hr == D3D_OK, "BeginScene returned failed (%08x)\n", hr);
+            ok( hr == D3D_OK, "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));
-            ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
+            ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
             hr = IDirect3DDevice8_EndScene(device);
-            ok(hr == D3D_OK, "EndScene failed (%08x)\n", hr);
+            ok(hr == D3D_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);
@@ -1616,7 +1611,7 @@ static void fog_with_shader_test(void)
     IDirect3DDevice8_DeleteVertexShader(device, vertex_shader[2]);
     IDirect3DDevice8_DeleteVertexShader(device, pixel_shader[1]);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -1628,10 +1623,10 @@ static void cnd_test(void)
     DWORD shader_11_coissue, shader_12_coissue, shader_13_coissue, shader_14_coissue;
     DWORD shader_11, shader_12, shader_13, shader_14;
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
     ULONG refcount;
     D3DCAPS8 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -1850,7 +1845,7 @@ static void cnd_test(void)
     }
 
     hr = IDirect3DDevice8_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");
@@ -1859,68 +1854,68 @@ static void cnd_test(void)
     }
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ffff, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_11, &shader_11);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_12, &shader_12);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_13, &shader_13);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_14, &shader_14);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_11_coissue, &shader_11_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_12_coissue, &shader_12_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_13_coissue, &shader_13_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_14_coissue, &shader_14_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_11_coissue_2, &shader_11_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_12_coissue_2, &shader_12_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_13_coissue_2, &shader_13_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_14_coissue_2, &shader_14_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShaderConstant(device, 1, test_data_c1, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShaderConstant returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetPixelShaderConstant(device, 2, test_data_c2, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShaderConstant returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_11);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_12);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_13);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_14);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_EndScene returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_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);
@@ -1969,43 +1964,43 @@ static void cnd_test(void)
             "pixel 482, 122 has color %08x, expected 0x00000000\n", color);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Present failed with %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ffff, 0.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetPixelShaderConstant(device, 1, test_data_c1_coi, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShaderConstant returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetPixelShaderConstant(device, 2, test_data_c2_coi, 1);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShaderConstant returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_11_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_12_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_13_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_14_coissue);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_EndScene returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_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
@@ -2064,39 +2059,39 @@ static void cnd_test(void)
             "pixel 482, 122 has color %08x, expected 0x0000ff00\n", color);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Present failed with %08x\n", hr);
+    ok(hr == D3D_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 = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ffff, 0.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_11_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_12_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_13_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetPixelShader(device, shader_14_coissue_2);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, 6 * sizeof(float));
-    ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice8_EndScene returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* 1.4 shader */
     color = getPixelColor(device, 158, 118);
@@ -2151,7 +2146,7 @@ static void cnd_test(void)
             "pixel 562, 122 has color %08x, expected 0x00000000\n", color);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Present failed with %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     IDirect3DDevice8_DeletePixelShader(device, shader_14_coissue_2);
     IDirect3DDevice8_DeletePixelShader(device, shader_13_coissue_2);
@@ -2166,7 +2161,7 @@ static void cnd_test(void)
     IDirect3DDevice8_DeletePixelShader(device, shader_12);
     IDirect3DDevice8_DeletePixelShader(device, shader_11);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -2175,8 +2170,8 @@ done:
 static void z_range_test(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     DWORD shader;
@@ -2247,56 +2242,56 @@ static void z_range_test(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disabled lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disabled lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 */
 
@@ -2345,7 +2340,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 = IDirect3DDevice8_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))
@@ -2355,37 +2350,37 @@ static void z_range_test(void)
         goto done;
     }
     hr = IDirect3DDevice8_CreateVertexShader(device, vertex_declaration, shader_code, &shader, 0);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShaderConstant(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShaderConstant(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, 0);
-    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 = IDirect3DDevice8_DeleteVertexShader(device, shader);
-    ok(SUCCEEDED(hr), "Failed to delete vertex shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to delete vertex shader, hr %#lx.\n", hr);
 
     /* Z < 1.0 */
     color = getPixelColor(device, 28, 238);
@@ -2409,10 +2404,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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -2421,9 +2416,8 @@ done:
 static void test_scalar_instructions(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     DWORD shader;
@@ -2516,10 +2510,10 @@ static void test_scalar_instructions(void)
     {
         const char *name;
         const DWORD *byte_code;
-        D3DCOLOR color;
+        unsigned int color;
         /* Some drivers, including Intel HD4000 10.18.10.3345 and VMware SVGA
          * 3D 7.14.1.5025, use the .x component instead of the .w one. */
-        D3DCOLOR broken_color;
+        unsigned int broken_color;
     }
     test_data[] =
     {
@@ -2541,7 +2535,7 @@ static void test_scalar_instructions(void)
     }
 
     hr = IDirect3DDevice8_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");
@@ -2552,19 +2546,19 @@ static void test_scalar_instructions(void)
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff336699, 0.0f, 0);
-        ok(SUCCEEDED(hr), "%s: Failed to clear, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to clear, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirect3DDevice8_CreateVertexShader(device, decl, test_data[i].byte_code, &shader, 0);
-        ok(SUCCEEDED(hr), "%s: Failed to create vertex shader, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to create vertex shader, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirect3DDevice8_SetVertexShader(device, shader);
-        ok(SUCCEEDED(hr), "%s: Failed to set vertex shader, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set vertex shader, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirect3DDevice8_BeginScene(device);
-        ok(SUCCEEDED(hr), "%s: Failed to begin scene, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to begin scene, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], 3 * sizeof(float));
-        ok(SUCCEEDED(hr), "%s: Failed to draw primitive, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to draw primitive, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirect3DDevice8_EndScene(device);
-        ok(SUCCEEDED(hr), "%s: Failed to end scene, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to end scene, hr %#lx.\n", test_data[i].name, hr);
 
         color = getPixelColor(device, 320, 240);
         ok(color_match(color, test_data[i].color, 4) || broken(color_match(color, test_data[i].broken_color, 4)),
@@ -2572,16 +2566,16 @@ static void test_scalar_instructions(void)
                 test_data[i].name, color, test_data[i].color);
 
         hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "%s: Failed to present, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to present, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirect3DDevice8_SetVertexShader(device, 0);
-        ok(SUCCEEDED(hr), "%s: Failed to set vertex shader, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set vertex shader, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirect3DDevice8_DeleteVertexShader(device, shader);
-        ok(SUCCEEDED(hr), "%s: Failed to delete vertex shader, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to delete vertex shader, hr %#lx.\n", test_data[i].name, hr);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -2592,8 +2586,8 @@ static void offscreen_test(void)
     IDirect3DSurface8 *backbuffer, *offscreen, *depthstencil;
     IDirect3DTexture8 *offscreenTexture;
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -2616,17 +2610,17 @@ static void offscreen_test(void)
     }
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "Clear failed, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &offscreenTexture);
-    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 = IDirect3DDevice8_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
                 D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &offscreenTexture);
-        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");
@@ -2636,51 +2630,51 @@ static void offscreen_test(void)
     }
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &depthstencil);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetDepthStencilSurface failed, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
-    ok(hr == D3D_OK, "Can't get back buffer, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DTexture8_GetSurfaceLevel(offscreenTexture, 0, &offscreen);
-    ok(hr == D3D_OK, "Can't get offscreen surface, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(hr == D3D_OK, "SetVertexShader failed, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MINFILTER failed (%#08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MAGFILTER failed (%#08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, offscreen, depthstencil);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depthstencil);
-    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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -2701,7 +2695,7 @@ static void offscreen_test(void)
     IDirect3DSurface8_Release(offscreen);
     IDirect3DSurface8_Release(depthstencil);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -2712,8 +2706,8 @@ static void test_blend(void)
     IDirect3DSurface8 *backbuffer, *offscreen, *depthstencil;
     IDirect3DTexture8 *offscreenTexture;
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -2756,95 +2750,95 @@ static void test_blend(void)
 
     /* Clear the render target with alpha = 0.5 */
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x80ff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 1, D3DUSAGE_RENDERTARGET,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &offscreenTexture);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &depthstencil);
-    ok(SUCCEEDED(hr), "Failed to get depth/stencil buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get depth/stencil buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DTexture8_GetSurfaceLevel(offscreenTexture, 0, &offscreen);
-    ok(hr == D3D_OK, "Can't get offscreen surface, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "SetVertexShader failed, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %#08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MINFILTER failed (%#08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DTEXF_NONE);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MAGFILTER failed (%#08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHABLENDENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, offscreen, 0);
-    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 = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x80ff0000, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depthstencil);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *) offscreenTexture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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),
@@ -2869,7 +2863,7 @@ static void test_blend(void)
     IDirect3DSurface8_Release(offscreen);
     IDirect3DSurface8_Release(depthstencil);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -2880,15 +2874,14 @@ static void p8_texture_test(void)
     IDirect3DTexture8 *texture, *texture2;
     IDirect3DDevice8 *device;
     PALETTEENTRY table[256];
+    unsigned int color, i;
     unsigned char *data;
     D3DLOCKED_RECT lr;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
     HRESULT hr;
-    UINT i;
 
     static const float quad[] =
     {
@@ -2923,32 +2916,32 @@ static void p8_texture_test(void)
     }
 
     hr = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, 0, D3DFMT_P8, D3DPOOL_MANAGED, &texture2);
-    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 = IDirect3DTexture8_LockRect(texture2, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture8_LockRect failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     data = lr.pBits;
     *data = 1;
     hr = IDirect3DTexture8_UnlockRect(texture2, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture8_UnlockRect failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, 0, D3DFMT_P8, D3DPOOL_MANAGED, &texture);
-    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 = IDirect3DTexture8_LockRect(texture, 0, &lr, NULL, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture8_LockRect failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     data = lr.pBits;
     *data = 1;
     hr = IDirect3DTexture8_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "IDirect3DTexture8_UnlockRect failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHABLENDENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* The first part of the test should work both with and without D3DPTEXTURECAPS_ALPHAPALETTE;
        alpha of every entry is set to 1.0, which MS says is required when there's no
@@ -2959,41 +2952,41 @@ static void p8_texture_test(void)
     }
     table[1].peRed = 0xff;
     hr = IDirect3DDevice8_SetPaletteEntries(device, 0, table);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPaletteEntries failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     table[1].peRed = 0;
     table[1].peBlue = 0xff;
     hr = IDirect3DDevice8_SetPaletteEntries(device, 1, table);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetPaletteEntries failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    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 = IDirect3DDevice8_SetCurrentTexturePalette(device, 0);
-    ok(SUCCEEDED(hr), "Failed to set texture palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture palette, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetCurrentTexturePalette(device, 1);
-    ok(SUCCEEDED(hr), "Failed to set texture palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture palette, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 5 * sizeof(float));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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, 32, 32);
     ok(color_match(color, 0x00ff0000, 0), "Got unexpected color 0x%08x.\n", color);
@@ -3001,25 +2994,25 @@ static void p8_texture_test(void)
     ok(color_match(color, 0x000000ff, 0), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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, 32, 32);
     ok(color_match(color, 0x000000ff, 0), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
     /* Test palettes with alpha */
     IDirect3DDevice8_GetDeviceCaps(device, &caps);
@@ -3027,10 +3020,10 @@ static void p8_texture_test(void)
         skip("no D3DPTEXTURECAPS_ALPHAPALETTE capability, tests with alpha in palette will be skipped\n");
     } else {
         hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHABLENDENABLE, TRUE);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         for (i = 0; i < 256; i++) {
             table[i].peRed = table[i].peGreen = table[i].peBlue = 0;
@@ -3039,36 +3032,36 @@ static void p8_texture_test(void)
         table[1].peRed = 0xff;
         table[1].peFlags = 0x80;
         hr = IDirect3DDevice8_SetPaletteEntries(device, 0, table);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetPaletteEntries failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         table[1].peRed = 0;
         table[1].peBlue = 0xff;
         table[1].peFlags = 0x80;
         hr = IDirect3DDevice8_SetPaletteEntries(device, 1, table);
-        ok(hr == D3D_OK, "IDirect3DDevice8_SetPaletteEntries failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX1);
-        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 = IDirect3DDevice8_SetCurrentTexturePalette(device, 0);
-        ok(SUCCEEDED(hr), "Failed to set texture palette, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture palette, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetCurrentTexturePalette(device, 1);
-        ok(SUCCEEDED(hr), "Failed to set texture palette, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture palette, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 5 * sizeof(float));
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_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, 32, 32);
         ok(color_match(color, 0x00800000, 1), "Got unexpected color 0x%08x.\n", color);
@@ -3076,13 +3069,13 @@ static void p8_texture_test(void)
         ok(color_match(color, 0x00000080, 1), "Got unexpected color 0x%08x.\n", color);
 
         hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
     }
 
     IDirect3DTexture8_Release(texture);
     IDirect3DTexture8_Release(texture2);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -3093,9 +3086,8 @@ static void texop_test(void)
     IDirect3DTexture8 *texture;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
@@ -3116,7 +3108,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)},
@@ -3156,40 +3148,40 @@ static void texop_test(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "GetDeviceCaps failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX0);
-    ok(SUCCEEDED(hr), "SetVertexShader failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateTexture failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DTexture8_LockRect(texture, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "LockRect failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     *((DWORD *)locked_rect.pBits) = D3DCOLOR_ARGB(0x99, 0x00, 0xff, 0x00);
     hr = IDirect3DTexture8_UnlockRect(texture, 0);
-    ok(SUCCEEDED(hr), "LockRect failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG0, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0xdd333333);
-    ok(SUCCEEDED(hr), "SetRenderState failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA);
-    ok(SUCCEEDED(hr), "SetRenderState failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -3200,31 +3192,31 @@ static void texop_test(void)
         }
 
         hr = IDirect3DDevice8_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(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed with 0x%08x\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed with 0x%08x\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed with 0x%08x\n", hr);
+        ok(SUCCEEDED(hr), "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 = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-        ok(SUCCEEDED(hr), "Present failed with 0x%08x\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
-        ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
+        ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     }
 
     IDirect3DTexture8_Release(texture);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -3243,9 +3235,9 @@ done:
 static void depth_clamp_test(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color;
     D3DVIEWPORT8 vp;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
@@ -3314,7 +3306,7 @@ static void depth_clamp_test(void)
     }
 
     hr = IDirect3DDevice8_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;
@@ -3324,55 +3316,55 @@ static void depth_clamp_test(void)
     vp.MaxZ = 7.5;
 
     hr = IDirect3DDevice8_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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)
     {
@@ -3402,10 +3394,10 @@ static void depth_clamp_test(void)
     }
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -3416,10 +3408,9 @@ static void depth_buffer_test(void)
     IDirect3DSurface8 *backbuffer, *rt1, *rt2, *rt3;
     IDirect3DSurface8 *depth_stencil;
     IDirect3DDevice8 *device;
-    unsigned int i, j;
+    unsigned int color, i, j;
     D3DVIEWPORT8 vp;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -3450,7 +3441,7 @@ static void depth_buffer_test(void)
         {{-1.0f, -1.0f, 0.66f}, 0xffff0000},
         {{ 1.0f, -1.0f, 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},
@@ -3475,71 +3466,71 @@ static void depth_buffer_test(void)
     vp.MaxZ = 1.0;
 
     hr = IDirect3DDevice8_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &depth_stencil);
-    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetRenderTarget(device, &backbuffer);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateRenderTarget(device, 320, 240, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, FALSE, &rt1);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateRenderTarget(device, 480, 360, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, FALSE, &rt2);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, FALSE, &rt3);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, rt3, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt1, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt2, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
     {
@@ -3554,7 +3545,7 @@ static void depth_buffer_test(void)
     }
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(depth_stencil);
     IDirect3DSurface8_Release(backbuffer);
@@ -3562,7 +3553,7 @@ static void depth_buffer_test(void)
     IDirect3DSurface8_Release(rt2);
     IDirect3DSurface8_Release(rt1);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -3576,10 +3567,9 @@ static void depth_buffer2_test(void)
     IDirect3DSurface8 *backbuffer, *rt1, *rt2;
     IDirect3DSurface8 *depth_stencil;
     IDirect3DDevice8 *device;
-    unsigned int i, j;
+    unsigned int color, i, j;
     D3DVIEWPORT8 vp;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -3614,57 +3604,57 @@ static void depth_buffer2_test(void)
     vp.MaxZ = 1.0;
 
     hr = IDirect3DDevice8_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, FALSE, &rt1);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateRenderTarget(device, 480, 360, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, FALSE, &rt2);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &depth_stencil);
-    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetRenderTarget(device, &backbuffer);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, rt1, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt2, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depth_stencil);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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)
     {
@@ -3679,14 +3669,14 @@ static void depth_buffer2_test(void)
     }
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(depth_stencil);
     IDirect3DSurface8_Release(backbuffer);
     IDirect3DSurface8_Release(rt2);
     IDirect3DSurface8_Release(rt1);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -3747,8 +3737,7 @@ static void intz_test(void)
     };
     static const struct
     {
-        UINT x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -3772,7 +3761,7 @@ static void intz_test(void)
     }
 
     hr = IDirect3DDevice8_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(1, 1))
     {
         skip("No pixel shader 1.1 support, skipping INTZ test.\n");
@@ -3795,94 +3784,94 @@ static void intz_test(void)
     }
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &original_rt);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, FALSE, &rt);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX2
             | D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEXCOORDSIZE4(1));
-    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS,
             D3DTTFF_COUNT4 | D3DTTFF_PROJECTED);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
 
     /* Render offscreen, using the INTZ texture as depth buffer */
     hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetPixelShader(device, 0);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     /* Setup the depth/stencil surface. */
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, NULL);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     IDirect3DSurface8_Release(ds);
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -3890,57 +3879,57 @@ static void intz_test(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 1, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     IDirect3DTexture8_Release(texture);
 
     /* Render onscreen while using the INTZ texture as depth buffer */
     hr = IDirect3DDevice8_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, ds);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetPixelShader(device, 0);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, NULL);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     IDirect3DSurface8_Release(ds);
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -3948,67 +3937,67 @@ static void intz_test(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 1, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     IDirect3DTexture8_Release(texture);
 
     /* Render offscreen, then onscreen, and finally check the INTZ texture in both areas */
     hr = IDirect3DDevice8_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetPixelShader(device, 0);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, ds);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, NULL);
-    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
     IDirect3DSurface8_Release(ds);
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -4016,15 +4005,15 @@ static void intz_test(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Present failed, hr %#lx.\n", hr);
 
     IDirect3DTexture8_Release(texture);
     hr = IDirect3DDevice8_DeletePixelShader(device, ps);
-    ok(SUCCEEDED(hr), "DeletePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DeletePixelShader failed, hr %#lx.\n", hr);
     IDirect3DSurface8_Release(original_rt);
     IDirect3DSurface8_Release(rt);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -4084,8 +4073,7 @@ static void shadow_test(void)
     };
     static const struct
     {
-        UINT x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -4109,7 +4097,7 @@ static void shadow_test(void)
     }
 
     hr = IDirect3DDevice8_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(1, 1))
     {
         skip("No pixel shader 1.1 support, skipping shadow test.\n");
@@ -4118,48 +4106,48 @@ static void shadow_test(void)
     }
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &original_rt);
-    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, 1024, 1024, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, FALSE, &rt);
-    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateRenderTarget failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX2
             | D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEXCOORDSIZE4(1));
-    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS,
             D3DTTFF_COUNT4 | D3DTTFF_PROJECTED);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(formats); ++i)
     {
@@ -4174,58 +4162,58 @@ static void shadow_test(void)
 
         hr = IDirect3DDevice8_CreateTexture(device, 1024, 1024, 1,
                 D3DUSAGE_DEPTHSTENCIL, format, D3DPOOL_DEFAULT, &texture);
-        ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
 
         hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &ds);
-        ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
-        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_SetPixelShader(device, 0);
-        ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
         /* Setup the depth/stencil surface. */
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, NULL);
-        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#lx.\n", hr);
         IDirect3DSurface8_Release(ds);
 
         hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-        ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)texture);
-        ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-        ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-        ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_SetTexture(device, 0, NULL);
-        ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_SetTexture(device, 1, NULL);
-        ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
         IDirect3DTexture8_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. */
@@ -4238,15 +4226,15 @@ static void shadow_test(void)
         release_surface_readback(&rb);
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_DeletePixelShader(device, ps);
-    ok(SUCCEEDED(hr), "DeletePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DeletePixelShader failed, hr %#lx.\n", hr);
     IDirect3DSurface8_Release(original_rt);
     IDirect3DSurface8_Release(rt);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -4259,8 +4247,8 @@ static void multisample_copy_rects_test(void)
     POINT dst_point = {96, 96};
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -4284,36 +4272,36 @@ static void multisample_copy_rects_test(void)
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, 256, 256, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, FALSE, &rt);
-    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 = IDirect3DDevice8_CreateDepthStencilSurface(device, 256, 256, D3DFMT_D24S8,
             D3DMULTISAMPLE_2_SAMPLES, &ds);
-    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 = IDirect3DDevice8_CreateDepthStencilSurface(device, 256, 256, D3DFMT_D24S8,
             D3DMULTISAMPLE_NONE, &ds_plain);
-    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 = IDirect3DDevice8_CreateImageSurface(device, 256, 256, D3DFMT_A8R8G8B8, &readback);
-    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 = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_CopyRects(device, rt, NULL, 0, readback, NULL);
-    ok(SUCCEEDED(hr), "Failed to read render target back, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to read render target back, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CopyRects(device, ds, NULL, 0, ds_plain, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "Depth buffer copy, hr %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Depth buffer copy, hr %#lx, expected %#lx.\n", hr, D3DERR_INVALIDCALL);
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 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 = IDirect3DDevice8_CopyRects(device, rt, &src_rect, 1, readback, &dst_point);
-    ok(SUCCEEDED(hr), "Failed to read render target back, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to read render target back, hr %#lx.\n", hr);
 
     hr = IDirect3DSurface8_LockRect(readback, &locked_rect, NULL, D3DLOCK_READONLY);
-    ok(SUCCEEDED(hr), "Failed to lock readback surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock readback surface, hr %#lx.\n", hr);
 
     color = *(DWORD *)((BYTE *)locked_rect.pBits + 31 * locked_rect.Pitch + 31 * 4);
     ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color);
@@ -4322,14 +4310,14 @@ static void multisample_copy_rects_test(void)
     ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DSurface8_UnlockRect(readback);
-    ok(SUCCEEDED(hr), "Failed to unlock readback surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock readback surface, hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(readback);
     IDirect3DSurface8_Release(ds_plain);
     IDirect3DSurface8_Release(ds);
     IDirect3DSurface8_Release(rt);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -4377,8 +4365,7 @@ static void resz_test(void)
     };
     static const struct
     {
-        UINT x, y;
-        D3DCOLOR color;
+        unsigned int x, y, color;
     }
     expected_colors[] =
     {
@@ -4431,7 +4418,7 @@ static void resz_test(void)
     }
 
     hr = IDirect3DDevice8_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 INTZ test.\n");
@@ -4440,144 +4427,145 @@ static void resz_test(void)
     }
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, FALSE, &rt);
-    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 = IDirect3DDevice8_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8,
             D3DMULTISAMPLE_2_SAMPLES, &ds);
 
     hr = IDirect3DDevice8_CreateTexture(device, 640, 480, 1,
             D3DUSAGE_DEPTHSTENCIL, MAKEFOURCC('I','N','T','Z'), D3DPOOL_DEFAULT, &texture);
-    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &intz_ds);
-    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceLevel failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, intz_ds);
-    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 = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ffff, 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 = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
     IDirect3DSurface8_Release(intz_ds);
     hr = IDirect3DDevice8_CreatePixelShader(device, ps_code, &ps);
-    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreatePixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX2
             | D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEXCOORDSIZE4(1));
-    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetVertexShader failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MAGFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MINFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS,
             D3DTTFF_COUNT4 | D3DTTFF_PROJECTED);
-    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#lx.\n", hr);
 
     /* Render offscreen (multisampled), blit the depth buffer into the INTZ texture and then check its contents. */
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, original_rt, 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 = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     /* Test edge cases - try with no texture at all */
     hr = IDirect3DDevice8_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 1, NULL);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
-    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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 */
     IDirect3DSurface8_Release(ds);
@@ -4586,75 +4574,75 @@ static void resz_test(void)
             D3DMULTISAMPLE_NONE, &ds);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, ds);
-    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 = IDirect3DDevice8_SetPixelShader(device, 0);
-    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0xf);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)texture);
-    ok(SUCCEEDED(hr), "SetTexture failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(ds);
     IDirect3DTexture8_Release(texture);
     hr = IDirect3DDevice8_DeletePixelShader(device, ps);
-    ok(SUCCEEDED(hr), "DeletePixelShader failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DeletePixelShader failed, hr %#lx.\n", hr);
     IDirect3DSurface8_Release(original_ds);
     IDirect3DSurface8_Release(original_rt);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -4662,16 +4650,13 @@ done:
 
 static void zenable_test(void)
 {
+    unsigned int color, x, y, i, j, test;
     IDirect3DDevice8 *device;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
     HRESULT hr;
-    UINT x, y;
-    UINT i, j;
-    UINT test;
     IDirect3DSurface8 *ds, *rt;
 
     static const struct
@@ -4697,9 +4682,9 @@ static void zenable_test(void)
     }
 
     hr = IDirect3DDevice8_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);
     hr = IDirect3DDevice8_GetRenderTarget(device, &rt);
-    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);
 
     for (test = 0; test < 2; ++test)
     {
@@ -4716,28 +4701,28 @@ static void zenable_test(void)
         if (!test)
         {
             hr = IDirect3DDevice8_SetRenderTarget(device, rt, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
         {
@@ -4753,14 +4738,14 @@ static void zenable_test(void)
         }
 
         hr = IDirect3DDevice8_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);
     }
 
     IDirect3DSurface8_Release(ds);
     IDirect3DSurface8_Release(rt);
 
     hr = IDirect3DDevice8_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))
@@ -4785,7 +4770,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,
@@ -4810,22 +4795,22 @@ static void zenable_test(void)
         DWORD vs, ps;
 
         hr = IDirect3DDevice8_CreateVertexShader(device, decl, vs_code, &vs, 0);
-        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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
         {
@@ -4841,16 +4826,16 @@ static void zenable_test(void)
         }
 
         hr = IDirect3DDevice8_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);
 
         hr = IDirect3DDevice8_DeletePixelShader(device, ps);
-        ok(SUCCEEDED(hr), "Failed to delete pixel shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to delete pixel shader, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_DeleteVertexShader(device, vs);
-        ok(SUCCEEDED(hr), "Failed to delete vertex shader, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to delete vertex shader, hr %#lx.\n", hr);
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -4859,9 +4844,8 @@ done:
 static void fog_special_test(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     DWORD ps, vs;
@@ -4889,7 +4873,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[] =
     {
@@ -4941,11 +4925,11 @@ static void fog_special_test(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code, &vs, 0);
-        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
     {
@@ -4955,7 +4939,7 @@ static void fog_special_test(void)
     if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 1))
     {
         hr = IDirect3DDevice8_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
     {
@@ -4967,35 +4951,35 @@ 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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);
         }
         else if (vs)
         {
             hr = IDirect3DDevice8_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
         {
@@ -5005,12 +4989,12 @@ static void fog_special_test(void)
         if (!tests[i].ps)
         {
             hr = IDirect3DDevice8_SetPixelShader(device, 0);
-            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 = IDirect3DDevice8_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
         {
@@ -5018,16 +5002,16 @@ static void fog_special_test(void)
         }
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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),
@@ -5037,7 +5021,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 = IDirect3DDevice8_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)
@@ -5045,7 +5029,7 @@ static void fog_special_test(void)
     if (ps)
         IDirect3DDevice8_DeletePixelShader(device, ps);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -5055,13 +5039,12 @@ static void volume_dxtn_test(void)
 {
     IDirect3DVolumeTexture8 *texture;
     struct surface_readback rb;
+    unsigned int colour, i, j;
     IDirect3DDevice8 *device;
     IDirect3DSurface8 *rt;
     D3DLOCKED_BOX box;
-    unsigned int i, j;
     IDirect3D8 *d3d;
     ULONG refcount;
-    DWORD colour;
     HWND window;
     HRESULT hr;
 
@@ -5088,17 +5071,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
@@ -5110,7 +5093,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[] =
     {
@@ -5148,7 +5131,7 @@ static void volume_dxtn_test(void)
     }
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &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)
     {
@@ -5160,37 +5143,37 @@ static void volume_dxtn_test(void)
         }
         hr = IDirect3DDevice8_CreateVolumeTexture(device, 8, 4, 2, 1, 0,
                 tests[i].format, D3DPOOL_MANAGED, &texture);
-        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 = IDirect3DVolumeTexture8_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 = IDirect3DVolumeTexture8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-        ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
@@ -5202,13 +5185,13 @@ static void volume_dxtn_test(void)
         release_surface_readback(&rb);
 
         hr = IDirect3DDevice8_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);
         IDirect3DVolumeTexture8_Release(texture);
     }
 
     IDirect3DSurface8_Release(rt);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -5218,10 +5201,9 @@ static void volume_v16u16_test(void)
 {
     IDirect3DVolumeTexture8 *texture;
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     D3DLOCKED_BOX box;
     IDirect3D8 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     DWORD shader;
@@ -5273,7 +5255,7 @@ static void volume_v16u16_test(void)
         goto done;
     }
     hr = IDirect3DDevice8_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.PixelShaderVersion < D3DPS_VERSION(1, 1))
     {
         skip("No pixel shader 1.1 support, skipping test.\n");
@@ -5282,13 +5264,13 @@ static void volume_v16u16_test(void)
     }
 
     hr = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_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++)
     {
@@ -5301,10 +5283,10 @@ static void volume_v16u16_test(void)
 
         hr = IDirect3DDevice8_CreateVolumeTexture(device, 1, 2, 2, 1, 0, D3DFMT_V16U16,
                 pool, &texture);
-        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 = IDirect3DVolumeTexture8_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;
@@ -5320,7 +5302,7 @@ static void volume_v16u16_test(void)
         texel[1] =  0;
 
         hr = IDirect3DVolumeTexture8_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)
         {
@@ -5328,29 +5310,29 @@ static void volume_v16u16_test(void)
 
             hr = IDirect3DDevice8_CreateVolumeTexture(device, 1, 2, 2, 1, 0, D3DFMT_V16U16,
                     D3DPOOL_DEFAULT, &texture2);
-            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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)texture,
                     (IDirect3DBaseTexture8 *)texture2);
-            ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
 
             IDirect3DVolumeTexture8_Release(texture);
             texture = texture2;
         }
 
         hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *) texture);
-        ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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),
@@ -5366,15 +5348,15 @@ static void volume_v16u16_test(void)
                 "Expected color 0x0040c0ff, got 0x%08x, V16U16 input -16384, 16384.\n", color);
 
         hr = IDirect3DDevice8_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);
 
         IDirect3DVolumeTexture8_Release(texture);
     }
 
     hr = IDirect3DDevice8_DeletePixelShader(device, shader);
-    ok(SUCCEEDED(hr), "Failed delete pixel shader, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed delete pixel shader, hr %#lx.\n", hr);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -5389,9 +5371,9 @@ static void fill_surface(IDirect3DSurface8 *surface, DWORD color, DWORD flags)
     DWORD *mem;
 
     hr = IDirect3DSurface8_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 = IDirect3DSurface8_LockRect(surface, &l, NULL, flags);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     if (FAILED(hr))
         return;
 
@@ -5404,7 +5386,7 @@ static void fill_surface(IDirect3DSurface8 *surface, DWORD color, DWORD flags)
         }
     }
     hr = IDirect3DSurface8_UnlockRect(surface);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 }
 
 static void add_dirty_rect_test_draw(IDirect3DDevice8 *device)
@@ -5424,11 +5406,11 @@ static void add_dirty_rect_test_draw(IDirect3DDevice8 *device)
     };
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
@@ -5439,9 +5421,8 @@ static void add_dirty_rect_test(void)
         *surface_managed0, *surface_managed1, *surface_dynamic;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
-    unsigned int i;
-    D3DCOLOR color;
     ULONG refcount;
     DWORD *texel;
     HWND window;
@@ -5469,124 +5450,124 @@ static void add_dirty_rect_test(void)
 
     hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_DEFAULT, &tex_dst1);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_DEFAULT, &tex_dst2);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &tex_src_red);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &tex_src_green);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 2, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_MANAGED, &tex_managed);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, D3DUSAGE_DYNAMIC,
             D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &tex_dynamic);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MIPFILTER, D3DTEXF_POINT);
-    ok(SUCCEEDED(hr), "Failed to set mip filter, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set mip filter, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)tex_dst2);
-    ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_red,
             (IDirect3DBaseTexture8 *)tex_dst2);
     fill_surface(surface_src_green, 0x00000080, D3DLOCK_NO_DIRTY_UPDATE);
     hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_red,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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),
@@ -5595,13 +5576,13 @@ static void add_dirty_rect_test(void)
     ok(color_match(color, 0x00ff0000, 1),
             "Expected color 0x00ff0000, got 0x%08x.\n", color);
     hr = IDirect3DDevice8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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),
@@ -5611,70 +5592,70 @@ static void add_dirty_rect_test(void)
     fill_surface(surface_src_green, 0x00000080, D3DLOCK_NO_DIRTY_UPDATE);
     hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_CopyRects(device, surface_src_green, NULL, 0, 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, 0x00000080, 1), "Got unexpected colour 0x%08x.\n", color);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DTexture8_AddDirtyRect(tex_src_green, NULL);
     hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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),
@@ -5683,55 +5664,55 @@ static void add_dirty_rect_test(void)
     ok(color_match(color, 0x00ffffff, 1),
             "Expected color 0x00ffffff, got 0x%08x.\n", color);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_green,
             (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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);
 
     /* CopyRects() ignores the missing dirty marker. */
     hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_red,
             (IDirect3DBaseTexture8 *)tex_dst2);
     hr = IDirect3DDevice8_CopyRects(device, surface_src_green, NULL, 0, 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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAXMIPLEVEL, 1);
-    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);
     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 = IDirect3DDevice8_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);
@@ -5741,86 +5722,86 @@ static void add_dirty_rect_test(void)
     ok(color_match(color, 0x00ff0000, 1),
             "Expected color 0x00ff0000, got 0x%08x.\n", color);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAXMIPLEVEL, 0);
-    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);
     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 = IDirect3DDevice8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAXMIPLEVEL, 1);
-    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);
     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 = IDirect3DDevice8_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 ResourceManagerDiscardBytes. */
     fill_surface(surface_managed0, 0x00ffff00, D3DLOCK_NO_DIRTY_UPDATE);
     fill_surface(surface_managed1, 0x00ff00ff, D3DLOCK_NO_DIRTY_UPDATE);
     hr = IDirect3DDevice8_ResourceManagerDiscardBytes(device, 0);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAXMIPLEVEL, 0);
-    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);
     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 = IDirect3DDevice8_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 blitting from a managed texture. */
     fill_surface(surface_managed0, 0x0000ff00, D3DLOCK_NO_DIRTY_UPDATE);
     hr = IDirect3DDevice8_CopyRects(device, surface_managed0, NULL, 0, surface_dst2, NULL);
-    ok(hr == D3D_OK, "Failed to update surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to update surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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);
     add_dirty_rect_test_draw(device);
     color = getPixelColor(device, 320, 240);
     ok(color_match(color, 0x0000ff00, 1), "Got unexpected colour 0x%08x.\n", color);
     hr = IDirect3DDevice8_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);
 
     /* Tests with dynamic textures */
     fill_surface(surface_dynamic, 0x0000ffff, 0);
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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);
@@ -5829,31 +5810,31 @@ static void add_dirty_rect_test(void)
     ok(color_match(color, 0x00ffff00, 1),
             "Expected color 0x00ffff00, got 0x%08x.\n", color);
     hr = IDirect3DDevice8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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);
     }
 
     IDirect3DSurface8_Release(surface_dst2);
@@ -5876,26 +5857,26 @@ static void add_dirty_rect_test(void)
 
     hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_DEFAULT, &tex_dst2);
-    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 = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
             D3DPOOL_SYSTEMMEM, &tex_src_green);
-    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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_CopyRects(device, surface_src_green, NULL, 0, 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 = IDirect3DDevice8_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);
 
     IDirect3DSurface8_Release(surface_dst2);
     IDirect3DSurface8_Release(surface_src_green);
@@ -5903,7 +5884,7 @@ static void add_dirty_rect_test(void)
     IDirect3DTexture8_Release(tex_src_green);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -5960,13 +5941,12 @@ static void test_3dc_formats(void)
     IDirect3D8 *d3d;
     IDirect3DDevice8 *device;
     IDirect3DTexture8 *ati1n_texture, *ati2n_texture;
+    unsigned int color, i;
     D3DCAPS8 caps;
     D3DLOCKED_RECT rect;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    unsigned int i;
 
     window = create_window();
     d3d = Direct3DCreate8(D3D_SDK_VERSION);
@@ -5989,7 +5969,7 @@ static void test_3dc_formats(void)
         goto done;
     }
     hr = IDirect3DDevice8_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");
@@ -5999,55 +5979,55 @@ static void test_3dc_formats(void)
 
     hr = IDirect3DDevice8_CreateTexture(device, 4, 4, 1, 0, ati1n_fourcc,
             D3DPOOL_MANAGED, &ati1n_texture);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_CreateTexture(device, 8, 4, 1, 0, ati2n_fourcc,
             D3DPOOL_MANAGED, &ati2n_texture);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
     {
@@ -6060,11 +6040,11 @@ static void test_3dc_formats(void)
     }
 
     hr = IDirect3DDevice8_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);
     IDirect3DTexture8_Release(ati2n_texture);
     IDirect3DTexture8_Release(ati1n_texture);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D8_Release(d3d);
@@ -6075,10 +6055,11 @@ static void test_fog_interpolation(void)
 {
     HRESULT hr;
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
     ULONG refcount;
     HWND window;
-    D3DCOLOR color;
+
     static const struct
     {
         struct vec3 position;
@@ -6097,7 +6078,6 @@ static void test_fog_interpolation(void)
         DWORD d;
         float f;
     } conv;
-    unsigned int i;
     static const struct
     {
         D3DFOGMODE vfog, tfog;
@@ -6138,30 +6118,30 @@ static void test_fog_interpolation(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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.
@@ -6170,7 +6150,7 @@ static void test_fog_interpolation(void)
      * The input value is independent of the actual z and w component of
      * the vertex position. */
     hr = IDirect3DDevice8_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++)
     {
@@ -6178,20 +6158,20 @@ static void test_fog_interpolation(void)
             continue;
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -6202,11 +6182,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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -6215,10 +6195,11 @@ static void test_negative_fixedfunction_fog(void)
 {
     HRESULT hr;
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
     ULONG refcount;
     HWND window;
-    D3DCOLOR color;
+
     static const struct
     {
         struct vec3 position;
@@ -6243,7 +6224,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,
@@ -6312,20 +6292,20 @@ static void test_negative_fixedfunction_fog(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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++)
     {
@@ -6333,38 +6313,38 @@ static void test_negative_fixedfunction_fog(void)
             continue;
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -6373,10 +6353,10 @@ static void test_table_fog_zw(void)
 {
     HRESULT hr;
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
     ULONG refcount;
     HWND window;
-    D3DCOLOR color;
     D3DCAPS8 caps;
     static struct
     {
@@ -6401,7 +6381,7 @@ static void test_table_fog_zw(void)
     {
         float z, w;
         D3DZBUFFERTYPE z_test;
-        D3DCOLOR color;
+        unsigned int color;
     }
     tests[] =
     {
@@ -6414,7 +6394,6 @@ static void test_table_fog_zw(void)
         {0.3f,  0.0f, D3DZB_TRUE,  0x00b24c00},
         {0.3f,  0.0f, D3DZB_FALSE, 0x00b24c00},
     };
-    unsigned int i;
 
     window = create_window();
     d3d = Direct3DCreate8(D3D_SDK_VERSION);
@@ -6429,7 +6408,7 @@ static void test_table_fog_zw(void)
     }
 
     hr = IDirect3DDevice8_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");
@@ -6437,25 +6416,25 @@ static void test_table_fog_zw(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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;
@@ -6466,40 +6445,39 @@ static void test_table_fog_zw(void)
         quad[2].position.w = tests[i].w;
         quad[3].position.w = tests[i].w;
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
 
 static void test_signed_formats(void)
 {
+    unsigned int expected_color, color, i, j, x, y;
     IDirect3DDevice8 *device;
     HWND window;
     HRESULT hr;
-    unsigned int i, j, x, y;
     IDirect3DTexture8 *texture, *texture_sysmem;
     D3DLOCKED_RECT locked_rect;
     DWORD shader, shader_alpha;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     D3DCAPS8 caps;
     ULONG refcount;
 
@@ -6628,7 +6606,6 @@ static void test_signed_formats(void)
         {0x00ba98a0, 0x004767a8, 0x00888881, 0x007878ff},
         {0x00c3c3c0, 0x003f3f80, 0x00e51fe1, 0x005fa2c8},
     };
-    D3DCOLOR expected_color;
 
     window = create_window();
     d3d = Direct3DCreate8(D3D_SDK_VERSION);
@@ -6643,7 +6620,7 @@ static void test_signed_formats(void)
     }
 
     hr = IDirect3DDevice8_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))
     {
@@ -6652,13 +6629,13 @@ static void test_signed_formats(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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++)
     {
@@ -6675,10 +6652,10 @@ static void test_signed_formats(void)
             texture_sysmem = NULL;
             hr = IDirect3DDevice8_CreateTexture(device, tests[j].width, 4, 1, 0,
                     formats[i].format, tests[j].pool, &texture);
-            ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
             hr = IDirect3DTexture8_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,
@@ -6686,34 +6663,34 @@ static void test_signed_formats(void)
                         tests[j].width * formats[i].pixel_size);
             }
             hr = IDirect3DTexture8_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 = IDirect3DDevice8_CreateTexture(device, tests[j].width, 4, 1, 0,
                         formats[i].format, D3DPOOL_DEFAULT, &texture);
-                ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
                 hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)texture_sysmem,
                         (IDirect3DBaseTexture8 *)texture);
-                ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to update texture, hr %#lx.\n", hr);
                 IDirect3DTexture8_Release(texture_sysmem);
             }
 
             hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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++)
             {
@@ -6732,19 +6709,19 @@ static void test_signed_formats(void)
                 }
             }
             hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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++)
             {
@@ -6762,7 +6739,7 @@ static void test_signed_formats(void)
                 }
             }
             hr = IDirect3DDevice8_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);
 
             IDirect3DTexture8_Release(texture);
         }
@@ -6773,24 +6750,23 @@ static void test_signed_formats(void)
 
 done:
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
 
 static void test_updatetexture(void)
 {
+    unsigned int color, t, i, f, l, x, y, z;
     IDirect3DDevice8 *device;
     IDirect3D8 *d3d;
     HWND window;
     HRESULT hr;
     IDirect3DBaseTexture8 *src, *dst;
-    unsigned int t, i, f, l, x, y, z;
     D3DLOCKED_RECT locked_rect;
     D3DLOCKED_BOX locked_box;
     ULONG refcount;
     D3DCAPS8 caps;
-    D3DCOLOR color;
     BOOL ati2n_supported, do_visual_test;
     static const struct
     {
@@ -6891,22 +6867,22 @@ static void test_updatetexture(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
-    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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
-    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 = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ADDRESSW, D3DTADDRESS_CLAMP);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
     {
@@ -6928,7 +6904,7 @@ static void test_updatetexture(void)
         }
 
         hr = IDirect3DDevice8_SetVertexShader(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)
         {
@@ -6942,36 +6918,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,
                             (IDirect3DTexture8 **)&src);
-                    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 = IDirect3DDevice8_CreateTexture(device,
                             tests[i].dst_width, tests[i].dst_height,
                             tests[i].dst_levels, 0, tests[i].dst_format, D3DPOOL_DEFAULT,
                             (IDirect3DTexture8 **)&dst);
-                    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 = IDirect3DDevice8_CreateCubeTexture(device,
                             tests[i].src_width,
                             tests[i].src_levels, 0, tests[i].src_format, D3DPOOL_SYSTEMMEM,
                             (IDirect3DCubeTexture8 **)&src);
-                    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 = IDirect3DDevice8_CreateCubeTexture(device,
                             tests[i].dst_width,
                             tests[i].dst_levels, 0, tests[i].dst_format, D3DPOOL_DEFAULT,
                             (IDirect3DCubeTexture8 **)&dst);
-                    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 = IDirect3DDevice8_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,
                             (IDirect3DVolumeTexture8 **)&src);
-                    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 = IDirect3DDevice8_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,
                             (IDirect3DVolumeTexture8 **)&dst);
-                    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");
@@ -7021,7 +6997,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)
                         {
@@ -7050,7 +7026,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)
@@ -7069,28 +7045,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);
                 IDirect3DBaseTexture8_Release(src);
                 IDirect3DBaseTexture8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)
@@ -7104,7 +7080,7 @@ static void test_updatetexture(void)
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -7144,15 +7120,14 @@ static void test_pointsize(void)
     IDirect3DSurface8 *rt, *backbuffer, *depthstencil;
     IDirect3DTexture8 *tex1, *tex2;
     IDirect3DDevice8 *device;
+    unsigned int color, i, j;
     DWORD vs, ps;
     D3DLOCKED_RECT lr;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
     HRESULT hr;
-    unsigned int i, j;
 
     static const DWORD tex1_data[4] = {0x00ff0000, 0x00ff0000, 0x00000000, 0x00000000};
     static const DWORD tex2_data[4] = {0x00000000, 0x0000ff00, 0x00000000, 0x0000ff00};
@@ -7282,7 +7257,7 @@ static void test_pointsize(void)
     }
 
     hr = IDirect3DDevice8_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.MaxPointSize < 32.0f)
     {
         skip("MaxPointSize %f < 32.0, skipping.\n", caps.MaxPointSize);
@@ -7293,99 +7268,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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX1);
-    ok(SUCCEEDED(hr), "Failed to set FVF, hr=%#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &matrix);
-    ok(SUCCEEDED(hr), "Failed to set projection matrix, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection matrix, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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");
@@ -7413,51 +7388,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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex1);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex2);
-    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 = IDirect3DTexture8_LockRect(tex1, 0, &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);
     memcpy(lr.pBits, tex1_data, sizeof(tex1_data));
     hr = IDirect3DTexture8_UnlockRect(tex1, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
     memset(&lr, 0, sizeof(lr));
     hr = IDirect3DTexture8_LockRect(tex2, 0, &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);
     memcpy(lr.pBits, tex2_data, sizeof(tex2_data));
     hr = IDirect3DTexture8_UnlockRect(tex2, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)tex1);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)tex2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_POINTSPRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable point sprites, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable point sprites, hr %#lx.\n", hr);
     ptsize = 32.0f;
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize);
-    ok(SUCCEEDED(hr), "Failed to set point size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set point size, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -7472,25 +7447,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 = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &matrix);
-    ok(SUCCEEDED(hr), "Failed to set projection matrix, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection matrix, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetDepthStencilSurface(device, &depthstencil);
-    ok(SUCCEEDED(hr), "Failed to get depth / stencil buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get depth / stencil buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, TRUE, &rt);
-    ok(SUCCEEDED(hr), "Failed to create a render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
     hr = IDirect3DDevice8_SetVertexShaderConstant(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)
     {
@@ -7499,7 +7474,7 @@ static void test_pointsize(void)
     }
 
     hr = IDirect3DDevice8_SetRenderTarget(device, rt, depthstencil);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_setups); ++i)
     {
@@ -7512,7 +7487,7 @@ static void test_pointsize(void)
         if (test_setups[i].vs->code)
         {
             hr = IDirect3DDevice8_CreateVertexShader(device, test_setups[i].decl, test_setups[i].vs->code, &vs, 0);
-            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
         {
@@ -7521,7 +7496,7 @@ static void test_pointsize(void)
         if (test_setups[i].ps->code)
         {
             hr = IDirect3DDevice8_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
         {
@@ -7529,9 +7504,9 @@ static void test_pointsize(void)
         }
 
         hr = IDirect3DDevice8_SetVertexShader(device, vs ? vs : test_setups[i].accepted_fvf);
-        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 = IDirect3DDevice8_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)
         {
@@ -7543,25 +7518,25 @@ static void test_pointsize(void)
 
             ptsize = tests[j].zero_size ? 0.0f : 32.0f;
             hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 (tests[j].zero_size)
             {
@@ -7618,7 +7593,7 @@ static void test_pointsize(void)
             IDirect3DDevice8_DeletePixelShader(device, ps);
     }
     hr = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depthstencil);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
 cleanup:
     IDirect3DSurface8_Release(backbuffer);
@@ -7628,7 +7603,7 @@ cleanup:
     IDirect3DTexture8_Release(tex1);
     IDirect3DTexture8_Release(tex2);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -7662,18 +7637,18 @@ static void test_multisample_mismatch(void)
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, FALSE, &rt_multi);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, rt_multi, ds);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(ds);
     IDirect3DSurface8_Release(rt_multi);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -7708,8 +7683,8 @@ static void test_texcoordindex(void)
     HRESULT hr;
     IDirect3DTexture8 *texture1, *texture2;
     D3DLOCKED_RECT locked_rect;
+    unsigned int color;
     ULONG refcount;
-    D3DCOLOR color;
     DWORD *ptr;
 
     window = create_window();
@@ -7724,65 +7699,65 @@ static void test_texcoordindex(void)
     }
 
     hr = IDirect3DDevice8_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture1);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture2);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr);
 
     hr = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture1);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetTexture(device, 1, (IDirect3DBaseTexture8 *)texture2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -7794,19 +7769,19 @@ static void test_texcoordindex(void)
     ok(color_match(color, 0x00ffffff, 2), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -7818,19 +7793,19 @@ static void test_texcoordindex(void)
     ok(color_match(color, 0x0000ffff, 2), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -7842,13 +7817,13 @@ static void test_texcoordindex(void)
     ok(color_match(color, 0x00ffff00, 2), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_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);
 
     IDirect3DTexture8_Release(texture1);
     IDirect3DTexture8_Release(texture2);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -7860,10 +7835,10 @@ static void test_vshader_input(void)
     DWORD texcoord_color_shader, color_ubyte_shader, color_color_shader, color_float_shader;
     DWORD color_nocolor_shader = 0;
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
     ULONG refcount;
     D3DCAPS8 caps;
-    DWORD color;
     HWND window;
     HRESULT hr;
 
@@ -8021,7 +7996,7 @@ static void test_vshader_input(void)
     }
 
     hr = IDirect3DDevice8_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");
@@ -8030,44 +8005,44 @@ static void test_vshader_input(void)
     }
 
     hr = IDirect3DDevice8_CreateVertexShader(device, decl_twotexcrd, swapped_shader_code, &swapped_twotexcrd_shader, 0);
-    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 = IDirect3DDevice8_CreateVertexShader(device, decl_onetexcrd, swapped_shader_code, &swapped_onetexcrd_shader, 0);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected error while creating vertex shader, hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected error while creating vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateVertexShader(device, decl_twotexcrd_wrongidx, swapped_shader_code, &swapped_twotex_wrongidx_shader, 0);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected error while creating vertex shader, hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected error while creating vertex shader, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateVertexShader(device, decl_twotexcrd_rightorder, swapped_shader_code, &swapped_twotexcrd_rightorder_shader, 0);
-    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 = IDirect3DDevice8_CreateVertexShader(device, decl_texcoord_color, texcoord_color_shader_code, &texcoord_color_shader, 0);
-    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 = IDirect3DDevice8_CreateVertexShader(device, decl_color_ubyte, color_color_shader_code, &color_ubyte_shader, 0);
-    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 = IDirect3DDevice8_CreateVertexShader(device, decl_color_color, color_color_shader_code, &color_color_shader, 0);
-    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 = IDirect3DDevice8_CreateVertexShader(device, decl_color_float, color_color_shader_code, &color_float_shader, 0);
-    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 = IDirect3DDevice8_CreateVertexShader(device, decl_nocolor, color_color_shader_code, &color_nocolor_shader, 0);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected error while creating vertex shader, hr %#x.\n", hr);
+    todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected error while creating vertex shader, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, swapped_twotexcrd_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, swapped_twotexcrd_rightorder_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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, 0x00ffff80, 1), "Got unexpected color 0x%08x for quad 1 (2crd).\n", color);
@@ -8075,41 +8050,41 @@ static void test_vshader_input(void)
     ok(color == 0x00000000, "Got unexpected color 0x%08x for quad 4 (2crd-rightorder).\n", color);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, color_ubyte_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 = IDirect3DDevice8_SetVertexShaderConstant(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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShaderConstant(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, color_float_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 = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     IDirect3DDevice8_SetVertexShader(device, 0);
 
@@ -8127,7 +8102,7 @@ static void test_vshader_input(void)
             "Input test: Quad 4(color-float) returned color 0x%08x, expected 0x00ffff00\n", color);
 
     hr = IDirect3DDevice8_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);
 
     IDirect3DDevice8_DeleteVertexShader(device, swapped_twotexcrd_shader);
     IDirect3DDevice8_DeleteVertexShader(device, swapped_onetexcrd_shader);
@@ -8140,7 +8115,7 @@ static void test_vshader_input(void)
     IDirect3DDevice8_DeleteVertexShader(device, color_nocolor_shader);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -8149,7 +8124,7 @@ done:
 static void test_fixed_function_fvf(void)
 {
     IDirect3DDevice8 *device;
-    DWORD color;
+    unsigned int color;
     IDirect3D8 *d3d;
     ULONG refcount;
     D3DCAPS8 caps;
@@ -8199,24 +8174,24 @@ static void test_fixed_function_fvf(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 == 0x00ffff00,
@@ -8225,16 +8200,16 @@ static void test_fixed_function_fvf(void)
 
     /* Test with no diffuse color attribute. */
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0);
-    ok(SUCCEEDED(hr), "IDirect3DDevice8_Clear failed with %08x\n", hr);
+    ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 diffuse attribute test.\n", color);
@@ -8242,21 +8217,21 @@ static void test_fixed_function_fvf(void)
 
     /* Test what happens with specular lighting enabled and no specular color attribute. */
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
 
     color = getPixelColor(device, 160, 360);
     ok(color == 0x00ffff00, "Got unexpected color 0x%08x in the no specular attribute test.\n", color);
@@ -8264,17 +8239,17 @@ static void test_fixed_function_fvf(void)
     IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
 
     hr = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad_transformed, sizeof(quad_transformed[0]));
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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,
@@ -8331,7 +8306,7 @@ static void test_fixed_function_fvf(void)
     IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -8340,13 +8315,12 @@ done:
 static void test_flip(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
     ULONG refcount;
     HWND window;
     HRESULT hr;
     IDirect3DSurface8 *back_buffers[3], *test_surface;
-    unsigned int i;
-    D3DCOLOR color;
     D3DPRESENT_PARAMETERS present_parameters = {0};
 
     window = create_window();
@@ -8373,35 +8347,35 @@ static void test_flip(void)
     for (i = 0; i < ARRAY_SIZE(back_buffers); ++i)
     {
         hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DDevice8_GetRenderTarget(device, &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);
     IDirect3DSurface8_Release(test_surface);
 
 
     hr = IDirect3DDevice8_SetRenderTarget(device, back_buffers[0], 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 = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, back_buffers[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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderTarget(device, back_buffers[2], 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_GetRenderTarget(device, &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);
     IDirect3DSurface8_Release(test_surface);
 
@@ -8409,7 +8383,7 @@ static void test_flip(void)
     for (i = 0; i < ARRAY_SIZE(back_buffers); ++i)
     {
         hr = IDirect3DDevice8_GetBackBuffer(device, 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);
         IDirect3DSurface8_Release(test_surface);
@@ -8422,10 +8396,10 @@ static void test_flip(void)
     ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = get_surface_color(back_buffers[0], 1, 1);
     ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
@@ -8433,7 +8407,7 @@ static void test_flip(void)
     ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_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 = get_surface_color(back_buffers[0], 1, 1);
     ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
@@ -8442,7 +8416,7 @@ static void test_flip(void)
         IDirect3DSurface8_Release(back_buffers[i]);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     if (FAILED(IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES)))
@@ -8460,22 +8434,22 @@ static void test_flip(void)
     for (i = 0; i < present_parameters.BackBufferCount; ++i)
     {
         hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DDevice8_SetRenderTarget(device, back_buffers[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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_NONE, TRUE, &test_surface);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CopyRects(device, back_buffers[0], NULL, 0, test_surface, NULL);
-    ok(SUCCEEDED(hr), "CopyRects failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CopyRects failed, hr %#lx.\n", hr);
 
     color = get_surface_color(test_surface, 1, 1);
     ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
@@ -8485,7 +8459,7 @@ static void test_flip(void)
         IDirect3DSurface8_Release(back_buffers[i]);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D8_Release(d3d);
@@ -8580,17 +8554,16 @@ static void test_uninitialized_varyings(void)
         {D3DVS_VERSION(1, 1), vs1_partial_code, D3DPS_VERSION(1, 1), ps1_texcoord_code, 0xff7f0000, TRUE,  TRUE},
     };
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
     HWND window;
     HRESULT hr;
     DWORD vs, ps;
-    unsigned int i;
     ULONG refcount;
     D3DCAPS8 caps;
     IDirect3DSurface8 *backbuffer;
     D3DADAPTER_IDENTIFIER8 identifier;
     struct surface_readback rb;
-    D3DCOLOR color;
     BOOL warp;
 
     window = create_window();
@@ -8605,31 +8578,31 @@ static void test_uninitialized_varyings(void)
     }
 
     hr = IDirect3D8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -8642,20 +8615,20 @@ static void test_uninitialized_varyings(void)
         if (tests[i].vs)
         {
             hr = IDirect3DDevice8_CreateVertexShader(device, decl, tests[i].vs, &vs, 0);
-            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);
             hr = IDirect3DDevice8_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
         {
             vs = 0;
             hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ);
-            ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#lx.\n", hr);
         }
         if (tests[i].ps)
         {
             hr = IDirect3DDevice8_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
         {
@@ -8663,19 +8636,19 @@ static void test_uninitialized_varyings(void)
         }
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -8693,11 +8666,11 @@ static void test_uninitialized_varyings(void)
     }
 
     hr = IDirect3DDevice8_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);
 
     IDirect3DSurface8_Release(backbuffer);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -8706,8 +8679,8 @@ static void test_shademode(void)
 {
     IDirect3DVertexBuffer8 *vb_strip;
     IDirect3DVertexBuffer8 *vb_list;
+    unsigned int color0, color1;
     IDirect3DDevice8 *device;
-    DWORD color0, color1;
     BYTE *data = NULL;
     IDirect3D8 *d3d;
     ULONG refcount;
@@ -8772,7 +8745,7 @@ static void test_shademode(void)
         const struct test_shader *vs, *ps;
         DWORD primtype;
         DWORD shademode;
-        DWORD color0, color1;
+        unsigned int color0, color1;
     }
     tests[] =
     {
@@ -8802,28 +8775,28 @@ static void test_shademode(void)
     }
 
     hr = IDirect3DDevice8_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);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_CreateVertexBuffer(device, sizeof(quad_strip), 0, 0, D3DPOOL_MANAGED, &vb_strip);
-    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 = IDirect3DVertexBuffer8_Lock(vb_strip, 0, sizeof(quad_strip), &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, quad_strip, sizeof(quad_strip));
     hr = IDirect3DVertexBuffer8_Unlock(vb_strip);
-    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 = IDirect3DDevice8_CreateVertexBuffer(device, sizeof(quad_list), 0, 0, D3DPOOL_MANAGED, &vb_list);
-    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 = IDirect3DVertexBuffer8_Lock(vb_list, 0, sizeof(quad_list), &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, quad_list, sizeof(quad_list));
     hr = IDirect3DVertexBuffer8_Unlock(vb_list);
-    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 = IDirect3DDevice8_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. */
@@ -8835,9 +8808,9 @@ static void test_shademode(void)
             if (caps.VertexShaderVersion >= tests[i].vs->version)
             {
                 hr = IDirect3DDevice8_CreateVertexShader(device, decl, tests[i].vs->code, &vs, 0);
-                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 = IDirect3DDevice8_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
             {
@@ -8849,16 +8822,16 @@ static void test_shademode(void)
         {
             vs = 0;
             hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-            ok(hr == D3D_OK, "Failed to set FVF, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Failed to set FVF, hr %#lx.\n", hr);
         }
         if (tests[i].ps->version)
         {
             if (caps.PixelShaderVersion >= tests[i].ps->version)
             {
                 hr = IDirect3DDevice8_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 = IDirect3DDevice8_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
             {
@@ -8878,20 +8851,20 @@ static void test_shademode(void)
 
         hr = IDirect3DDevice8_SetStreamSource(device, 0,
                 tests[i].primtype == D3DPT_TRIANGLESTRIP ? vb_strip : vb_list, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 */
@@ -8916,12 +8889,12 @@ static void test_shademode(void)
     }
 
     hr = IDirect3DDevice8_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);
 
     IDirect3DVertexBuffer8_Release(vb_strip);
     IDirect3DVertexBuffer8_Release(vb_list);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -8929,13 +8902,12 @@ static void test_shademode(void)
 static void test_multisample_init(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color, x, y;
     IDirect3D8 *d3d;
     IDirect3DSurface8 *back, *multi;
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    D3DCOLOR color;
-    unsigned int x, y;
     struct surface_readback rb;
     BOOL all_zero = TRUE;
 
@@ -8957,13 +8929,13 @@ static void test_multisample_init(void)
     }
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
             D3DMULTISAMPLE_2_SAMPLES, FALSE, &multi);
-    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 = IDirect3DDevice8_CopyRects(device, multi, NULL, 0, back, NULL);
-    ok(SUCCEEDED(hr), "CopyRects failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CopyRects failed, hr %#lx.\n", hr);
 
     get_rt_readback(back, &rb);
     for (y = 0; y < 480; ++y)
@@ -8987,7 +8959,7 @@ static void test_multisample_init(void)
     IDirect3DSurface8_Release(back);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
 done:
     IDirect3D8_Release(d3d);
@@ -9001,12 +8973,11 @@ static void test_texture_blending(void)
 
     IDirect3DTexture8 *texture_bumpmap, *texture_red;
     IDirect3DSurface8 *backbuffer;
+    unsigned int color, i, j, k;
     struct surface_readback rb;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice8 *device;
-    unsigned int i, j, k;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
@@ -9073,7 +9044,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[] =
@@ -9432,7 +9403,7 @@ static void test_texture_blending(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice8_GetDeviceCaps failed hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice8_GetDeviceCaps failed hr %#lx.\n", hr);
 
     if(!(caps.PrimitiveMiscCaps & D3DPMISCCAPS_TSSARGTEMP))
     {
@@ -9450,31 +9421,31 @@ static void test_texture_blending(void)
     }
 
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, 0, D3DFMT_V8U8, D3DPOOL_MANAGED, &texture_bumpmap);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreateTexture failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice8_CreateTexture failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture_red);
-    ok(hr == D3D_OK, "IDirect3DDevice8_CreateTexture failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice8_CreateTexture failed, hr %#lx.\n", hr);
 
     memset(&locked_rect, 0, sizeof(locked_rect));
     hr = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_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 = IDirect3DTexture8_UnlockRect(texture_red, 0);
-    ok(SUCCEEDED(hr), "UnlockRect failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "UnlockRect failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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)
     {
@@ -9482,7 +9453,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;
         }
 
@@ -9494,7 +9465,7 @@ static void test_texture_blending(void)
             {
                 hr = IDirect3DDevice8_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)
@@ -9518,23 +9489,23 @@ static void test_texture_blending(void)
                 {
                     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetTexture(device, j, (IDirect3DBaseTexture8 *)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 = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-        ok(hr == D3D_OK, "Test %u: IDirect3DDevice8_Clear failed, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: IDirect3DDevice8_Clear failed, hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -9542,14 +9513,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 = IDirect3DDevice8_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);
     }
 
     IDirect3DTexture8_Release(texture_bumpmap);
     IDirect3DTexture8_Release(texture_red);
     IDirect3DSurface8_Release(backbuffer);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -9610,10 +9581,9 @@ static void test_color_clamping(void)
         {D3DVS_VERSION(1, 1), vs1_code, D3DPS_VERSION(1, 1), ps1_code, 0x007f7f7f},
     };
     IDirect3DDevice8 *device;
+    unsigned int color, i;
     IDirect3D8 *d3d;
-    unsigned int i;
     ULONG refcount;
-    D3DCOLOR color;
     D3DCAPS8 caps;
     DWORD vs, ps;
     HWND window;
@@ -9631,41 +9601,41 @@ static void test_color_clamping(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -9678,7 +9648,7 @@ static void test_color_clamping(void)
         if (tests[i].vs)
         {
             hr = IDirect3DDevice8_CreateVertexShader(device, decl, tests[i].vs, &vs, 0);
-            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
         {
@@ -9687,7 +9657,7 @@ static void test_color_clamping(void)
         if (tests[i].ps)
         {
             hr = IDirect3DDevice8_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
         {
@@ -9695,21 +9665,21 @@ static void test_color_clamping(void)
         }
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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)),
@@ -9722,10 +9692,10 @@ static void test_color_clamping(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -9733,9 +9703,9 @@ static void test_color_clamping(void)
 static void test_edge_antialiasing_blending(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d8;
     ULONG refcount;
-    D3DCOLOR color;
     D3DCAPS8 caps;
     HWND window;
     HRESULT hr;
@@ -9777,111 +9747,111 @@ static void test_edge_antialiasing_blending(void)
     }
 
     hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
-    trace("Edge antialiasing support: %#x.\n", caps.RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
+    trace("Edge antialiasing support: %#lx.\n", caps.RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetRenderState(device, D3DRS_EDGEANTIALIAS, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -9909,9 +9879,9 @@ static void test_max_index16(void)
     IDirect3DIndexBuffer8 *ib;
     IDirect3DDevice8 *device;
     struct vertex *vb_data;
+    unsigned int color;
     IDirect3D8 *d3d8;
     ULONG refcount;
-    D3DCOLOR color;
     D3DCAPS8 caps;
     HWND window;
     BYTE *data;
@@ -9923,7 +9893,7 @@ static void test_max_index16(void)
     ok(!!d3d8, "Failed to create a D3D object.\n");
 
     hr = IDirect3D8_GetAdapterIdentifier(d3d8, 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(d3d8, window, window, TRUE)))
@@ -9935,10 +9905,10 @@ static void test_max_index16(void)
     }
 
     hr = IDirect3DDevice8_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);
         IDirect3DDevice8_Release(device);
         IDirect3D8_Release(d3d8);
         DestroyWindow(window);
@@ -9947,50 +9917,50 @@ static void test_max_index16(void)
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device, vertex_count * sizeof(*green_quad), 0,
             D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DPOOL_MANAGED, &vb);
-    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 = IDirect3DDevice8_CreateIndexBuffer(device, sizeof(indices), 0,
             D3DFMT_INDEX16, D3DPOOL_MANAGED, &ib);
-    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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DVertexBuffer8_Lock(vb, 0, sizeof(green_quad), (BYTE **)&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 = IDirect3DVertexBuffer8_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 = IDirect3DIndexBuffer8_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 = IDirect3DIndexBuffer8_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 = IDirect3DDevice8_SetIndices(device, ib, 0);
-    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 = IDirect3DDevice8_SetStreamSource(device, 0, vb, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 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 = IDirect3DDevice8_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);
@@ -10001,7 +9971,7 @@ static void test_max_index16(void)
     IDirect3DIndexBuffer8_Release(ib);
     IDirect3DVertexBuffer8_Release(vb);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d8);
     DestroyWindow(window);
 }
@@ -10011,8 +9981,8 @@ static void test_backbuffer_resize(void)
     D3DPRESENT_PARAMETERS present_parameters = {0};
     IDirect3DSurface8 *backbuffer;
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -10042,16 +10012,16 @@ static void test_backbuffer_resize(void)
     /* Wine d3d8 implementation had a bug which was triggered by a
      * SetRenderTarget() call with an unreferenced surface. */
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DSurface8_Release(backbuffer);
-    ok(!refcount, "Surface has %u references left.\n", refcount);
+    ok(!refcount, "Surface has %lu references left.\n", refcount);
     hr = IDirect3DDevice8_SetRenderTarget(device, backbuffer, 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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, 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 = IDirect3DDevice8_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);
 
@@ -10064,43 +10034,43 @@ static void test_backbuffer_resize(void)
     present_parameters.EnableAutoDepthStencil = TRUE;
     present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DDevice8_SetRenderTarget(device, backbuffer, 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);
     IDirect3DSurface8_Release(backbuffer);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -10127,9 +10097,9 @@ static void test_drawindexedprimitiveup(void)
     };
     static const unsigned short indices[] = {0, 1, 2, 3, 4, 5, 6, 7};
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
     ULONG refcount;
-    D3DCOLOR color;
     HWND window;
     HRESULT hr;
 
@@ -10146,33 +10116,33 @@ static void test_drawindexedprimitiveup(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -10184,14 +10154,14 @@ static void test_drawindexedprimitiveup(void)
     ok(color_match(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
@@ -10203,21 +10173,20 @@ static void test_drawindexedprimitiveup(void)
     ok(color_match(color, 0x00bf0040, 1), "Got unexpected color 0x%08x.\n", color);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
 
 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_IDENTIFIER8 identifier;
     IDirect3DVertexBuffer8 *buffer;
     IDirect3DDevice8 *device;
     BOOL unsynchronised, ret;
     IDirect3D8 *d3d;
-    D3DCOLOR colour;
     ULONG refcount;
     D3DCAPS8 caps;
     HWND window;
@@ -10278,7 +10247,7 @@ static void test_map_synchronisation(void)
     }
 
     hr = IDirect3D8_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))
     {
@@ -10287,12 +10256,12 @@ static void test_map_synchronisation(void)
     }
 
     hr = IDirect3DDevice8_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);
@@ -10302,32 +10271,32 @@ static void test_map_synchronisation(void)
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device, size,
             D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &buffer);
-    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 = IDirect3DVertexBuffer8_Lock(buffer, 0, size, (BYTE **)&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 = IDirect3DVertexBuffer8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_SetStreamSource(device, 0, buffer, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
 
@@ -10335,25 +10304,25 @@ static void test_map_synchronisation(void)
     ret = QueryPerformanceCounter(&ts[0]);
     ok(ret, "Failed to read performance counter.\n");
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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");
@@ -10366,7 +10335,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;
     }
@@ -10376,36 +10345,36 @@ static void test_map_synchronisation(void)
     {
         hr = IDirect3DDevice8_CreateVertexBuffer(device, size,
                 D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &buffer);
-        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 = IDirect3DVertexBuffer8_Lock(buffer, 0, size, (BYTE **)&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 = IDirect3DVertexBuffer8_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 = IDirect3DDevice8_SetStreamSource(device, 0, buffer, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DVertexBuffer8_Lock(buffer, size - sizeof(quad2),
                 sizeof(quad2), (BYTE **)&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 = IDirect3DVertexBuffer8_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);
@@ -10413,14 +10382,14 @@ static void test_map_synchronisation(void)
                 tests[i].unsynchronised ? "unsynchronised" : "synchronised", tests[i].flags);
 
         hr = IDirect3DDevice8_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);
 
         IDirect3DVertexBuffer8_Release(buffer);
     }
 
 done:
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -10472,12 +10441,12 @@ static void test_viewport(void)
     }
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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);
 
     /* This crashes on Windows. */
     /* hr = IDirect3DDevice8_SetViewport(device, NULL); */
@@ -10488,40 +10457,40 @@ static void test_viewport(void)
         {
             hr = IDirect3DDevice8_CreateRenderTarget(device, rt_sizes[i].x, rt_sizes[i].y,
                     D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, TRUE, &rt);
-            ok(SUCCEEDED(hr), "Failed to create render target, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx (i %u).\n", hr, i);
             hr = IDirect3DDevice8_SetRenderTarget(device, rt, NULL);
-            ok(SUCCEEDED(hr), "Failed to set render target, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx (i %u).\n", hr, i);
         }
         else
         {
             hr = IDirect3DDevice8_GetBackBuffer(device, 0, D3DBACKBUFFER_TYPE_MONO, &rt);
-            ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#lx.\n", hr);
         }
 
         for (j = 0; j < ARRAY_SIZE(tests); ++j)
         {
             hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to clear, hr %#lx (i %u, j %u).\n", hr, i, j);
 
             hr = IDirect3DDevice8_SetViewport(device, &tests[j].vp);
             if (tests[j].vp.X + tests[j].vp.Width > rt_sizes[i].x
                     || tests[j].vp.Y + tests[j].vp.Height > rt_sizes[i].y)
             {
                 ok(hr == D3DERR_INVALIDCALL,
-                        "Setting the viewport returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                        "Setting the viewport returned unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
                 continue;
             }
             else
             {
-                ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+                ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
             }
 
             hr = IDirect3DDevice8_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
-            ok(SUCCEEDED(hr), "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice8_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx (i %u, j %u).\n", hr, i, j);
 
             get_rt_readback(rt, &rb);
             check_rect(&rb, tests[j].expected_rect, tests[j].message);
@@ -10532,10 +10501,10 @@ static void test_viewport(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -10544,10 +10513,9 @@ done:
 static void test_color_vertex(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int colour, i;
     D3DMATERIAL8 material;
     IDirect3D8 *d3d;
-    D3DCOLOR colour;
-    unsigned int i;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -10561,7 +10529,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[] =
     {
@@ -10610,36 +10579,36 @@ static void test_color_vertex(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | tests[i].fvf);
-        ok(SUCCEEDED(hr), "Failed to set vertex format, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set vertex format, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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),
@@ -10648,7 +10617,7 @@ static void test_color_vertex(void)
     }
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -10657,14 +10626,13 @@ static void test_sysmem_draw(void)
 {
     IDirect3DVertexBuffer8 *vb, *vb_s0, *vb_s1, *dst_vb, *get_vb;
     D3DPRESENT_PARAMETERS present_parameters = {0};
+    unsigned int colour, i, stride;
     IDirect3DTexture8 *texture;
     IDirect3DIndexBuffer8 *ib;
     IDirect3DDevice8 *device;
-    unsigned int i, stride;
     struct vec4 *dst_data;
     D3DLOCKED_RECT lr;
     IDirect3D8 *d3d;
-    D3DCOLOR colour;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -10742,48 +10710,48 @@ static void test_sysmem_draw(void)
     }
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_CreateVertexBuffer(device, sizeof(quad), 0, 0, D3DPOOL_SYSTEMMEM, &vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer8_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 = IDirect3DVertexBuffer8_Unlock(vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_SetStreamSource(device, 0, vb, sizeof(*quad));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateVertexBuffer(device, ARRAY_SIZE(quad) * sizeof(*dst_data),
             0, D3DFVF_XYZRHW, D3DPOOL_SYSTEMMEM, &dst_vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_SetStreamSource(device, 0, vb, sizeof(*quad));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_ProcessVertices(device, 0, 0, ARRAY_SIZE(quad), dst_vb, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer8_Lock(dst_vb, 0, 0, (BYTE **)&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,
@@ -10792,168 +10760,168 @@ static void test_sysmem_draw(void)
                 i, dst_data[i].x, dst_data[i].y, dst_data[i].z, dst_data[i].w);
     }
     hr = IDirect3DVertexBuffer8_Unlock(dst_vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_SetStreamSource(device, 0, vb, sizeof(*quad));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateIndexBuffer(device, sizeof(indices), 0,
             D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DIndexBuffer8_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 = IDirect3DIndexBuffer8_Unlock(ib);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetIndices(device, ib, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateVertexShader(device, decl, NULL, &vs, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(device, vs);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device, sizeof(quad_s0), 0, 0, D3DPOOL_SYSTEMMEM, &vb_s0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer8_Lock(vb_s0, 0, sizeof(quad_s0), &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 = IDirect3DVertexBuffer8_Unlock(vb_s0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateVertexBuffer(device, sizeof(quad_s1), 0, 0, D3DPOOL_SYSTEMMEM, &vb_s1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer8_Lock(vb_s1, 0, sizeof(quad_s1), &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 = IDirect3DVertexBuffer8_Unlock(vb_s1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetStreamSource(device, 0, vb_s0, sizeof(*quad_s0));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetStreamSource(device, 1, vb_s1, sizeof(*quad_s1));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetIndices(device, ib, 4);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_SetStreamSource(device, 0, vb, sizeof(*quad));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetIndices(device, ib, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirect3DVertexBuffer8_Release(vb_s1);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
     hr = IDirect3DDevice8_GetStreamSource(device, 1, &get_vb, &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 = IDirect3DVertexBuffer8_Release(get_vb);
-    ok(!refcount, "Unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Unexpected refcount %lu.\n", refcount);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, vs);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetStreamSource(device, 0, vb_s0, sizeof(*quad_s0));
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &texture);
-    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 = IDirect3DTexture8_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 = IDirect3DTexture8_UnlockRect(texture, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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);
 
     IDirect3DTexture8_Release(texture);
     IDirect3DVertexBuffer8_Release(vb_s0);
@@ -10962,7 +10930,7 @@ static void test_sysmem_draw(void)
     IDirect3DVertexBuffer8_Release(dst_vb);
     IDirect3DVertexBuffer8_Release(vb);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -10972,9 +10940,8 @@ static void test_alphatest(void)
 #define ALPHATEST_PASSED 0x0000ff00
 #define ALPHATEST_FAILED 0x00ff0000
     IDirect3DDevice8 *device;
-    unsigned int i, j;
+    unsigned int color, i, j;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     D3DCAPS8 caps;
     DWORD value;
@@ -10985,9 +10952,7 @@ static void test_alphatest(void)
     static const struct
     {
         D3DCMPFUNC func;
-        D3DCOLOR color_less;
-        D3DCOLOR color_equal;
-        D3DCOLOR color_greater;
+        unsigned int color_less, color_equal, color_greater;
     }
     test_data[] =
     {
@@ -11026,14 +10991,14 @@ static void test_alphatest(void)
     }
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 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 = IDirect3DDevice8_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);
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHATESTENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState, hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader failed, hr %#lx.\n", hr);
 
     ps = 0;
     for (j = 0; j < 2; ++j)
@@ -11053,64 +11018,64 @@ static void test_alphatest(void)
             };
             memset(&caps, 0, sizeof(caps));
             hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
-            ok(hr == D3D_OK, "IDirect3DDevice8_GetDeviceCaps failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_GetDeviceCaps failed, hr %#lx.\n", hr);
             if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
                 break;
 
             hr = IDirect3DDevice8_CreatePixelShader(device, shader_code, &ps);
-            ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_SetPixelShader(device, ps);
-            ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader failed, hr %#lx.\n", hr);
         }
 
         for (i = 0; i < ARRAY_SIZE(test_data); ++i)
         {
             hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHAFUNC, test_data[i].func);
-            ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHAREF, 0x70);
-            ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_BeginScene(device);
-            ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-            ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_EndScene(device);
-            ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed, hr %#lx.\n", hr);
             color = getPixelColor(device, 320, 240);
             ok(color_match(color, test_data[i].color_greater, 0),
                     "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
                     color, test_data[i].color_greater, test_data[i].func);
             hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-            ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0);
-            ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHAREF, 0xff70);
-            ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_GetRenderState(device, D3DRS_ALPHAREF, &value);
-            ok(hr == D3D_OK, "IDirect3DDevice8_GetRenderState failed, hr %#x.\n", hr);
-            ok(value == 0xff70, "Unexpected D3DRS_ALPHAREF value %#x.\n", value);
+            ok(hr == D3D_OK, "IDirect3DDevice8_GetRenderState failed, hr %#lx.\n", hr);
+            ok(value == 0xff70, "Unexpected D3DRS_ALPHAREF value %#lx.\n", value);
             hr = IDirect3DDevice8_BeginScene(device);
-            ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
-            ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr %#lx.\n", hr);
             hr = IDirect3DDevice8_EndScene(device);
-            ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed, hr %#lx.\n", hr);
             color = getPixelColor(device, 320, 240);
             ok(color_match(color, test_data[i].color_greater, 0),
                     "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
                     color, test_data[i].color_greater, test_data[i].func);
             hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
-            ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr %#x.\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr %#lx.\n", hr);
         }
     }
     if (ps)
         IDirect3DDevice8_DeletePixelShader(device, ps);
 
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 done:
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
@@ -11119,8 +11084,8 @@ done:
 static void test_desktop_window(void)
 {
     IDirect3DDevice8 *device;
+    unsigned int color;
     IDirect3D8 *d3d;
-    D3DCOLOR color;
     ULONG refcount;
     HWND window;
     HRESULT hr;
@@ -11142,15 +11107,15 @@ static void test_desktop_window(void)
     ok(!!device, "Failed to create a D3D device.\n");
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
 
     IDirect3D8_Release(d3d);
 }
@@ -11160,9 +11125,9 @@ static void test_sample_mask(void)
     IDirect3DSurface8 *rt, *ms_rt;
     struct surface_readback rb;
     IDirect3DDevice8 *device;
+    unsigned int colour;
     IDirect3D8 *d3d;
     ULONG refcount;
-    DWORD colour;
     HWND window;
     HRESULT hr;
 
@@ -11201,31 +11166,31 @@ static void test_sample_mask(void)
     }
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, FALSE, &ms_rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_SetRenderTarget(device, ms_rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DDevice8_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 = IDirect3DDevice8_CopyRects(device, ms_rt, NULL, 0, rt, NULL);
-    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.
@@ -11240,12 +11205,12 @@ static void test_sample_mask(void)
     release_surface_readback(&rb);
 
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DSurface8_Release(ms_rt);
     IDirect3DSurface8_Release(rt);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -11297,62 +11262,62 @@ static void test_dynamic_map_synchronization(void)
 
     hr = IDirect3DDevice8_CreateVertexBuffer(device, 200 * 4 * sizeof(struct dynamic_vb_vertex),
             D3DUSAGE_DYNAMIC, D3DFVF_XYZ, D3DPOOL_DEFAULT, &buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice8_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 = IDirect3DDevice8_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_SetStreamSource(device, 0, buffer, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_SetVertexShader(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 = IDirect3DVertexBuffer8_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((struct dynamic_vb_vertex *)data, 0, y);
 
         hr = IDirect3DVertexBuffer8_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 = IDirect3DDevice8_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 = IDirect3DVertexBuffer8_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((struct dynamic_vb_vertex *)data, x, y);
 
             hr = IDirect3DVertexBuffer8_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 = IDirect3DDevice8_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 = IDirect3DDevice8_GetRenderTarget(device, &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);
     IDirect3DSurface8_Release(rt);
 
     hr = IDirect3DDevice8_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer8_Release(buffer);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -11364,11 +11329,10 @@ 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;
     IDirect3DSurface8 *rt, *backbuffer, *cur;
     struct surface_readback rb;
     IDirect3DDevice8 *device;
-    unsigned int i, j, x, y;
-    DWORD colour, expected;
     DWORD shader = 0;
     IDirect3D8 *d3d;
     ULONG refcount;
@@ -11732,24 +11696,24 @@ static void test_filling_convention(void)
 
     hr = IDirect3DDevice8_CreateRenderTarget(device, vp_size, vp_size,
             D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice8_GetBackBuffer(device, 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 = IDirect3DDevice8_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 = IDirect3DDevice8_CreateVertexShader(device, decl, vs_code, &shader, 0);
-        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 = IDirect3DDevice8_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 = IDirect3DDevice8_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);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -11765,21 +11729,21 @@ static void test_filling_convention(void)
             cur = (j & 1) ? rt : backbuffer;
 
             hr = IDirect3DDevice8_SetVertexShader(device, (j & 2) ? tests[i].fvf : shader);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice8_SetRenderTarget(device, cur, NULL);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice8_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 = IDirect3DDevice8_SetViewport(device, &vp);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice8_BeginScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice8_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 = IDirect3DDevice8_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++)
@@ -11827,7 +11791,7 @@ static void test_filling_convention(void)
             /* IDirect3DDevice8::CopyRects can't stretch, so don't bother making the offscreen surface
              * visible. Use the d3d9 test if you need to see visual output. */
             hr = IDirect3DDevice8_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);
         }
     }
 
@@ -11836,7 +11800,7 @@ static void test_filling_convention(void)
     IDirect3DSurface8_Release(backbuffer);
     IDirect3DSurface8_Release(rt);
     refcount = IDirect3DDevice8_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D8_Release(d3d);
     DestroyWindow(window);
 }
@@ -11855,7 +11819,7 @@ START_TEST(visual)
 
     memset(&identifier, 0, sizeof(identifier));
     hr = IDirect3D8_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);
     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 */
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 89d6df8382b..19c4eec7921 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -2612,6 +2612,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;
@@ -2622,10 +2623,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;
-- 
GitLab

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



More information about the wine-devel mailing list