forked from hkc/cc-stuff
32 lines
719 B
C
32 lines
719 B
C
#ifndef _CC_COMMON_H_
|
|
#define _CC_COMMON_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
|
|
typedef uint8_t GlyphBitmap[11];
|
|
|
|
struct rgba { uint8_t r, g, b, a; };
|
|
union color {
|
|
struct rgba rgba;
|
|
uint32_t v;
|
|
};
|
|
|
|
struct palette {
|
|
const uint8_t count;
|
|
union color colors[] __attribute__((counted_by(count)));
|
|
};
|
|
|
|
#define LENGTHOF(...) (sizeof(__VA_ARGS__) / sizeof(*(__VA_ARGS__)))
|
|
#define PALETTE(...) { .count = LENGTHOF((union color[]){__VA_ARGS__}), .colors = {__VA_ARGS__} }
|
|
|
|
const extern GlyphBitmap cc_font_atlas[256];
|
|
const extern struct palette cc_default_palette, cc_default_gray_palette;
|
|
|
|
|
|
int read_varint(FILE *fp, unsigned int *out);
|
|
int write_varint(FILE *fp, unsigned int in);
|
|
|
|
#endif
|