home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / emx / test / vmode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  800 b   |  43 lines

  1. /* vmode.c (emx+gcc) */
  2.  
  3. /* Show & select video mode, test int86() */
  4. /* DOS only (see also vio.c) */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <dos.h>
  9.  
  10. static void usage (void)
  11. {
  12.   fputs ("Usage: vmode [<mode_number>]\n", stderr);
  13.   exit (1);
  14. }
  15.  
  16.  
  17. int main (int argc, char *argv[])
  18. {
  19.   long mode;
  20.   char *p;
  21.   union REGS r;
  22.  
  23.   if (argc == 1)
  24.     {
  25.       r.h.ah = 0x0f;
  26.       _int86 (0x10, &r, &r);
  27.       printf ("Mode 0x%x, %d columns\n", r.h.al, r.h.ah);
  28.     }
  29.   else if (argc == 2)
  30.     {
  31.       errno = 0;
  32.       mode = strtol (argv[1], &p, 0);
  33.       if (errno != 0 || mode < 0 || mode > 255 || *p != 0)
  34.         usage ();
  35.       r.h.ah = 0x00;
  36.       r.h.al = (unsigned char)mode;
  37.       _int86 (0x10, &r, &r);
  38.     }
  39.   else
  40.     usage ();
  41.   return (0);
  42. }
  43.