Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/modules/simple_sample/gfx/gfx.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2020 CTCaer
4
* Copyright (c) 2018 M4xw
5
*
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms and conditions of the GNU General Public License,
8
* version 2, as published by the Free Software Foundation.
9
*
10
* This program is distributed in the hope it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
* more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef _GFX_H_
20
#define _GFX_H_
21
22
#include <utils/types.h>
23
24
#define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC)
25
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC)
26
#define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC)
27
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC)
28
29
typedef struct _gfx_ctxt_t
30
{
31
u32 *fb;
32
u32 width;
33
u32 height;
34
u32 stride;
35
} gfx_ctxt_t;
36
37
typedef struct _gfx_con_t
38
{
39
gfx_ctxt_t *gfx_ctxt;
40
u32 fntsz;
41
u32 x;
42
u32 y;
43
u32 savedx;
44
u32 savedy;
45
u32 fgcol;
46
int fillbg;
47
u32 bgcol;
48
bool mute;
49
} gfx_con_t;
50
51
// Global gfx console and context.
52
extern gfx_ctxt_t gfx_ctxt;
53
extern gfx_con_t gfx_con;
54
55
void gfx_init_ctxt(u32 *fb, u32 width, u32 height, u32 stride);
56
void gfx_clear_grey(u8 color);
57
void gfx_clear_partial_grey(u8 color, u32 pos_x, u32 height);
58
void gfx_clear_color(u32 color);
59
void gfx_con_init();
60
void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol);
61
void gfx_con_getpos(u32 *x, u32 *y);
62
void gfx_con_setpos(u32 x, u32 y);
63
void gfx_putc(char c);
64
void gfx_puts(char *s);
65
void gfx_printf(const char *fmt, ...);
66
void gfx_hexdump(u32 base, const u8 *buf, u32 len);
67
68
void gfx_set_pixel(u32 x, u32 y, u32 color);
69
void gfx_line(int x0, int y0, int x1, int y1, u32 color);
70
void gfx_put_small_sep();
71
void gfx_put_big_sep();
72
void gfx_set_rect_grey(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y);
73
void gfx_set_rect_rgb(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y);
74
void gfx_set_rect_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y);
75
void gfx_render_bmp_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y);
76
77
#endif
78
79