home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name scmode -- Return the screen video mode
- *
- * Synopsis adapter = scmode(pmode,pcolumns,papage);
- *
- * int adapter Returned adapter status.
- * 1 is returned for the Color/Graphics
- * Adapter (or if another adapter is
- * emulating the CGA),
- * or 0 for the Monochrome Adapter (or if
- * another adapter is emulating
- * the Monochrome Adapter).
- * int *pmode Returned screen mode.
- * int *pcolumns Returned number of columns on screen.
- * int *papage Returned active page.
- *
- * Description SCMODE returns the current video setting of the screen
- * display. The functional value indicates which adapter
- * is used. The integer pointers are used to store values
- * describing the screen.
- *
- * See the list of possible modes in SCNEWDEV.C.
- *
- * This function also sets the global variables b_device,
- * b_vga, and b_mcga (declared in BSCREENS.H) to SC_COLOR
- * (1) or SC_MONO (0) depending on which device is in use.
- *
- * Returns adapter Adapter used
- * b_device Adapter used
- * b_vga b_device (if VGA is current device)
- * b_mcga b_device (if MCGA is current device)
- * *pmode Screen mode
- * *pcolumns Number of columns on screen
- * *papage Active display page
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1983,1987,1989
- *
- **/
-
- #include <dos.h>
-
- #include <bscreens.h>
-
- int b_device = SC_DONT_KNOW; /* Current adapter: SC_DONT_KNOW, */
- /* SC_MONO, or SC_COLOR */
-
- #define VIDEO_FIELD 0x0030 /* The bits to be examined in */
- /* the BIOS equipment flag. */
- #define MONO_FLAG 0x0030
- #define COLOR_80 0x0020
- #define COLOR_40 0x0010
-
- int scmode(pmode,pcolumns,papage)
- int *pmode,*pcolumns,*papage;
- {
- union REGS inregs,outregs; /* Registers for BIOS calls */
-
- inregs.h.ah = 15;
- int86(SC_BIOS_INT,&inregs,&outregs);
- *pmode = (outregs.h.al & 0x7f); /* Discard bit 7 (sign bit) */
- *pcolumns = outregs.h.ah; /* of mode. */
- *papage = outregs.h.bh;
-
- int86(17,&inregs,&outregs); /* Equipment setting determines */
- /* which adapter is used. */
-
- switch (outregs.x.ax & VIDEO_FIELD)
- {
- case MONO_FLAG:
- b_device = SC_MONO;
- break;
- case COLOR_80:
- case COLOR_40:
- default: /* Impossible bit settings. */
- b_device = SC_COLOR;
- break;
- }
-
- /* Check VGA/MCGA state. */
- inregs.x.ax = 0x1a00;
- int86(SC_BIOS_INT,&inregs,&outregs);
- if (outregs.h.al == 0x1a)
- { /* Function 0x1a is supported. */
- switch (outregs.h.bl) /* Handle active device. */
- {
- case 0x07:
- case 0x08: b_vga = b_device; break;
-
- case 0x0b:
- case 0x0c: b_mcga = b_device; break;
- }
- switch (outregs.h.bh) /* Handle alternate device. */
- {
- case 0x07:
- case 0x08:
- b_vga = (b_device == SC_MONO ? SC_COLOR : SC_MONO);
- break;
-
- case 0x0b:
- case 0x0c:
- if (b_device == SC_MONO)
- b_mcga = SC_COLOR;
- break;
- }
- }
-
- return b_device;
- }