home *** CD-ROM | disk | FTP | other *** search
- /* ==( dos/screen.c )== */
- /* ----------------------------------------------- */
- /* Pro-C - Copyright (C) 1988, 1989 Vestronix Inc. */
- /* Modification to this source is not supported */
- /* by Vestronix Inc. */
- /* All Rights Reserved */
- /* ----------------------------------------------- */
- /* Written Geo 26-Aug-88 */
- /* Modified Geo 1-May-90 See comments below */
- /* ----------------------------------------------- */
- /* %W% (%H% %T%) */
-
- /*
- * Modifications
- *
- * 1-May-90 Geo - Fix for Herc cards byte is bios area
- * not being set, default any values less than 24x80 to 24x80
- * 1-Mar-90 SBF - ttykeys[] initialization
- * 25-Oct-89 Geo - 1.32 Merge
- *
- *
- */
-
- # include <stdio.h>
- # include <bench.h>
-
- # include "pregs.h"
-
- char _page = 0;
-
- /* Bios data */
- char far *videoscreen = (char far *)0xb8000000L; /* Assume colour */
- char far *videorows = (char far *)0x00400084L;
- char far *videocols = (char far *)0x0040004aL;
-
- /* EXTERNs in bench.c */
- extern char snowwait; /* get_term() & procenv.exe */
-
- /* Original cursor setting */
- int _cursorg = 0x0607;
- int resetcurs = -999;
-
- extern short ttykeys[];
-
- /* Settings used by cursor() */
- static int _curson = 0x010D; /* 0x0607; */
- static int _cursoff = 0x2000;
-
- /* System rows & cols, Range 0..n-1 */
- static short _sysrows = 24;
- static short _syscols = 79;
- static short _sysrc = 0x184f; /* (25-1) rows (80-1) cols */
-
- /*
- * Cursor is off or big
- * returns previous setting
- * to allow cursor setting to be changed
- * without affecting the calling routine's
- * cursor setting
- */
- int cursor(flag)
- int flag;
- {
- static int lastv = -999;
- RegStorage;
-
- if (flag == lastv)
- return(flag);
-
- if (flag == -1)
- Regs_cx = _cursorg;
- else
- Regs_cx = (flag == ON) ? _curson : _cursoff;
- Regs_ah = 0x01;
- Video(); /* Set cursor type */
-
- /* Set latest state, return previous */
- lswap(int, lastv, flag);
- return(flag);
- }
-
- /* Should not be called directly */
- void _cls()
- {
- RegStorage;
-
- Regs_bh = 0x07;
- Regs_cx = 0x0000;
- Regs_dx = _sysrc;
- Regs_ax = 0x0700;
-
- Video(); /* Initialise window */
- }
-
- /*
- * Clear all display cells to DOS normal
- * and reset the cursor style
- */
- void resetscr()
- {
- flushscr();
-
- _cls();
-
- /* Reset cursor shape with original */
- resetcurs = cursor(-1);
- moveto(1, 1); /* Looks nicer at the top */
- }
-
- void moveto(row, col)
- int row, col;
- {
- RegStorage;
-
- Regs_bh = _page;
- Regs_dh = (unsigned char)row;
- Regs_dl = (unsigned char)col;
- Regs_ah = 0x02;
-
- Video(); /* Set cursor position */
- }
-
- /* System default tables */
- /* Colour is used by the system */
- static unsigned char _colcrt[] =
- { 0x00, 0x17, 0x30, 0x47, 0x17, 0x1f, 0x30, 0x4f,
- 0x1f, 0x1e, 0x1f, 0x2f, 0x3f, 0x71, 0x5f, 0x6f};
- /* Mono is available when swapped */
- static unsigned char _monochrome[] =
- { 0x00, 0x07, 0x70, 0x01, 0x87, 0x0f, 0xf0, 0x09,
- 0x8f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07};
-
- extern unsigned char mono[]; /* bench.c */
-
- /* Called from create_w() on init */
- get_term()
- {
- extern char xmonitor; /* mip/wdata.c */
- int i;
- unsigned char mode;
- RegStorage;
-
- /* First get current active page */
- Regs_cx = 0x00; /* trying the status bits */
- Regs_ah = 0x0f;
- Video(); /* Get current display mode */
-
- mode = Regs_al; /* Mashes al next statement */
- _syscols = Regs_ah;
- _syscols--; /* Keep range 0 .. n-1 */
-
- _page = Regs_bh;
-
- /* Set up colour or direct video */
- if (mode != 7)
- {
- Regs_cx = 0;
- Regs_bl = 0x10;
- Regs_ah = 0x12;
- Video();
-
- /* Trial ega setup */
- /* _sysrows = 42; */
-
- if (Regs_cx == 0)
- snowwait = TRUE; /* CGA */
- else
- /* Far system addreses - take care (~bitmask dangerous) */
- snowwait = FALSE;
-
- # ifdef WDEBUGII
- fprintf(stderr, "\nMonitor is %s\n",(snowwait?"CGA":"EGA"));
- # endif
-
- /* Colour */
- _curson = 0x010D; /* 0x0607; */ /* 6, 7 */
- }
- else
- {
- snowwait = FALSE;
- videoscreen = (char far *)0xB0000000L; /* Monochrome */
- _curson = 0x0b0c; /* 11, 12 */
- }
-
- xmonitor = (char)((mode == 3)? CGA : MONO);
-
- /* Set up default colour table */
- bytecpy(colour, (mode == 3)? _colcrt : _monochrome, sizeof(_colcrt));
-
- /* Set up default mono table */
- bytecpy(mono, (mode != 3)? _colcrt : _monochrome, sizeof(_colcrt));
-
- /* Current cursor setting */
- Regs_bh = _page;
- Regs_ah = 0x03;
- Video(); /* Read cursor position (also cursor setting) */
- _cursorg = Regs_cx;
-
- # ifdef WDEBUGII
- fprintf(stderr, "Cursor setting %04x", _cursorg);
- # endif
-
- /* Confirm cursor is off */
- cursor(OFF);
-
- /* Sysrc used for single value in resetting screen */
- _sysrc = (_sysrows << 8) | _syscols;
- /* Hack for larger video */
- w_nrows = *videorows;
- if (w_nrows < 24)
- w_nrows = 24;
- w_ncols = *videocols;
- if (w_ncols < 80)
- w_ncols = 80;
- _sysrc = (w_nrows << 8) | w_ncols;
-
- for (i = 1; i < MAX_TTYKEYS; i++)
- ttykeys[i] = _K_Base(i);
-
- return(TRUE);
- }
-
- /* Swaps in 2nd set of attributes */
- /* Recommend a redraws after this */
- swap_attr()
- {
- register int i;
-
- for (i = 0; i < sizeof(_colcrt); i++)
- lswap(unsigned char, colour[i], mono[i]);
- }
-
- void init_w(row, col)
- int row, col;
- {
- extern int _wsystart;
-
- row; col; /* to get used */
- get_term();
- _wstartup();
- _wsystart = 1;
-
- create_w(1, 1, w_nrows, w_ncols);
- }
-
- void end_w(flag)
- int flag;
- {
- extern int _wsystart; /* wdata.c */
-
- if (_wsystart == 0)
- {
- # ifdef WDEBUGI
- fprintf(stderr, "\nend_w() : No windowing to end\n");
- # endif
- return;
- }
-
- if (flag == TRUE)
- resetscr();
- else
- {
- flushscr(); /* Update highlight menus */
- cursor(-1);
- }
- _wshutdown();
- }
-
- void flushcurs() {}
-
-