hekate/nyx: gfx: add text color defines
And reduce code size when using W/EPRINTF macros
This commit is contained in:
@@ -152,9 +152,9 @@ void gfx_con_init()
|
||||
gfx_con.y = 0;
|
||||
gfx_con.savedx = 0;
|
||||
gfx_con.savedy = 0;
|
||||
gfx_con.fgcol = 0xFFFFFFFF;
|
||||
gfx_con.fgcol = TXT_CLR_DEFAULT;
|
||||
gfx_con.fillbg = 1;
|
||||
gfx_con.bgcol = 0xFF000000;
|
||||
gfx_con.bgcol = TXT_CLR_BG;
|
||||
gfx_con.mute = 0;
|
||||
|
||||
gfx_con_init_done = true;
|
||||
@@ -230,7 +230,7 @@ void gfx_putc(char c)
|
||||
else if (c == '\n')
|
||||
{
|
||||
gfx_con.x = gfx_column;
|
||||
gfx_con.y +=16;
|
||||
gfx_con.y += 16;
|
||||
if (gfx_con.y > gfx_ctxt.height - 33)
|
||||
{
|
||||
gfx_con.y = 0;
|
||||
@@ -297,7 +297,7 @@ void gfx_putc(char c)
|
||||
}
|
||||
}
|
||||
|
||||
void gfx_puts(char *s)
|
||||
void gfx_puts(const char *s)
|
||||
{
|
||||
if (!s || !gfx_con_init_done || gfx_con.mute)
|
||||
return;
|
||||
@@ -359,9 +359,9 @@ void gfx_printf(const char *fmt, ...)
|
||||
int fill, fcnt;
|
||||
|
||||
va_start(ap, fmt);
|
||||
while(*fmt)
|
||||
while (*fmt)
|
||||
{
|
||||
if(*fmt == '%')
|
||||
if (*fmt == '%')
|
||||
{
|
||||
fmt++;
|
||||
fill = 0;
|
||||
@@ -426,6 +426,17 @@ void gfx_printf(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void _gfx_cputs(u32 color, const char *s)
|
||||
{
|
||||
gfx_con.fgcol = color;
|
||||
gfx_puts(s);
|
||||
gfx_putc('\n');
|
||||
gfx_con.fgcol = TXT_CLR_DEFAULT;
|
||||
}
|
||||
|
||||
void gfx_wputs(const char *s) { _gfx_cputs(TXT_CLR_WARNING, s); }
|
||||
void gfx_eputs(const char *s) { _gfx_cputs(TXT_CLR_ERROR, s); }
|
||||
|
||||
void gfx_hexdump(u32 base, const void *buf, u32 len)
|
||||
{
|
||||
if (!gfx_con_init_done || gfx_con.mute)
|
||||
|
||||
@@ -21,10 +21,25 @@
|
||||
|
||||
#include <bdk.h>
|
||||
|
||||
#define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC)
|
||||
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC)
|
||||
#define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC)
|
||||
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC)
|
||||
#define TXT_CLR_BG 0xFF000000 // Black.
|
||||
#define TXT_CLR_DEFAULT 0xFFFFFFFF // White.
|
||||
#define TXT_CLR_WARNING 0xFFFFDD00 // Yellow.
|
||||
#define TXT_CLR_ERROR 0xFFFF0000 // Red.
|
||||
#define TXT_CLR_CYAN_L 0xFF00CCFF // Light Cyan. 0xFF0099EE 0xFF00DDFF FF0AB9E6
|
||||
#define TXT_CLR_TURQUOISE 0xFF00FFCC // Turquoise.
|
||||
#define TXT_CLR_ORANGE 0xFFFFBA00 // Orange.
|
||||
#define TXT_CLR_GREENISH 0xFF96FF00 // Toxic Green. 0xFFAEFD14 0xFFC7EA46
|
||||
#define TXT_CLR_GREEN_D 0xFF008800 // Dark Green.
|
||||
#define TXT_CLR_RED_D 0xFF880000 // Dark Red. 0xFF800000
|
||||
#define TXT_CLR_GREY_D 0xFF303030 // Darkest Grey.
|
||||
#define TXT_CLR_GREY_DM 0xFF444444 // Darker Grey.
|
||||
#define TXT_CLR_GREY_M 0xFF555555 // Dark Grey.
|
||||
#define TXT_CLR_GREY 0xFF888888 // Grey.
|
||||
|
||||
#define EPRINTF(text) gfx_eputs(text)
|
||||
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", TXT_CLR_ERROR, args, TXT_CLR_DEFAULT)
|
||||
#define WPRINTF(text) gfx_wputs(text)
|
||||
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", TXT_CLR_WARNING, args, TXT_CLR_DEFAULT)
|
||||
|
||||
typedef struct _gfx_ctxt_t
|
||||
{
|
||||
@@ -60,7 +75,9 @@ void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol);
|
||||
void gfx_con_getpos(u32 *x, u32 *y);
|
||||
void gfx_con_setpos(u32 x, u32 y);
|
||||
void gfx_putc(char c);
|
||||
void gfx_puts(char *s);
|
||||
void gfx_puts(const char *s);
|
||||
void gfx_wputs(const char *s);
|
||||
void gfx_eputs(const char *s);
|
||||
void gfx_printf(const char *fmt, ...) /* __attribute__((format(printf, 1, 2))) */;
|
||||
void gfx_hexdump(u32 base, const void *buf, u32 len);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user