diff options
author | smatz <smatz@openttd.org> | 2008-06-18 21:19:04 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-06-18 21:19:04 +0000 |
commit | 5259d13da7db6583b0ac2ead56572ced6c679dac (patch) | |
tree | 4997235d0f8568325d0c8f7c1412cca55e69496d /src | |
parent | 25db4b3aae9e534de31b1baf71d917f15675ef6e (diff) | |
download | openttd-5259d13da7db6583b0ac2ead56572ced6c679dac.tar.xz |
(svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
Diffstat (limited to 'src')
-rw-r--r-- | src/blitter/32bpp_base.hpp | 7 | ||||
-rw-r--r-- | src/endian_check.cpp | 2 | ||||
-rw-r--r-- | src/gfx_func.h | 2 | ||||
-rw-r--r-- | src/gfx_type.h | 11 | ||||
-rw-r--r-- | src/os/macosx/splash.cpp | 2 | ||||
-rw-r--r-- | src/screenshot.cpp | 19 | ||||
-rw-r--r-- | src/table/palettes.h | 13 |
7 files changed, 32 insertions, 24 deletions
diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index dca8728ad..aa3d8f72f 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -37,11 +37,10 @@ public: /** * Look up the colour in the current palette. - **/ - static inline uint32 LookupColourInPalette(uint8 index) + */ + static inline uint32 LookupColourInPalette(uint index) { - if (index == 0) return 0x00000000; // Full transparent pixel */ - return ComposeColour(0xFF, _cur_palette[index].r, _cur_palette[index].g, _cur_palette[index].b); + return _cur_palette[index]; } /** diff --git a/src/endian_check.cpp b/src/endian_check.cpp index e70c2adc8..c13db036c 100644 --- a/src/endian_check.cpp +++ b/src/endian_check.cpp @@ -19,7 +19,7 @@ enum Endian { }; /** - * Shortcut to printf("#define TTD_*_ENDIAN 0/1") + * Shortcut to printf("#define TTD_ENDIAN TTD_*_ENDIAN") * @param endian endian type to define */ static inline void printf_endian(Endian endian) diff --git a/src/gfx_func.h b/src/gfx_func.h index cb4d04c84..c6c633ec2 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -62,7 +62,7 @@ extern int _pal_count_dirty; extern int _num_resolutions; extern Dimension _resolutions[32]; extern Dimension _cur_resolution; -extern Colour _cur_palette[256]; +extern Colour _cur_palette[256]; ///< Current palette. Entry 0 has to be always fully transparent! void HandleKeypress(uint32 key); void HandleCtrlChanged(); diff --git a/src/gfx_type.h b/src/gfx_type.h index c65e69fad..f5ed4a328 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -5,6 +5,7 @@ #ifndef GFX_TYPE_H #define GFX_TYPE_H +#include "core/endian_type.hpp" #include "core/enum_type.hpp" #include "core/geometry_type.hpp" #include "zoom_type.h" @@ -142,9 +143,13 @@ struct DrawPixelInfo { }; struct Colour { - byte r; - byte g; - byte b; +#if TTD_ENDIAN == TTD_BIG_ENDIAN + uint8 a, r, g, b; ///< colour channels in BE order +#else + uint8 b, g, r, a; ///< colour channels in LE order +#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ + + operator uint32 () { return *(uint32 *)this; } }; enum FontSize { diff --git a/src/os/macosx/splash.cpp b/src/os/macosx/splash.cpp index 6e60b12ca..41a714a78 100644 --- a/src/os/macosx/splash.cpp +++ b/src/os/macosx/splash.cpp @@ -124,11 +124,13 @@ void DisplaySplashImage() } for (i = 0; i < num_palette; i++) { + _cur_palette[i].a = i == 0 ? 0 : 0xff; _cur_palette[i].r = palette[i].red; _cur_palette[i].g = palette[i].green; _cur_palette[i].b = palette[i].blue; } + _cur_palette[0xff].a = 0xff; _cur_palette[0xff].r = 0; _cur_palette[0xff].g = 0; _cur_palette[0xff].b = 0; diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 1282c76c4..6f5cc0105 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -428,20 +428,15 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user return false; } - if (sizeof(*palette) == 3) { - success = fwrite(palette, 256 * sizeof(*palette), 1, f) == 1; - } else { - /* If the palette is word-aligned, copy it to a temporary byte array */ - byte tmp[256 * 3]; - uint i; + /* Palette is word-aligned, copy it to a temporary byte array */ + byte tmp[256 * 3]; - for (i = 0; i < 256; i++) { - tmp[i * 3 + 0] = palette[i].r; - tmp[i * 3 + 1] = palette[i].g; - tmp[i * 3 + 2] = palette[i].b; - } - success = fwrite(tmp, sizeof(tmp), 1, f) == 1; + for (uint i = 0; i < 256; i++) { + tmp[i * 3 + 0] = palette[i].r; + tmp[i * 3 + 1] = palette[i].g; + tmp[i * 3 + 2] = palette[i].b; } + success = fwrite(tmp, sizeof(tmp), 1, f) == 1; fclose(f); diff --git a/src/table/palettes.h b/src/table/palettes.h index 51e5dc571..6aa98c765 100644 --- a/src/table/palettes.h +++ b/src/table/palettes.h @@ -2,11 +2,18 @@ /** @file palettes.h The colour translation of the GRF palettes. */ -#define M(r, g, b) { r, g, b } +#include "../core/endian_type.hpp" + +#if TTD_ENDIAN == TTD_BIG_ENDIAN + #define M(r, g, b) { 0xff, r, g, b } +#else + #define M(r, g, b) { b, g, r, 0xff } +#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ + static const Colour _palettes[][256] = { /* palette 1 (TTD Windows) */ { - M( 0, 0, 0), M(212, 0, 212), M(212, 0, 212), M(212, 0, 212), + { 0, 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), @@ -74,7 +81,7 @@ static const Colour _palettes[][256] = { /* palette 2 (mixed TTD DOS + TTD Windows palette */ { - M( 0, 0, 0), M( 16, 16, 16), M( 32, 32, 32), M( 48, 48, 48), + { 0, 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), |