The PS/2 and VGA BIOS keep a display combination code: a number for the active adapter and monitor, and one for a second, alternate display. Function 1Ah with AL = 00h returns them in BL and BH and sets AL to 1Ah as proof that it understood the call. An EGA, CGA or MDA BIOS does not have the function and leaves AL as it was, so CMP AL, 1Ah after the call is the standard test for a VGA.
| Code | Display |
|---|---|
| 00h | none |
| 01h | MDA, monochrome monitor |
| 02h | CGA, colour monitor |
| 04h | EGA, colour monitor |
| 05h | EGA, monochrome monitor |
| 06h | PGA |
| 07h | VGA, monochrome monitor |
| 08h | VGA, colour monitor |
| 0Ah, 0Ch | MCGA, digital / analogue colour monitor |
| 0Bh | MCGA, monochrome monitor |
| FFh | unknown |
AL = 01h sets the codes, which only display drivers that switch monitors need. Programs read them:
MOV AX, 1A00h ; get the display combination codeINT 10hCMP AL, 1Ah ; does the BIOS know the function?JNE OLD1MOV [DCC1], BX ; BL = active, BH = alternateMOV AH, 09hMOV DX, OFFSET TXT1INT 21hMOV AL, BYTE PTR [DCC1] ; the active displayCALL PHEX2MOV AH, 09hMOV DX, OFFSET TXT2INT 21hMOV AL, BYTE PTR [DCC1+1] ; the alternateCALL PHEX2MOV DX, OFFSET TXT3JMP LAST1OLD1:MOV DX, OFFSET TXT4 ; an EGA or olderLAST1:MOV AH, 09hINT 21hDCC1 DW 0TXT1 DB "active $"TXT2 DB "h, alternate $"TXT3 DB "h", 13, 10, "$"TXT4 DB "no VGA BIOS", 13, 10, "$"PHEX2: ; print AL as two hex digits; changes AX, CX, DXPUSH AXMOV CL, 4SHR AL, CL ; the high nibble firstCALL PDIG1POP AXAND AL, 0Fh ; then the low one, falling into PDIG1PDIG1:ADD AL, "0"CMP AL, "9"JBE PDIG2ADD AL, 7 ; "A".."F"PDIG2:MOV DL, ALMOV AH, 02h ; DOS: print DLINT 21hRET
Finding out what card is there
The usual ladder: try INT 10h AH=1Ah (VGA or MCGA); if AL did not come back as 1Ah, try INT 10h AH=12h with BL = 10h (EGA); if BL stays 10h, look at the mode from INT 10h AH=0Fh: 07h means a monochrome card, anything else a CGA. Telling a Hercules card from a plain MDA needs a hardware trick: bit 7 of port 3BAh changes with each frame only on a Hercules.
Pitfalls
An SVGA card reports 08h like any VGA; learning more about it takes the VESA functions, starting with AX = 4F00h. The codes say what the BIOS believes is attached, which on old machines came from switches set by hand. DOSBox-X configured as an EGA or CGA machine does not answer, exactly like the real cards.