Changeset - r9551:5cfb47d30fe1
[Not reviewed]
master
0 7 0
smatz - 16 years ago 2008-06-18 21:19:04
smatz@openttd.org
(svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
7 files changed with 32 insertions and 24 deletions:
0 comments (0 inline, 0 general)
src/blitter/32bpp_base.hpp
Show inline comments
 
@@ -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];
 
	}
 

	
 
	/**
src/endian_check.cpp
Show inline comments
 
@@ -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)
src/gfx_func.h
Show inline comments
 
@@ -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();
src/gfx_type.h
Show inline comments
 
@@ -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 {
src/os/macosx/splash.cpp
Show inline comments
 
@@ -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;
src/screenshot.cpp
Show inline comments
 
@@ -428,20 +428,15 @@ static bool MakePCXImage(const char *nam
 
		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);
 

	
src/table/palettes.h
Show inline comments
 
@@ -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),
0 comments (0 inline, 0 general)