paulo@0: /* Basic data types for LOCKJAW, an implementation of the Soviet Mind Game paulo@0: paulo@0: Copyright (C) 2006 Damian Yerrick paulo@0: paulo@0: This work is free software; you can redistribute it and/or modify paulo@0: it under the terms of the GNU General Public License as published by paulo@0: the Free Software Foundation; either version 2 of the License, or paulo@0: (at your option) any later version. paulo@0: paulo@0: This program is distributed in the hope that it will be useful, paulo@0: but WITHOUT ANY WARRANTY; without even the implied warranty of paulo@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the paulo@0: GNU General Public License for more details. paulo@0: paulo@0: You should have received a copy of the GNU General Public License paulo@0: along with this program; if not, write to the Free Software paulo@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA paulo@0: paulo@0: Original game concept and design by Alexey Pajitnov. paulo@0: The Software is not sponsored or endorsed by Alexey Pajitnov, Elorg, paulo@0: or The Tetris Company LLC. paulo@0: paulo@0: */ paulo@0: paulo@0: #ifndef LJTYPES_H paulo@0: #define LJTYPES_H paulo@0: paulo@0: /** paulo@0: * A 16.16 signed number. Used commonly for Y piece positions. paulo@0: */ paulo@0: typedef signed int LJFixed; paulo@0: paulo@0: static inline signed int ljfixfloor(LJFixed f) __attribute__((const)); paulo@0: paulo@0: static inline signed int ljfixfloor(LJFixed f) { paulo@0: return f >> 16; paulo@0: } paulo@0: paulo@0: static inline LJFixed ljitofix(signed int f) __attribute__((const)); paulo@0: paulo@0: static inline LJFixed ljitofix(signed int f) { paulo@0: return f << 16; paulo@0: } paulo@0: paulo@0: /* paulo@0: * In most cases, macros are deprecated in favor of static inline functions paulo@0: * because the latter allow the compiler to perform more type checks. paulo@0: * However, the C language forbids calling a function in an inline paulo@0: * constructor, even if it is a static inline function with no side effects. paulo@0: * For example, GCC gives the misleading error message paulo@0: * "error: initializer element is not constant". paulo@0: * Therefore, I have to provide a second implementation of ljitofix() paulo@0: * as a macro for use in global variable initializers. paulo@0: */ paulo@0: #define LJITOFIX(f) ((LJFixed)((f) << 16)) paulo@0: paulo@0: paulo@0: typedef unsigned int LJBits; paulo@0: paulo@0: #endif paulo@0: