Add weapon cycling bindings for mouse and joystick buttons. Add weapon cycling bindi...
[chocolate-doom.git] / src / m_fixed.c
blobba76b36c087632eb4e6538f40d29afda5e7165c7
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // Copyright(C) 1993-1996 Id Software, Inc.
5 // Copyright(C) 2005 Simon Howard
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 // 02111-1307, USA.
22 // DESCRIPTION:
23 // Fixed point implementation.
25 //-----------------------------------------------------------------------------
29 #include "stdlib.h"
31 #include "doomtype.h"
32 #include "i_system.h"
34 #include "m_fixed.h"
39 // Fixme. __USE_C_FIXED__ or something.
41 fixed_t
42 FixedMul
43 ( fixed_t a,
44 fixed_t b )
46 return ((int64_t) a * (int64_t) b) >> FRACBITS;
52 // FixedDiv, C version.
55 fixed_t FixedDiv(fixed_t a, fixed_t b)
57 if ((abs(a) >> 14) >= abs(b))
59 return (a^b) < 0 ? INT_MIN : INT_MAX;
61 else
63 int64_t result;
65 result = ((int64_t) a << 16) / b;
67 return (fixed_t) result;