Miscellaneous routines
[Core]
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) |
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 |
#define | QRAN_MASK ((1<<QRAN_SHIFT)-1) |
#define | QRAN_MAX QRAN_MASK |
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. | |
Defines | |
#define | STR(x) #x |
#define | XSTR(x) STR(x) |
Create text string from a literal. |
Define Documentation
#define STR | ( | x | ) | #x |
Function Documentation
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
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.
INLINE int qran | ( | void | ) |
Quick (and very dirty) pseudo-random number generator.
- Returns:
- random in range [0,8000h>
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
Generated on Mon Aug 25 17:03:57 2008 for libtonc by 1.5.3