/* init_adapter.c ********** Copyright 1988 by Vermont Creative Software ********** NAME init_adapter.c -- resets display adapter under XENIX DATE: October 25, 1988 February 28, 1991 -- adapted for Vermont Views USAGE Used to reset the display adapter under XENIX after a system call or other routine has caused the screen to scroll. FUNCTION Opens /dev/console, reads its mode, and resets its mode to be the same as it currently is. This has the effect of reinitializing the start address registers of the adapter so that they are the same as they were when the program started. The display is incidentally cleared, so redisp_wn(&wn0) must be called after this function. CALL int init_adapter() RETURNS = 0 if unable to open the console device, or the mode set or reset call fails = 1 if successful CAUTIONS Useful only on IBM PC AT's and compatibles running XENIX. The console display will be cleared. */ #include #include #include #include #ifdef M_I386 #define sotofar(segment, offset) ((char far *) (((unsigned) (segment)) << 32)\ +(unsigned) (offset)) #endif int init_adapter() { int retval = 1; /*default return value (success) */ int fd; /*file handle for console */ int mode; /*current display adapter mode */ if (_wnmemmap) /*if running memory-mapped */ { /*reset display adapter */ if ((fd = open("/dev/console", O_WRONLY)) == -1 || (mode = ioctl(fd, CONS_GET, 0)) == -1 || ioctl(fd, MODESWITCH | mode, 0) == -1) retval = 0; if (fd != -1) close(fd); } return(retval); }