src/macros.h
author skidd13
Mon, 26 Nov 2007 17:50:22 +0000
changeset 7971 8509d595142a
parent 7967 a230c063a672
child 8005 2318a0547719
permissions -rw-r--r--
(svn r11527) -Codechange: Split the bitmath functions of to their own files
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6111
diff changeset
     3
/** @file macros.h */
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6111
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#ifndef MACROS_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#define MACROS_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
7971
8509d595142a (svn r11527) -Codechange: Split the bitmath functions of to their own files
skidd13
parents: 7967
diff changeset
     8
#include "core/bitmath_func.hpp"
7937
1e7a22ea20d4 (svn r11490) -Codechange: Split the math functions to their own header
skidd13
parents: 7932
diff changeset
     9
#include "core/math_func.hpp"
1e7a22ea20d4 (svn r11490) -Codechange: Split the math functions to their own header
skidd13
parents: 7932
diff changeset
    10
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5605
diff changeset
    11
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5605
diff changeset
    12
#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
7619
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    14
/**
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    15
 * Whether a sprite comes from the original graphics files or a new grf file
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    16
 * (either supplied by OpenTTD or supplied by the user).
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    17
 *
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    18
 * @param sprite The sprite to check
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    19
 * @return True if it is a new sprite, or false if it is original.
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    20
 */
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    21
#define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE)
a1cf1e29bb38 (svn r11149) -Fix [FS#1225]: Draw building stages for new house ground sprites.
maedhros
parents: 7516
diff changeset
    22
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2775
diff changeset
    24
#define for_each_bit(_i, _b)            \
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2775
diff changeset
    25
	for (_i = 0; _b != 0; _i++, _b >>= 1) \
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2775
diff changeset
    26
		if (_b & 1)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
2966
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    29
static inline uint16 ReadLE16Aligned(const void* x)
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    30
{
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    31
	return FROM_LE16(*(const uint16*)x);
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    32
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
2966
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    34
static inline uint16 ReadLE16Unaligned(const void* x)
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    35
{
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    36
#ifdef OTTD_ALIGNMENT
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    37
	return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    38
#else
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    39
	return FROM_LE16(*(const uint16*)x);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
#endif
2966
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    41
}
661554d683cd (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2952
diff changeset
    42
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4274
diff changeset
    44
/** return the largest value that can be entered in a variable.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4274
diff changeset
    45
 */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4274
diff changeset
    46
#define MAX_UVALUE(type) ((type)~(type)0)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4274
diff changeset
    47
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
#endif /* MACROS_H */