libtonc
Miscellaneous routines

Modules

 DMA
 
 Timer
 

Macros

#define STR(x)   #x
 
#define XSTR(x)   STR(x)
 Create text string from a literal.
 

Variables

const u8 oam_sizes [3][4][2]
 
const BG_AFFINE bg_aff_default
 
COLORvid_page
 
int __qran_seed
 

Sector checking

u32 octant (int x, int y)
 Get the octant that (x, y) is in.
 
u32 octant_rot (int x0, int y0)
 Get the rotated octant that (x, y) is in.
 

Random numbers

int sqran (int seed)
 Quick (and very dirty) pseudo-random number generator.
 
INLINE int qran (void)
 Quick (and very dirty) pseudo-random number generator.
 
INLINE int qran_range (int min, int max)
 Ranged random number.
 
#define QRAN_SHIFT   15
 Quick (and very dirty) pseudo-random number generator.
 
#define QRAN_MASK   ((1<<QRAN_SHIFT)-1)
 Quick (and very dirty) pseudo-random number generator.
 
#define QRAN_MAX   QRAN_MASK
 Quick (and very dirty) pseudo-random number generator.
 

Inline assembly

#define ASM_CMT(str)   asm volatile("@# " str)
 Assembly comment.
 
#define ASM_BREAK()   asm volatile("\tmov\t\tr11, r11")
 No$gba breakpoint.
 
#define ASM_NOP()   asm volatile("\tnop")
 No-op; wait a bit.
 

Detailed Description

Macro Definition Documentation

◆ QRAN_MASK

#define QRAN_MASK   ((1<<QRAN_SHIFT)-1)

Quick (and very dirty) pseudo-random number generator.

Returns
random in range [0,8000h>

◆ QRAN_MAX

#define QRAN_MAX   QRAN_MASK

Quick (and very dirty) pseudo-random number generator.

Returns
random in range [0,8000h>

◆ QRAN_SHIFT

#define QRAN_SHIFT   15

Quick (and very dirty) pseudo-random number generator.

Returns
random in range [0,8000h>

Function Documentation

◆ octant()

u32 octant ( int  x,
int  y 
)

Get the octant that (x, y) is in.

This function divides the circle in 8 parts. The angle starts at the y=0 line and then moves in the direction of the x=0 line. On the screen, this would be like starting at the 3 o'clock position and moving clockwise

◆ octant_rot()

u32 octant_rot ( int  x0,
int  y0 
)

Get the rotated octant that (x, y) is in.

Like octant() but with a twist. The 0-octant starts 22.5° earlier so that 3 o'clock falls in the middle of octant 0, instead of at its start. This can be useful for 8 directional pointing.

◆ qran()

INLINE int qran ( void  )

Quick (and very dirty) pseudo-random number generator.

Returns
random in range [0,8000h>

References QRAN_MAX.

Referenced by qran_range().

◆ qran_range()

INLINE int qran_range ( int  min,
int  max 
)

Ranged random number.

Returns
random in range [min, max>
Note
(max-min) must be lower than 8000h

References max(), min(), qran(), and QRAN_SHIFT.

◆ sqran()

int sqran ( int  seed)

Quick (and very dirty) pseudo-random number generator.

Returns
random in range [0,8000h>

References sqran().

Referenced by sqran().