1 /* Public Domain Curses */
2 
3 #include "pdcdos.h"
4 
5 #include <stdlib.h>
6 
7 /* return width of screen/viewport */
8 
PDC_get_columns(void)9 int PDC_get_columns(void)
10 {
11     PDCREGS regs;
12     int cols;
13     const char *env_cols;
14 
15     PDC_LOG(("PDC_get_columns() - called\n"));
16 
17     /* use the value from COLS environment variable, if set. MH 10-Jun-92 */
18     /* and use the minimum of COLS and return from int10h    MH 18-Jun-92 */
19 
20     regs.h.ah = 0x0f;
21     PDCINT(0x10, regs);
22     cols = (int)regs.h.ah;
23 
24     env_cols = getenv("COLS");
25 
26     if (env_cols)
27         cols = min(atoi(env_cols), cols);
28 
29     PDC_LOG(("PDC_get_columns() - returned: cols %d\n", cols));
30 
31     return cols;
32 }
33 
34 /* get the cursor size/shape */
35 
PDC_get_cursor_mode(void)36 int PDC_get_cursor_mode(void)
37 {
38     PDC_LOG(("PDC_get_cursor_mode() - called\n"));
39 
40     return getdosmemword(0x460);
41 }
42 
43 /* return number of screen rows */
44 
PDC_get_rows(void)45 int PDC_get_rows(void)
46 {
47     const char *env_rows;
48     int rows;
49 
50     PDC_LOG(("PDC_get_rows() - called\n"));
51 
52     /* use the value from LINES environment variable, if set. MH 10-Jun-92 */
53     /* and use the minimum of LINES and *ROWS.                MH 18-Jun-92 */
54 
55     rows = getdosmembyte(0x484) + 1;
56     env_rows = getenv("LINES");
57 
58     if (env_rows)
59         rows = min(atoi(env_rows), rows);
60 
61     if (rows == 1 && pdc_adapter == _MDS_GENIUS)
62         rows = 66;
63     if (rows == 1 && pdc_adapter == _MDA)
64         rows = 25;
65 
66     if (rows == 1)
67     {
68         rows = 25;
69         pdc_direct_video = FALSE;
70     }
71 
72     switch (pdc_adapter)
73     {
74     case _EGACOLOR:
75     case _EGAMONO:
76         switch (rows)
77         {
78         case 25:
79         case 43:
80             break;
81         default:
82             rows = 25;
83         }
84         break;
85 
86     case _VGACOLOR:
87     case _VGAMONO:
88         break;
89 
90     default:
91         rows = 25;
92         break;
93     }
94 
95     PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));
96 
97     return rows;
98 }
99