gba-trycatch

diff src/sincos.c @ 4:78d1664c2443

- fixed sin_x16/cos_x16 - added fixed point header
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Jun 2014 03:04:56 +0300
parents 8e9225853d75
children
line diff
     1.1 --- a/src/sincos.c	Sat Jun 14 01:56:58 2014 +0300
     1.2 +++ b/src/sincos.c	Sat Jun 14 03:04:56 2014 +0300
     1.3 @@ -1,4 +1,5 @@
     1.4  #include <math.h>
     1.5 +#include "fixed.h"
     1.6  #include "sincos.h"
     1.7  #include "logger.h"
     1.8  
     1.9 @@ -31,12 +32,12 @@
    1.10  
    1.11  int32_t sin_x16(int32_t radians)
    1.12  {
    1.13 -	int32_t na = (radians << 16) / (M_PI_X16 * 2);
    1.14 -	return sin_int((na >> 8) * (SINLUT_SIZE << 8));
    1.15 +	int32_t na = x16div(radians, M_PI_X16 * 2);
    1.16 +	return (sin_int((na * SINLUT_SIZE) >> 16) << 16) / SINLUT_SCALE;
    1.17  }
    1.18  
    1.19  int32_t cos_x16(int32_t radians)
    1.20  {
    1.21 -	int32_t na = (radians << 16) / (M_PI_X16 * 2);
    1.22 -	return cos_int((na >> 8) * (SINLUT_SIZE << 8));
    1.23 +	int32_t na = x16div(radians, M_PI_X16 * 2);
    1.24 +	return (cos_int((na * SINLUT_SIZE) >> 16) << 16) / SINLUT_SCALE;
    1.25  }