diff options
author | clone2727 | 2011-07-18 16:04:39 -0700 |
---|---|---|
committer | clone2727 | 2011-07-18 16:04:39 -0700 |
commit | 6370984b2238f90aa3e03ac70725b3cfc671d581 (patch) | |
tree | 031784ab3bfc44bff048e3b4d9b9e1e969a22af8 /common/math.h | |
parent | 85a056f3824151e4f1838de2ca3aeb7e824c32b8 (diff) | |
parent | 26d15ce675447070ed5ba99a3b21253b1a4459f7 (diff) | |
download | scummvm-rg350-6370984b2238f90aa3e03ac70725b3cfc671d581.tar.gz scummvm-rg350-6370984b2238f90aa3e03ac70725b3cfc671d581.tar.bz2 scummvm-rg350-6370984b2238f90aa3e03ac70725b3cfc671d581.zip |
Merge pull request #50 from clone2727/bink
Add support for Bink video to SCUMM HE
Diffstat (limited to 'common/math.h')
-rw-r--r-- | common/math.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/common/math.h b/common/math.h new file mode 100644 index 0000000000..2ad71cee65 --- /dev/null +++ b/common/math.h @@ -0,0 +1,83 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +// Based on eos' math code + +#ifndef COMMON_MATH_H +#define COMMON_MATH_H + +#include "common/scummsys.h" + +#ifndef M_SQRT1_2 + #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#endif + +#ifndef M_PI + #define M_PI 3.14159265358979323846 +#endif + +#ifndef FLT_MIN + #define FLT_MIN 1E-37 +#endif + +#ifndef FLT_MAX + #define FLT_MAX 1E+37 +#endif + +namespace Common { + +/** A complex number. */ +struct Complex { + float re, im; +}; + +const float *getSineTable(int bits); +const float *getCosineTable(int bits); + +// See http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogLookup +static const char LogTable256[256] = { +#define LT(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n + -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + LT(4), LT(5), LT(5), LT(6), LT(6), LT(6), LT(6), + LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7) +}; + +inline uint32 log2(uint32 v) { + register uint32 t, tt; + + if ((tt = v >> 16)) + return (t = tt >> 8) ? 24 + LogTable256[t] : 16 + LogTable256[tt]; + else + return (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v]; +} + +inline float rad2deg(float rad) { + return rad * 180.0 / M_PI; +} + +inline float deg2rad(float deg) { + return deg * M_PI / 180.0; +} + +} // End of namespace Common + +#endif // COMMON_MATH_H |