]> Chaos Git - corbenik/ctrulib.git/commitdiff
use 3 intensity levels
authorDave Murphy <davem@devkitpro.org>
Sat, 13 Dec 2014 02:21:50 +0000 (02:21 +0000)
committerDave Murphy <davem@devkitpro.org>
Sat, 13 Dec 2014 02:21:50 +0000 (02:21 +0000)
libctru/include/3ds/console.h
libctru/source/console.c

index f8bcde6669dbbab538073eeafa031695fc7921df..fd65284c608864b2e55a181bd178ec93773cd555 100644 (file)
@@ -92,8 +92,9 @@ typedef struct PrintConsole
        bool consoleInitialised;        /*!< True if the console is initialized */\r
 }PrintConsole;\r
 \r
-#define CONSOLE_COLOR_BRIGHT   (1<<0)\r
-#define CONSOLE_COLOR_REVERSE  (1<<1)\r
+#define CONSOLE_COLOR_BOLD     (1<<0)\r
+#define CONSOLE_COLOR_FAINT    (1<<1)\r
+#define CONSOLE_COLOR_REVERSE  (1<<2)\r
 \r
 /*!    \brief Loads the font into the console\r
        \param console pointer to the console to update, if NULL it will update the current console\r
index 087bce7572b973d559fd3bb0e3c4038c8b9faf10..24946e178eab5cecf9dbb3b569ee5446dedb44cc 100644 (file)
@@ -8,22 +8,32 @@
 \r
 //set up the palette for color printing\r
 static u16 colorTable[] = {\r
-       RGB565( 0, 0, 0),       // normal black\r
-       RGB565(17, 0, 0),       // normal red\r
-       RGB565( 0,34, 0),       // normal green\r
-       RGB565(17,34, 0),       // normal yellow\r
-       RGB565( 0, 0,17),       // normal blue\r
-       RGB565(17, 0,17),       // normal magenta\r
-       RGB565( 0,34,17),       // normal cyan\r
-       RGB565(17,34,17),       // normal white\r
-       RGB565( 0, 0, 0),       // bright black\r
-       RGB565(25, 0, 0),       // bright red\r
-       RGB565( 0,52, 0),       // bright green\r
-       RGB565(25,52, 0),       // bright yellow\r
-       RGB565( 4,18,31),       // bright blue\r
-       RGB565(25, 0,25),       // bright magenta\r
-       RGB565( 0,52,25),       // bright cyan\r
-       RGB565(28,57,28)        // bright white\r
+       RGB8_to_565(  0,  0,  0),       // black\r
+       RGB8_to_565(128,  0,  0),       // red\r
+       RGB8_to_565(  0,128,  0),       // green\r
+       RGB8_to_565(128,128,  0),       // yellow\r
+       RGB8_to_565(  0,  0,128),       // blue\r
+       RGB8_to_565(128,  0,128),       // magenta\r
+       RGB8_to_565(  0,128,128),       // cyan\r
+       RGB8_to_565(192,192,192),       // white\r
+\r
+       RGB8_to_565(128,128,128),       // bright black\r
+       RGB8_to_565(255,  0,  0),       // bright red\r
+       RGB8_to_565(  0,255,  0),       // bright green\r
+       RGB8_to_565(255,255,  0),       // bright yellow\r
+       RGB8_to_565(  0,  0,255),       // bright blue\r
+       RGB8_to_565(255,  0,255),       // bright magenta\r
+       RGB8_to_565(  0,255,255),       // bright cyan\r
+       RGB8_to_565(255,255,255),       // bright white\r
+\r
+       RGB8_to_565(  0,  0,  0),       // faint black\r
+       RGB8_to_565( 64,  0,  0),       // faint red\r
+       RGB8_to_565(  0, 64,  0),       // faint green\r
+       RGB8_to_565( 64, 64,  0),       // faint yellow\r
+       RGB8_to_565(  0,  0, 64),       // faint blue\r
+       RGB8_to_565( 64,  0, 64),       // faint magenta\r
+       RGB8_to_565(  0, 64, 64),       // faint cyan\r
+       RGB8_to_565( 96, 96, 96),       // faint white\r
 };\r
 \r
 PrintConsole defaultConsole =\r
@@ -36,7 +46,7 @@ PrintConsole defaultConsole =
        },\r
        (u16*)NULL,\r
        0,0,    //cursorX cursorY\r
-       0,0,     //prevcursorX prevcursorY\r
+       0,0,    //prevcursorX prevcursorY\r
        40,     //console width\r
        30,     //console height\r
        0,      //window x\r
@@ -46,7 +56,7 @@ PrintConsole defaultConsole =
        3,              //tab size\r
        7,              // foreground color\r
        0,              // background color\r
-       CONSOLE_COLOR_BRIGHT,   // flags\r
+       0,              // flags\r
        0,              //print callback\r
        false   //console initialized\r
 };\r
@@ -290,15 +300,18 @@ ssize_t con_write(struct _reent *r,int fd,const char *ptr, size_t len) {
                                                        escapeseq += consumed;\r
                                                        escapelen -= consumed;\r
 \r
-                                                       if (parameter == 0 ) {\r
-                                                               currentConsole->flags |= CONSOLE_COLOR_BRIGHT;\r
-                                                               currentConsole->flags &= ~CONSOLE_COLOR_REVERSE;\r
-                                                               currentConsole->bg = 0;\r
-                                                               currentConsole->fg = 7;\r
+                                                       if (parameter == 0 ) { //reset\r
+                                                               currentConsole->flags = 0;\r
+                                                               currentConsole->bg    = 0;\r
+                                                               currentConsole->fg    = 7;\r
                                                        } else if (parameter == 7) { // reverse video\r
                                                                currentConsole->flags |= CONSOLE_COLOR_REVERSE;\r
+                                                       } else if (parameter == 1) { // bright\r
+                                                               currentConsole->flags |= CONSOLE_COLOR_BOLD;\r
+                                                               currentConsole->flags &= ~CONSOLE_COLOR_FAINT;\r
                                                        } else if (parameter == 2) { // half bright\r
-                                                               currentConsole->flags &= ~CONSOLE_COLOR_BRIGHT;\r
+                                                               currentConsole->flags &= ~CONSOLE_COLOR_BOLD;\r
+                                                               currentConsole->flags |= CONSOLE_COLOR_FAINT;\r
                                                        } else if (parameter >= 30 && parameter <= 37) { // writing color\r
                                                                currentConsole->fg = parameter - 30;\r
                                                        } else if (parameter >= 40 && parameter <= 47) { // screen color\r
@@ -437,9 +450,10 @@ void consoleDrawChar(int c) {
        int writingColor = currentConsole->fg;\r
        int screenColor = currentConsole->bg;\r
 \r
-       if (currentConsole->flags & CONSOLE_COLOR_BRIGHT) {\r
-               writingColor |= 8;\r
-               screenColor |=8;\r
+       if (currentConsole->flags & CONSOLE_COLOR_BOLD) {\r
+               writingColor += 8;\r
+       } else if (currentConsole->flags & CONSOLE_COLOR_FAINT) {\r
+               writingColor += 16;\r
        }\r
 \r
        if (currentConsole->flags & CONSOLE_COLOR_REVERSE) {\r