add missing tools/pngdump to the repo
[gbajam22] / src / sprite.h
1 #ifndef SPRITE_H_
2 #define SPRITE_H_
3
4 #include <stdint.h>
5
6 enum {
7         SPR_ROTSCL      = 0x0100,
8         SPR_DBLSZ       = 0x0200,
9         SPR_BLEND       = 0x0400,
10         SPR_OBJWIN      = 0x0800,
11         SPR_MOSAIC      = 0x1000,
12         SPR_256COL      = 0x2000,
13         SPR_HRECT       = 0x4000,
14         SPR_VRECT       = 0x8000,
15
16         SPR_HFLIP       = 0x100000,
17         SPR_VFLIP       = 0x200000,
18         SPR_SZ16        = 0x400000,
19         SPR_SZ32        = 0x800000,
20         SPR_SZ64        = 0xc00000
21 };
22 #define SPR_SZ8         0
23 #define SPR_ROTSCL_SEL(x)       ((unsigned int)(x) << 17)
24 #define SPR_PRIO(x)                     ((unsigned int)(x) & 3)
25
26
27 struct hwsprite {
28         short id;
29         short width, height;
30         short x, y;
31         unsigned int flags;
32 };
33
34 struct sprite {
35         short x, y;
36         struct hwsprite hwspr[8];
37         short num_hwspr;
38 };
39
40 void spr_setup(int xtiles, int ytiles, unsigned char *pixels, unsigned char *cmap);
41 void spr_clear(void);
42
43 #define spr_oam_clear(oam, idx) spr_oam(oam, idx, 0, 0, 160, 0)
44 void spr_oam(uint16_t *oam, int idx, int spr, int x, int y, unsigned int flags);
45 void spr_spr_oam(uint16_t *oam, int idx, struct sprite *spr);
46
47 /* idx is the rotation/scale parameter index (0-31), not the sprite index */
48 void spr_transform(uint16_t *oam, int idx, int16_t *mat);
49
50
51 #endif  /* SPRITE_H_ */