home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / v / vgalib12.tar / vgalib / vgatest.c < prev   
C/C++ Source or Header  |  1993-01-01  |  2KB  |  87 lines

  1. #include <vga.h>
  2.  
  3. static char line[1024];
  4.  
  5. static void testmode(int mode)
  6. {
  7.    int xmax, ymax, colors, i, x, y;
  8.  
  9.    vga_setmode(mode);
  10.  
  11.    vga_screenoff();
  12.  
  13.    xmax   = vga_getxdim()-1;
  14.    ymax   = vga_getydim()-1;
  15.  
  16.    vga_drawline(   0,    0, xmax,    0);
  17.    vga_drawline(xmax,    0, xmax, ymax);
  18.    vga_drawline(xmax, ymax,    0, ymax);
  19.    vga_drawline(   0, ymax,    0,    0);
  20.    
  21.    for(i = 0; i <= 15; i++) {
  22.        vga_setcolor(i);
  23.        vga_drawline(10+i*5, 10, 90+i*5, 90);
  24.    }
  25.    for(i = 0; i <= 15; i++) {
  26.        vga_setcolor(i);
  27.        vga_drawline(90+i*5, 10, 10+i*5, 90);
  28.    }
  29.  
  30.    if (vga_getcolors() == 256) {
  31.        for(i = 0; i < 64; i++)
  32.            vga_setpalette(i+128, i, i, i);
  33.        for(i = 0; i <= xmax; i++)
  34.               line[i] = 128 + i%64;
  35.    } 
  36.    if (vga_getcolors() == 16)       
  37.        for(i = 0; i <= xmax; i++)
  38.               line[i] = i%16;
  39.    if (vga_getcolors() == 2)       
  40.        for(i = 0; i <= xmax; i++)
  41.               line[i] = 0x11;
  42.    
  43.    for(i = 100; i < 190; i++)
  44.        vga_drawscanline(i, line);
  45.  
  46.    vga_screenon(); 
  47.  
  48.    vga_getch();
  49.  
  50.    vga_setmode(TEXT);
  51. }
  52.  
  53.  
  54. main()
  55. {
  56.     int mode;
  57.  
  58.     printf("Chose from one of the following video modes: \n");
  59.     printf("     1:  320x200 pixels, 16 colors \n");
  60.     printf("     2:  640x200 pixels, 16 colors \n");
  61.     printf("     3:  640x350 pixels, 16 colors \n");
  62.     printf("     4:  640x480 pixels, 16 colors \n");
  63.     printf("     5:  320x200 pixels, 256 colors \n");
  64.     printf("     6:  320x240 pixels, 256 colors \n");
  65.     printf("     7:  320x400 pixels, 256 colors \n");
  66.     printf("     8:  360x480 pixels, 256 colors \n");
  67.     printf("     9:  640x480 pixels, Monochrome \n");
  68.     printf("    10:  640x480 pixels, 256 colors (only ET4000) \n");
  69.     printf("    11:  800x600 pixels, 256 colors (only ET4000) \n");
  70.     printf("    12: 1024x768 pixels, 256 colors (only ET4000) \n");
  71.     printf("Enter mode number (1-12): ");
  72.     scanf("%d", &mode);
  73.     printf("\n");
  74.  
  75.     if (mode < 1 || mode > 12) {
  76.     printf("Error: Mode number out of range \n");
  77.     exit(-1);
  78.     }
  79.  
  80.     if (vga_hasmode(mode))
  81.     testmode(mode);
  82.     else {
  83.     printf("Error: Video mode not supported by graphics card\n");
  84.     exit(-1);
  85.     }
  86. }
  87.