I had graphical problems with an online game called Angels Online, when
just a black screen was visible, and complaints about missing converter
from  WINED3DFMT_R5G6B5 to WINED3DFMT_X8R8G8B8, so I added a converter
for this format, and the game runs flawlessly now on wine, the 1.1.1
release as well as git version (at least for me). I hope this was the
right way to fix it.

Kind regards,

Einars Lielmanis
diff --git a/dlls/wined3d/surface_base.c b/dlls/wined3d/surface_base.c
index 57809e1..cb981fa 100644
--- a/dlls/wined3d/surface_base.c
+++ b/dlls/wined3d/surface_base.c
@@ -636,6 +636,27 @@ void convert_r32f_r16f(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, un
     }
 }
 
+void convert_565_0888(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h) {
+    unsigned int x, y;
+    WORD *src_w;
+    DWORD *dst_dw;
+
+    TRACE("Converting %dx%d pixels, pitches %d %d\n", w, h, pitch_in, pitch_out);
+    for(y = 0; y < h; y++) {
+        src_w = (WORD *) (src + y * pitch_in);
+        dst_dw = (DWORD *) (dst + y * pitch_out);
+        for(x = 0; x < w; x++) {
+            unsigned short srcval = *(src_w + x);
+            dst_dw[x] =((srcval << 8) & 0xf80000) | /* h */
+                        ((srcval << 3) & 0x070000) | /* h - 3 bits */
+                        ((srcval << 5) & 0x00fc00) | /* g */
+                        ((srcval >> 1) & 0x000300) | /* g - 2 bits */
+                        ((srcval << 3) & 0x0000f8) | /* l */
+                        ((srcval >> 2) & 0x000007);  /* l - 3 bits */
+        }
+    }
+}
+
 struct d3dfmt_convertor_desc {
     WINED3DFORMAT from, to;
     void (*convert)(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
@@ -643,6 +664,7 @@ struct d3dfmt_convertor_desc {
 
 struct d3dfmt_convertor_desc convertors[] = {
     {WINED3DFMT_R32F,       WINED3DFMT_R16F,        convert_r32f_r16f},
+    {WINED3DFMT_R5G6B5,     WINED3DFMT_X8R8G8B8,    convert_565_0888},
 };
 
 static inline struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, WINED3DFORMAT to) {


Reply via email to