From: Michael Gernoth Date: Sat, 26 Jan 2008 10:38:33 +0000 (+0100) Subject: fix power grid overlay on big endian X servers X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/micropolis/commitdiff_plain/2d56c40cb9008f8a235bf1dfec4bc2ca98ee7406 fix power grid overlay on big endian X servers --- diff --git a/src/sim/g_smmaps.c b/src/sim/g_smmaps.c index 84b7a47..8b5f345 100644 --- a/src/sim/g_smmaps.c +++ b/src/sim/g_smmaps.c @@ -295,14 +295,26 @@ void drawPower(SimView *view) case 16: { unsigned short *p; - p = (short *)image; - p[0] = p[1] = p[2] = pix; + p = (unsigned short *)image; + if (view->x->x_big_endian) { + p[0] = p[1] = p[2] = ((pix & 0xff) << 8) | ((pix & 0xff00) >> 8); + } else { + p[0] = p[1] = p[2] = pix; + } image += lineBytes; - p = (short *)image; - p[0] = p[1] = p[2] = pix; + p = (unsigned short *)image; + if (view->x->x_big_endian) { + p[0] = p[1] = p[2] = ((pix & 0xff) << 8) | ((pix & 0xff00) >> 8); + } else { + p[0] = p[1] = p[2] = pix; + } image += lineBytes; - p = (short *)image; - p[0] = p[1] = p[2] = pix; + p = (unsigned short *)image; + if (view->x->x_big_endian) { + p[0] = p[1] = p[2] = ((pix & 0xff) << 8) | ((pix & 0xff00) >> 8); + } else { + p[0] = p[1] = p[2] = pix; + } image += lineBytes; } break; @@ -315,12 +327,21 @@ void drawPower(SimView *view) unsigned char *img = image; for (x = 0; x < 4; x++) { - *(img++) = (pix >> 0) & 0xff; - *(img++) = (pix >> 8) & 0xff; - *(img++) = (pix >> 16) & 0xff; - if (pixelBytes == 4) { - img++; - } // if + if (view->x->x_big_endian) { + if (pixelBytes == 4) { + img++; + } // if + *(img++) = (pix >> 16) & 0xff; + *(img++) = (pix >> 8) & 0xff; + *(img++) = (pix >> 0) & 0xff; + } else { + *(img++) = (pix >> 0) & 0xff; + *(img++) = (pix >> 8) & 0xff; + *(img++) = (pix >> 16) & 0xff; + if (pixelBytes == 4) { + img++; + } // if + } } // for x image += lineBytes; } // for y