Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libctru/include/3ds/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ typedef struct PrintConsole
#define CONSOLE_CROSSED_OUT (1<<8) ///< Crossed out text
#define CONSOLE_FG_CUSTOM (1<<9) ///< Foreground custom color
#define CONSOLE_BG_CUSTOM (1<<10) ///< Background custom color
#define CONSOLE_COLOR_FG_BRIGHT (1<<11) ///< Bright foreground color
#define CONSOLE_COLOR_BG_BRIGHT (1<<12) ///< Bright background color

/// Console debug devices supported by libnds.
typedef enum {
Expand Down
30 changes: 18 additions & 12 deletions libctru/source/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,18 @@ static void consoleHandleColorEsc(int code)
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
escapeSeq.color.fg = 0;
break;
case 90 ... 97: // bright foreground
escapeSeq.color.flags &= ~CONSOLE_COLOR_FAINT;
escapeSeq.color.flags |= CONSOLE_COLOR_FG_BRIGHT;
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
escapeSeq.color.fg = code - 90;
break;
case 100 ... 107: // bright background
escapeSeq.color.flags &= ~CONSOLE_COLOR_FAINT;
escapeSeq.color.flags |= CONSOLE_COLOR_BG_BRIGHT;
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
escapeSeq.color.bg = code - 100;
break;
}
break;
case ESC_BUILDING_FORMAT_FG:
Expand Down Expand Up @@ -831,23 +843,17 @@ void consoleDrawChar(int c) {
u16 bg = currentConsole->bg;

if (!(currentConsole->flags & CONSOLE_FG_CUSTOM)) {
if (currentConsole->flags & CONSOLE_COLOR_BOLD) {
fg = colorTable[fg + 8];
if (currentConsole->flags & (CONSOLE_COLOR_BOLD | CONSOLE_COLOR_FG_BRIGHT)) {
fg += 8;
} else if (currentConsole->flags & CONSOLE_COLOR_FAINT) {
fg = colorTable[fg + 16];
} else {
fg = colorTable[fg];
fg += 16;
}
fg = colorTable[fg];
}

if (!(currentConsole->flags & CONSOLE_BG_CUSTOM)) {
if (currentConsole->flags & CONSOLE_COLOR_BOLD) {
bg = colorTable[bg + 8];
} else if (currentConsole->flags & CONSOLE_COLOR_FAINT) {
bg = colorTable[bg + 16];
} else {
bg = colorTable[bg];
}
if (currentConsole->flags & CONSOLE_COLOR_BG_BRIGHT) bg +=8;
bg = colorTable[bg];
}

if (currentConsole->flags & CONSOLE_COLOR_REVERSE) {
Expand Down