From: Michael Gernoth <michael@gernoth.net>
Date: Tue, 15 Jan 2008 13:30:34 +0000 (+0100)
Subject: fix colors on BGR displays
X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/micropolis/commitdiff_plain/3fec6683f3fb3d8354310bb1010511d200752e6c?hp=76cc4ab602596795aa7cec1469e21a344b7fea0f

fix colors on BGR displays
---

diff --git a/src/sim/w_x.c b/src/sim/w_x.c
index 06d3b9e..3d8dd48 100644
--- a/src/sim/w_x.c
+++ b/src/sim/w_x.c
@@ -327,28 +327,43 @@ FindXDisplay(Tk_Window tkwin)
 	      color->pixel; \
 	    break; \
 	  case 15: \
+	    if (xd->visual->red_mask == 0x7c00) { \
 	    xd->pixels[i] = \
 	      (((color->red >> (8 + 3)) & 0x1f) << (5 + 5)) | \
 	      (((color->green >> (8 + 2)) & 0x1f) << (5)) | \
 	      (((color->blue >> (8 + 3)) & 0x1f) << (0)); \
+	    } else { \
+	      (((color->blue >> (8 + 3)) & 0x1f) << (5 + 5)) | \
+	      (((color->green >> (8 + 2)) & 0x1f) << (5)) | \
+	      (((color->red >> (8 + 3)) & 0x1f) << (0)); \
+	    } \
 	    break; \
 	  case 16: \
+	    if (xd->visual->red_mask == 0xf800) { \
 	    xd->pixels[i] = \
 	      (((color->red >> (8 + 3)) & 0x1f) << (6 + 5)) | \
 	      (((color->green >> (8 + 2)) & 0x3f) << (5)) | \
 	      (((color->blue >> (8 + 3)) & 0x1f) << (0)); \
+	    } else { \
+	    xd->pixels[i] = \
+	      (((color->blue >> (8 + 3)) & 0x1f) << (6 + 5)) | \
+	      (((color->green >> (8 + 2)) & 0x3f) << (5)) | \
+	      (((color->red >> (8 + 3)) & 0x1f) << (0)); \
+	    } \
 	    break; \
 	  case 24: \
+	  case 32: \
+	    if (xd->visual->red_mask == 0xff0000) { \
 	    xd->pixels[i] = \
 	      ((color->red & 0xff) << 16) | \
 	      ((color->green & 0xff) << 8) | \
 	      ((color->blue & 0xff) << 0); \
-	    break; \
-	  case 32: \
+	    } else { \
 	    xd->pixels[i] = \
-	      ((color->red & 0xff) << 16) | \
+	      ((color->blue & 0xff) << 16) | \
 	      ((color->green & 0xff) << 8) | \
-	      ((color->blue & 0xff) << 0); \
+	      ((color->red & 0xff) << 0); \
+	    } \
 	    break; \
 	  } \
 	} \