libtonc
Tiled Backgrounds

Macros

#define CBB_CLEAR(cbb)   memset32(&tile_mem[cbb], 0, CBB_SIZE/4)
 
#define SBB_CLEAR(sbb)   memset32(&se_mem[sbb], 0, SBB_SIZE/4)
 
#define SBB_CLEAR_ROW(sbb, row)    memset32(&se_mem[sbb][(row)*32], 0, 32/2)
 
#define __BG_TYPES   ((0x0C7F<<16)|(0x0C40))
 
#define BG_IS_AFFINE(n)   ( (__BG_TYPES>>(4*(REG_DISPCNT&7)+(n) ))&1 )
 
#define BG_IS_AVAIL(n)   ( (__BG_TYPES>>(4*(REG_DISPCNT&7)+(n)+16))&1 )
 

Functions

INLINE void se_fill (SCR_ENTRY *sbb, SCR_ENTRY se)
 Fill screenblock sbb with se.
 
INLINE void se_plot (SCR_ENTRY *sbb, int x, int y, SCR_ENTRY se)
 Plot a screen entry at (x,y) of screenblock sbb.
 
INLINE void se_rect (SCR_ENTRY *sbb, int left, int top, int right, int bottom, SCR_ENTRY se)
 Fill a rectangle on sbb with se.
 
INLINE void se_frame (SCR_ENTRY *sbb, int left, int top, int right, int bottom, SCR_ENTRY se)
 Create a border on sbb with se.
 
INLINE void se_hline (SCR_ENTRY *sbb, int x0, int x1, int y, SCR_ENTRY se)
 Draw a horizontal line on sbb with se.
 
INLINE void se_vline (SCR_ENTRY *sbb, int x, int y0, int y1, SCR_ENTRY se)
 Draw a vertical line on sbb with se.
 
void se_window (SCR_ENTRY *sbb, int left, int top, int right, int bottom, SCR_ENTRY se0)
 Create a framed rectangle.
 
INLINE void bg_aff_set (BG_AFFINE *bgaff, FIXED pa, FIXED pb, FIXED pc, FIXED pd)
 Set the elements of an bg affine matrix.
 
INLINE void bg_aff_identity (BG_AFFINE *bgaff)
 Set an bg affine matrix to the identity matrix.
 
INLINE void bg_aff_scale (BG_AFFINE *bgaff, FIXED sx, FIXED sy)
 Set an bg affine matrix for scaling.
 
INLINE void bg_aff_shearx (BG_AFFINE *bgaff, FIXED hx)
 
INLINE void bg_aff_sheary (BG_AFFINE *bgaff, FIXED hy)
 
void bg_aff_rotate (BG_AFFINE *bgaff, u16 alpha)
 Set bg matrix to counter-clockwise rotation.
 
void bg_aff_rotscale (BG_AFFINE *bgaff, int sx, int sy, u16 alpha)
 Set bg matrix to 2d scaling, then counter-clockwise rotation.
 
void bg_aff_premul (BG_AFFINE *dst, const BG_AFFINE *src)
 Pre-multiply dst by src: D = S*D.
 
void bg_aff_postmul (BG_AFFINE *dst, const BG_AFFINE *src)
 Post-multiply dst by src: D= D*S.
 
void bg_aff_rotscale2 (BG_AFFINE *bgaff, const AFF_SRC *as)
 Set bg matrix to 2d scaling, then counter-clockwise rotation.
 
void bg_rotscale_ex (BG_AFFINE *bgaff, const AFF_SRC_EX *asx)
 Set bg affine matrix to a rot/scale around an arbitrary point.
 

Detailed Description

Function Documentation

◆ bg_aff_rotate()

void bg_aff_rotate ( BG_AFFINE bgaff,
u16  alpha 
)

Set bg matrix to counter-clockwise rotation.

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

References lu_cos(), and lu_sin().

◆ bg_aff_rotscale()

void bg_aff_rotscale ( BG_AFFINE bgaff,
int  sx,
int  sy,
u16  alpha 
)

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

Parameters
bgaffObject 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().

◆ bg_aff_rotscale2()

void bg_aff_rotscale2 ( BG_AFFINE bgaff,
const AFF_SRC as 
)

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

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

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

◆ bg_rotscale_ex()

void bg_rotscale_ex ( BG_AFFINE bgaff,
const AFF_SRC_EX asx 
)

Set bg affine matrix to a rot/scale around an arbitrary point.

Rotate and scale round an arbitrary point using the asx data.

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

References AFF_SRC_EX::alpha, lu_cos(), lu_sin(), 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.

◆ se_window()

void se_window ( SCR_ENTRY sbb,
int  left,
int  top,
int  right,
int  bottom,
SCR_ENTRY  se0 
)

Create a framed rectangle.

In contrast to se_frame(), se_frame_ex() uses nine tiles starting at se0 for the frame, which indicate the borders and center for the window.

Note
Rectangle is nor normalized.