2024-10-03 18:57:44 +03:00
|
|
|
#ifndef _CC_COMMON_H_
|
|
|
|
#define _CC_COMMON_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2024-10-05 12:44:16 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
2024-10-03 18:57:44 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-10-05 12:44:16 +03:00
|
|
|
|
|
|
|
int read_varint(FILE *fp, unsigned int *out);
|
|
|
|
int write_varint(FILE *fp, unsigned int in);
|
|
|
|
|
2024-10-03 18:57:44 +03:00
|
|
|
#endif
|