Updated lerp6 and lerp16 (LinEar inteRPolation) to use the new int64 header so that it can be used with FIXMATH_NO_64BIT.

Included "int64.h" in "fixmath.h" so that 64-bit integer support is now part of the libraries functionality.
This commit is contained in:
flatmush 2011-03-03 11:51:10 +00:00
parent cc1e97463e
commit 5fd33d1f98
3 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,5 @@
#include "fix16.h"
#include "int64.h"
@ -219,23 +220,21 @@ fix16_t fix16_sdiv(fix16_t inArg0, fix16_t inArg1) {
#ifndef FIXMATH_NO_64BIT
fix16_t fix16_lerp8(fix16_t inArg0, fix16_t inArg1, uint8_t inFract) {
int64_t tempOut;
tempOut = ((int64_t)inArg0 * (256 - inFract));
tempOut += ((int64_t)inArg1 * inFract);
tempOut >>= 8;
return (fix16_t)tempOut;
int64_t tempOut = int64_mul_i32_i32(inArg0, ((1 << 8) - inFract));
tempOut = int64_add(tempOut, int64_mul_i32_i32(inArg1, inFract));
tempOut = int64_shift(tempOut, -8);
return (fix16_t)int64_lo(tempOut);
}
fix16_t fix16_lerp16(fix16_t inArg0, fix16_t inArg1, uint16_t inFract) {
int64_t tempOut;
tempOut = ((int64_t)inArg0 * (fix16_one - inFract));
tempOut += ((int64_t)inArg1 * inFract);
tempOut >>= 16;
return (fix16_t)tempOut;
int64_t tempOut = int64_mul_i32_i32(inArg0, ((1 << 16) - inFract));
tempOut = int64_add(tempOut, int64_mul_i32_i32(inArg1, inFract));
tempOut = int64_shift(tempOut, -16);
return (fix16_t)int64_lo(tempOut);
}
#ifndef FIXMATH_NO_64BIT
fix16_t fix16_lerp32(fix16_t inArg0, fix16_t inArg1, uint32_t inFract) {
int64_t tempOut;
tempOut = ((int64_t)inArg0 * (0 - inFract));

View File

@ -72,11 +72,11 @@ extern fix16_t fix16_sdiv(fix16_t inArg0, fix16_t inArg1);
#ifndef FIXMATH_NO_64BIT
/*! Returns the linear interpolation: (inArg0 * (1 - inFract)) + (inArg1 * inFract)
*/
extern fix16_t fix16_lerp8(fix16_t inArg0, fix16_t inArg1, uint8_t inFract);
extern fix16_t fix16_lerp16(fix16_t inArg0, fix16_t inArg1, uint16_t inFract);
#ifndef FIXMATH_NO_64BIT
extern fix16_t fix16_lerp32(fix16_t inArg0, fix16_t inArg1, uint32_t inFract);
#endif

View File

@ -12,6 +12,7 @@ extern "C"
*/
#include "uint32.h"
#include "int64.h"
#include "fract32.h"
#include "fix16.h"