libtonc
|
Modules | |
Miscellaneous routines | |
DMA | |
Macros | |
#define | countof(_array) ( sizeof(_array)/sizeof(_array[0]) ) |
Get the number of elements in an array. | |
#define | SND_RATE(note, oct) ( 2048-(__snd_rates[note]>>(4+(oct))) ) |
Gives the period of a note for the tone-gen registers. | |
Enumerations | |
enum | eSndNoteId { NOTE_C =0 , NOTE_CIS , NOTE_D , NOTE_DIS , NOTE_E , NOTE_F , NOTE_FIS , NOTE_G , NOTE_GIS , NOTE_A , NOTE_BES , NOTE_B } |
Functions | |
INLINE uint | align (uint x, uint width) |
Align x to the next multiple of width. | |
INLINE void | profile_start (void) |
Start a profiling run. | |
INLINE uint | profile_stop (void) |
Stop a profiling run and return the time since its start. | |
Variables | |
const uint | __snd_rates [12] |
Copying and filling routines | |
void * | tonccpy (void *dst, const void *src, uint size) |
VRAM-safe cpy. | |
void * | __toncset (void *dst, u32 fill, uint size) |
VRAM-safe memset, internal routine. | |
INLINE void * | toncset (void *dst, u8 src, uint count) |
VRAM-safe memset, byte version. Size in bytes. | |
INLINE void * | toncset16 (void *dst, u16 src, uint count) |
VRAM-safe memset, halfword version. Size in hwords. | |
INLINE void * | toncset32 (void *dst, u32 src, uint count) |
VRAM-safe memset, word version. Size in words. | |
void | memset16 (void *dst, u16 hw, uint hwcount) |
Fastfill for halfwords, analogous to memset() | |
void | memcpy16 (void *dst, const void *src, uint hwcount) |
Copy for halfwords. | |
IWRAM_CODE void | memset32 (void *dst, u32 wd, uint wdcount) |
Fast-fill by words, analogous to memset() | |
IWRAM_CODE void | memcpy32 (void *dst, const void *src, uint wdcount) |
Fast-copy by words. | |
#define | GRIT_CPY(dst, name) memcpy16(dst, name, name##Len/2) |
Simplified copier for GRIT-exported data. | |
Repeated-value creators | |
These function take a hex-value and duplicate it to all fields, like 0x88 -> 0x88888888. | |
INLINE u16 | dup8 (u8 x) |
Duplicate a byte to form a halfword: 0x12 -> 0x1212. | |
INLINE u32 | dup16 (u16 x) |
Duplicate a halfword to form a word: 0x1234 -> 0x12341234. | |
INLINE u32 | quad8 (u8 x) |
Quadruple a byte to form a word: 0x12 -> 0x12121212. | |
INLINE u32 | octup (u8 x) |
Octuple a nybble to form a word: 0x1 -> 0x11111111. | |
Packing routines. | |
INLINE u16 | bytes2hword (u8 b0, u8 b1) |
Pack 2 bytes into a word. Little-endian order. | |
INLINE u32 | bytes2word (u8 b0, u8 b1, u8 b2, u8 b3) |
Pack 4 bytes into a word. Little-endian order. | |
INLINE u32 | hword2word (u16 h0, u16 h1) |
Pack 2 bytes into a word. Little-endian order. | |
#define SND_RATE | ( | note, | |
oct | |||
) | ( 2048-(__snd_rates[note]>>(4+(oct))) ) |
Gives the period of a note for the tone-gen registers.
GBA sound range: 8 octaves: [-2, 5]; 8*12= 96 notes (kinda).
note | ID (range: [0,11>). See eSndNoteId. |
oct | octave (range [-2,4)>). |
void * __toncset | ( | void * | dst, |
u32 | fill, | ||
uint | size | ||
) |
VRAM-safe memset, internal routine.
This version mimics memset in functionality, with the benefit of working for VRAM as well. It is also slightly faster than the original memset.
dst | Destination pointer. |
fill | Word to fill with. |
size | Fill-length in bytes. |
References BIT_MASK.
Referenced by toncset(), toncset16(), and toncset32().
void memcpy16 | ( | void * | dst, |
const void * | src, | ||
uint | hwcount | ||
) |
Copy for halfwords.
Uses memcpy32()
if hwn>6 and src and dst are aligned equally.
dst | Destination address. |
src | Source address. |
hwcount | Number of halfwords to fill. |
Referenced by sbmp16_blit(), and srf_pal_copy().
IWRAM_CODE void memcpy32 | ( | void * | dst, |
const void * | src, | ||
uint | wdcount | ||
) |
Fast-copy by words.
Like CpuFastFill(), only without the requirement of 32byte chunks
dst | Destination address. |
src | Source address. |
wdcount | Number of words. |
Referenced by oam_copy(), and schr4c_blit().
void memset16 | ( | void * | dst, |
u16 | hw, | ||
uint | hwcount | ||
) |
Fastfill for halfwords, analogous to memset()
Uses memset32()
if hwcount>5
dst | Destination address. |
hw | Source halfword (not address). |
hwcount | Number of halfwords to fill. |
Referenced by bmp16_frame(), bmp16_hline(), bmp16_rect(), bmp8_hline(), bmp8_rect(), sbmp16_floodfill_internal(), sbmp16_frame(), sbmp16_hline(), and sbmp16_rect().
IWRAM_CODE void memset32 | ( | void * | dst, |
u32 | wd, | ||
uint | wdcount | ||
) |
Fast-fill by words, analogous to memset()
Like CpuFastSet(), only without the requirement of 32byte chunks and no awkward store-value-in-memory-first issue.
dst | Destination address. |
wd | Fill word (not address). |
wdcount | Number of words to fill. |
Referenced by irq_init(), m3_fill(), m4_fill(), m5_fill(), schr4c_rect(), schr4r_rect(), and se_fill().
INLINE void profile_start | ( | void | ) |
Start a profiling run.
References REG_TM2CNT, REG_TM2D, REG_TM3CNT, REG_TM3D, TM_CASCADE, and TM_ENABLE.
INLINE uint profile_stop | ( | void | ) |
Stop a profiling run and return the time since its start.
References REG_TM2CNT, REG_TM2D, and REG_TM3D.
void * tonccpy | ( | void * | dst, |
const void * | src, | ||
uint | size | ||
) |
VRAM-safe cpy.
This version mimics memcpy in functionality, with the benefit of working for VRAM as well. It is also slightly faster than the original memcpy, but faster implementations can be made.
dst | Destination pointer. |
src | Source pointer. |
size | Fill-length in bytes. |
Referenced by sbmp8_blit().