From 2273d9a80f4a087219d3d5fbdfa60037aabfecbf Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 30 Dec 2016 20:39:11 -0800 Subject: roto: some fixed point macro cleanups --- modules/roto/roto.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/roto/roto.c b/modules/roto/roto.c index 21e68b7..bbf8bdb 100644 --- a/modules/roto/roto.c +++ b/modules/roto/roto.c @@ -8,13 +8,14 @@ /* Copyright (C) 2016 Vito Caputo */ /* Some defines for the fixed-point stuff in render(). */ -#define FIXED_TRIG_LUT_SIZE 4096 /* size of the cos/sin look-up tables */ -#define FIXED_BITS 12 /* fractional bits */ -#define FIXED_EXP 4096 /* 2^FIXED_BITS */ -#define FIXED_COS(_rad) costab[_rad % FIXED_TRIG_LUT_SIZE] -#define FIXED_SIN(_rad) sintab[_rad % FIXED_TRIG_LUT_SIZE] -#define FIXED_MULT(_a, _b) ((_a * _b) >> FIXED_BITS) -#define FIXED_NEW(_i) (_i << FIXED_BITS) +#define FIXED_TRIG_LUT_SIZE 4096 /* size of the cos/sin look-up tables */ +#define FIXED_BITS 11 /* fractional bits */ +#define FIXED_EXP (1 << FIXED_BITS) /* 2^FIXED_BITS */ +#define FIXED_MASK (FIXED_EXP - 1) /* fractional part mask */ +#define FIXED_COS(_rad) costab[(_rad) % FIXED_TRIG_LUT_SIZE] +#define FIXED_SIN(_rad) sintab[(_rad) % FIXED_TRIG_LUT_SIZE] +#define FIXED_MULT(_a, _b) (((_a) * (_b)) >> FIXED_BITS) +#define FIXED_NEW(_i) ((_i) << FIXED_BITS) #define FIXED_TO_INT(_f) ((_f) >> FIXED_BITS) -- cgit v1.2.3