forked from Tasssadar/multirom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
framebuffer.h
136 lines (112 loc) · 2.71 KB
/
framebuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef H_FRAMEBUFFER
#define H_FRAMEBUFFER
#include <linux/fb.h>
#include <stdarg.h>
struct FB {
uint32_t *bits;
uint32_t *mapped;
uint32_t size;
int fd;
struct fb_fix_screeninfo fi;
struct fb_var_screeninfo vi;
};
extern struct FB *fb;
#define ISO_CHAR_HEIGHT 16
#define ISO_CHAR_WIDTH 8
// Colors, 0xAABBGGRR
#define BLACK 0xFF000000
#define WHITE 0xFFFFFFFF
#define LBLUE 0xFFCC9900
#define LBLUE2 0xFFF4DFA8
#define GRAYISH 0xFFBEBEBE
#define GRAY 0xFF7F7F7F
#define DRED 0xFF0000CC
enum
{
SIZE_SMALL = 1,
SIZE_NORMAL = 2,
SIZE_BIG = 3,
SIZE_EXTRA = 4,
};
#define fb_size(fb) ((fb)->vi.xres * (fb)->vi.yres * 4)
extern int fb_width;
extern int fb_height;
int fb_open(void);
void fb_close(void);
void fb_update(void);
void fb_switch(int n_sig);
inline struct FB *get_active_fb();
void fb_set_active_framebuffer(unsigned n);
enum
{
FB_TEXT = 0,
FB_RECT = 1,
FB_BOX = 2,
};
typedef struct
{
int id;
int type;
int x;
int y;
} fb_item_header;
typedef struct
{
fb_item_header head;
uint32_t color;
int8_t size;
char *text;
} fb_text;
typedef struct
{
fb_item_header head;
int w;
int h;
uint32_t color;
} fb_rect;
typedef struct
{
fb_item_header head;
int w, h;
fb_text **texts;
fb_rect *background[3];
} fb_msgbox;
typedef struct
{
fb_text **texts;
fb_rect **rects;
fb_msgbox *msgbox;
} fb_items_t;
void fb_remove_item(void *item);
int fb_generate_item_id();
fb_text *fb_add_text(int x, int y, uint32_t color, int size, const char *fmt, ...);
fb_text *fb_add_text_long(int x, int y, uint32_t color, int size, char *text);
fb_rect *fb_add_rect(int x, int y, int w, int h, uint32_t color);
fb_msgbox *fb_create_msgbox(int w, int h, int bgcolor);
fb_text *fb_msgbox_add_text(int x, int y, int size, char *txt, ...);
void fb_msgbox_rm_text(fb_text *text);
void fb_destroy_msgbox(void);
void fb_rm_text(fb_text *t);
void fb_rm_rect(fb_rect *r);
void fb_draw_text(fb_text *t);
void fb_draw_char(int x, int y, char c, uint32_t color, int size);
void fb_draw_square(int x, int y, uint32_t color, int size);
void fb_draw_overlay(void);
void fb_draw_rect(fb_rect *r);
void fb_fill(uint32_t color);
void fb_draw(void);
void fb_clear(void);
void fb_freeze(int freeze);
int fb_clone(char **buff);
void fb_push_context(void);
void fb_pop_context(void);
inline int center_x(int x, int width, int size, const char *text);
inline int center_y(int y, int height, int size);
#if 0
#define fb_debug(fmt, ...) fb_printf(fmt, ##__VA_ARGS__)
#else
#define fb_debug(fmt, ...) ERROR(fmt, ##__VA_ARGS__)
#define fb_printf(fmt, ...) ERROR(fmt, ##__VA_ARGS__)
#endif
int vt_set_mode(int graphics);
#endif