home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume6 / ega-wanderer / patch1 / venix286.c < prev   
C/C++ Source or Header  |  1989-02-24  |  741b  |  48 lines

  1. /*
  2.  *    EGA init/reset for VENIX/286
  3.  */
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. #include <sys/pc_csl.h>
  7.  
  8. typedef    unsigned char    uchar;
  9.  
  10. extern uchar        *EGAaddr;
  11. extern int        EGAifd;
  12. extern int        EGAofd;
  13.  
  14. #define    VIDFD        1
  15.  
  16. #define    PHYS_SEL    ((uchar *) 0x170000L)
  17. #define EGA_PHYS    ((unsigned) (0xA0000L/512))
  18.  
  19. egainit()
  20. {
  21.     char *tty, *ttyname();
  22.  
  23.     if ( (tty = ttyname(VIDFD)) == NULL || strncmp(tty,"/dev/scrn",9) != 0 )
  24.         return( 0 );
  25.  
  26.     if (ioctl(VIDFD, PHYS_MEM, EGA_PHYS) != -1) {
  27.         EGAaddr = PHYS_SEL;
  28.         EGAifd = 0;
  29.         EGAofd = VIDFD;
  30.         write( EGAofd, "\033[16g", 5 );
  31.         Clear();
  32.         return( 1 );
  33.     }
  34.  
  35.     EGAaddr = NULL;
  36.  
  37.     return( 0 );
  38. }
  39.  
  40. egareset()
  41. {
  42.     if ( EGAaddr ) {
  43.         Clear();
  44.         write(EGAofd, "\033[0g", 4 );
  45.         ioctl(EGAofd, PHYS_MEM, -1);
  46.     }
  47. }
  48.