home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name scpages -- Return the number of video display pages for
- * the current video device and mode.
- *
- * Synopsis num_pages = scpages();
- *
- * int num_pages The number of display pages.
- *
- * Description This function reports the number of pages supported on
- * the current video display adapter in the current mode.
- * It returns 1 for modes that do not support multiple
- * pages, such as mode 7 on the Monochrome Adapter.
- *
- * Use SCAPAGE to display any given page. Use SCPAGE to
- * direct Blaise C TOOLS screen output to any page, whether
- * it is currently displayed or not.
- *
- * Returns num_pages The number of display pages.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1986-1989
- *
- **/
-
- #include <dos.h>
-
- #include <bscreens.h>
-
- int scpages()
- {
- int pages;
- int mode,columns,act_page;
- union REGS inregs,outregs;
- struct SREGS sregs;
- struct /* mytable: Table of mode */
- { /* information returned by VGA/ */
- /* MCGA function AH=0x1b, BX=0. */
- char junk1[0x29];
- unsigned char pages; /* Number of display pages. */
- char junk2[0x16];
- } mytable;
-
- if (!b_know_hw)
- scequip(); /* Sense hardware present. */
-
- pages = 0; /* In case of impossible */
- /* conditions. */
-
- scmode(&mode,&columns,&act_page); /* Get VGA/MCGA state. */
-
- if (b_vga == b_device || b_mcga == b_device)
- switch (mode)
- {
- case 0: /* Handle cases where BIOS is */
- case 1: /* wrong. */
- pages = (scrows() > 43) ? 7 : 8;
- break;
- case 2:
- case 3:
- case 7:
- pages = (scrows() >= 43) ? 4 : 8;
- break;
-
- default: /* Ask the BIOS. */
- inregs.h.ah = 0x1b;
- inregs.x.bx = 0;
- inregs.x.di = utoff(&mytable);
- sregs.es = utseg(&mytable);
- int86x(SC_BIOS_INT,&inregs,&outregs,&sregs);
- pages = mytable.pages;
- break;
- }
- else if (b_ega == b_device)
- switch (mode) /* Enhanced Graphics Adapter */
- {
- case 0:
- case 1:
- if (scrows() == 25)
- pages = 8;
- else /* Presumable 43-line mode */
- pages = ((b_mem_ega == 64) ? 4 : 8);
- break;
- case 2:
- case 3:
- case 7:
- if (scrows() == 25)
- pages = ((b_mem_ega == 64) ? 4 : 8);
- else /* Presumable 43-line mode */
- pages = b_mem_ega >> 5;
- break;
- case 4:
- case 5:
- case 6:
- pages = 1;
- break;
- case 13:
- pages = b_mem_ega >> 5;
- break;
- case 14:
- pages = b_mem_ega >> 6;
- break;
- case 16:
- pages = (b_mem_ega == 256) ? 2 : 1;
- break;
- }
- else
- switch (mode)
- {
- case 0:
- case 1:
- pages = 8; /* Color/Graphics Adapter 40 col*/
- break;
- case 2:
- case 3:
- pages = 4; /* Color/Graphics Adapter 80 col*/
- break;
- case 4: /* CGA medium-res graphics */
- case 5: /* CGA medium-res graphics */
- case 6: /* CGA high-res graphics */
- case 7: /* Monochrome Adapter */
- case 8: /* PCjr low-res graphics */
- case 9: /* PCjr medium-res graphics */
- case 10: /* PCjr high-res graphics */
- pages = 1;
- break;
- }
-
- return pages;
- }