From 276e43bad96799ae902957a247aae6c7d44ff975 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Tue, 15 Jan 2008 22:10:35 +0100 Subject: [PATCH] more big endian fixes (overlays on minimaps) --- src/sim/g_map.c | 93 ++++++++++++++++++------------------------ src/sim/headers/view.h | 1 + src/sim/w_x.c | 1 + 3 files changed, 41 insertions(+), 54 deletions(-) diff --git a/src/sim/g_map.c b/src/sim/g_map.c index 87c7e27..667cfae 100644 --- a/src/sim/g_map.c +++ b/src/sim/g_map.c @@ -406,25 +406,15 @@ drawRect(SimView *view, int pixel, int solid, unsigned char *image = &data[(line * y) + (x * pixelBytes)]; - if (solid) { - for (i = h; i > 0; i--) { - for (j = w; j > 0; j--) { + for (i = h; i > 0; i--) { + for (j = w; j > 0; j--) { + if (solid || stipple++ & 1) *image = pixel; - image++; - } - image += line - w; - } - } else { - for (i = h; i > 0; i--) { - for (j = w; j > 0; j--) { - if (stipple++ & 1) - *image = pixel; - image++; - } - if (!(w & 1)) - stipple++; - image += line - w; + image++; } + if (!(w & 1)) + stipple++; + image += line - w; } } break; @@ -438,26 +428,22 @@ drawRect(SimView *view, int pixel, int solid, image = &data[(line * y) + x]; - if (solid) { - for (i = h; i > 0; i--) { - for (j = w; j > 0; j--) { - *image = pixel; - image++; - } - image += line - w; - } - } else { - for (i = h; i > 0; i--) { - for (j = w; j > 0; j--) { - if (stipple++ & 1) - *image = pixel; - image++; + for (i = h; i > 0; i--) { + for (j = w; j > 0; j--) { + if (solid || stipple++ & 1) { + if (view->x->x_big_endian) { + *image = ((pixel & 0xff) << 8) | ((pixel & 0xff00) >> 8); + } else { + *image = pixel; + } } - if (!(w & 1)) - stipple++; - image += line - w; + image++; } + if (!(w & 1)) + stipple++; + image += line - w; } + } break; @@ -470,37 +456,36 @@ drawRect(SimView *view, int pixel, int solid, image = &data[(line * y) + x * pixelBytes]; - if (solid) { - for (i = h; i > 0; i--) { - for (j = w; j > 0; j--) { - *(image++) = (pixel >> 0) & 0xff; - *(image++) = (pixel >> 8) & 0xff; - *(image++) = (pixel >> 16) & 0xff; + for (i = h; i > 0; i--) { + for (j = w; j > 0; j--) { + if (view->x->x_big_endian) { if (pixelBytes == 4) { image++; } - } - image += line - w * pixelBytes; - } - } else { - for (i = h; i > 0; i--) { - for (j = w; j > 0; j--) { + if (solid || stipple++ & 1) { + *(image++) = (pixel >> 16) & 0xff; + *(image++) = (pixel >> 8) & 0xff; + *(image++) = (pixel >> 0) & 0xff; + } else { + image += 3; + } + } else { if (stipple++ & 1) { - *(image++) = (pixel >> 0) & 0xff; - *(image++) = (pixel >> 8) & 0xff; - *(image++) = (pixel >> 16) & 0xff; + *(image++) = (pixel >> 0) & 0xff; + *(image++) = (pixel >> 8) & 0xff; + *(image++) = (pixel >> 16) & 0xff; } else { image += 3; } if (pixelBytes == 4) { - image++; + image++; } } - if (!(w & 1)) { - stipple++; - } - image += line - w * pixelBytes; } + if (!(w & 1)) { + stipple++; + } + image += line - w * pixelBytes; } } break; diff --git a/src/sim/headers/view.h b/src/sim/headers/view.h index 8f87fe0..744e0b3 100644 --- a/src/sim/headers/view.h +++ b/src/sim/headers/view.h @@ -114,6 +114,7 @@ typedef struct XDisplay { Pixmap horiz_stipple; Pixmap diag_stipple; int needs_swap; + int x_big_endian; } XDisplay; diff --git a/src/sim/w_x.c b/src/sim/w_x.c index 3d8dd48..e32aeed 100644 --- a/src/sim/w_x.c +++ b/src/sim/w_x.c @@ -601,6 +601,7 @@ InitNewView(SimView *view, char *title, int class, int w, int h) } view->x->needs_swap = !(*(unsigned char*) (&test)); + view->x->x_big_endian = (ImageByteOrder(view->x->dpy) == MSBFirst); GetPixmaps(view->x); -- 2.39.5