diff options
author | tron <tron@openttd.org> | 2005-06-30 05:27:32 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-06-30 05:27:32 +0000 |
commit | 6319c11b1f007dbaf37e492d05c2181f4ca9db2d (patch) | |
tree | 820d87a559381f3d0fa23a7bf0763578868b7150 | |
parent | f18346732297370a5ea0bcfbaf8f7b0cc0ad3b54 (diff) | |
download | openttd-6319c11b1f007dbaf37e492d05c2181f4ca9db2d.tar.xz |
(svn r2497) Use a struct array for palette entries instead of a flat byte array
-rw-r--r-- | gfx.c | 109 | ||||
-rw-r--r-- | gfx.h | 10 | ||||
-rw-r--r-- | screenshot.c | 31 | ||||
-rw-r--r-- | sdl.c | 11 | ||||
-rw-r--r-- | table/palettes.h | 317 | ||||
-rw-r--r-- | win32.c | 9 |
6 files changed, 244 insertions, 243 deletions
@@ -6,6 +6,8 @@ #include "table/palettes.h" #include "hal.h" +Colour _cur_palette[256]; + static void GfxMainBlitter(const Sprite *sprite, int x, int y, int mode); static int _stringwidth_out; @@ -1482,21 +1484,17 @@ static void GfxMainBlitter(const Sprite* sprite, int x, int y, int mode) #if 0 static void GfxScalePalette(int pal, byte scaling) { - byte *dst, *src; - size_t count; + const Colour* src; + uint i; GfxInitPalettes(); - dst = _cur_palette; src = GET_PALETTE(pal); - count = 256; - do { - dst[0] = (byte)(src[0] * scaling >> 8); - dst[1] = (byte)(src[1] * scaling >> 8); - dst[2] = (byte)(src[2] * scaling >> 8); - dst += 3; - src += 3; - } while (--count); + for (i = 0; i < lengthof(_cur_palette); i++) { + _cur_palette[i].r = src[i].r * scaling >> 8; + _cur_palette[i].g = src[i].g * scaling >> 8; + _cur_palette[i].b = src[i].b * scaling >> 8; + } } #endif @@ -1504,8 +1502,7 @@ void DoPaletteAnimations(void); void GfxInitPalettes(void) { - int pal = _use_dos_palette?1:0; - memcpy(_cur_palette, _palettes[pal], 256*3); + memcpy(_cur_palette, _palettes[_use_dos_palette ? 1 : 0], sizeof(_cur_palette)); _pal_first_dirty = 0; _pal_last_dirty = 255; @@ -1514,12 +1511,11 @@ void GfxInitPalettes(void) #define EXTR(p,q) (((uint16)(_timer_counter * (p)) * (q)) >> 16) #define EXTR2(p,q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16) -#define COPY_TRIPLET do {d[0]=s[0+j]; d[1]=s[1+j]; d[2]=s[2+j];d+=3;}while(0) void DoPaletteAnimations(void) { - const byte *s; - byte *d; + const Colour* s; + Colour* d; /* Amount of colors to be rotated. * A few more for the DOS palette, because the water colors are * 245-254 for DOS and 217-226 for Windows. */ @@ -1527,46 +1523,46 @@ void DoPaletteAnimations(void) int j; int i; const ExtraPaletteValues *ev = &_extra_palette_values; - byte old_val[114]; // max(c*(38:28)) = 114 + Colour old_val[38]; // max(38, 28) - d = _cur_palette + 217*3; - memcpy(old_val, d, c*3); + d = &_cur_palette[217]; + memcpy(old_val, d, c * sizeof(*old_val)); // Dark blue water s = ev->a; if (_opt.landscape == LT_CANDY) s = ev->ac; - j = EXTR(320,5) * 3; + j = EXTR(320,5); for(i=0; i!=5; i++) { - COPY_TRIPLET; - j+=3; - if (j == 15) j = 0; + *d++ = s[j]; + j++; + if (j == 5) j = 0; } // Glittery water s = ev->b; if (_opt.landscape == LT_CANDY) s = ev->bc; - j = EXTR(128, 15) * 3; + j = EXTR(128, 15); for(i=0; i!=5; i++) { - COPY_TRIPLET; - j += 9; - if (j >= 45) j -= 45; + *d++ = s[j]; + j += 3; + if (j >= 15) j -= 15; } s = ev->e; - j = EXTR2(512, 5) * 3; + j = EXTR2(512, 5); for(i=0; i!=5; i++) { - COPY_TRIPLET; - j += 3; - if (j == 3*5) j = 0; + *d++ = s[j]; + j++; + if (j == 5) j = 0; } // Oil refinery fire animation s = ev->oil_ref; - j = EXTR2(512, 7) * 3; + j = EXTR2(512, 7); for(i=0; i!=7; i++) { - COPY_TRIPLET; - j += 3; - if (j == 3*7) j = 0; + *d++ = s[j]; + j++; + if (j == 7) j = 0; } // Radio tower blinking @@ -1576,27 +1572,28 @@ void DoPaletteAnimations(void) (v = 255, i < 0x3f) || (v = 128, i < 0x4A || i >= 0x75) || (v = 20); - d[0] = v; - d[1] = d[2] = 0; - d += 3; + d->r = v; + d->g = 0; + d->b = 0; + d++; i ^= 0x40; (v = 255, i < 0x3f) || (v = 128, i < 0x4A || i >= 0x75) || (v = 20); - d[0] = v; - - d[1] = d[2] = 0; - d += 3; + d->r = v; + d->g = 0; + d->b = 0; + d++; } // Handle lighthouse and stadium animation s = ev->lighthouse; - j = EXTR(256, 4) * 3; + j = EXTR(256, 4); for(i=0; i!=4; i++) { - COPY_TRIPLET; - j += 3; - if (j == 3*4) j = 0; + *d++ = s[j]; + j++; + if (j == 4) j = 0; } // Animate water for old DOS graphics @@ -1604,27 +1601,27 @@ void DoPaletteAnimations(void) // Dark blue water DOS s = ev->a; if (_opt.landscape == LT_CANDY) s = ev->ac; - j = EXTR(320,5) * 3; + j = EXTR(320,5); for(i=0; i!=5; i++) { - COPY_TRIPLET; - j+=3; - if (j == 15) j = 0; + *d++ = s[j]; + j++; + if (j == 5) j = 0; } // Glittery water DOS s = ev->b; if (_opt.landscape == LT_CANDY) s = ev->bc; - j = EXTR(128, 15) * 3; + j = EXTR(128, 15); for(i=0; i!=5; i++) { - COPY_TRIPLET; - j += 9; - if (j >= 45) j -= 45; + *d++ = s[j]; + j += 3; + if (j >= 15) j -= 15; } } - if (memcmp(old_val, _cur_palette + 217*3, c*3)) { + if (memcmp(old_val, &_cur_palette[217], c * sizeof(*old_val)) != 0) { if (_pal_first_dirty > 217) _pal_first_dirty = 217; - if (_pal_last_dirty < 217+c) _pal_last_dirty = 217+c; + if (_pal_last_dirty < 217 + c) _pal_last_dirty = 217 + c; } } @@ -94,9 +94,13 @@ VARDEF bool _use_dos_palette; //enum { NUM_SPRITES = 0x1500 }; enum { NUM_SPRITES = 0x3500 }; // 1500 + space for custom GRF sets -/* tables.h */ -extern byte _palettes[4][256 * 3]; -VARDEF byte _cur_palette[768]; +typedef struct Colour { + byte r; + byte g; + byte b; +} Colour; + +extern Colour _cur_palette[256]; typedef enum StringColorFlags { diff --git a/screenshot.c b/screenshot.c index 098070f38..ba309bf57 100644 --- a/screenshot.c +++ b/screenshot.c @@ -11,7 +11,7 @@ // called by the ScreenShot proc to generate screenshot lines. typedef void ScreenshotCallback(void *userdata, byte *buf, uint y, uint pitch, uint n); -typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const byte *palette); +typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette); typedef struct { const char *name; @@ -52,7 +52,7 @@ typedef struct RgbQuad { assert_compile(sizeof(RgbQuad) == 4); // generic .BMP writer -static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const byte *palette) +static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) { BitmapFileHeader bfh; BitmapInfoHeader bih; @@ -93,9 +93,9 @@ static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *user // convert the palette to the windows format for (i = 0; i != 256; i++) { - rq[i].red = *palette++; - rq[i].green = *palette++; - rq[i].blue = *palette++; + rq[i].red = palette[i].r; + rq[i].green = palette[i].g; + rq[i].blue = palette[i].b; rq[i].reserved = 0; } @@ -156,7 +156,7 @@ static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message) DEBUG(misc, 0) ("WARNING(libpng): %s - %s\n", message, (char *)png_get_error_ptr(png_ptr)); } -static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const byte *palette) +static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) { png_color rq[256]; byte *buff; @@ -201,15 +201,10 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); // convert the palette to the .PNG format. - { - // avoids "might be clobbered" warning of argument "palette" - const byte *pal = palette; - - for (i = 0; i != 256; i++) { - rq[i].red = *pal++; - rq[i].green = *pal++; - rq[i].blue = *pal++; - } + for (i = 0; i != 256; i++) { + rq[i].red = palette[i].r; + rq[i].green = palette[i].g; + rq[i].blue = palette[i].b; } png_set_PLTE(png_ptr, info_ptr, rq, 256); @@ -275,7 +270,7 @@ typedef struct { } PcxHeader; assert_compile(sizeof(PcxHeader) == 128); -static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const byte *palette) +static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) { byte *buff; FILE *f; @@ -383,7 +378,9 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user fclose(f); return false; } - if (fwrite(palette, 256 * 3, 1, f) != 1) { + + {assert_compile(sizeof(*palette) == 3);} + if (fwrite(palette, 256 * sizeof(*palette), 1, f) != 1) { fclose(f); return false; } @@ -195,13 +195,12 @@ static SDL_Color pal[256]; static void UpdatePalette(uint start, uint end) { uint i; - byte *b; - for (i = start, b = _cur_palette + start * 3; i != end; i++, b += 3) { - pal[i].r = b[0]; - pal[i].g = b[1]; - pal[i].b = b[2]; - pal[i].unused = b[3]; + for (i = start; i != end; i++) { + pal[i].r = _cur_palette[i].r; + pal[i].g = _cur_palette[i].g; + pal[i].b = _cur_palette[i].b; + pal[i].unused = 0; } SDL_CALL SDL_SetColors(_sdl_screen, pal, start, end); diff --git a/table/palettes.h b/table/palettes.h index cacca03e2..123f6ed4a 100644 --- a/table/palettes.h +++ b/table/palettes.h @@ -1,169 +1,174 @@ -byte _palettes[4][256 * 3] = { -/* palette 1 (TTD Windows) */ -{ - 0, 0, 0, 212, 0, 212, 212, 0, 212, 212, 0, 212, -212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, -212, 0, 212, 212, 0, 212, 168, 168, 168, 184, 184, 184, -200, 200, 200, 216, 216, 216, 232, 232, 232, 252, 252, 252, - 52, 60, 72, 68, 76, 92, 88, 96, 112, 108, 116, 132, -132, 140, 152, 156, 160, 172, 176, 184, 196, 204, 208, 220, - 48, 44, 4, 64, 60, 12, 80, 76, 20, 96, 92, 28, -120, 120, 64, 148, 148, 100, 176, 176, 132, 204, 204, 168, -100, 100, 100, 116, 116, 116, 104, 80, 44, 124, 104, 72, -152, 132, 92, 184, 160, 120, 212, 188, 148, 244, 220, 176, -132, 132, 132, 88, 4, 16, 112, 16, 32, 136, 32, 52, -160, 56, 76, 188, 84, 108, 204, 104, 124, 220, 132, 144, -236, 156, 164, 252, 188, 192, 252, 212, 0, 252, 232, 60, -252, 248, 128, 76, 40, 0, 96, 60, 8, 116, 88, 28, -136, 116, 56, 156, 136, 80, 176, 156, 108, 196, 180, 136, - 68, 24, 0, 96, 44, 4, 128, 68, 8, 156, 96, 16, -184, 120, 24, 212, 156, 32, 232, 184, 16, 252, 212, 0, -252, 248, 128, 252, 252, 192, 32, 4, 0, 64, 20, 8, - 84, 28, 16, 108, 44, 28, 128, 56, 40, 148, 72, 56, -168, 92, 76, 184, 108, 88, 196, 128, 108, 212, 148, 128, - 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, - 64, 112, 12, 84, 132, 20, 104, 148, 28, 128, 168, 44, - 64, 64, 64, 44, 68, 32, 60, 88, 48, 80, 104, 60, -104, 124, 76, 128, 148, 92, 152, 176, 108, 180, 204, 124, - 16, 52, 24, 32, 72, 44, 56, 96, 72, 76, 116, 88, - 96, 136, 108, 120, 164, 136, 152, 192, 168, 184, 220, 200, - 32, 24, 0, 56, 28, 0, 80, 80, 80, 88, 52, 12, -104, 64, 24, 124, 84, 44, 140, 108, 64, 160, 128, 88, - 76, 40, 16, 96, 52, 24, 116, 68, 40, 136, 84, 56, -164, 96, 64, 184, 112, 80, 204, 128, 96, 212, 148, 112, -224, 168, 128, 236, 188, 148, 80, 28, 4, 100, 40, 20, -120, 56, 40, 140, 76, 64, 160, 100, 96, 184, 136, 136, - 36, 40, 68, 48, 52, 84, 64, 64, 100, 80, 80, 116, -100, 100, 136, 132, 132, 164, 172, 172, 192, 212, 212, 224, - 48, 48, 48, 64, 44, 144, 88, 64, 172, 104, 76, 196, -120, 88, 224, 140, 104, 252, 160, 136, 252, 188, 168, 252, - 0, 24, 108, 0, 36, 132, 0, 52, 160, 0, 72, 184, - 0, 96, 212, 24, 120, 220, 56, 144, 232, 88, 168, 240, -128, 196, 252, 188, 224, 252, 16, 64, 96, 24, 80, 108, - 40, 96, 120, 52, 112, 132, 80, 140, 160, 116, 172, 192, -156, 204, 220, 204, 240, 252, 172, 52, 52, 212, 52, 52, -252, 52, 52, 252, 100, 88, 252, 144, 124, 252, 184, 160, -252, 216, 200, 252, 244, 236, 72, 20, 112, 92, 44, 140, -112, 68, 168, 140, 100, 196, 168, 136, 224, 204, 180, 252, -204, 180, 252, 232, 208, 252, 60, 0, 0, 92, 0, 0, -128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, -252, 0, 0, 252, 80, 0, 252, 108, 0, 252, 136, 0, -252, 164, 0, 252, 192, 0, 252, 220, 0, 252, 252, 0, -204, 136, 8, 228, 144, 4, 252, 156, 0, 252, 176, 48, -252, 196, 100, 252, 216, 152, 8, 24, 88, 12, 36, 104, - 20, 52, 124, 28, 68, 140, 40, 92, 164, 56, 120, 188, - 72, 152, 216, 100, 172, 224, 92, 156, 52, 108, 176, 64, -124, 200, 76, 144, 224, 92, 224, 244, 252, 204, 240, 252, -180, 220, 236, 132, 188, 216, 88, 152, 172, 16, 16, 16, - 32, 32, 32, 8, 92, 104, 16, 100, 112, 24, 108, 120, - 32, 116, 128, 44, 124, 140, 92, 164, 184, 116, 180, 196, -148, 200, 216, 180, 220, 232, 216, 244, 252, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -252, 60, 0, 252, 80, 0, 252, 104, 0, 252, 128, 0, -252, 148, 0, 252, 172, 0, 252, 196, 0, 252, 0, 0, -252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -252, 228, 0, 148, 148, 148, 212, 0, 212, 212, 0, 212, -212, 0, 212, 212, 0, 212, 212, 0, 212, 212, 0, 212, -212, 0, 212, 212, 0, 212, 212, 0, 212, 252, 252, 252, -}, - -/* palette 2 (mixed TTD DOS + TTD Windows palette */ -{ - 0, 0, 0, 16, 16, 16, 32, 32, 32, 48, 48, 48, - 65, 64, 65, 82, 80, 82, 98, 101, 98, 115, 117, 115, -131, 133, 131, 148, 149, 148, 168, 168, 168, 184, 184, 184, -200, 200, 200, 216, 216, 216, 232, 232, 232, 252, 252, 252, - 52, 60, 72, 68, 76, 92, 88, 96, 112, 108, 116, 132, -132, 140, 152, 156, 160, 172, 176, 184, 196, 204, 208, 220, - 48, 44, 4, 64, 60, 12, 80, 76, 20, 96, 92, 28, -120, 120, 64, 148, 148, 100, 176, 176, 132, 204, 204, 168, - 72, 44, 4, 88, 60, 20, 104, 80, 44, 124, 104, 72, -152, 132, 92, 184, 160, 120, 212, 188, 148, 244, 220, 176, - 64, 0, 4, 88, 4, 16, 112, 16, 32, 136, 32, 52, -160, 56, 76, 188, 84, 108, 204, 104, 124, 220, 132, 144, -236, 156, 164, 252, 188, 192, 252, 212, 0, 252, 232, 60, -252, 248, 128, 76, 40, 0, 96, 60, 8, 116, 88, 28, -136, 116, 56, 156, 136, 80, 176, 156, 108, 196, 180, 136, - 68, 24, 0, 96, 44, 4, 128, 68, 8, 156, 96, 16, -184, 120, 24, 212, 156, 32, 232, 184, 16, 252, 212, 0, -252, 248, 128, 252, 252, 192, 32, 4, 0, 64, 20, 8, - 84, 28, 16, 108, 44, 28, 128, 56, 40, 148, 72, 56, -168, 92, 76, 184, 108, 88, 196, 128, 108, 212, 148, 128, - 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, - 64, 112, 12, 84, 132, 20, 104, 148, 28, 128, 168, 44, - 28, 52, 24, 44, 68, 32, 60, 88, 48, 80, 104, 60, -104, 124, 76, 128, 148, 92, 152, 176, 108, 180, 204, 124, - 16, 52, 24, 32, 72, 44, 56, 96, 72, 76, 116, 88, - 96, 136, 108, 120, 164, 136, 152, 192, 168, 184, 220, 200, - 32, 24, 0, 56, 28, 0, 72, 40, 0, 88, 52, 12, -104, 64, 24, 124, 84, 44, 140, 108, 64, 160, 128, 88, - 76, 40, 16, 96, 52, 24, 116, 68, 40, 136, 84, 56, -164, 96, 64, 184, 112, 80, 204, 128, 96, 212, 148, 112, -224, 168, 128, 236, 188, 148, 80, 28, 4, 100, 40, 20, -120, 56, 40, 140, 76, 64, 160, 100, 96, 184, 136, 136, - 36, 40, 68, 48, 52, 84, 64, 64, 100, 80, 80, 116, -100, 100, 136, 132, 132, 164, 172, 172, 192, 212, 212, 224, - 40, 20, 112, 64, 44, 144, 88, 64, 172, 104, 76, 196, -120, 88, 224, 140, 104, 252, 160, 136, 252, 188, 168, 252, - 0, 24, 108, 0, 36, 132, 0, 52, 160, 0, 72, 184, - 0, 96, 212, 24, 120, 220, 56, 144, 232, 88, 168, 240, -128, 196, 252, 188, 224, 252, 16, 64, 96, 24, 80, 108, - 40, 96, 120, 52, 112, 132, 80, 140, 160, 116, 172, 192, -156, 204, 220, 204, 240, 252, 172, 52, 52, 212, 52, 52, -252, 52, 52, 252, 100, 88, 252, 144, 124, 252, 184, 160, -252, 216, 200, 252, 244, 236, 72, 20, 112, 92, 44, 140, -112, 68, 168, 140, 100, 196, 168, 136, 224, 204, 180, 252, -204, 180, 252, 232, 208, 252, 60, 0, 0, 92, 0, 0, -128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, -252, 0, 0, 252, 80, 0, 252, 108, 0, 252, 136, 0, -252, 164, 0, 252, 192, 0, 252, 220, 0, 252, 252, 0, -204, 136, 8, 228, 144, 4, 252, 156, 0, 252, 176, 48, -252, 196, 100, 252, 216, 152, 8, 24, 88, 12, 36, 104, - 20, 52, 124, 28, 68, 140, 40, 92, 164, 56, 120, 188, - 72, 152, 216, 100, 172, 224, 92, 156, 52, 108, 176, 64, -124, 200, 76, 144, 224, 92, 224, 244, 252, 204, 240, 252, -180, 220, 236, 132, 188, 216, 88, 152, 172, 16, 16, 16, - 32, 32, 32, 8, 92, 104, 16, 100, 112, 24, 108, 120, - 32, 116, 128, 44, 124, 140, 92, 164, 184, 116, 180, 196, -148, 200, 216, 180, 220, 232, 216, 244, 252, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -252, 60, 0, 252, 80, 0, 252, 104, 0, 252, 128, 0, -252, 148, 0, 252, 172, 0, 252, 196, 0, 252, 0, 0, -252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -252, 228, 0, 148, 148, 148, 16, 101, 115, 24, 109, 123, - 32, 117, 131, 41, 125, 139, 90, 165, 189, 115, 182, 197, -148, 202, 222, 180, 222, 238, 222, 246, 255, 252, 252, 252, -} - +#define M(r, g, b) { r, g, b } +static Colour _palettes[][256] = { + /* palette 1 (TTD Windows) */ + { + M( 0, 0, 0), M(212, 0, 212), M(212, 0, 212), M(212, 0, 212), + M(212, 0, 212), M(212, 0, 212), M(212, 0, 212), M(212, 0, 212), + M(212, 0, 212), M(212, 0, 212), M(168, 168, 168), M(184, 184, 184), + M(200, 200, 200), M(216, 216, 216), M(232, 232, 232), M(252, 252, 252), + M( 52, 60, 72), M( 68, 76, 92), M( 88, 96, 112), M(108, 116, 132), + M(132, 140, 152), M(156, 160, 172), M(176, 184, 196), M(204, 208, 220), + M( 48, 44, 4), M( 64, 60, 12), M( 80, 76, 20), M( 96, 92, 28), + M(120, 120, 64), M(148, 148, 100), M(176, 176, 132), M(204, 204, 168), + M(100, 100, 100), M(116, 116, 116), M(104, 80, 44), M(124, 104, 72), + M(152, 132, 92), M(184, 160, 120), M(212, 188, 148), M(244, 220, 176), + M(132, 132, 132), M( 88, 4, 16), M(112, 16, 32), M(136, 32, 52), + M(160, 56, 76), M(188, 84, 108), M(204, 104, 124), M(220, 132, 144), + M(236, 156, 164), M(252, 188, 192), M(252, 212, 0), M(252, 232, 60), + M(252, 248, 128), M( 76, 40, 0), M( 96, 60, 8), M(116, 88, 28), + M(136, 116, 56), M(156, 136, 80), M(176, 156, 108), M(196, 180, 136), + M( 68, 24, 0), M( 96, 44, 4), M(128, 68, 8), M(156, 96, 16), + M(184, 120, 24), M(212, 156, 32), M(232, 184, 16), M(252, 212, 0), + M(252, 248, 128), M(252, 252, 192), M( 32, 4, 0), M( 64, 20, 8), + M( 84, 28, 16), M(108, 44, 28), M(128, 56, 40), M(148, 72, 56), + M(168, 92, 76), M(184, 108, 88), M(196, 128, 108), M(212, 148, 128), + M( 8, 52, 0), M( 16, 64, 0), M( 32, 80, 4), M( 48, 96, 4), + M( 64, 112, 12), M( 84, 132, 20), M(104, 148, 28), M(128, 168, 44), + M( 64, 64, 64), M( 44, 68, 32), M( 60, 88, 48), M( 80, 104, 60), + M(104, 124, 76), M(128, 148, 92), M(152, 176, 108), M(180, 204, 124), + M( 16, 52, 24), M( 32, 72, 44), M( 56, 96, 72), M( 76, 116, 88), + M( 96, 136, 108), M(120, 164, 136), M(152, 192, 168), M(184, 220, 200), + M( 32, 24, 0), M( 56, 28, 0), M( 80, 80, 80), M( 88, 52, 12), + M(104, 64, 24), M(124, 84, 44), M(140, 108, 64), M(160, 128, 88), + M( 76, 40, 16), M( 96, 52, 24), M(116, 68, 40), M(136, 84, 56), + M(164, 96, 64), M(184, 112, 80), M(204, 128, 96), M(212, 148, 112), + M(224, 168, 128), M(236, 188, 148), M( 80, 28, 4), M(100, 40, 20), + M(120, 56, 40), M(140, 76, 64), M(160, 100, 96), M(184, 136, 136), + M( 36, 40, 68), M( 48, 52, 84), M( 64, 64, 100), M( 80, 80, 116), + M(100, 100, 136), M(132, 132, 164), M(172, 172, 192), M(212, 212, 224), + M( 48, 48, 48), M( 64, 44, 144), M( 88, 64, 172), M(104, 76, 196), + M(120, 88, 224), M(140, 104, 252), M(160, 136, 252), M(188, 168, 252), + M( 0, 24, 108), M( 0, 36, 132), M( 0, 52, 160), M( 0, 72, 184), + M( 0, 96, 212), M( 24, 120, 220), M( 56, 144, 232), M( 88, 168, 240), + M(128, 196, 252), M(188, 224, 252), M( 16, 64, 96), M( 24, 80, 108), + M( 40, 96, 120), M( 52, 112, 132), M( 80, 140, 160), M(116, 172, 192), + M(156, 204, 220), M(204, 240, 252), M(172, 52, 52), M(212, 52, 52), + M(252, 52, 52), M(252, 100, 88), M(252, 144, 124), M(252, 184, 160), + M(252, 216, 200), M(252, 244, 236), M( 72, 20, 112), M( 92, 44, 140), + M(112, 68, 168), M(140, 100, 196), M(168, 136, 224), M(204, 180, 252), + M(204, 180, 252), M(232, 208, 252), M( 60, 0, 0), M( 92, 0, 0), + M(128, 0, 0), M(160, 0, 0), M(196, 0, 0), M(224, 0, 0), + M(252, 0, 0), M(252, 80, 0), M(252, 108, 0), M(252, 136, 0), + M(252, 164, 0), M(252, 192, 0), M(252, 220, 0), M(252, 252, 0), + M(204, 136, 8), M(228, 144, 4), M(252, 156, 0), M(252, 176, 48), + M(252, 196, 100), M(252, 216, 152), M( 8, 24, 88), M( 12, 36, 104), + M( 20, 52, 124), M( 28, 68, 140), M( 40, 92, 164), M( 56, 120, 188), + M( 72, 152, 216), M(100, 172, 224), M( 92, 156, 52), M(108, 176, 64), + M(124, 200, 76), M(144, 224, 92), M(224, 244, 252), M(204, 240, 252), + M(180, 220, 236), M(132, 188, 216), M( 88, 152, 172), M( 16, 16, 16), + M( 32, 32, 32), M( 8, 92, 104), M( 16, 100, 112), M( 24, 108, 120), + M( 32, 116, 128), M( 44, 124, 140), M( 92, 164, 184), M(116, 180, 196), + M(148, 200, 216), M(180, 220, 232), M(216, 244, 252), M( 0, 0, 0), + M( 0, 0, 0), M( 0, 0, 0), M( 0, 0, 0), M( 0, 0, 0), + M(252, 60, 0), M(252, 80, 0), M(252, 104, 0), M(252, 128, 0), + M(252, 148, 0), M(252, 172, 0), M(252, 196, 0), M(252, 0, 0), + M(252, 0, 0), M( 0, 0, 0), M( 0, 0, 0), M( 0, 0, 0), + M(252, 228, 0), M(148, 148, 148), M(212, 0, 212), M(212, 0, 212), + M(212, 0, 212), M(212, 0, 212), M(212, 0, 212), M(212, 0, 212), + M(212, 0, 212), M(212, 0, 212), M(212, 0, 212), M(252, 252, 252) + }, + /* palette 2 (mixed TTD DOS + TTD Windows palette */ + { + M( 0, 0, 0), M( 16, 16, 16), M( 32, 32, 32), M( 48, 48, 48), + M( 65, 64, 65), M( 82, 80, 82), M( 98, 101, 98), M(115, 117, 115), + M(131, 133, 131), M(148, 149, 148), M(168, 168, 168), M(184, 184, 184), + M(200, 200, 200), M(216, 216, 216), M(232, 232, 232), M(252, 252, 252), + M( 52, 60, 72), M( 68, 76, 92), M( 88, 96, 112), M(108, 116, 132), + M(132, 140, 152), M(156, 160, 172), M(176, 184, 196), M(204, 208, 220), + M( 48, 44, 4), M( 64, 60, 12), M( 80, 76, 20), M( 96, 92, 28), + M(120, 120, 64), M(148, 148, 100), M(176, 176, 132), M(204, 204, 168), + M( 72, 44, 4), M( 88, 60, 20), M(104, 80, 44), M(124, 104, 72), + M(152, 132, 92), M(184, 160, 120), M(212, 188, 148), M(244, 220, 176), + M( 64, 0, 4), M( 88, 4, 16), M(112, 16, 32), M(136, 32, 52), + M(160, 56, 76), M(188, 84, 108), M(204, 104, 124), M(220, 132, 144), + M(236, 156, 164), M(252, 188, 192), M(252, 212, 0), M(252, 232, 60), + M(252, 248, 128), M( 76, 40, 0), M( 96, 60, 8), M(116, 88, 28), + M(136, 116, 56), M(156, 136, 80), M(176, 156, 108), M(196, 180, 136), + M( 68, 24, 0), M( 96, 44, 4), M(128, 68, 8), M(156, 96, 16), + M(184, 120, 24), M(212, 156, 32), M(232, 184, 16), M(252, 212, 0), + M(252, 248, 128), M(252, 252, 192), M( 32, 4, 0), M( 64, 20, 8), + M( 84, 28, 16), M(108, 44, 28), M(128, 56, 40), M(148, 72, 56), + M(168, 92, 76), M(184, 108, 88), M(196, 128, 108), M(212, 148, 128), + M( 8, 52, 0), M( 16, 64, 0), M( 32, 80, 4), M( 48, 96, 4), + M( 64, 112, 12), M( 84, 132, 20), M(104, 148, 28), M(128, 168, 44), + M( 28, 52, 24), M( 44, 68, 32), M( 60, 88, 48), M( 80, 104, 60), + M(104, 124, 76), M(128, 148, 92), M(152, 176, 108), M(180, 204, 124), + M( 16, 52, 24), M( 32, 72, 44), M( 56, 96, 72), M( 76, 116, 88), + M( 96, 136, 108), M(120, 164, 136), M(152, 192, 168), M(184, 220, 200), + M( 32, 24, 0), M( 56, 28, 0), M( 72, 40, 0), M( 88, 52, 12), + M(104, 64, 24), M(124, 84, 44), M(140, 108, 64), M(160, 128, 88), + M( 76, 40, 16), M( 96, 52, 24), M(116, 68, 40), M(136, 84, 56), + M(164, 96, 64), M(184, 112, 80), M(204, 128, 96), M(212, 148, 112), + M(224, 168, 128), M(236, 188, 148), M( 80, 28, 4), M(100, 40, 20), + M(120, 56, 40), M(140, 76, 64), M(160, 100, 96), M(184, 136, 136), + M( 36, 40, 68), M( 48, 52, 84), M( 64, 64, 100), M( 80, 80, 116), + M(100, 100, 136), M(132, 132, 164), M(172, 172, 192), M(212, 212, 224), + M( 40, 20, 112), M( 64, 44, 144), M( 88, 64, 172), M(104, 76, 196), + M(120, 88, 224), M(140, 104, 252), M(160, 136, 252), M(188, 168, 252), + M( 0, 24, 108), M( 0, 36, 132), M( 0, 52, 160), M( 0, 72, 184), + M( 0, 96, 212), M( 24, 120, 220), M( 56, 144, 232), M( 88, 168, 240), + M(128, 196, 252), M(188, 224, 252), M( 16, 64, 96), M( 24, 80, 108), + M( 40, 96, 120), M( 52, 112, 132), M( 80, 140, 160), M(116, 172, 192), + M(156, 204, 220), M(204, 240, 252), M(172, 52, 52), M(212, 52, 52), + M(252, 52, 52), M(252, 100, 88), M(252, 144, 124), M(252, 184, 160), + M(252, 216, 200), M(252, 244, 236), M( 72, 20, 112), M( 92, 44, 140), + M(112, 68, 168), M(140, 100, 196), M(168, 136, 224), M(204, 180, 252), + M(204, 180, 252), M(232, 208, 252), M( 60, 0, 0), M( 92, 0, 0), + M(128, 0, 0), M(160, 0, 0), M(196, 0, 0), M(224, 0, 0), + M(252, 0, 0), M(252, 80, 0), M(252, 108, 0), M(252, 136, 0), + M(252, 164, 0), M(252, 192, 0), M(252, 220, 0), M(252, 252, 0), + M(204, 136, 8), M(228, 144, 4), M(252, 156, 0), M(252, 176, 48), + M(252, 196, 100), M(252, 216, 152), M( 8, 24, 88), M( 12, 36, 104), + M( 20, 52, 124), M( 28, 68, 140), M( 40, 92, 164), M( 56, 120, 188), + M( 72, 152, 216), M(100, 172, 224), M( 92, 156, 52), M(108, 176, 64), + M(124, 200, 76), M(144, 224, 92), M(224, 244, 252), M(204, 240, 252), + M(180, 220, 236), M(132, 188, 216), M( 88, 152, 172), M( 16, 16, 16), + M( 32, 32, 32), M( 8, 92, 104), M( 16, 100, 112), M( 24, 108, 120), + M( 32, 116, 128), M( 44, 124, 140), M( 92, 164, 184), M(116, 180, 196), + M(148, 200, 216), M(180, 220, 232), M(216, 244, 252), M( 0, 0, 0), + M( 0, 0, 0), M( 0, 0, 0), M( 0, 0, 0), M( 0, 0, 0), + M(252, 60, 0), M(252, 80, 0), M(252, 104, 0), M(252, 128, 0), + M(252, 148, 0), M(252, 172, 0), M(252, 196, 0), M(252, 0, 0), + M(252, 0, 0), M( 0, 0, 0), M( 0, 0, 0), M( 0, 0, 0), + M(252, 228, 0), M(148, 148, 148), M( 16, 101, 115), M( 24, 109, 123), + M( 32, 117, 131), M( 41, 125, 139), M( 90, 165, 189), M(115, 182, 197), + M(148, 202, 222), M(180, 222, 238), M(222, 246, 255), M(252, 252, 252) + } }; #define GET_PALETTE(x) _palettes[x] typedef struct { - byte a[15]; // dark blue water - byte ac[15]; // dark blue water Toyland - byte lighthouse[12]; // lighthouse & stadium - byte oil_ref[21]; // oil refinery - byte e[15]; // ??? - byte b[45]; // glittery water - byte bc[45]; // glittery water Toyland + Colour a[15]; // dark blue water + Colour ac[15]; // dark blue water Toyland + Colour lighthouse[12]; // lighthouse & stadium + Colour oil_ref[21]; // oil refinery + Colour e[15]; // ??? + Colour b[45]; // glittery water + Colour bc[45]; // glittery water Toyland } ExtraPaletteValues; static const ExtraPaletteValues _extra_palette_values = { - {32, 68,112, 36, 72,116, 40, 76,120, 44, 80,124, 48, 84,128}, - {28,108,124, 32,112,128, 36,116,132, 40,120,136, 44,124,140}, - {240,208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {252, 60, 0,252, 84, 0,252,108, 0,252,124, 0,252,148, 0, - 252,172, 0,252,196, 0}, - { 76, 24, 8,108, 44, 24,144, 72, 52,176,108, 84,212,148,128}, - {216,244,252,172,208,224,132,172,196,100,132,168, 72,100,144, - 72,100,144, 72,100,144, 72,100,144, 72,100,144, 72,100,144, - 72,100,144, 72,100,144,100,132,168,132,172,196,172,208,224}, - {216,244,252,180,220,232,148,200,216,116,180,196, 92,164,184, - 92,164,184, 92,164,184, 92,164,184, 92,164,184, 92,164,184, - 92,164,184, 92,164,184,116,180,196,148,200,216,180,220,232}, + { M( 32, 68, 112), M( 36, 72, 116), M( 40, 76, 120), M( 44, 80, 124), + M( 48, 84, 128) }, + { M( 28, 108, 124), M( 32, 112, 128), M( 36, 116, 132), M( 40, 120, 136), + M( 44, 124, 140) }, + { M(240, 208, 0), M( 0, 0, 0), M( 0, 0, 0), M( 0, 0, 0) }, + { M(252, 60, 0), M(252, 84, 0), M(252, 108, 0), M(252, 124, 0), + M(252, 148, 0), M(252, 172, 0), M(252, 196, 0) }, + { M( 76, 24, 8), M(108, 44, 24), M(144, 72, 52), M(176, 108, 84), + M(212, 148, 128) }, + { M(216, 244, 252), M(172, 208, 224), M(132, 172, 196), M(100, 132, 168), + M( 72, 100, 144), M( 72, 100, 144), M( 72, 100, 144), M( 72, 100, 144), + M( 72, 100, 144), M( 72, 100, 144), M( 72, 100, 144), M( 72, 100, 144), + M(100, 132, 168), M(132, 172, 196), M(172, 208, 224) }, + { M(216, 244, 252), M(180, 220, 232), M(148, 200, 216), M(116, 180, 196), + M( 92, 164, 184), M( 92, 164, 184), M( 92, 164, 184), M( 92, 164, 184), + M( 92, 164, 184), M( 92, 164, 184), M( 92, 164, 184), M( 92, 164, 184), + M(116, 180, 196), M(148, 200, 216), M(180, 220, 232) } }; +#undef M // Color table for colors in lang files (e.g. {BLACK}) typedef struct StringColor { @@ -50,17 +50,16 @@ static void MakePalette(void) { LOGPALETTE *pal; uint i; - byte *b; pal = alloca(sizeof(LOGPALETTE) + (256-1) * sizeof(PALETTEENTRY)); pal->palVersion = 0x300; pal->palNumEntries = 256; - for (i = 0, b = _cur_palette; i != 256; i++, b += 3) { - pal->palPalEntry[i].peRed = b[0]; - pal->palPalEntry[i].peGreen = b[1]; - pal->palPalEntry[i].peBlue = b[2]; + for (i = 0; i != 256; i++) { + pal->palPalEntry[i].peRed = _cur_palette[i].r; + pal->palPalEntry[i].peGreen = _cur_palette[i].g; + pal->palPalEntry[i].peBlue = _cur_palette[i].b; pal->palPalEntry[i].peFlags = 0; } |