Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 40327 - DIsplay error in xmame compiled for PPC
Summary: DIsplay error in xmame compiled for PPC
Status: VERIFIED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: PPC Porters
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-03 16:41 UTC by Maciej J. Woloszyk
Modified: 2006-02-04 06:04 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej J. Woloszyk 2004-02-03 16:41:47 UTC
I've found quite annoying bug in PPC version of xmame. The fullscreen xv code seems not to be endian-aware and because of that when emulator is switched to xv YUV fullscreen mode everything turns green+pink.

As I really needed to run it in fullscreen I did some investigation and here is the solution (probably qick and dirty, but working). There are two files that need patching. First is src/unix/video-drivers/x11_window.c where there is a YUV lookup table generation code which is not endian-aware. The second is blit.h where there is a code to convert bitmap using the lookup table into YUV packed format. And again - this code isn't endian-aware. Below is the patch I worked out and applied on the xmame-0.78.1 package. After this the emulator compiles fine on PPC and works as it sholud.

---------- 0.78.1-yuvppc-fix.patch --------------------------------
--- src/unix/video-drivers/x11_window.c 2003-12-27 00:29:16.000000000 +0100
+++ src/unix/video-drivers/x11_window.c 2004-02-03 23:04:22.000000000 +0100
@@ -1463,7 +1463,11 @@

         /* Storing this data in YUYV order simplifies using the data for
            YUY2, both with and without smoothing... */
+#ifdef LSB_FIRST
         hwscale_yuvlookup[i]=(y<<0) | (u<<8) | (y<<16) | (v<<24);
+#else
+        hwscale_yuvlookup[i]=(y<<24) | (u<<16) | (y<<8) | (v<<0);
+#endif
       }
    }
 }
--- src/unix/video-drivers/blit.h       2003-12-27 00:29:16.000000000 +0100
+++ src/unix/video-drivers/blit.h       2004-02-04 01:17:56.000000000 +0100
@@ -72,6 +72,7 @@
    }\
       }
 #elif defined BLIT_HWSCALE_YUY2
+#ifdef LSB_FIRST /* x86 etc */
 #define COPY_LINE2(SRC, END, DST) \
    {\
       SRC_PIXEL  *src = SRC; \
@@ -89,6 +90,25 @@
          *dst++=y|y2|((uv1+uv2)&0xff00ff00);\
       } \
    }
+#else /* ppc etc */
+#define COPY_LINE2(SRC, END, DST) \
+   {\
+      SRC_PIXEL  *src = SRC; \
+      SRC_PIXEL  *end = END; \
+      unsigned long *dst = (unsigned long *)DST; \
+      unsigned int r,y,y2,uv1,uv2; \
+      for(;src<end;) \
+      { \
+         r=INDIRECT[*src++]; \
+         y=r&0xff000000 ; \
+         uv1=(r&0x00ff00ff); \
+         r=INDIRECT[*src++]; \
+         uv2=(uv1+(r&0x00ff00ff))>>1; \
+         y2=r&0xff00; \
+         *dst++=y|y2|(uv2&0x00ff00ff); \
+      } \
+   }
+#endif
 #else /* normal indirect */
 #define COPY_LINE2(SRC, END, DST) \
       {\
@@ -428,24 +448,43 @@
       *(dst+2) = (INDIRECT[*(src+2)]>>16) | (INDIRECT[*(src+3)]<< 8); \
    }
 #elif defined BLIT_HWSCALE_YUY2
+#ifdef LSB_FIRST /* x86 etc */
 #define COPY_LINE2(SRC, END, DST) \
    {\
       SRC_PIXEL  *src = SRC; \
       SRC_PIXEL  *end = END; \
       unsigned long *dst = (unsigned long *)DST; \
-      unsigned int r,r2,y,y2,uv1,uv2; \
+      unsigned int r,y,y2,uv1,uv2; \
       for(;src<end;) \
       { \
          r=INDIRECT[*src++]; \
-         r2=INDIRECT[*src++]; \
-         y=r&0xff; \
-         y2=r2&0xff0000; \
+         y=r&255; \
          uv1=(r&0xff00ff00)>>1; \
-         uv2=(r2&0xff00ff00)>>1; \
-         uv1=(uv1+uv2)&0xff00ff00; \
-         *dst++=y|y2|uv1; \
+         r=INDIRECT[*src++]; \
+         uv2=(r&0xff00ff00)>>1; \
+         y2=r&0xff0000; \
+         *dst++=y|y2|((uv1+uv2)&0xff00ff00);\
+      } \
+   }
+#else /* ppc etc */
+#define COPY_LINE2(SRC, END, DST) \
+   {\
+      SRC_PIXEL  *src = SRC; \
+      SRC_PIXEL  *end = END; \
+      unsigned long *dst = (unsigned long *)DST; \
+      unsigned int r,y,y2,uv1,uv2; \
+      for(;src<end;) \
+      { \
+         r=INDIRECT[*src++]; \
+         y=r&0xff000000 ; \
+         uv1=(r&0x00ff00ff); \
+         r=INDIRECT[*src++]; \
+         uv2=(uv1+(r&0x00ff00ff))>>1; \
+         y2=r&0xff00; \
+         *dst++=y|y2|(uv2&0x00ff00ff); \
       } \
    }
+#endif
 #else /* normal indirect */
 #define COPY_LINE2(SRC, END, DST) \
    SRC_PIXEL  *src = SRC; \
-----------------------------------------------------------------------
Comment 1 David Holm (RETIRED) gentoo-dev 2004-02-15 03:50:35 UTC
I have added the patch to the ebuild for all big-endian archs. Please test this on sparc, mips and alpha.

Great work, I always assumed this was a bug in the ati driver. ;)
BTW, have you submitted the patch to the xmame developers? I assume 0.79 will be released shortly.
Comment 2 Maciej J. Woloszyk 2004-02-15 06:59:13 UTC
Yes. I did sent the patch to the xmame list. It already is in 0.79 beta
source tree so in the next release it should be in public sources.
Comment 3 Lars Weiler (RETIRED) gentoo-dev 2004-04-03 15:23:20 UTC
As there is already xmame-0.80.1 out and all arches made it stable, I close this bug.
Comment 4 Lars Weiler (RETIRED) gentoo-dev 2004-04-03 16:06:48 UTC
Somehow I forgot to close.