summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/blitter/32bpp_anim.cpp4
-rw-r--r--src/blitter/32bpp_base.hpp2
-rw-r--r--src/blitter/32bpp_optimized.cpp6
-rw-r--r--src/gfx_type.h11
-rw-r--r--src/table/palettes.h10
5 files changed, 16 insertions, 17 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index 8dbcb0043..1c72a1382 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -97,7 +97,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
uint m = *src_n;
/* In case the m-channel is zero, do not remap this pixel in any way */
if (m == 0) {
- *dst = *src_px;
+ *dst = src_px->data;
*anim = 0;
} else {
uint r = remap[m];
@@ -161,7 +161,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
uint m = *src_n++;
/* Above 217 (PALETTE_ANIM_SIZE_START) is palette animation */
*anim++ = m;
- *dst++ = (m >= PALETTE_ANIM_SIZE_START) ? this->LookupColourInPalette(m) : *src_px;
+ *dst++ = (m >= PALETTE_ANIM_SIZE_START) ? this->LookupColourInPalette(m) : src_px->data;
src_px++;
} while (--n != 0);
} else {
diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp
index 2b21d4607..236b902ef 100644
--- a/src/blitter/32bpp_base.hpp
+++ b/src/blitter/32bpp_base.hpp
@@ -41,7 +41,7 @@ public:
*/
static inline uint32 LookupColourInPalette(uint index)
{
- return _cur_palette[index];
+ return _cur_palette[index].data;
}
/**
diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp
index ae360c99b..d4827e788 100644
--- a/src/blitter/32bpp_optimized.cpp
+++ b/src/blitter/32bpp_optimized.cpp
@@ -110,7 +110,7 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
uint m = *src_n;
/* In case the m-channel is zero, do not remap this pixel in any way */
if (m == 0) {
- *dst = *src_px;
+ *dst = src_px->data;
} else {
uint r = remap[m];
if (r != 0) *dst = this->LookupColourInPalette(r);
@@ -162,7 +162,9 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
/* faster than memcpy(), n is usually low */
src_n += n;
do {
- *dst++ = *src_px++;
+ *dst = src_px->data;
+ dst++;
+ src_px++;
} while (--n != 0);
} else {
src_n += n;
diff --git a/src/gfx_type.h b/src/gfx_type.h
index 7796d19e0..57f1b3d42 100644
--- a/src/gfx_type.h
+++ b/src/gfx_type.h
@@ -138,14 +138,15 @@ struct DrawPixelInfo {
};
/** Structure to access the alpha, red, green, and blue channels from a 32 bit number. */
-struct Colour {
+union Colour {
+ uint32 data; ///< Conversion of the channel information to a 32 bit number.
+ struct {
#if TTD_ENDIAN == TTD_BIG_ENDIAN
- uint8 a, r, g, b; ///< colour channels in BE order
+ uint8 a, r, g, b; ///< colour channels in BE order
#else
- uint8 b, g, r, a; ///< colour channels in LE order
+ uint8 b, g, r, a; ///< colour channels in LE order
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */
-
- operator uint32 () const { return *(uint32 *)this; } ///< Conversion of the channel information to a 32 bit number.
+ };
};
/** Available font sizes */
diff --git a/src/table/palettes.h b/src/table/palettes.h
index 794b235ef..3207cab9d 100644
--- a/src/table/palettes.h
+++ b/src/table/palettes.h
@@ -4,16 +4,12 @@
#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 */
+#define M(r, g, b) { 0xff << 24 | (r) << 16 | (g) << 8 | (b) }
static const Colour _palettes[][256] = {
/* palette 0 (mixed TTD DOS + TTD Windows palette */
{
- { 0, 0, 0, 0 }, M( 16, 16, 16), M( 32, 32, 32), M( 48, 48, 48),
+ { 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),
@@ -81,7 +77,7 @@ static const Colour _palettes[][256] = {
/* palette 1 (TTD Windows) */
{
- { 0, 0, 0, 0 }, M(212, 0, 212), M(212, 0, 212), M(212, 0, 212),
+ { 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),