diff options
author | YamaArashi <shadow962@live.com> | 2016-09-18 20:25:39 -0700 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-09-18 20:25:39 -0700 |
commit | e94dd6a9c5b498d494df006a4cbcee367cdcbaac (patch) | |
tree | ed3f90deaa561044679e568426f4662163ac1fcd /src | |
parent | 854f2de277279c3f5dd37b96796f3de22522e7e3 (diff) |
decompile trigonometric functions
Diffstat (limited to 'src')
-rw-r--r-- | src/trig.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/trig.c b/src/trig.c new file mode 100644 index 000000000..cd9f39cac --- /dev/null +++ b/src/trig.c @@ -0,0 +1,35 @@ +#include "global.h" + +extern s16 gSineTable[]; +extern s16 gSineDegreeTable[]; + +// amplitude * sin(index*(π/128)) +s16 Sin(s16 index, s16 amplitude) +{ + return (amplitude * gSineTable[index]) >> 8; +} + +// amplitude * cos(index*(π/128)) +s16 Cos(s16 index, s16 amplitude) +{ + return (amplitude * gSineTable[index + 64]) >> 8; +} + +// angle in degrees +s16 Sin2(u16 angle) +{ + s32 angleMod = angle % 180; + s32 negate = ((angle / 180) & 1); + s16 value = gSineDegreeTable[angleMod]; + + if (negate) + return -value; + else + return value; +} + +// angle in degrees +s16 Cos2(u16 angle) +{ + return Sin2(angle + 90); +} |