SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
tools.h
Go to the documentation of this file.
1
9
10#ifndef _TOOLS_H_
11#define _TOOLS_H_
12
13#include "bmp.h"
14#include "vdp.h"
15#include "vdp_tile.h"
16#include "vdp_bg.h"
17#include "map.h"
18
19
24#define COMPRESSION_NONE 0
29#define COMPRESSION_APLIB 1
34#define COMPRESSION_LZ4W 2
35
36
41#define BLASTEM_PROFIL_START VDP_setReg(0x9F, 0xC0);
46#define BLASTEM_PROFIL_END VDP_setReg(0x9F, 0x00);
47
48
59typedef s16 _comparatorCallback(void* o1, void* o2);
60
61
66void setRandomSeed(u16 seed);
71u16 random(void);
72
73
98int kprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
99
105void KLog(char* text);
106void KLog_U1(char* t1, u32 v1);
107void KLog_U2(char* t1, u32 v1, char* t2, u32 v2);
108void KLog_U3(char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3);
109void KLog_U4(char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4, u32 v4);
110void KLog_U1_(char* t1, u32 v1, char* t2);
111void KLog_U2_(char* t1, u32 v1, char* t2, u32 v2, char* t3);
112void KLog_U3_(char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4);
113void KLog_U4_(char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4, u32 v4, char* t5);
114void KLog_U1x(u16 minSize, char* t1, u32 v1);
115void KLog_U2x(u16 minSize, char* t1, u32 v1, char* t2, u32 v2);
116void KLog_U3x(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3);
117void KLog_U4x(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4, u32 v4);
118void KLog_U1x_(u16 minSize, char* t1, u32 v1, char* t2);
119void KLog_U2x_(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3);
120void KLog_U3x_(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4);
121void KLog_U4x_(u16 minSize, char* t1, u32 v1, char* t2, u32 v2, char* t3, u32 v3, char* t4, u32 v4, char* t5);
122void KLog_S1(char* t1, s32 v1);
123void KLog_S2(char* t1, s32 v1, char* t2, s32 v2);
124void KLog_S3(char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3);
125void KLog_S4(char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3, char* t4, s32 v4);
126void KLog_S1_(char* t1, s32 v1, char* t2);
127void KLog_S2_(char* t1, s32 v1, char* t2, s32 v2, char* t3);
128void KLog_S3_(char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3, char* t4);
129void KLog_S4_(char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3, char* t4, s32 v4, char* t5);
130void KLog_S1x(u16 minSize, char* t1, s32 v1);
131void KLog_S2x(u16 minSize, char* t1, s32 v1, char* t2, s32 v2);
132void KLog_S3x(u16 minSize, char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3);
133void KLog_S4x(u16 minSize, char* t1, s32 v1, char* t2, s32 v2, char* t3, s32 v3, char* t4, s32 v4);
134void KLog_f1(char* t1, fix16 v1);
135void KLog_f2(char* t1, fix16 v1, char* t2, fix16 v2);
136void KLog_f3(char* t1, fix16 v1, char* t2, fix16 v2, char* t3, fix16 v3);
137void KLog_f4(char* t1, fix16 v1, char* t2, fix16 v2, char* t3, fix16 v3, char* t4, fix16 v4);
138void KLog_f1x(s16 numDec, char* t1, fix16 v1);
139void KLog_f2x(s16 numDec, char* t1, fix16 v1, char* t2, fix16 v2);
140void KLog_f3x(s16 numDec, char* t1, fix16 v1, char* t2, fix16 v2, char* t3, fix16 v3);
141void KLog_f4x(s16 numDec, char* t1, fix16 v1, char* t2, fix16 v2, char* t3, fix16 v3, char* t4, fix16 v4);
142void KLog_F1(char* t1, fix32 v1);
143void KLog_F2(char* t1, fix32 v1, char* t2, fix32 v2);
144void KLog_F3(char* t1, fix32 v1, char* t2, fix32 v2, char* t3, fix32 v3);
145void KLog_F4(char* t1, fix32 v1, char* t2, fix32 v2, char* t3, fix32 v3, char* t4, fix32 v4);
146void KLog_F1x(s16 numDec, char* t1, fix32 v1);
147void KLog_F2x(s16 numDec, char* t1, fix32 v1, char* t2, fix32 v2);
148void KLog_F3x(s16 numDec, char* t1, fix32 v1, char* t2, fix32 v2, char* t3, fix32 v3);
149void KLog_F4x(s16 numDec, char* t1, fix32 v1, char* t2, fix32 v2, char* t3, fix32 v3, char* t4, fix32 v4);
150
151
164Bitmap *allocateBitmap(const Bitmap *bitmap);
179Bitmap *allocateBitmapEx(u16 width, u16 heigth);
191TileSet *allocateTileSet(const TileSet *tileset);
203TileSet *allocateTileSetEx(u16 numTile);
215TileMap *allocateTileMap(const TileMap *tilemap);
229TileMap *allocateTileMapEx(u16 width, u16 heigth);
242Image *allocateImage(const Image *image);
254Map *allocateMap(const MapDefinition *mapDef);
255
270Bitmap *unpackBitmap(const Bitmap *src, Bitmap *dest);
285TileSet *unpackTileSet(const TileSet *src, TileSet *dest);
300TileMap *unpackTileMap(const TileMap *src, TileMap *dest);
315Image *unpackImage(const Image *src, Image *dest);
316
333u32 unpack(u16 compression, u8 *src, u8 *dest);
334
346u32 aplib_unpack(u8 *src, u8 *dest);
359u32 lz4w_unpack(const u8 *src, u8 *dest);
360
361
373void qsort_u8(u8 *data, u16 left, u16 right);
385void qsort_s8(s8 *data, u16 left, u16 right);
397void qsort_u16(u16 *data, u16 left, u16 right);
409void qsort_s16(s16 *data, u16 left, u16 right);
421void qsort_u32(u32 *data, u16 left, u16 right);
433void qsort_s32(s32 *data, u16 left, u16 right);
434
446void qsort(void** data, u16 len, _comparatorCallback* cb);
447
448
449
450#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:112
Map structure containing information for large background/plane update based on MapDefinition.
Definition map.h:179
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
s16 _comparatorCallback(void *o1, void *o2)
Callback for QSort comparaison.
Definition tools.h:59
int kprintf(const char *fmt,...) __attribute__((format(printf
Composes a string with the same text that would be printed if format was used on printf,...
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.
void qsort_u8(u8 *data, u16 left, u16 right)
Quick sort algo on u8 data array.
u16 random(void)
Returns a random u16 integer value.
Definition tools.c:37
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.
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.
s16 fix16
Definition types.h:203
unsigned long u32
Definition types.h:105
short s16
Definition types.h:84
char s8
Definition types.h:79
long s32
Definition types.h:89
unsigned short u16
Definition types.h:100
s32 fix32
Definition types.h:208
unsigned char u8
Definition types.h:95
VDP main.
VDP background plane support.
VDP General Tile / Tilemap operations.