NXEngine v1.0.0.6
[NXEngine.git] / siflib / sectSprites.h
blobdaae3537e43c79365b202a0c54b184f30307ab0e
2 #ifndef _SECT_SPRITES_H
3 #define _SECT_SPRITES_H
5 // this decodes and encodes the main sprites[] array of SIFSprite structures.
7 class DBuffer;
8 #include "sif.h"
11 class SIFSpritesSect
13 public:
14 // get how many sprites are in the file. You can call this first if you need
15 // to know how big to make the array.
16 static int GetSpriteCount(const uint8_t *data, int datalen);
18 // decode from a SIF_SECTION_SPRITES and use the resultant data to fill in
19 // an array of SIFSprite structures pointed to by sprites.
20 static bool Decode(const uint8_t *data, int datalen, \
21 SIFSprite *sprites, int *nsprites_out, int maxsprites);
23 // read sprites out of the given array of SIFSprite structures and generate
24 // a SIF_SECTION_SPRITES record.
25 static uint8_t *Encode(SIFSprite *sprites, int nsprites, int *datalen_out);
28 private:
29 static void LoadRect(SIFRect *rect, const uint8_t **data, const uint8_t *data_end);
30 static void LoadPoint(SIFPoint *pt, const uint8_t **data, const uint8_t *data_end);
31 static void LoadPointList(SIFPointList *lst, const uint8_t **data, const uint8_t *data_end);
32 static bool LoadFrame(SIFFrame *frame, int ndirs, const uint8_t **data, const uint8_t *data_end);
34 static void SaveRect(SIFRect *rect, DBuffer *out);
35 static void SavePoint(SIFPoint *pt, DBuffer *out);
36 static void SavePointList(SIFPointList *lst, DBuffer *out);
37 static void SaveOptionalPoint(int type, SIFPoint *pt, DBuffer *out);
38 static void SaveOptionalRect(int type, SIFRect *rect, DBuffer *out);
39 static void SaveFrame(SIFFrame *frame, int ndirs, DBuffer *out);
44 // field types within SIFDir which are optional
45 enum
47 S_DIR_END, // ends section list
49 S_DIR_DRAW_POINT, // default is [0,0]
50 S_DIR_ACTION_POINT, // default is [0,0]
51 S_DIR_ACTION_POINT_2, // default is [0,0]
52 S_DIR_PF_BBOX // default is no per-frame bbox, or rather [0,0]-[0,0]
55 #endif