Changeset - r9870:dd3f7f4ab6d7
[Not reviewed]
master
0 3 0
belugas - 16 years ago 2008-08-08 02:28:28
belugas@openttd.org
(svn r14016) -Codechange: Remove some magical numbers
3 files changed with 17 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/blitter/32bpp_anim.cpp
Show inline comments
 
@@ -161,16 +161,16 @@ inline void Blitter_32bppAnim::Draw(cons
 
						do {
 
							/* Compiler assumes pointer aliasing, can't optimise this on its own */
 
							uint m = *src_n++;
 
							/* Above 217 is palette animation */
 
							/* Above 217 (PALETTE_ANIM_SIZE_START) is palette animation */
 
							*anim++ = m;
 
							*dst++ = (m >= 217) ? this->LookupColourInPalette(m) : *src_px;
 
							*dst++ = (m >= PALETTE_ANIM_SIZE_START) ? this->LookupColourInPalette(m) : *src_px;
 
							src_px++;
 
						} while (--n != 0);
 
					} else {
 
						do {
 
							uint m = *src_n++;
 
							*anim++ = m;
 
							if (m >= 217) {
 
							if (m >= PALETTE_ANIM_SIZE_START) {
 
								*dst = ComposeColourPANoCheck(this->LookupColourInPalette(m), src_px->a, *dst);
 
							} else {
 
								*dst = ComposeColourRGBANoCheck(src_px->r, src_px->g, src_px->b, src_px->a, *dst);
 
@@ -327,7 +327,7 @@ void Blitter_32bppAnim::CopyFromBuffer(v
 
	}
 

	
 
	/* We update the palette (or the pixels that do animation) immediatly, to avoid graphical glitches */
 
	this->PaletteAnimate(217, _use_dos_palette ? 38 : 28);
 
	this->PaletteAnimate(PALETTE_ANIM_SIZE_START, _use_dos_palette ? PALETTE_ANIM_SIZE_DOS : PALETTE_ANIM_SIZE_WIN);
 
}
 

	
 
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
src/gfx.cpp
Show inline comments
 
@@ -997,8 +997,8 @@ void DoPaletteAnimations()
 
	 * A few more for the DOS palette, because the water colors are
 
	 * 245-254 for DOS and 217-226 for Windows.  */
 
	const ExtraPaletteValues *ev = &_extra_palette_values;
 
	int c = _use_dos_palette ? 38 : 28;
 
	Colour old_val[38];
 
	int c = _use_dos_palette ? PALETTE_ANIM_SIZE_DOS : PALETTE_ANIM_SIZE_WIN;
 
	Colour old_val[PALETTE_ANIM_SIZE_DOS];
 
	uint i;
 
	uint j;
 
	uint old_tc = _palette_animation_counter;
 
@@ -1007,7 +1007,7 @@ void DoPaletteAnimations()
 
		_palette_animation_counter = 0;
 
	}
 

	
 
	d = &_cur_palette[217];
 
	d = &_cur_palette[PALETTE_ANIM_SIZE_START];
 
	memcpy(old_val, d, c * sizeof(*old_val));
 

	
 
	/* Dark blue water */
 
@@ -1101,8 +1101,8 @@ void DoPaletteAnimations()
 
	if (blitter != NULL && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) {
 
		_palette_animation_counter = old_tc;
 
	} else {
 
		if (memcmp(old_val, &_cur_palette[217], c * sizeof(*old_val)) != 0) {
 
			_pal_first_dirty = 217;
 
		if (memcmp(old_val, &_cur_palette[PALETTE_ANIM_SIZE_START], c * sizeof(*old_val)) != 0) {
 
			_pal_first_dirty = PALETTE_ANIM_SIZE_START;
 
			_pal_count_dirty = c;
 
		}
 
	}
src/gfx_type.h
Show inline comments
 
@@ -191,7 +191,7 @@ enum Colours {
 
	COLOUR_GREY,
 
	COLOUR_WHITE,
 
	COLOUR_END,
 
	INVALID_COLOUR = 0xFF
 
	INVALID_COLOUR = 0xFF,
 
};
 

	
 
/** Colour of the strings, see _string_colormap in table/palettes.h or docs/ottd-colourtext-palette.png */
 
@@ -216,6 +216,13 @@ enum TextColour {
 
	TC_BLACK       = 0x10,
 
};
 

	
 
/** Defines a few values that are related to animations using palette changes */
 
enum PaletteAnimationSizes {
 
	PALETTE_ANIM_SIZE_WIN   = 28,   ///< number of animated colours in Windows palette
 
	PALETTE_ANIM_SIZE_DOS   = 38,   ///< number of animated colours in DOS palette
 
	PALETTE_ANIM_SIZE_START = 217,  ///< Index in  the _palettes array from which all animations are taking places (table/palettes.h)
 
};
 

	
 
enum StringColorFlags {
 
	IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
 
};
0 comments (0 inline, 0 general)