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:
parent
cc1e97463e
commit
5fd33d1f98
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ extern "C"
|
|||
*/
|
||||
|
||||
#include "uint32.h"
|
||||
#include "int64.h"
|
||||
#include "fract32.h"
|
||||
#include "fix16.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue