libtonc
Look-up tables

Tonc's internal look-up tables and related routines. More...

Macros

#define SIN_LUT_SIZE   514
 
#define DIV_LUT_SIZE   257
 

Functions

INLINE s32 lu_sin (uint theta)
 Look-up a sine value (2π = 0x10000)
 
INLINE s32 lu_cos (uint theta)
 Look-up a cosine value (2π = 0x10000)
 
INLINE uint lu_div (uint x)
 Look-up a division value between 0 and 255.
 
INLINE int lu_lerp32 (const s32 lut[], uint x, const uint shift)
 Linear interpolator for 32bit LUTs.
 
INLINE int lu_lerp16 (const s16 lut[], uint x, const uint shift)
 As lu_lerp32, but for 16bit LUTs.
 

Variables

s32 div_lut [257]
 
s16 sin_lut [514]
 

Detailed Description

Tonc's internal look-up tables and related routines.

Function Documentation

◆ lu_cos()

INLINE s32 lu_cos ( uint  theta)

Look-up a cosine value (2π = 0x10000)

Parameters
thetaAngle in [0,FFFFh] range
Returns
.12f cosine value

Referenced by bg_aff_rotate(), bg_aff_rotscale(), bg_aff_rotscale2(), bg_rotscale_ex(), obj_aff_rotate(), obj_aff_rotscale(), obj_aff_rotscale2(), and obj_rotscale_ex().

◆ lu_div()

INLINE uint lu_div ( uint  x)

Look-up a division value between 0 and 255.

Parameters
xreciprocal to look up.
Returns
1/x (.16f)

Referenced by clr_rgbscale().

◆ lu_lerp32()

INLINE int lu_lerp32 ( const s32  lut[],
uint  x,
const uint  shift 
)

Linear interpolator for 32bit LUTs.

A lut is essentially the discrete form of a function, f(x). You can get values for non-integer x via (linear) interpolation between f(x) and f(x+1).

Parameters
lutThe LUT to interpolate from.
xFixed point number to interpolate at.
shiftNumber of fixed-point bits of x.

◆ lu_sin()

INLINE s32 lu_sin ( uint  theta)

Look-up a sine value (2π = 0x10000)

Parameters
thetaAngle in [0,FFFFh] range
Returns
.12f sine value

Referenced by bg_aff_rotate(), bg_aff_rotscale(), bg_aff_rotscale2(), bg_rotscale_ex(), obj_aff_rotate(), obj_aff_rotscale(), obj_aff_rotscale2(), and obj_rotscale_ex().