sgdk
Loading...
Searching...
No Matches
tools.h
Go to the documentation of this file.
1
10#ifndef _TOOLS_H_
11#define _TOOLS_H_
12
13#include "bmp.h"
14#include "vdp_tile.h"
15#include "vdp_bg.h"
16#include "map.h"
17
18
23#define COMPRESSION_NONE 0
28#define COMPRESSION_APLIB 1
33#define COMPRESSION_LZ4W 2
34
35
46typedef s16 _comparatorCallback(void* o1, void* o2);
47
48
53void setRandomSeed(u16 seed);
58u16 random(void);
59
60
85u16 kprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
86
92void KLog(char* text);
93void KLog_U1(char* t1, u32 v1);
94void KLog_U2(char* t1, u32 v1, char* t2, u32 v2);
95void KLog_U3(char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3);
96void KLog_U4(char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4, u32 v4);
97void KLog_U1_(char* t1, u32 v1, char* t2);
98void KLog_U2_(char* t1, u32 v1, char* t2, u32 v2, char* t3);
99void KLog_U3_(char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4);
100void KLog_U4_(char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4, u32 v4, char* t5);
101void KLog_U1x(u16 minSize, char* t1, u32 v1);
102void KLog_U2x(u16 minSize, char* t1, u32 v1, char* t2, u32 v2);
103void KLog_U3x(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3);
104void KLog_U4x(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4, u32 v4);
105void KLog_U1x_(u16 minSize, char* t1, u32 v1, char* t2);
106void KLog_U2x_(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3);
107void KLog_U3x_(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4);
108void KLog_U4x_(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4, u32 v4, char* t5);
109void KLog_S1(char* t1, s32 v1);
110void KLog_S2(char* t1, s32 v1, char* t2, s32 v2);
111void KLog_S3(char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3);
112void KLog_S4(char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3, char* t4, s32 v4);
113void KLog_S1_(char* t1, s32 v1, char* t2);
114void KLog_S2_(char* t1, s32 v1, char* t2, s32 v2, char* t3);
115void KLog_S3_(char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3, char* t4);
116void KLog_S4_(char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3, char* t4, s32 v4, char* t5);
117void KLog_S1x(u16 minSize, char* t1, s32 v1);
118void KLog_S2x(u16 minSize, char* t1, s32 v1, char* t2, s32 v2);
119void KLog_S3x(u16 minSize, char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3);
120void KLog_S4x(u16 minSize, char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3, char* t4, s32 v4);
121void KLog_f1(char* t1, fix16 v1);
122void KLog_f2(char* t1, fix16 v1, char* t2, fix16 v2);
123void KLog_f3(char* t1, fix16 v1, char* t2, fix16 v2, char* t3, fix16 v3);
124void KLog_f4(char* t1, fix16 v1, char* t2, fix16 v2, char* t3, fix16 v3, char* t4, fix16 v4);
125void KLog_f1x(s16 numDec, char* t1, fix16 v1);
126void KLog_f2x(s16 numDec, char* t1, fix16 v1, char* t2, fix16 v2);
127void KLog_f3x(s16 numDec, char* t1, fix16 v1, char* t2, fix16 v2, char* t3, fix16 v3);
128void KLog_f4x(s16 numDec, char* t1, fix16 v1, char* t2, fix16 v2, char* t3, fix16 v3, char* t4, fix16 v4);
129void KLog_F1(char* t1, fix32 v1);
130void KLog_F2(char* t1, fix32 v1, char* t2, fix32 v2);
131void KLog_F3(char* t1, fix32 v1, char* t2, fix32 v2, char* t3, fix32 v3);
132void KLog_F4(char* t1, fix32 v1, char* t2, fix32 v2, char* t3, fix32 v3, char* t4, fix32 v4);
133void KLog_F1x(s16 numDec, char* t1, fix32 v1);
134void KLog_F2x(s16 numDec, char* t1, fix32 v1, char* t2, fix32 v2);
135void KLog_F3x(s16 numDec, char* t1, fix32 v1, char* t2, fix32 v2, char* t3, fix32 v3);
136void KLog_F4x(s16 numDec, char* t1, fix32 v1, char* t2, fix32 v2, char* t3, fix32 v3, char* t4, fix32 v4);
137
138
151Bitmap *allocateBitmap(const Bitmap *bitmap);
166Bitmap *allocateBitmapEx(u16 width, u16 heigth);
178TileSet *allocateTileSet(const TileSet *tileset);
202TileMap *allocateTileMap(const TileMap *tilemap);
216TileMap *allocateTileMapEx(u16 width, u16 heigth);
229Image *allocateImage(const Image *image);
241Map *allocateMap(const MapDefinition *mapDef);
242
257Bitmap *unpackBitmap(const Bitmap *src, Bitmap *dest);
272TileSet *unpackTileSet(const TileSet *src, TileSet *dest);
287TileMap *unpackTileMap(const TileMap *src, TileMap *dest);
302Image *unpackImage(const Image *src, Image *dest);
303
320u32 unpack(u16 compression, u8 *src, u8 *dest);
321
333u32 aplib_unpack(u8 *src, u8 *dest);
346u32 lz4w_unpack(const u8 *src, u8 *dest);
347
348
360void qsort_u8(u8 *data, u16 left, u16 right);
372void qsort_s8(s8 *data, u16 left, u16 right);
384void qsort_u16(u16 *data, u16 left, u16 right);
396void qsort_s16(s16 *data, u16 left, u16 right);
408void qsort_u32(u32 *data, u16 left, u16 right);
420void qsort_s32(s32 *data, u16 left, u16 right);
421
433void qsort(void** data, u16 len, _comparatorCallback* cb);
434
435
436
437#endif // _TOOLS_H_
Software bitmap engine.
MAP (large background map) management unit.
Genesis 4bpp Bitmap structure definition. Use the unpackBitmap() method to unpack if compression is ...
Definition bmp.h:161
Image structure which contains all data to define an image in a background plane. Use the unpackImag...
Definition vdp_bg.h:34
MapDefinition structure which contains data for large level background. It's optimized to encode lar...
Definition map.h:77
Map structure containing information for large background/plane update based on MapDefinition.
Definition map.h:141
TileMap structure which contains tilemap background definition. Use the unpackTileMap() method to un...
Definition vdp_tile.h:137
Tile set structure which contains tiles definition. Use the unpackTileSet() method to unpack if comp...
Definition vdp_tile.h:114
void setRandomSeed(u16 seed)
Set the randomizer seed (to allow different reproductible series)
Definition tools.c:30
Bitmap * unpackBitmap(const Bitmap *src, Bitmap *dest)
Unpack the specified source Bitmap and return result in a new allocated Bitmap.
Definition tools.c:1028
TileSet * allocateTileSet(const TileSet *tileset)
Allocate TileSet structure which can receive unpacked tiles data of the specified TileSet.
Definition tools.c:905
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,...
u32 unpack(u16 compression, u8 *src, u8 *dest)
Unpack the specified source data buffer in the specified destination buffer. if source is not packed...
Definition tools.c:1136
TileSet * unpackTileSet(const TileSet *src, TileSet *dest)
Unpack the specified TileSet structure and return result in a new allocated TileSet.
Definition tools.c:1057
s16 _comparatorCallback(void *o1, void *o2)
Callback for QSort comparaison.
Definition tools.h:46
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)
void qsort_u16(u16 *data, u16 left, u16 right)
Quick sort algo on u16 data array.
Image * allocateImage(const Image *image)
Allocate Image structure which can receive unpacked image data of the specified Image....
Definition tools.c:952
void qsort_u8(u8 *data, u16 left, u16 right)
Quick sort algo on u8 data array.
TileMap * unpackTileMap(const TileMap *src, TileMap *dest)
Unpack the specified TileMap structure and return result in a new allocated TileMap.
Definition tools.c:1084
u16 random(void)
Returns a random u16 integer value.
Definition tools.c:37
Image * unpackImage(const Image *src, Image *dest)
Unpack the specified Image structure and return result in a new allocated Image.
Definition tools.c:1112
u32 lz4w_unpack(const u8 *src, u8 *dest)
Unpack (LZ4W) the specified source data buffer in the specified destination buffer.
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.
u16 void KLog(char *text)
KDebug log helper methods.
Definition tools.c:77
TileSet * allocateTileSetEx(u16 numTile)
Allocate a new TileSet structure which can receive the data for the specified number of tile.
Definition tools.c:910
TileMap * allocateTileMapEx(u16 width, u16 heigth)
Allocate a new TileMap structure which can receive tilemap data for the specified TileMap dimension.
Definition tools.c:933
Map * allocateMap(const MapDefinition *mapDef)
Allocate Map structure which can receive unpacked data of the specified MapDefinition.
Definition tools.c:977
void qsort_s8(s8 *data, u16 left, u16 right)
Quick sort algo on s8 data array.
u32 aplib_unpack(u8 *src, u8 *dest)
Unpack (aplib packer) the specified source data buffer in the specified destination buffer.
Bitmap * allocateBitmapEx(u16 width, u16 heigth)
Allocate a new Bitmap structure which can receive the bitmap data for the specified Bitmap dimension....
Definition tools.c:889
Bitmap * allocateBitmap(const Bitmap *bitmap)
Allocate a new Bitmap structure which can receive unpacked bitmap data of the specified Bitmap....
Definition tools.c:884
TileMap * allocateTileMap(const TileMap *tilemap)
Allocate TileMap structure which can receive unpacked tilemap data of the specified TileMap.
Definition tools.c:928
unsigned long u32
Definition types.h:105
s32 fix32
Definition types.h:186
char s8
Definition types.h:79
unsigned short u16
Definition types.h:100
unsigned char u8
Definition types.h:95
long s32
Definition types.h:89
short s16
Definition types.h:84
s16 fix16
Definition types.h:181
VDP background plane support.
VDP General Tile / Tilemap operations.