home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 11screen / dspytype.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  1.4 KB  |  65 lines

  1. /*
  2.  *    dspytype -- determine display adapter type
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <dos.h>
  7. #include <local\bioslib.h>
  8. #include <local\video.h>
  9.  
  10. #define MDA_SEG    0xB000
  11. #define CGA_SEG 0xB800
  12.  
  13. main()
  14. {
  15.     extern int memchk(unsigned int, unsigned int);
  16.     int mdaflag, egaflag, cgaflag;
  17.     int ega_mem, ega_mode;
  18.     unsigned int features, switches;
  19.     static int memtab[] = {
  20.         64, 128, 192, 256
  21.     };
  22.  
  23.     mdaflag = egaflag = cgaflag = 0;
  24.     
  25.     /* look for display adapters */
  26.     if (ega_info(&ega_mem, &ega_mode, &features, &switches))
  27.         ++egaflag;
  28.     fputs("Enhanced graphics adapter ", stdout);
  29.     if (egaflag) {
  30.         fputs("installed\n", stdout);
  31.         fprintf(stdout, "EGA memory size = %d-KB\n", memtab[ega_mem]);
  32.         fprintf(stdout, "EGA is in %s mode\n",
  33.             ega_mode ? "monochrome" : "color");
  34.     }
  35.     else
  36.         fputs("not installed\n", stdout);
  37.  
  38.     if (egaflag && ega_mode == 0) {
  39.         /* look for IBM monochrome memory */
  40.         if (memchk(MDA_SEG, 0))
  41.             ++mdaflag;
  42.     }
  43.     else {
  44.         /* look for IBM monochrome memory */
  45.         if (memchk(CGA_SEG, 0))
  46.             ++cgaflag;
  47.     }
  48.     fputs("Monochrome adapter ", stdout);
  49.     if (mdaflag)
  50.         fputs("installed\n", stdout);
  51.     else
  52.         fputs("not installed\n", stdout);
  53.     fputs("Color/graphics adapter ", stdout);
  54.     if (cgaflag)
  55.         fputs("installed\n", stdout);
  56.     else
  57.         fputs("not installed\n", stdout);
  58.  
  59.     /* report video settings */
  60.     getstate();
  61.     fprintf(stdout, "mode=%d width=%d page=%d\n", Vmode, Vwidth, Vpage);
  62.  
  63.     exit(0);
  64. }
  65.