Mercurial > hg > index.fcgi > lj > lj046
comparison src/ljtypes.h @ 0:c84446dfb3f5
initial add
author | paulo@localhost |
---|---|
date | Fri, 13 Mar 2009 00:39:12 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e32604d0946a |
---|---|
1 /* Basic data types for LOCKJAW, an implementation of the Soviet Mind Game | |
2 | |
3 Copyright (C) 2006 Damian Yerrick <tepples+lj@spamcop.net> | |
4 | |
5 This work is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2 of the License, or | |
8 (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Original game concept and design by Alexey Pajitnov. | |
20 The Software is not sponsored or endorsed by Alexey Pajitnov, Elorg, | |
21 or The Tetris Company LLC. | |
22 | |
23 */ | |
24 | |
25 #ifndef LJTYPES_H | |
26 #define LJTYPES_H | |
27 | |
28 /** | |
29 * A 16.16 signed number. Used commonly for Y piece positions. | |
30 */ | |
31 typedef signed int LJFixed; | |
32 | |
33 static inline signed int ljfixfloor(LJFixed f) __attribute__((const)); | |
34 | |
35 static inline signed int ljfixfloor(LJFixed f) { | |
36 return f >> 16; | |
37 } | |
38 | |
39 static inline LJFixed ljitofix(signed int f) __attribute__((const)); | |
40 | |
41 static inline LJFixed ljitofix(signed int f) { | |
42 return f << 16; | |
43 } | |
44 | |
45 /* | |
46 * In most cases, macros are deprecated in favor of static inline functions | |
47 * because the latter allow the compiler to perform more type checks. | |
48 * However, the C language forbids calling a function in an inline | |
49 * constructor, even if it is a static inline function with no side effects. | |
50 * For example, GCC gives the misleading error message | |
51 * "error: initializer element is not constant". | |
52 * Therefore, I have to provide a second implementation of ljitofix() | |
53 * as a macro for use in global variable initializers. | |
54 */ | |
55 #define LJITOFIX(f) ((LJFixed)((f) << 16)) | |
56 | |
57 | |
58 typedef unsigned int LJBits; | |
59 | |
60 #endif | |
61 |