aboutsummaryrefslogtreecommitdiffstats
path: root/demos/3rdparty/doom/m_fixed.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-12-24 01:00:14 +1000
committerinmarket <andrewh@inmarket.com.au>2013-12-24 01:00:14 +1000
commit39adfff2a9f73919dd09593efc38884dc2a05f40 (patch)
treef0fdf8c70ce4a1396e33927f9033049de370c56a /demos/3rdparty/doom/m_fixed.c
parent57d9c4854beefd22aa367f6a44b5da4a586632b1 (diff)
downloaduGFX-39adfff2a9f73919dd09593efc38884dc2a05f40.tar.gz
uGFX-39adfff2a9f73919dd09593efc38884dc2a05f40.tar.bz2
uGFX-39adfff2a9f73919dd09593efc38884dc2a05f40.zip
demo - DOOM the game.
Runs but not quite functional yet (requires user input to be completed). Shareware WAD file. Please read README.txt and DOOMLIC.txt
Diffstat (limited to 'demos/3rdparty/doom/m_fixed.c')
-rw-r--r--demos/3rdparty/doom/m_fixed.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/demos/3rdparty/doom/m_fixed.c b/demos/3rdparty/doom/m_fixed.c
new file mode 100644
index 00000000..4e0792d6
--- /dev/null
+++ b/demos/3rdparty/doom/m_fixed.c
@@ -0,0 +1,87 @@
+// Emacs style mode select -*- C++ -*-
+//-----------------------------------------------------------------------------
+//
+// $Id:$
+//
+// Copyright (C) 1993-1996 by id Software, Inc.
+//
+// This source is available for distribution and/or modification
+// only under the terms of the DOOM Source Code License as
+// published by id Software. All rights reserved.
+//
+// The source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
+// for more details.
+//
+// $Log:$
+//
+// DESCRIPTION:
+// Fixed point implementation.
+//
+//-----------------------------------------------------------------------------
+
+
+static const char
+rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
+
+#include "stdlib.h"
+
+#include "doomtype.h"
+#include "i_system.h"
+
+#ifdef __GNUG__
+#pragma implementation "m_fixed.h"
+#endif
+#include "m_fixed.h"
+
+
+
+
+// Fixme. __USE_C_FIXED__ or something.
+
+fixed_t
+FixedMul
+( fixed_t a,
+ fixed_t b )
+{
+ return ((long long) a * (long long) b) >> FRACBITS;
+}
+
+
+
+//
+// FixedDiv, C version.
+//
+
+fixed_t
+FixedDiv
+( fixed_t a,
+ fixed_t b )
+{
+ if ( (abs(a)>>14) >= abs(b))
+ return (a^b)<0 ? MININT : MAXINT;
+ return FixedDiv2 (a,b);
+}
+
+
+
+fixed_t
+FixedDiv2
+( fixed_t a,
+ fixed_t b )
+{
+#if 0
+ long long c;
+ c = ((long long)a<<16) / ((long long)b);
+ return (fixed_t) c;
+#endif
+
+ double c;
+
+ c = ((double)a) / ((double)b) * FRACUNIT;
+
+ if (c >= 2147483648.0 || c < -2147483648.0)
+ I_Error("FixedDiv: divide by zero");
+ return (fixed_t) c;
+}