fix remapping behavior. Remapping is only necessary if we are rendering on the workbe...
[AROS-Contrib.git] / Games / Doom / m_fixed.c
bloba0c61ba2de9c9a5f82f5b19de0bd5036e48b74bf
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id$
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 //
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
15 // for more details.
17 // $Log$
18 // Revision 1.2 2002/04/27 09:51:47 hkiel
19 // reversed order of FixedDiv() and helper function FixedDiv2() to avoid
20 // implicit prototype
22 // Revision 1.1 2000/02/29 18:21:04 stegerg
23 // Doom port based on ADoomPPC. Read README.AROS!
26 // DESCRIPTION:
27 // Fixed point implementation.
29 //-----------------------------------------------------------------------------
32 static const char
33 rcsid[] = "$Id$";
35 #include "stdlib.h"
37 #include "doomtype.h"
38 #include "i_system.h"
40 #ifdef __GNUG__
41 #pragma implementation "m_fixed.h"
42 #endif
43 #include "m_fixed.h"
48 // Fixme. __USE_C_FIXED__ or something.
50 fixed_t
51 FixedMul
52 ( fixed_t a,
53 fixed_t b )
55 return ((long long) a * (long long) b) >> FRACBITS;
61 // FixedDiv, C version.
64 fixed_t
65 FixedDiv2
66 ( fixed_t a,
67 fixed_t b )
69 #if 0
70 long long c;
71 c = ((long long)a<<16) / ((long long)b);
72 return (fixed_t) c;
73 #else
75 double c;
77 c = ((double)a) / ((double)b) * FRACUNIT;
79 if (c >= 2147483648.0 || c < -2147483648.0)
80 I_Error("FixedDiv: divide by zero");
81 return (fixed_t) c;
82 #endif
87 fixed_t
88 FixedDiv
89 ( fixed_t a,
90 fixed_t b )
92 if ( (abs(a)>>14) >= abs(b))
93 return (a^b)<0 ? MININT : MAXINT;
94 return FixedDiv2 (a,b);