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