* ----------------------------------------------------------------------- */
#include <inttypes.h>
+#include <colortbl.h>
#include "vesa.h"
#include "video.h"
/*
- * Color map (ARGB) for the 16 PC colors. This can be overridden by the
- * application, and do not have to match the traditional colors.
- */
-uint32_t vesacon_color_map[16] = {
- 0x00000000, /* black */
- 0x400000ff, /* dark blue */
- 0x4000ff00, /* dark green */
- 0x4000ffff, /* dark cyan */
- 0x40ff0000, /* dark red */
- 0x40ff00ff, /* dark purple */
- 0x80ff8000, /* brown */
- 0xc0ffffff, /* light grey */
- 0x40ffffff, /* dark grey */
- 0xc00000ff, /* bright blue */
- 0xc000ff00, /* bright green */
- 0xc000ffff, /* bright cyan */
- 0xc0ff0000, /* bright red */
- 0xc0ff00ff, /* bright purple */
- 0xffffff00, /* yellow */
- 0xffffffff, /* white */
-};
-
-/*
* Linear alpha blending. Useless for anything that's actually
* depends on color accuracy (because of gamma), but it's fine for
* what we want.
chxbits = chbits;
chxbits &= (cptr->sha & 0x02) ? 0xff : 0x00;
chxbits ^= (cptr->sha & 0x01) ? 0xff : 0x00;
- fgcolor = vesacon_color_map[cptr->attr & 0x0f];
- bgcolor = vesacon_color_map[cptr->attr >> 4];
+ fgcolor = console_color_table[cptr->attr].argb_fg;
+ bgcolor = console_color_table[cptr->attr].argb_bg;
cptr++;
break;
case FONT_WIDTH-1:
st_init, /* Normal (no ESC seen) */
st_esc, /* ESC seen */
st_csi, /* CSI seen */
+ st_soh, /* SOH seen */
+ st_sohc, /* SOH # seen */
+ st_sohc1, /* SOH # digit seen */
};
#define MAX_PARMS 16
static const struct term_state default_state =
{
.disabled = 0,
- .attr = 0x07, /* Grey on black */
+ .attr = 0, /* First color table entry */
.vtgraphics = 0,
.intensity = 1,
.underline = 0,
break;
}
}
-
- /* Turn into an attribute code */
- {
- int bg = st.bg;
- int fg;
-
- if ( st.underline )
- fg = 0x01;
- else if ( st.intensity == 0 )
- fg = 0x08;
- else
- fg = st.fg;
-
- if ( st.reverse ) {
- bg = fg & 0x07;
- fg &= 0x08;
- fg |= st.bg;
- }
-
- if ( st.blink )
- bg ^= 0x08;
-
- if ( st.intensity == 2 )
- fg ^= 0x08;
-
- st.attr = (bg << 4) | fg;
- }
}
break;
case 's':
}
}
break;
+
+ case st_soh:
+ if ( ch == '#' )
+ st.state = st_sohc;
+ else
+ st.state = st_init;
+ break;
+
+ case st_sohc:
+ {
+ int n = (unsigned char)ch - '0';
+ if (n < 10) {
+ st.param[0] = n*10;
+ st.state = st_sohc1;
+ } else {
+ st.state = st_init;
+ }
+ }
+ break;
+
+ case st_sohc1:
+ {
+ int n = (unsigned char)ch - '0';
+ const char *p;
+
+ if (n < 10) {
+ st.param[0] += n;
+ if (st.param[0] < console_color_table_size) {
+ /* Set the color table index */
+ st.attr = st.param[0];
+
+ /* See if there are any other attributes we care about */
+ st.state = st_csi;
+ for (p = console_color_table[st.param[0]]; *p; p++)
+ vesacon_putchar(*p);
+ vesacon_putchar('m');
+ }
+ }
+
+ st.state = st_init;
+ }
+ break;
}
/* If we fell off the end of the screen, adjust */