5 #include <netinet/in.h>
6 #include "../lib/include/endianness.h"
10 #if defined(IS_LITTLE_ENDIAN) && !defined(PALPIC_OPENGL)
19 typedef struct palpic
{
22 uint8_t palcount
; /* 0 means 256 */
36 #define palpic_empty { {'p', 'P', 'i', 'C', }, 1, 0, 0, 0, 0, 0, 0 }
38 #define PRGB(R,G,B) ((prgb) {.colors.r = R, .colors.g = G, .colors.b = B, .colors.a = 0xff,})
41 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
44 static inline void palpic_hostformat(struct palpic
*p
) {
45 p
->spritecount
= ntohs(p
->spritecount
);
46 p
->width
= ntohs(p
->width
);
47 p
->height
= ntohs(p
->height
);
50 static inline void palpic_fileformat(struct palpic
*p
) {
51 p
->spritecount
= htons(p
->spritecount
);
52 p
->width
= htons(p
->width
);
53 p
->height
= htons(p
->height
);
56 static inline prgb
* palpic_getpalette(const struct palpic
* p
) {
60 #define palpic_getpalcount(P) (P->palcount ? P->palcount : 256)
62 static inline uint8_t* palpic_getdata(const struct palpic
* p
) {
63 return (uint8_t*)(p
+ 1) + (sizeof(prgb
) * palpic_getpalcount(p
));
66 static inline uint32_t palpic_getfilesize(const struct palpic
* p
) {
67 return sizeof(palpic
) + (sizeof(prgb
) * palpic_getpalcount(p
)) + (p
->width
* p
->height
);
70 static inline unsigned palpic_getspriteheight(const struct palpic
* p
) {
71 return p
->height
/ p
->spritecount
;
74 static inline unsigned palpic_getspritewidth(const struct palpic
* p
) {
78 static inline unsigned palpic_getspritecount(const struct palpic
* p
) {
79 return p
->spritecount
;
82 static inline uint8_t* palpic_getspritedata(const struct palpic
* p
, uint16_t spritenum
) {
83 return palpic_getdata(p
) + (spritenum
* palpic_getspriteheight(p
) * palpic_getspritewidth(p
));
93 void blit_sprite(int x_pos
, int y_pos
, struct vo_desc
*video
,
94 unsigned scale
, const struct palpic
* pic
, uint16_t spritenum
, const prgb
*palette
);
96 #pragma RcB2 DEP "palpic.c"