home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / SCMODE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-13  |  2.4 KB  |  81 lines

  1. /**
  2. *
  3. * Name        scmode -- Return the screen video mode
  4. *
  5. * Synopsis    adapter = scmode(pmode,pcolumns,papage);
  6. *
  7. *        int adapter      Returned adapter status.
  8. *                  1 is returned for the Color/Graphics
  9. *                   Adapter (or if the Enhanced Graphics
  10. *                   Adapter or the Professional Graphics
  11. *                   Controller is emulating the CGA),
  12. *                  or 0 for the Monochrome Adapter (or if
  13. *                   the Enhanced Graphics Adapter is
  14. *                   emulating the Monochrome Adapter).
  15. *        int *pmode      Returned screen mode.
  16. *        int *pcolumns      Returned number of columns on screen.
  17. *        int *papage      Returned active page.
  18. *
  19. * Description    SCMODE returns the current video setting of the screen
  20. *        display.  The functional value indicates which adapter
  21. *        is used.  The integer pointers are used to store values
  22. *        describing the screen.
  23. *
  24. *        See the list of possible modes in SCNEWDEV.C.
  25. *
  26. *        This function also sets the global variable b_device
  27. *        (declared in BSCREEN.H) to COLOR (1) or MONO (0)
  28. *        depending on which device is in use.
  29. *
  30. * Returns    adapter       Adapter used
  31. *        b_device      Adapter used
  32. *        *pmode          Screen mode
  33. *        *pcolumns      Number of columns on screen
  34. *        *papage       Active display page
  35. *
  36. * Version    3.0 (C)Copyright Blaise Computing Inc.    1983, 1984, 1986
  37. *
  38. * Version    3.02 March 24, 1987
  39. *        Changed to ignore bit 7 of mode (which is set on EGA
  40. *            when resetting the mode without clearing the screen).
  41. *
  42. **/
  43.  
  44. #include <bscreen.h>
  45.  
  46. #define  VIDEO_FIELD  0x0030          /* The bits to be examined in   */
  47.                       /* the BIOS equipment flag.     */
  48. #define  MONO_FLAG    0x0030
  49. #define  COLOR_80     0x0020
  50. #define  COLOR_40     0x0010
  51.  
  52. int scmode(pmode,pcolumns,papage)
  53. int *pmode,*pcolumns,*papage;
  54. {
  55.     int ax,bx,cx,dx,flags;          /* Registers for BIOS call      */
  56.  
  57.     ax = utbyword(15,0);
  58.     bios(16,&ax,&bx,&cx,&dx,&flags);
  59.     *pmode    = (ax & 0x7f);          /* Discard bit 7 (sign bit) of  */
  60.                       /*   mode.              */
  61.     *pcolumns = uthibyte(ax);
  62.     *papage   = uthibyte(bx);
  63.  
  64.     bios(17,&ax,&bx,&cx,&dx,&flags);  /* Equipment setting determines */
  65.                       /* which adapter is used.       */
  66.  
  67.     switch (ax & VIDEO_FIELD)
  68.     {
  69.     case MONO_FLAG:
  70.         b_device = MONO;
  71.         break;
  72.     case COLOR_80:
  73.     case COLOR_40:
  74.     default:              /* Impossible bit settings.     */
  75.         b_device = COLOR;
  76.         break;
  77.     }
  78.  
  79.     return b_device;
  80. }
  81.