Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/nyx/nyx_gui/gfx/gfx.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2021 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 <bdk.h>
23
24
#define GFX_COL_KEEP 0xFFFE
25
#define GFX_COL_AUTO 0xFFFF
26
27
#define TXT_CLR_BG 0xFF000000 // Black.
28
#define TXT_CLR_DEFAULT 0xFFFFFFFF // White.
29
#define TXT_CLR_WARNING 0xFFFFDD00 // Yellow.
30
#define TXT_CLR_ERROR 0xFFFF0000 // Red.
31
#define TXT_CLR_CYAN_L 0xFF00CCFF // Light Cyan. 0xFF0099EE 0xFF00DDFF FF0AB9E6
32
#define TXT_CLR_TURQUOISE 0xFF00FFCC // Turquoise.
33
#define TXT_CLR_ORANGE 0xFFFFBA00 // Orange.
34
#define TXT_CLR_GREENISH 0xFF96FF00 // Toxic Green. 0xFFAEFD14 0xFFC7EA46
35
#define TXT_CLR_GREEN_D 0xFF008800 // Dark Green.
36
#define TXT_CLR_RED_D 0xFF880000 // Dark Red. 0xFF800000
37
#define TXT_CLR_GREY_D 0xFF303030 // Darkest Grey.
38
#define TXT_CLR_GREY_DM 0xFF444444 // Darker Grey.
39
#define TXT_CLR_GREY_M 0xFF555555 // Dark Grey.
40
#define TXT_CLR_GREY 0xFF888888 // Grey.
41
42
#define EPRINTF(text) gfx_eputs(text)
43
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", TXT_CLR_ERROR, args, TXT_CLR_DEFAULT)
44
#define WPRINTF(text) gfx_wputs(text)
45
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", TXT_CLR_WARNING, args, TXT_CLR_DEFAULT)
46
47
typedef struct _gfx_ctxt_t
48
{
49
u32 *fb;
50
u32 width;
51
u32 height;
52
u32 stride;
53
} gfx_ctxt_t;
54
55
typedef struct _gfx_con_t
56
{
57
gfx_ctxt_t *gfx_ctxt;
58
u32 fntsz;
59
u32 x;
60
u32 y;
61
u32 col;
62
u32 savedx;
63
u32 savedy;
64
u32 savedcol;
65
u32 fgcol;
66
int fillbg;
67
u32 bgcol;
68
bool mute;
69
} gfx_con_t;
70
71
// Global gfx console and context.
72
extern gfx_ctxt_t gfx_ctxt;
73
extern gfx_con_t gfx_con;
74
75
void gfx_init_ctxt(u32 *fb, u32 width, u32 height, u32 stride);
76
void gfx_clear_grey(u8 color);
77
void gfx_clear_color(u32 color);
78
void gfx_con_init();
79
void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol);
80
void gfx_con_getpos(u32 *x, u32 *y, u32 *c);
81
void gfx_con_setpos(u32 x, u32 y, u32 c);
82
void gfx_putc(char c);
83
void gfx_puts(const char *s);
84
void gfx_wputs(const char *s);
85
void gfx_eputs(const char *s);
86
void gfx_printf(const char *fmt, ...) /* __attribute__((format(printf, 1, 2))) */;
87
void gfx_hexdump(u32 base, const void *buf, u32 len);
88
89
void gfx_set_pixel(u32 x, u32 y, u32 color);
90
91
void gfx_set_rect_pitch(u32 *fb, const u32 *buf, u32 stride, u32 pos_x, u32 pos_y, u32 pos_x2, u32 pos_y2);
92
void gfx_set_rect_land_pitch(u32 *fb, const u32 *buf, u32 stride, u32 pos_x, u32 pos_y, u32 pos_x2, u32 pos_y2);
93
void gfx_set_rect_land_block(u32 *fb, const u32 *buf, u32 pos_x, u32 pos_y, u32 pos_x2, u32 pos_y2);
94
95
#endif
96
97