home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_01 / 3n01054a < prev    next >
Text File  |  1991-12-03  |  2KB  |  98 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <dos.h>
  4.  
  5. struct video {
  6.    int segment;
  7.    int type;
  8.    int iscolor;
  9.    int mode;
  10.    int page;
  11.    int rows;
  12.    int cols;
  13. };
  14.  
  15. void initvideo(void);
  16. void getvconfig(struct video *);
  17.  
  18. /*
  19. ** descriptors for each display code starting with code 00
  20. */
  21. char *types[] = {
  22.    "[00] No display",
  23.    "[01] Monochrome Display Adapter (MDA) w/mono display",
  24.    "[02] Color Graphics Adapter (CGA) w/color display",
  25.    "[03] <reserved>",
  26.    "[04] Enhanced Graphics Adapter (EGA) w/color display",
  27.    "[05] Enhanced Graphics Adapter (EGA) w/mono display",
  28.    "[06] Professional Graphics System (PGS) w/color display",
  29.    "[07] Video Graphics Array (VGA) w/analog mono display",
  30.    "[08] Video Graphics Array (VGA) w/analog color display",
  31.    "[09] <reserved>",
  32.    "[10] <reserved>",
  33.    "[11] Multi-Color Graphics Array (MCGA) w/analog mono display",
  34.    "[12] Multi-Color Graphics Array (MCGA) w/analog color display",
  35.    "Unknown display combination code",
  36. };
  37.  
  38. struct video v;
  39. int color = 0x07;
  40.  
  41. /*
  42. ** writes a string at the specified location
  43. ** by writing directly to video memory
  44. */
  45. void vwrite(char *str,int row,int col,int color)
  46. {
  47.    char far *screen;
  48.  
  49.    FP_SEG(screen) = v.segment;
  50.    FP_OFF(screen) = (((row - 1) * v.cols) + (col - 1)) * 2;
  51.  
  52.    while(*str) {
  53.       *screen++ = *str++;
  54.       *screen++ = (char)color;
  55.    }
  56. } /* vwrite */
  57.  
  58. void main(int argc, char *argv[])
  59. {
  60.    int blkwht = 0;
  61.    char buffer[81];
  62.  
  63.    /* force black and white if /b option was given */
  64.    if(argc)
  65.       if(!stricmp(argv[1],"/B"))
  66.          blkwht = 1;
  67.  
  68.    /* detect host display type */
  69.    initvideo();
  70.  
  71.    /* fill our video data structure */
  72.    getvconfig(&v);
  73.  
  74.    if(v.iscolor && !blkwht)
  75.       color = 0x1F;
  76.  
  77.    /* print out values */
  78.    sprintf(buffer,"v.segment : %04X",v.segment);
  79.    vwrite(buffer,3,1,color);
  80.    sprintf(buffer,"v.type    : %s",
  81.       (v.type >= 0 && v.type <= 13) ? types[v.type] : types[13]);
  82.    vwrite(buffer,4,1,color);
  83.    sprintf(buffer,"v.iscolor : %d",v.iscolor);
  84.    vwrite(buffer,5,1,color);
  85.    sprintf(buffer,"v.mode    : %d",v.mode);
  86.    vwrite(buffer,6,1,color);
  87.    sprintf(buffer,"v.page    : %d",v.page);
  88.    vwrite(buffer,7,1,color);
  89.    sprintf(buffer,"v.rows    : %d",v.rows);
  90.    vwrite(buffer,8,1,color);
  91.    sprintf(buffer,"v.cols    : %d",v.cols);
  92.    vwrite(buffer,9,1,color);
  93.  
  94. } /* main */
  95.  
  96.  
  97.  
  98.