Using CALL INTERRUPT to Determine Current Video Mode

ID: Q40548


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0
  • Microsoft QuickBASIC for MS-DOS, versions 4.0, 4.0b, 4.5
  • Microsoft BASIC Compiler for MS-DOS, versions 6.0, 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2, versions 7.0, 7.1


SUMMARY

Microsoft Visual Basic for MS-DOS cannot determine which kind of video card is installed on your machine. However, you can use the CALL INTERRUPT statement to invoke ROM BIOS video Interrupt 10h, function 0Fh (Get Video Mode) to find out which video mode the machine is currently using. From the information returned by this interrupt, you can determine whether the video card installed is a monochrome card, such as a Hercules or compatible card, or if it is a color card, such as an IBM CGA, EGA, VGA, or compatible card.

In Microsoft QuickBasic for MS-DOS, versions 2.0, 2.01, and 3.0, you can use the CALL INT86 routine instead of CALL INTERRUPT to invoke the video interrupt.


MORE INFORMATION

A Basic application may need to determine whether or not the video system in the machine it is running on is monochrome or color (that is, to decide which colors to use for its output, etc.).

The ROM BIOS Interrupt 10h, function 0Fh, will return the current video mode. If this interrupt returns a 7 in the AL register, the video card is a monochrome card and cannot support color. If it returns something other than 7, the video card can support color; however, this does NOT determine whether or not a color monitor is connected to the computer.

Also, this function can determine where video memory for text mode begins. If the function returns 7, video memory begins at the segment paragraph address of B000h; otherwise, it begins at segment B800h.

For more information, see Page 415 of "Advanced MS-DOS" by Ray Duncan (Microsoft Press, 1986) and Page 45 of "Microsoft QuickBasic Programmer's Toolbox" by John Clark Craig (Microsoft Press, 1988).

The following sample listing demonstrates the use of CALL INTERRUPT to obtain the current video mode.


' To try this example in VBDOS.EXE:
'  1. From the File menu, choose New Project.
'  2. Copy the code example to the Code window.
'  3. Press F5 to run the program.
'
' To run this program in the environment, you must invoke the
' environment with the /L switch to load the default Quick library:
' VBDOS.EXE /L for Visual Basic 1.0 for MS-DOS
' QB /L QB.QLB or QB /L QB.LIB for QuickBasic for MS-DOS
' QB /L QBX.QLB for Basic PDS for MS-DOS
' Use the following include file for Visual Basic 1.0 for MS-DOS:
REM $INCLUDE: 'VBDOS.BI'
' Use the following include file for QuickBasic for MS-DOS:
REM $INCLUDE: 'QB.BI'
' Use the following include file for Basic PDS for MS-DOS:
REM $INCLUDE: 'QBX.BI'

FUNCTION GetVMode% STATIC

'--------------------------------------------------------------------
' Function to return the current video mode. The mode value returned
' is the same value returned from Interrupt 10h, function 0Fh -- Get
' Video Mode (7 = Monochrome card, other = color graphics card).
'--------------------------------------------------------------------
  DIM InRegs AS RegType, OutRegs AS RegType
  InRegs.ax = &HF00                    ' INT 10h, Fn. 0Fh (get vmode).
  CALL INTERRUPT(&H10, InRegs, OutRegs)
  GetVMode% = OutRegs.ax AND 255       ' AL returns the Video Mode.
END FUNCTION 

Additional query words: VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10

Keywords :
Version : MS-DOS:1.0,4.0,4.0b,4.5; :6.0,6.0b,7.0,7.1
Platform : MS-DOS
Issue type :


Last Reviewed: December 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.