sgdk
|
Misc tools methods. More...
Go to the source code of this file.
Defines | |
#define | COMPRESSION_NONE 0 |
No compression. | |
#define | COMPRESSION_APLIB 1 |
Use aplib (appack or sixpack) compression scheme. | |
#define | COMPRESSION_LZ4W 2 |
Use LZ4W compression scheme. | |
Typedefs | |
typedef s16 | _comparatorCallback (void *o1, void *o2) |
Callback for QSort comparaison. | |
Functions | |
void | setRandomSeed (u16 seed) |
Set the randomizer seed (to allow reproductible value if we are lucky with HV counter :p) | |
u16 | random () |
Returns a random u16 integer value. | |
u32 | getFPS () |
fix32 | getFPS_f () |
u16 | kprintf (const char *fmt,...) __attribute__((format(printf |
Composes a string with the same text that would be printed if format was used on printf, but instead of being printed to screen, the content is printed in KMod console. | |
u16 void | KLog (char *text) |
KDebug log helper methods. | |
void | KLog_U1 (char *t1, u32 v1) |
void | KLog_U2 (char *t1, u32 v1, char *t2, u32 v2) |
void | KLog_U3 (char *t1, u32 v1, char *t2, u32 v2, char *t3, u32 v3) |
void | KLog_U4 (char *t1, u32 v1, char *t2, u32 v2, char *t3, u32 v3, char *t4, u32 v4) |
void | KLog_U1_ (char *t1, u32 v1, char *t2) |
void | KLog_U2_ (char *t1, u32 v1, char *t2, u32 v2, char *t3) |
void | KLog_U3_ (char *t1, u32 v1, char *t2, u32 v2, char *t3, u32 v3, char *t4) |
void | KLog_U4_ (char *t1, u32 v1, char *t2, u32 v2, char *t3, u32 v3, char *t4, u32 v4, char *t5) |
void | KLog_U1x (u16 minSize, char *t1, u32 v1) |
void | KLog_U2x (u16 minSize, char *t1, u32 v1, char *t2, u32 v2) |
void | KLog_U3x (u16 minSize, char *t1, u32 v1, char *t2, u32 v2, char *t3, u32 v3) |
void | KLog_U4x (u16 minSize, char *t1, u32 v1, char *t2, u32 v2, char *t3, u32 v3, char *t4, u32 v4) |
void | KLog_U1x_ (u16 minSize, char *t1, u32 v1, char *t2) |
void | KLog_U2x_ (u16 minSize, char *t1, u32 v1, char *t2, u32 v2, char *t3) |
void | KLog_U3x_ (u16 minSize, char *t1, u32 v1, char *t2, u32 v2, char *t3, u32 v3, char *t4) |
void | KLog_U4x_ (u16 minSize, char *t1, u32 v1, char *t2, u32 v2, char *t3, u32 v3, char *t4, u32 v4, char *t5) |
void | KLog_S1 (char *t1, s32 v1) |
void | KLog_S2 (char *t1, s32 v1, char *t2, s32 v2) |
void | KLog_S3 (char *t1, s32 v1, char *t2, s32 v2, char *t3, s32 v3) |
void | KLog_S4 (char *t1, s32 v1, char *t2, s32 v2, char *t3, s32 v3, char *t4, s32 v4) |
void | KLog_S1_ (char *t1, s32 v1, char *t2) |
void | KLog_S2_ (char *t1, s32 v1, char *t2, s32 v2, char *t3) |
void | KLog_S3_ (char *t1, s32 v1, char *t2, s32 v2, char *t3, s32 v3, char *t4) |
void | KLog_S4_ (char *t1, s32 v1, char *t2, s32 v2, char *t3, s32 v3, char *t4, s32 v4, char *t5) |
void | KLog_S1x (u16 minSize, char *t1, s32 v1) |
void | KLog_S2x (u16 minSize, char *t1, s32 v1, char *t2, s32 v2) |
void | KLog_S3x (u16 minSize, char *t1, s32 v1, char *t2, s32 v2, char *t3, s32 v3) |
void | KLog_S4x (u16 minSize, char *t1, s32 v1, char *t2, s32 v2, char *t3, s32 v3, char *t4, s32 v4) |
void | KLog_f1 (char *t1, fix16 v1) |
void | KLog_f2 (char *t1, fix16 v1, char *t2, fix16 v2) |
void | KLog_f3 (char *t1, fix16 v1, char *t2, fix16 v2, char *t3, fix16 v3) |
void | KLog_f4 (char *t1, fix16 v1, char *t2, fix16 v2, char *t3, fix16 v3, char *t4, fix16 v4) |
void | KLog_f1x (s16 numDec, char *t1, fix16 v1) |
void | KLog_f2x (s16 numDec, char *t1, fix16 v1, char *t2, fix16 v2) |
void | KLog_f3x (s16 numDec, char *t1, fix16 v1, char *t2, fix16 v2, char *t3, fix16 v3) |
void | KLog_f4x (s16 numDec, char *t1, fix16 v1, char *t2, fix16 v2, char *t3, fix16 v3, char *t4, fix16 v4) |
void | KLog_F1 (char *t1, fix32 v1) |
void | KLog_F2 (char *t1, fix32 v1, char *t2, fix32 v2) |
void | KLog_F3 (char *t1, fix32 v1, char *t2, fix32 v2, char *t3, fix32 v3) |
void | KLog_F4 (char *t1, fix32 v1, char *t2, fix32 v2, char *t3, fix32 v3, char *t4, fix32 v4) |
void | KLog_F1x (s16 numDec, char *t1, fix32 v1) |
void | KLog_F2x (s16 numDec, char *t1, fix32 v1, char *t2, fix32 v2) |
void | KLog_F3x (s16 numDec, char *t1, fix32 v1, char *t2, fix32 v2, char *t3, fix32 v3) |
void | KLog_F4x (s16 numDec, char *t1, fix32 v1, char *t2, fix32 v2, char *t3, fix32 v3, char *t4, fix32 v4) |
Bitmap * | allocateBitmap (const Bitmap *bitmap) |
Allocate a new Bitmap structure which can receive unpacked bitmap data of the specified Bitmap. There is no memory allocated for the palette data as it assumes to always use a reference for Palette field. | |
Bitmap * | allocateBitmapEx (u16 width, u16 heigth) |
Allocate a new Bitmap structure which can receive the bitmap data for the specified Bitmap dimension. There is no memory allocated for the palette data as it assumes to always use a reference for Palette field. | |
TileSet * | allocateTileSet (const TileSet *tileset) |
Allocate TileSet structure which can receive unpacked tiles data of the specified TileSet. | |
TileSet * | allocateTileSetEx (u16 numTile) |
Allocate a new TileSet structure which can receive the data for the specified number of tile. | |
TileMap * | allocateTileMap (const TileMap *tilemap) |
Allocate TileMap structure which can receive unpacked tilemap data of the specified TileMap. | |
TileMap * | allocateTileMapEx (u16 width, u16 heigth) |
Allocate a new TileMap structure which can receive tilemap data for the specified TileMap dimension. | |
Image * | allocateImage (const Image *image) |
Allocate Image structure which can receive unpacked image data of the specified Image. There is no memory allocated for the palette data as it assumes to always use a reference for Palette field. | |
Map * | allocateMap (const MapDefinition *mapDef) |
Allocate Map structure which can receive unpacked data of the specified MapDefinition. | |
Bitmap * | unpackBitmap (const Bitmap *src, Bitmap *dest) |
Unpack the specified source Bitmap and return result in a new allocated Bitmap. | |
TileSet * | unpackTileSet (const TileSet *src, TileSet *dest) |
Unpack the specified TileSet structure and return result in a new allocated TileSet. | |
TileMap * | unpackTileMap (const TileMap *src, TileMap *dest) |
Unpack the specified TileMap structure and return result in a new allocated TileMap. | |
Image * | unpackImage (const Image *src, Image *dest) |
Unpack the specified Image structure and return result in a new allocated Image. | |
u32 | unpack (u16 compression, u8 *src, u8 *dest) |
Unpack the specified source data buffer in the specified destination buffer. if source is not packed then nothing is done. | |
u32 | aplib_unpack (u8 *src, u8 *dest) |
Unpack (aplib packer) the specified source data buffer in the specified destination buffer. | |
u32 | lz4w_unpack (const u8 *src, u8 *dest) |
Unpack (LZ4W) the specified source data buffer in the specified destination buffer. | |
void | qsort_u8 (u8 *data, u16 left, u16 right) |
Quick sort algo on u8 data array. | |
void | qsort_s8 (s8 *data, u16 left, u16 right) |
Quick sort algo on s8 data array. | |
void | qsort_u16 (u16 *data, u16 left, u16 right) |
Quick sort algo on u16 data array. | |
void | qsort_s16 (s16 *data, u16 left, u16 right) |
Quick sort algo on s16 data array. | |
void | qsort_u32 (u32 *data, u16 left, u16 right) |
Quick sort algo on u32 data array. | |
void | qsort_s32 (s32 *data, u16 left, u16 right) |
Quick sort algo on s32 data array. | |
void | qsort (void **data, u16 len, _comparatorCallback *cb) |
Quick sort algo on array of pointer (object) |
Misc tools methods.
This unit provides some misc tools methods as getFPS(), unpack()...
typedef s16 _comparatorCallback(void *o1, void *o2) |
Callback for QSort comparaison.
This callback is used to compare 2 objects.
Return value should be:
< 0 if o1 is below o2
= 0 if o1 is equal to o2
> 0 if o1 is above o2
Allocate a new Bitmap structure which can receive the bitmap data for the specified Bitmap dimension.
There is no memory allocated for the palette data as it assumes to always use a reference for Palette field.
width | Width in pixel of the bitmap structure we want to allocate. |
heigth | heigth in pixel of the bitmap structure we want to allocate. |
Map* allocateMap | ( | const MapDefinition * | mapDef | ) |
Allocate Map structure which can receive unpacked data of the specified MapDefinition.
mapDef | Source MapDefinition we want to allocate Map object for. |
Allocate a new TileSet structure which can receive the data for the specified number of tile.
numTile | Number of tile this tileset can contain |
Unpack (aplib packer) the specified source data buffer in the specified destination buffer.
src | Source data buffer containing the packed data (aplib packer) to unpack. |
dest | Destination buffer where to store unpacked data, be sure to allocate enough space. |
u32 getFPS | ( | ) |
fix32 getFPS_f | ( | ) |
u16 void KLog | ( | char * | text | ) |
KDebug log helper methods.
u16 kprintf | ( | const char * | fmt, |
... | |||
) |
Composes a string with the same text that would be printed if format was used on printf, but instead of being printed to screen, the content is printed in KMod console.
fmt | C string that contains the text to be written to destination string. It can optionally contain embedded format specifiers. |
... | (additional arguments) Depending on the format string, the function may expect a sequence of additional arguments, each containing a value to be used to replace a format specifier in the format string. |
There should be at least as many of these arguments as the number of values specified in the format specifiers.
Additional arguments are ignored by the function.
Copy the string pointed by 'fmt' param to KMod console.
If 'fmt' includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
Note that internally a buffer of 255 characters is allocated so consider this limitation !
Unpack (LZ4W) the specified source data buffer in the specified destination buffer.
src | Source data buffer containing the packed data (LZ4W packed) to unpack. |
dest | Destination buffer where to store unpacked data, be sure to allocate enough space. The size of unpacked data is contained in the first 4 bytes of 'src'. |
void qsort | ( | void ** | data, |
u16 | len, | ||
_comparatorCallback * | cb | ||
) |
Quick sort algo on array of pointer (object)
data | array of pointer (pointer of object to sort). |
len | number of element in the data array |
cb | comparator callback used to compare 2 objects. |
Quick sort algo on s16 data array.
data | s16 data pointer. |
left | left index (should be 0). |
right | right index (should be table size - 1). |
Quick sort algo on s32 data array.
data | s32 data pointer. |
left | left index (should be 0). |
right | right index (should be table size - 1). |
Quick sort algo on s8 data array.
data | s8 data pointer. |
left | left index (should be 0). |
right | right index (should be table size - 1). |
Quick sort algo on u16 data array.
data | u16 data pointer. |
left | left index (should be 0). |
right | right index (should be table size - 1). |
Quick sort algo on u32 data array.
data | u32 data pointer. |
left | left index (should be 0). |
right | right index (should be table size - 1). |
Quick sort algo on u8 data array.
data | u8 data pointer. |
left | left index (should be 0). |
right | right index (should be table size - 1). |
Unpack the specified source data buffer in the specified destination buffer.
if source is not packed then nothing is done.
compression | compression type, accepted values: COMPRESSION_APLIB COMPRESSION_LZ4W |
src | Source data buffer containing the packed data to unpack. |
dest | Destination buffer where to store unpacked data, be sure to allocate enough space. |
Unpack the specified source Bitmap and return result in a new allocated Bitmap.
src | bitmap to unpack. |
dest | Destination bitmap where to store unpacked data, be sure to allocate enough space in image buffer. If set to NULL then a dynamic allocated Bitmap is returned. |
Unpack the specified Image structure and return result in a new allocated Image.
src | image to unpack. |
dest | Destination Image where to store unpacked data. If set to NULL then a dynamic allocated Image is returned. |
Unpack the specified TileMap structure and return result in a new allocated TileMap.
src | tilemap to unpack. |
dest | Destination tilemap where to store unpacked data, be sure to allocate enough space in tiles and tilemap buffer. If set to NULL then a dynamic allocated TileMap is returned. |
Unpack the specified TileSet structure and return result in a new allocated TileSet.
src | tiles to unpack. |
dest | Destination TileSet structure where to store unpacked data, be sure to allocate enough space in tiles and tilemap buffer. If set to NULL then a dynamic allocated TileSet is returned. |