Commit b69bf2fd authored by deuce's avatar deuce
Browse files

Here's some things I did.

They don't fix any problems, and likely nothing will use this code.
parent 3ea0ba6e
......@@ -289,6 +289,7 @@ static int try_curses_init(int mode)
cio_api.setpalette = curs_setpalette;
cio_api.get_modepalette = curs_get_modepalette;
cio_api.set_modepalette = curs_set_modepalette;
cio_api.attr2palette = curs_attr2palette;
return(1);
}
return(0);
......
......@@ -4684,18 +4684,19 @@ CIOLIBEXPORT char* CIOLIBCALL cterm_write(struct cterminal * cterm, const void *
struct vmem_cell tmpvc[1];
int orig_fonts[4];
char lastch = 0;
int palette_offset = 0;
if(!cterm->started)
cterm_start(cterm);
/* Now rejigger the current modes palette... */
if (cio_api.options & CONIO_OPT_EXTENDED_PALETTE) {
mpalette = get_modepalette(palette);
if (mpalette) {
for (i=0; i < 16; i++)
palette[i] += 16;
set_modepalette(palette);
}
if (cio_api.options & CONIO_OPT_EXTENDED_PALETTE)
palette_offset = 0;
mpalette = get_modepalette(palette);
if (mpalette) {
for (i=0; i < 16; i++)
palette[i] += palette_offset;
set_modepalette(palette);
}
/* Deedle up the fonts */
......@@ -5425,12 +5426,10 @@ CIOLIBEXPORT char* CIOLIBCALL cterm_write(struct cterminal * cterm, const void *
SETCURSORTYPE(cterm->cursor);
/* Now rejigger the current modes palette... */
if (cio_api.options & CONIO_OPT_EXTENDED_PALETTE) {
if (mpalette) {
for (i=0; i < 16; i++)
palette[i] -= 16;
set_modepalette(palette);
}
if (mpalette) {
for (i=0; i < 16; i++)
palette[i] -= palette_offset;
set_modepalette(palette);
}
/* De-doodle the fonts */
......
......@@ -1170,15 +1170,33 @@ scale_integer_up(int from)
return ret;
}
uint32_t palette[16];
int curs_attr2palette(uint8_t attr, uint32_t *fgp, uint32_t *bgp)
{
uint32_t fg = attr & 0x0f;
uint32_t bg = (attr >> 4) & 0x0f;
if (!(vflags & CIOLIB_VIDEO_BGBRIGHT))
bg &= 0x07;
if (vflags & CIOLIB_VIDEO_NOBRIGHT)
fg &= 0x07;
if (fgp)
*fgp = palette[fg];
if (bgp)
*bgp = palette[bg];
return 1;
}
int curs_setpalette(uint32_t entry, uint16_t r, uint16_t g, uint16_t b)
{
if (!can_change_color())
return 0;
init_color(entry, scale_integer_up(r>>8), scale_integer_up(g>>8), scale_integer_up(b>>8));
init_color(curses_color(entry), scale_integer_up(r>>8), scale_integer_up(g>>8), scale_integer_up(b>>8));
return 1;
}
uint32_t palette[16];
int curs_set_modepalette(uint32_t p[16])
{
int i;
......@@ -1189,7 +1207,7 @@ int curs_set_modepalette(uint32_t p[16])
for (i = 0; i < 16; i++) {
struct dac_colors *c;
c = &dac_default[p[i]];
init_color(curses_color(i), scale_integer_up(c->red), scale_integer_up(c->green), scale_integer_up(c->blue));
curs_setpalette(i, c->red<<8 | c->red, c->green<<8 | c->green, c->blue<<8 | c->blue);
}
return 1;
}
......
......@@ -72,6 +72,7 @@ int curs_getfont(int font_num);
int curs_set_modepalette(uint32_t p[16]);
int curs_get_modepalette(uint32_t p[16]);
int curs_setpalette(uint32_t entry, uint16_t r, uint16_t g, uint16_t b);
int curs_attr2palette(uint8_t attr, uint32_t *fgp, uint32_t *bgp);
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment