fix right scroll treshold
[rofl0r-openDOW.git] / palpic.h
blobefcbd0568a2f71e1900d610cce1e3292cdaa58d8
1 #ifndef PALPIC_H
2 #define PALPIC_H
4 #include <stdint.h>
5 #include <netinet/in.h>
6 #include "../lib/include/endianness.h"
8 typedef union {
9 struct colors {
10 #if defined(IS_LITTLE_ENDIAN) && !defined(PALPIC_OPENGL)
11 uint8_t a,b,g,r;
12 #else
13 uint8_t r,g,b,a;
14 #endif
15 } colors;
16 uint32_t val;
17 } prgb;
19 typedef struct palpic {
20 char magic[4];
21 uint8_t version;
22 uint8_t palcount;
23 uint16_t spritecount;
24 uint16_t width;
25 uint16_t height;
26 uint16_t flags;
27 uint16_t padding;
28 //prgb palette[];
29 //uint8_t data[];
30 } palpic;
32 enum palpic_flags {
33 PPF_TRANSPARENT = 1,
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,})
40 #if __GNUC__ + 0 > 3
41 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
42 #endif
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) {
55 return (prgb*) (p+1);
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) {
71 return p->width;
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));
82 struct vo_desc {
83 void *mem;
84 unsigned pitch;
85 unsigned width;
86 unsigned height;
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);
92 //RcB: DEP "palpic.c"
94 #endif