X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/micropolis/blobdiff_plain/6a5fa4e03967ab980cdc7ef96a42400bc29b4414..6f214ac0ef5899987197c2e4c9baa0b51a04c197:/src/sim/g_smmaps.c diff --git a/src/sim/g_smmaps.c b/src/sim/g_smmaps.c index ed8c075..e66ad40 100644 --- a/src/sim/g_smmaps.c +++ b/src/sim/g_smmaps.c @@ -84,63 +84,67 @@ int DynamicData[32]; if (tile >= TILE_COUNT) tile -= TILE_COUNT; -#if defined(MSDOS) || defined(OSF1) || defined(IS_INTEL) - -#define ROW1_8(n) \ +#define LE_ROW1_8(n) \ l = mem[n]; \ image[0] = l; \ image[1] = l >>8; \ image[2] = l >>16; \ image += lineBytes; -#define ROW1_16(n) \ +#define LE_ROW1_16(n) \ memcpy((char *)image, ((char *)mem) + (n * 4 * 2), (3 * 2)); \ image += lineBytes; -#define ROW1_24(n) \ +#define LE_ROW1_24(n) \ memcpy((char *)image, ((char *)mem) + (n * 4 * 3), (3 * 3)); \ image += lineBytes; -#define ROW1_32(n) \ +#define LE_ROW1_32(n) \ memcpy((char *)image, ((char *)mem) + (n * 4 * 4), (3 * 4)); \ image += lineBytes; -#else - -#define ROW1_8(n) \ +#define BE_ROW1_8(n) \ l = mem[n]; \ image[0] = l >>24; \ image[1] = l >>16; \ image[2] = l >>8; \ image += lineBytes; -#define ROW1_16(n) \ +#define BE_ROW1_16(n) \ l = mem[n]; /* XXX: WRONG. handle depth */ \ image[0] = l >>24; \ image[1] = l >>16; \ image[2] = l >>8; \ image += lineBytes; -#define ROW1_24(n) \ +#define BE_ROW1_24(n) \ l = mem[n]; /* XXX: WRONG. handle depth */ \ image[0] = l >>24; \ image[1] = l >>16; \ image[2] = l >>8; \ image += lineBytes; -#define ROW1_32(n) \ +#define BE_ROW1_32(n) \ l = mem[n]; /* XXX: WRONG. handle depth */ \ image[0] = l >>24; \ image[1] = l >>16; \ image[2] = l >>8; \ image += lineBytes; -#endif +#define LE_ROW3_8 LE_ROW1_8(0) LE_ROW1_8(1) LE_ROW1_8(2) +#define LE_ROW3_16 LE_ROW1_16(0) LE_ROW1_16(1) LE_ROW1_16(2) +#define LE_ROW3_24 LE_ROW1_24(0) LE_ROW1_24(1) LE_ROW1_24(2) +#define LE_ROW3_32 LE_ROW1_32(0) LE_ROW1_32(1) LE_ROW1_32(2) -#define ROW3_8 ROW1_8(0) ROW1_8(1) ROW1_8(2) -#define ROW3_16 ROW1_16(0) ROW1_16(1) ROW1_16(2) -#define ROW3_24 ROW1_24(0) ROW1_24(1) ROW1_24(2) -#define ROW3_32 ROW1_32(0) ROW1_32(1) ROW1_32(2) +#define BE_ROW3_8 BE_ROW1_8(0) BE_ROW1_8(1) BE_ROW1_8(2) +#define BE_ROW3_16 BE_ROW1_16(0) BE_ROW1_16(1) BE_ROW1_16(2) +#define BE_ROW3_24 BE_ROW1_24(0) BE_ROW1_24(1) BE_ROW1_24(2) +#define BE_ROW3_32 BE_ROW1_32(0) BE_ROW1_32(1) BE_ROW1_32(2) + +#define ROW3_8 if (view->x->needs_swap) { BE_ROW3_8 } else { LE_ROW3_8 } +#define ROW3_16 LE_ROW3_16 +#define ROW3_24 LE_ROW3_24 +#define ROW3_32 LE_ROW3_32 #define ROW3 \ switch (view->x->depth) { \ @@ -153,8 +157,6 @@ int DynamicData[32]; ROW3_16 \ break; \ case 24: \ - ROW3_24 \ - break; \ case 32: \ ROW3_32 \ break; \ @@ -293,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; @@ -313,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 @@ -344,29 +367,29 @@ int dynamicFilter(int col, int row) c = col >>1; if (((DynamicData[0] > DynamicData[1]) || - ((x = PopDensity[c][r]) >= DynamicData[0]) && - (x <= DynamicData[1])) && + (((x = PopDensity[c][r]) >= DynamicData[0]) && + (x <= DynamicData[1]))) && ((DynamicData[2] > DynamicData[3]) || - ((x = RateOGMem[c>>2][r>>2]) >= ((2 * DynamicData[2]) - 256)) && - (x <= ((2 * DynamicData[3]) - 256))) && + (((x = RateOGMem[c>>2][r>>2]) >= ((2 * DynamicData[2]) - 256)) && + (x <= ((2 * DynamicData[3]) - 256)))) && ((DynamicData[4] > DynamicData[5]) || - ((x = TrfDensity[c][r]) >= DynamicData[4]) && - (x <= DynamicData[5])) && + (((x = TrfDensity[c][r]) >= DynamicData[4]) && + (x <= DynamicData[5]))) && ((DynamicData[6] > DynamicData[7]) || - ((x = PollutionMem[c][r]) >= DynamicData[6]) && - (x <= DynamicData[7])) && + (((x = PollutionMem[c][r]) >= DynamicData[6]) && + (x <= DynamicData[7]))) && ((DynamicData[8] > DynamicData[9]) || - ((x = CrimeMem[c][r]) >= DynamicData[8]) && - (x <= DynamicData[9])) && + (((x = CrimeMem[c][r]) >= DynamicData[8]) && + (x <= DynamicData[9]))) && ((DynamicData[10] > DynamicData[11]) || - ((x = LandValueMem[c][r]) >= DynamicData[10]) && - (x <= DynamicData[11])) && + (((x = LandValueMem[c][r]) >= DynamicData[10]) && + (x <= DynamicData[11]))) && ((DynamicData[12] > DynamicData[13]) || - ((x = PoliceMapEffect[c>>2][r>>2]) >= DynamicData[12]) && - (x <= DynamicData[13])) && + (((x = PoliceMapEffect[c>>2][r>>2]) >= DynamicData[12]) && + (x <= DynamicData[13]))) && ((DynamicData[14] > DynamicData[15]) || - ((x = FireRate[c>>2][r>>2]) >= DynamicData[14]) && - (x <= DynamicData[15]))) { + (((x = FireRate[c>>2][r>>2]) >= DynamicData[14]) && + (x <= DynamicData[15])))) { return 1; } else { return 0;