return 0;
}
+static inline int display_mask_vga(void)
+{
+ uint8_t mask = UsingVGA & 0x1;
+ return (DisplayMask & ++mask);
+}
+
static void msg_setbg(uint8_t data)
{
if (unhexchar(&data) == 0) {
data <<= 4;
- if (DisplayMask & UsingVGA) {
+ if (display_mask_vga())
TextAttribute = data;
- }
NextCharJump = msg_setfg;
} else {
static void msg_setfg(uint8_t data)
{
if (unhexchar(&data) == 0) {
- if (DisplayMask & UsingVGA) {
+ if (display_mask_vga()) {
/* setbg set foreground to 0 */
TextAttribute |= data;
}
NextCharJump = msg_setbg;
}
+/* Convert ANSI colors to PC display attributes */
+static int convert_to_pcdisplay[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
+
+static void set_fgbg(void)
+{
+ uint8_t bg, fg;
+
+ fg = convert_to_pcdisplay[(TextAttribute & 0x7)];
+ bg = convert_to_pcdisplay[((TextAttribute >> 4) & 0x7)];
+
+ printf("\033[");
+ if (TextAttribute & 0x40)
+ printf("1;"); /* Foreground bright */
+
+ printf("3%dm\033[", fg);
+
+ if (TextAttribute & 0x80)
+ printf("5;"); /* Foreground blink */
+
+ printf("4%dm", bg);
+}
+
static void msg_formfeed(void)
{
- printf("\033[2J\033[H");
+ set_fgbg();
+ printf("\033[2J\033[H\033[0m");
}
static void msg_novga(void)
VGAFilePtr = (uint16_t *)VGAFileBuf;
}
-/* Convert ANSI colors to PC display attributes */
-static int convert_to_pcdisplay[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
static void msg_normal(uint8_t data)
{
- uint8_t bg, fg;
- uint8_t mask = UsingVGA & 0x1;
-
/* 0x1 = text mode, 0x2 = graphics mode */
- if (!(DisplayMask & ++mask) || !(DisplayCon & 0x01)) {
+ if (!display_mask_vga() || !(DisplayCon & 0x01)) {
/* Write to serial port */
if (DisplayMask & 0x4)
write_serial(data);
return; /* Not screen */
}
- fg = convert_to_pcdisplay[(TextAttribute & 0x7)];
- bg = convert_to_pcdisplay[((TextAttribute >> 4) & 0x7)];
-
- printf("\033[");
- if (TextAttribute & 0x40)
- printf("1;"); /* Foreground bright */
-
- printf("3%dm\033[", fg);
-
- if (TextAttribute & 0x80)
- printf("5;"); /* Foreground blink */
-
- printf("4%dm%c\033[0m", bg, data);
+ set_fgbg();
+ printf("%c\033[0m", data);
}
static void msg_modectl(uint8_t data)