view src/ljtypes.h @ 3:17286938e22a

change DS alt. rotate key to rotate twice
author paulo@localhost
date Wed, 08 Apr 2009 21:50:13 -0700
parents
children
line source
1 /* Basic data types for LOCKJAW, an implementation of the Soviet Mind Game
3 Copyright (C) 2006 Damian Yerrick <tepples+lj@spamcop.net>
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.
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.
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
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.
23 */
25 #ifndef LJTYPES_H
26 #define LJTYPES_H
28 /**
29 * A 16.16 signed number. Used commonly for Y piece positions.
30 */
31 typedef signed int LJFixed;
33 static inline signed int ljfixfloor(LJFixed f) __attribute__((const));
35 static inline signed int ljfixfloor(LJFixed f) {
36 return f >> 16;
37 }
39 static inline LJFixed ljitofix(signed int f) __attribute__((const));
41 static inline LJFixed ljitofix(signed int f) {
42 return f << 16;
43 }
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))
58 typedef unsigned int LJBits;
60 #endif