5 #include <netinet/in.h>
6 #include "../lib/include/endianness.h"
10 #if defined(IS_LITTLE_ENDIAN) && !defined(PALPIC_OPENGL)
19 typedef struct palpic
{
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
->width
= ntohs(p
->width
);
46 p
->height
= ntohs(p
->width
);
49 static inline void palpic_fileformat(struct palpic
*p
) {
50 p
->width
= htons(p
->width
);
51 p
->height
= htons(p
->width
);
54 static inline prgb
* palpic_getpalette(const struct palpic
* p
) {
58 static inline uint8_t* palpic_getdata(const struct palpic
* p
) {
59 return (uint8_t*)(p
+ 1) + (sizeof(prgb
) * p
->palcount
);
62 static inline uint32_t palpic_getfilesize(const struct palpic
* p
) {
63 return sizeof(palpic
) + (sizeof(prgb
) * p
->palcount
) + (p
->width
* p
->height
);
66 static inline unsigned palpic_getspriteheight(const struct palpic
* p
) {
67 return p
->height
/ p
->spritecount
;
70 static inline unsigned palpic_getspritewidth(const struct palpic
* p
) {
74 static inline unsigned palpic_getspritecount(const struct palpic
* p
) {
75 return p
->spritecount
;
78 static inline uint8_t* palpic_getspritedata(const struct palpic
* p
, uint16_t spritenum
) {
79 return palpic_getdata(p
) + (spritenum
* palpic_getspriteheight(p
) * palpic_getspritewidth(p
));
89 void blit_sprite(int x_pos
, int y_pos
, struct vo_desc
*video
,
90 unsigned scale
, const struct palpic
* pic
, uint16_t spritenum
, const prgb
*palette
);