3c1b86e7a2a5490f1c5d90fdd10973813a0da0f3
[coreboot.git] / payloads / libpayload / curses / PDCurses-3.4 / os2 / pdcdisp.c
1 /* Public Domain Curses */
2
3 #include "pdcos2.h"
4
5 RCSID("$Id: pdcdisp.c,v 1.49 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 /* ACS definitions originally by jshumate@wrdis01.robins.af.mil -- these 
8    match code page 437 and compatible pages (CP850, CP852, etc.) */
9
10 #ifdef CHTYPE_LONG
11
12 # define A(x) ((chtype)x | A_ALTCHARSET)
13
14 chtype acs_map[128] =
15 {
16     A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9),
17     A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
18     A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27),
19     A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
20     '\'', '(', ')', '*',
21
22     A(0x1a), A(0x1b), A(0x18), A(0x19),
23
24     '/',
25
26     0xdb,
27
28     '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
29     '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
30     'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
31     'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
32
33     A(0x04), 0xb1,
34
35     'b', 'c', 'd', 'e',
36
37     0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
38     0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3,
39     0xf2, 0xe3, 0xd8, 0x9c, 0xf9,
40
41     A(127)
42 };
43
44 # undef A
45
46 #endif
47
48 /* position hardware cursor at (y, x) */
49
50 void PDC_gotoyx(int row, int col)
51 {
52     PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
53
54 #ifdef EMXVIDEO
55     v_gotoxy(col, row);
56 #else
57     VioSetCurPos(row, col, 0);
58 #endif
59 }
60
61 /* update the given physical line to look like the corresponding line in
62    curscr */
63
64 void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
65 {
66     /* this should be enough for the maximum width of a screen. */
67
68     struct {unsigned char text, attr;} temp_line[256];
69     int j;
70
71     PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
72
73     /* replace the attribute part of the chtype with the 
74        actual color value for each chtype in the line */
75
76     for (j = 0; j < len; j++)
77     {
78         chtype ch = srcp[j];
79
80         temp_line[j].attr = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
81
82 #ifdef CHTYPE_LONG
83         if (ch & A_ALTCHARSET && !(ch & 0xff80))
84             ch = acs_map[ch & 0x7f];
85 #endif
86         temp_line[j].text = ch & 0xff;
87     }
88
89 #ifdef EMXVIDEO
90     v_putline((char *)temp_line, x, lineno, len);
91 #else
92     VioWrtCellStr((PCH)temp_line, (USHORT)(len * sizeof(unsigned short)),
93                   (USHORT)lineno, (USHORT)x, 0);
94 #endif
95 }