soc/amd/stoneyridge: remove LIDS field from global NVS
[coreboot.git] / payloads / libpayload / curses / pdcurses-backend / pdcscrn.c
blob6286b7f60073b751f81c75b72a2bc7fe4cb9d098
1 /* Public Domain Curses */
3 #include "lppdc.h"
5 #include <stdlib.h>
7 #ifdef CHTYPE_LONG
8 # define PDC_OFFSET 32
9 #else
10 # define PDC_OFFSET 8
11 #endif
13 /* COLOR_PAIR to attribute encoding table. */
15 unsigned char *pdc_atrtab = (unsigned char *)NULL;
17 short curstoreal[16], realtocurs[16] =
19 COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
20 COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
21 COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
22 COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
25 /* close the physical screen -- may restore the screen to its state
26 before PDC_scr_open(); miscellaneous cleanup */
28 void PDC_scr_close(void)
30 PDC_LOG(("PDC_scr_close() - called\n"));
32 reset_shell_mode();
34 if (SP->visibility != 1)
35 curs_set(1);
37 /* Position cursor to the bottom left of the screen. */
39 PDC_gotoyx(PDC_get_rows() - 2, 0);
42 void PDC_scr_free(void)
44 if (SP)
45 free(SP);
46 if (pdc_atrtab)
47 free(pdc_atrtab);
49 pdc_atrtab = (unsigned char *)NULL;
52 /* open the physical screen -- allocate SP, miscellaneous intialization,
53 and may save the existing screen for later restoration */
55 int PDC_scr_open(int argc, char **argv)
57 int i;
59 PDC_LOG(("PDC_scr_open() - called\n"));
61 SP = calloc(1, sizeof(SCREEN));
62 pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
64 if (!SP || !pdc_atrtab)
65 return ERR;
67 for (i = 0; i < 16; i++)
68 curstoreal[realtocurs[i]] = i;
70 SP->orig_attr = FALSE;
72 SP->lines = PDC_get_rows();
73 SP->cols = PDC_get_columns();
75 #if CONFIG(LP_SPEAKER)
76 SP->audible = TRUE;
77 #endif
79 return OK;
82 /* the core of resize_term() */
84 int PDC_resize_screen(int nlines, int ncols)
86 PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
87 nlines, ncols));
89 return ERR;
92 void PDC_reset_prog_mode(void)
94 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
97 void PDC_reset_shell_mode(void)
99 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
102 void PDC_restore_screen_mode(int i)
106 void PDC_save_screen_mode(int i)
110 void PDC_init_pair(short pair, short fg, short bg)
112 unsigned char att, temp_bg;
113 chtype i;
115 fg = curstoreal[fg];
116 bg = curstoreal[bg];
118 for (i = 0; i < PDC_OFFSET; i++)
120 att = fg | (bg << 4);
122 if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
123 att = bg | (fg << 4);
124 if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
125 att = 1;
126 if (i & (A_INVIS >> PDC_ATTR_SHIFT))
128 temp_bg = att >> 4;
129 att = temp_bg << 4 | temp_bg;
131 if (i & (A_BOLD >> PDC_ATTR_SHIFT))
132 att |= 8;
133 if (i & (A_BLINK >> PDC_ATTR_SHIFT))
134 att |= 128;
136 pdc_atrtab[pair * PDC_OFFSET + i] = att;
140 int PDC_pair_content(short pair, short *fg, short *bg)
142 *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
143 *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
145 return OK;
148 bool PDC_can_change_color(void)
150 return FALSE;
153 int PDC_color_content(short color, short *red, short *green, short *blue)
155 return ERR;
158 int PDC_init_color(short color, short red, short green, short blue)
160 return ERR;