From 0e1a90a7a99356fe67574d10026904ac331d576d Mon Sep 17 00:00:00 2001 From: yellows8 Date: Wed, 13 Dec 2017 13:42:02 -0500 Subject: [PATCH] Changed the RGBA8 define to RGBA8_MAXALPHA and adjusted it + moved it into gfx.h. Added RGBA8 define to gfx.h which is the same as the original except it now uses an input alpha param. Added a comment to gfx.c regarding width/height. --- nx/include/switch/gfx/gfx.h | 6 +++++ nx/source/devices/console.c | 51 +++++++++++++++++-------------------- nx/source/gfx/gfx.c | 2 ++ 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/nx/include/switch/gfx/gfx.h b/nx/include/switch/gfx/gfx.h index 5daaae00..513038cc 100644 --- a/nx/include/switch/gfx/gfx.h +++ b/nx/include/switch/gfx/gfx.h @@ -1,3 +1,9 @@ +/// Converts red, green, blue, and alpha components to packed RGBA8. +#define RGBA8(r,g,b,a) (((r)&0xff)|(((g)&0xff)<<8)|(((b)&0xff)<<16)|(((a)&0xff)<<24)) + +/// Same as RGBA8 except with alpha=0xff. +#define RGBA8_MAXALPHA(r,g,b) RGBA8(r,g,b,0xff) + /// Do not use viInitialize/viExit when using these. void gfxInitDefault(void); void gfxExit(void); diff --git a/nx/source/devices/console.c b/nx/source/devices/console.c index 62ab1133..e25894d0 100644 --- a/nx/source/devices/console.c +++ b/nx/source/devices/console.c @@ -5,37 +5,34 @@ #include "default_font_bin.h" -/// Converts red, green, and blue components to packed RGBA8, with alpha=0xff. -#define RGBA8(r,g,b) (((r)&0xff)|(((g)&0xff)<<8)|(((b)&0xff)<<16)|(0xff<<24)) - //set up the palette for color printing static u32 colorTable[] = { - RGBA8( 0, 0, 0), // black - RGBA8(128, 0, 0), // red - RGBA8( 0,128, 0), // green - RGBA8(128,128, 0), // yellow - RGBA8( 0, 0,128), // blue - RGBA8(128, 0,128), // magenta - RGBA8( 0,128,128), // cyan - RGBA8(192,192,192), // white + RGBA8_MAXALPHA( 0, 0, 0), // black + RGBA8_MAXALPHA(128, 0, 0), // red + RGBA8_MAXALPHA( 0,128, 0), // green + RGBA8_MAXALPHA(128,128, 0), // yellow + RGBA8_MAXALPHA( 0, 0,128), // blue + RGBA8_MAXALPHA(128, 0,128), // magenta + RGBA8_MAXALPHA( 0,128,128), // cyan + RGBA8_MAXALPHA(192,192,192), // white - RGBA8(128,128,128), // bright black - RGBA8(255, 0, 0), // bright red - RGBA8( 0,255, 0), // bright green - RGBA8(255,255, 0), // bright yellow - RGBA8( 0, 0,255), // bright blue - RGBA8(255, 0,255), // bright magenta - RGBA8( 0,255,255), // bright cyan - RGBA8(255,255,255), // bright white + RGBA8_MAXALPHA(128,128,128), // bright black + RGBA8_MAXALPHA(255, 0, 0), // bright red + RGBA8_MAXALPHA( 0,255, 0), // bright green + RGBA8_MAXALPHA(255,255, 0), // bright yellow + RGBA8_MAXALPHA( 0, 0,255), // bright blue + RGBA8_MAXALPHA(255, 0,255), // bright magenta + RGBA8_MAXALPHA( 0,255,255), // bright cyan + RGBA8_MAXALPHA(255,255,255), // bright white - RGBA8( 0, 0, 0), // faint black - RGBA8( 64, 0, 0), // faint red - RGBA8( 0, 64, 0), // faint green - RGBA8( 64, 64, 0), // faint yellow - RGBA8( 0, 0, 64), // faint blue - RGBA8( 64, 0, 64), // faint magenta - RGBA8( 0, 64, 64), // faint cyan - RGBA8( 96, 96, 96), // faint white + RGBA8_MAXALPHA( 0, 0, 0), // faint black + RGBA8_MAXALPHA( 64, 0, 0), // faint red + RGBA8_MAXALPHA( 0, 64, 0), // faint green + RGBA8_MAXALPHA( 64, 64, 0), // faint yellow + RGBA8_MAXALPHA( 0, 0, 64), // faint blue + RGBA8_MAXALPHA( 64, 0, 64), // faint magenta + RGBA8_MAXALPHA( 0, 64, 64), // faint cyan + RGBA8_MAXALPHA( 96, 96, 96), // faint white }; //The below width/height is for 720p. diff --git a/nx/source/gfx/gfx.c b/nx/source/gfx/gfx.c index 08a691a3..664879c6 100644 --- a/nx/source/gfx/gfx.c +++ b/nx/source/gfx/gfx.c @@ -30,6 +30,8 @@ extern size_t g_nvgfx_singleframebuf_size; //static Result _gfxGetDisplayResolution(u64 *width, u64 *height); +//TODO: Figure out what all is required to use non-720p width/height. + //TODO: Let the user configure some of this? static bufferProducerQueueBufferInput g_gfxQueueBufferData = { .timestamp = 0x0,