home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / SCPAGES.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  3.3 KB  |  130 lines

  1. /**
  2. *
  3. * Name        scpages -- Return the number of video display pages for
  4. *               the current video device and mode.
  5. *
  6. * Synopsis    num_pages = scpages();
  7. *
  8. *        int num_pages      The number of display pages.
  9. *
  10. * Description    This function reports the number of pages supported on
  11. *        the current video display adapter in the current mode.
  12. *        It returns 1 for modes that do not support multiple
  13. *        pages, such as mode 7 on the Monochrome Adapter.
  14. *
  15. *        Use SCAPAGE to display any given page.    Use SCPAGE to
  16. *        direct Blaise C TOOLS screen output to any page, whether
  17. *        it is currently displayed or not.
  18. *
  19. * Returns    num_pages      The number of display pages.
  20. *
  21. * Version    6.00 (C)Copyright Blaise Computing Inc.  1986-1989
  22. *
  23. **/
  24.  
  25. #include <dos.h>
  26.  
  27. #include <bscreens.h>
  28.  
  29. int scpages()
  30. {
  31.     int      pages;
  32.     int      mode,columns,act_page;
  33.     union  REGS  inregs,outregs;
  34.     struct SREGS sregs;
  35.     struct                  /* mytable:  Table of mode      */
  36.     {                      /* information returned by VGA/ */
  37.                       /* MCGA function AH=0x1b, BX=0. */
  38.     char          junk1[0x29];
  39.     unsigned char pages;          /* Number of display pages.     */
  40.     char          junk2[0x16];
  41.     } mytable;
  42.  
  43.     if (!b_know_hw)
  44.     scequip();              /* Sense hardware present.      */
  45.  
  46.     pages = 0;                  /* In case of impossible          */
  47.                       /* conditions.              */
  48.  
  49.     scmode(&mode,&columns,&act_page); /* Get VGA/MCGA state.          */
  50.  
  51.     if (b_vga == b_device || b_mcga == b_device)
  52.     switch (mode)
  53.     {
  54.         case 0:              /* Handle cases where BIOS is   */
  55.         case 1:              /* wrong.               */
  56.         pages = (scrows() > 43) ? 7 : 8;
  57.         break;
  58.         case 2:
  59.         case 3:
  60.         case 7:
  61.         pages = (scrows() >= 43) ? 4 : 8;
  62.         break;
  63.  
  64.         default:              /* Ask the BIOS.              */
  65.         inregs.h.ah = 0x1b;
  66.         inregs.x.bx = 0;
  67.         inregs.x.di = utoff(&mytable);
  68.         sregs.es    = utseg(&mytable);
  69.         int86x(SC_BIOS_INT,&inregs,&outregs,&sregs);
  70.         pages = mytable.pages;
  71.         break;
  72.     }
  73.     else if (b_ega == b_device)
  74.     switch (mode)              /* Enhanced Graphics Adapter    */
  75.     {
  76.         case 0:
  77.         case 1:
  78.         if (scrows() == 25)
  79.             pages = 8;
  80.         else              /* Presumable 43-line mode      */
  81.             pages = ((b_mem_ega == 64) ? 4 : 8);
  82.         break;
  83.         case 2:
  84.         case 3:
  85.         case 7:
  86.         if (scrows() == 25)
  87.             pages = ((b_mem_ega == 64) ? 4 : 8);
  88.         else              /* Presumable 43-line mode      */
  89.             pages = b_mem_ega >> 5;
  90.         break;
  91.         case 4:
  92.         case 5:
  93.         case 6:
  94.         pages = 1;
  95.         break;
  96.         case 13:
  97.         pages = b_mem_ega >> 5;
  98.         break;
  99.         case 14:
  100.         pages = b_mem_ega >> 6;
  101.         break;
  102.         case 16:
  103.         pages = (b_mem_ega == 256) ? 2 : 1;
  104.         break;
  105.     }
  106.     else
  107.     switch (mode)
  108.     {
  109.         case 0:
  110.         case 1:
  111.         pages = 8;          /* Color/Graphics Adapter 40 col*/
  112.         break;
  113.         case 2:
  114.         case 3:
  115.         pages = 4;          /* Color/Graphics Adapter 80 col*/
  116.         break;
  117.         case 4:              /* CGA  medium-res graphics     */
  118.         case 5:              /* CGA  medium-res graphics     */
  119.         case 6:              /* CGA  high-res     graphics     */
  120.         case 7:              /* Monochrome Adapter          */
  121.         case 8:              /* PCjr low-res     graphics     */
  122.         case 9:              /* PCjr medium-res graphics     */
  123.         case 10:              /* PCjr high-res     graphics     */
  124.         pages = 1;
  125.         break;
  126.     }
  127.  
  128.     return pages;
  129. }
  130.