libtonc
Objects

Macros

#define OAM_CLEAR()   memset32(oam_mem, 0, OAM_SIZE/4)
 

Functions

void oam_init (OBJ_ATTR *obj, uint count)
 Initialize an array of count OBJ_ATTRs with with safe values.
 
INLINE void oam_copy (OBJ_ATTR *dst, const OBJ_ATTR *src, uint count)
 Copies count OAM entries from src to dst.
 
INLINE OBJ_ATTRobj_set_attr (OBJ_ATTR *obj, u16 a0, u16 a1, u16 a2)
 Set the attributes of an object.
 
INLINE void obj_set_pos (OBJ_ATTR *obj, int x, int y)
 Set the position of obj.
 
INLINE void obj_hide (OBJ_ATTR *obj)
 Hide an object.
 
INLINE void obj_unhide (OBJ_ATTR *obj, u16 mode)
 Unhide an object.
 
INLINE const u8 * obj_get_size (const OBJ_ATTR *obj)
 Get object's sizes as a byte array.
 
INLINE int obj_get_width (const OBJ_ATTR *obj)
 Get object's width.
 
INLINE int obj_get_height (const OBJ_ATTR *obj)
 Gets object's height.
 
void obj_copy (OBJ_ATTR *dst, const OBJ_ATTR *src, uint count)
 Copy attributes 0-2 in count OBJ_ATTRs.
 
void obj_hide_multi (OBJ_ATTR *obj, uint count)
 Hide an array of OBJ_ATTRs.
 
void obj_unhide_multi (OBJ_ATTR *obj, u16 mode, uint count)
 
void obj_aff_copy (OBJ_AFFINE *dst, const OBJ_AFFINE *src, uint count)
 
INLINE void obj_aff_set (OBJ_AFFINE *oaff, FIXED pa, FIXED pb, FIXED pc, FIXED pd)
 Set the elements of an object affine matrix.
 
INLINE void obj_aff_identity (OBJ_AFFINE *oaff)
 Set an object affine matrix to the identity matrix.
 
INLINE void obj_aff_scale (OBJ_AFFINE *oaff, FIXED sx, FIXED sy)
 Set an object affine matrix for scaling.
 
INLINE void obj_aff_shearx (OBJ_AFFINE *oaff, FIXED hx)
 
INLINE void obj_aff_sheary (OBJ_AFFINE *oaff, FIXED hy)
 
void obj_aff_rotate (OBJ_AFFINE *oaff, u16 alpha)
 Set obj matrix to counter-clockwise rotation.
 
void obj_aff_rotscale (OBJ_AFFINE *oaff, FIXED sx, FIXED sy, u16 alpha)
 Set obj matrix to 2d scaling, then counter-clockwise rotation.
 
void obj_aff_premul (OBJ_AFFINE *dst, const OBJ_AFFINE *src)
 Pre-multiply dst by src: D = S*D.
 
void obj_aff_postmul (OBJ_AFFINE *dst, const OBJ_AFFINE *src)
 Post-multiply dst by src: D= D*S.
 
void obj_aff_rotscale2 (OBJ_AFFINE *oaff, const AFF_SRC *as)
 Set obj matrix to 2d scaling, then counter-clockwise rotation.
 
void obj_rotscale_ex (OBJ_ATTR *obj, OBJ_AFFINE *oaff, const AFF_SRC_EX *asx)
 Rot/scale an object around an arbitrary point.
 
INLINE void obj_aff_scale_inv (OBJ_AFFINE *oa, FIXED wx, FIXED wy)
 
INLINE void obj_aff_rotate_inv (OBJ_AFFINE *oa, u16 theta)
 
INLINE void obj_aff_shearx_inv (OBJ_AFFINE *oa, FIXED hx)
 
INLINE void obj_aff_sheary_inv (OBJ_AFFINE *oa, FIXED hy)
 

Detailed Description

Function Documentation

◆ obj_aff_rotate()

void obj_aff_rotate ( OBJ_AFFINE oaff,
u16  alpha 
)

Set obj matrix to counter-clockwise rotation.

Parameters
oaffObject affine struct to set.
alphaCCW angle. full-circle is 10000h.

References lu_cos(), and lu_sin().

◆ obj_aff_rotscale()

void obj_aff_rotscale ( OBJ_AFFINE oaff,
FIXED  sx,
FIXED  sy,
u16  alpha 
)

Set obj matrix to 2d scaling, then counter-clockwise rotation.

Parameters
oaffObject affine struct to set.
sxHorizontal scale (zoom). .8 fixed point.
syVertical scale (zoom). .8 fixed point.
alphaCCW angle. full-circle is 10000h.

References lu_cos(), and lu_sin().

◆ obj_aff_rotscale2()

void obj_aff_rotscale2 ( OBJ_AFFINE oaff,
const AFF_SRC as 
)

Set obj matrix to 2d scaling, then counter-clockwise rotation.

Parameters
oaffObject affine struct to set.
asStruct with scales and angle.

References AFF_SRC::alpha, lu_cos(), lu_sin(), AFF_SRC::sx, and AFF_SRC::sy.

◆ obj_rotscale_ex()

void obj_rotscale_ex ( OBJ_ATTR obj,
OBJ_AFFINE oaff,
const AFF_SRC_EX asx 
)

Rot/scale an object around an arbitrary point.

Sets up obj and oaff for rot/scale transformation around an arbitrary point using the asx data.

Parameters
objObject to set.
oaffObject affine data to set.
asxAffine source data: screen and texture origins, scales and angle.

References AFF_SRC_EX::alpha, Div(), lu_cos(), lu_sin(), obj_set_pos(), AFF_SRC_EX::scr_x, AFF_SRC_EX::scr_y, AFF_SRC_EX::sx, AFF_SRC_EX::sy, AFF_SRC_EX::tex_x, and AFF_SRC_EX::tex_y.

◆ obj_unhide()

INLINE void obj_unhide ( OBJ_ATTR obj,
u16  mode 
)

Unhide an object.

Parameters
objObject to unhide.
modeObject mode to unhide to. Necessary because this affects the affine-ness of the object.

References BFN_SET2.