[AD] small bug in 15 and 16 bit asm color converters

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


The attached patch fixes a small bug in the 15 and 16 bit mmx color
converters. The problem was, the rgb values only were shifted from 15/16
bit to their 24bit positions. So all colors were kind of dark (e.g.
255/0/0 would become 248/0/0, or 255/255/255 would be 248/251/241 - ugh,
greenish gray instead of white) - but still, it was hard to notice.

For some unexplainable reason, the mouse background-update code wasn't
affected by this - so the mouse would leave trails with the right
color :) This probably suggest some bug with the mouse drawing - I'm a
bit puzzled where exactly it is though. Somehow, it manages to escape
the asm color converison.

-- 
Elias Pschernig
Index: src/misc/icolconv.s
===================================================================
RCS file: /cvsroot/alleg/allegro/src/misc/icolconv.s,v
retrieving revision 1.27
diff -u -r1.27 icolconv.s
--- src/misc/icolconv.s	27 Jul 2004 08:07:45 -0000	1.27
+++ src/misc/icolconv.s	23 Oct 2004 12:09:15 -0000
@@ -79,9 +79,12 @@
       movl %ecx, %ebp
 
 
-#define INIT_CONVERSION_2(mask_red, mask_green, mask_blue)                           \
+#define INIT_CONVERSION_2(mask_red, mask_green, mask_blue, diff_24bit)               \
       /* init register values */                                                   ; \
                                                                                    ; \
+      movl diff_24bit, %esi                                                        ; \
+      movd %esi, %mm6                                                              ; \
+      punpckldq %mm6, %mm6                                                         ; \
       movl mask_green, %esi                                                        ; \
       movd %esi, %mm3                                                              ; \
       punpckldq %mm3, %mm3                                                         ; \
@@ -566,7 +569,7 @@
    pushl %esi
    pushl %edi
 
-   INIT_CONVERSION_2 ($0x7c00, $0x03e0, $0x001f);
+   INIT_CONVERSION_2 ($0x7c00, $0x03e0, $0x001f, $0x00777777);
 
    /* 15 bit to 32 bit conversion:
     we have:    
@@ -602,6 +605,7 @@
          PAND (4, 2)        /* pand %mm4, %mm2 */
          pslld $9, %mm2
          por %mm2, %mm0
+         por %mm6, %mm0
          movq %mm0, (%edi)
          addl $8, %edi
 
@@ -627,6 +631,7 @@
          PAND (4, 2)        /* pand %mm4, %mm2 */
          pslld $9, %mm2
          por %mm2, %mm0
+         por %mm6, %mm0
          movd %mm0, (%edi)
          addl $4, %edi
 
@@ -814,7 +819,7 @@
    pushl %esi
    pushl %edi
 
-   INIT_CONVERSION_2 ($0xf800, $0x07e0, $0x001f);
+   INIT_CONVERSION_2 ($0xf800, $0x07e0, $0x001f, $0x00773377);
 
    /* 16 bit to 32 bit conversion:
     we have:
@@ -850,6 +855,7 @@
          PAND (4, 2)        /* pand %mm4, %mm2 */
          pslld $8, %mm2
          por %mm2, %mm0
+         por %mm6, %mm0
          movq %mm0, (%edi)
          addl $8, %edi
 
@@ -875,6 +881,7 @@
          PAND (4, 2)        /* pand %mm4, %mm2 */
          pslld $8, %mm2
          por %mm2, %mm0
+         por %mm6, %mm0
          movd %mm0, (%edi)
          addl $4, %edi
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/