home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
1989
/
02
/
dunteman.asc
< prev
next >
Wrap
Text File
|
1989-01-04
|
4KB
|
112 lines
_Structured Programming Column_
by Jeff Duntemann
[EXAMPLE 1]
FUNCTION QueryAdapterType : AdapterType;
VAR
Regs : Registers;
Code : Byte;
BEGIN
Regs.AH := $1A; { Attempt to call VGA Identify Adapter Function }
Regs.AL := $00; { Must clear AL to 0 ... }
Intr($10,Regs);
IF Regs.AL = $1A THEN { ...so that if $1A comes back in AL... }
BEGIN { ...we know a PS/2 video BIOS is out there. }
CASE Regs.BL OF { Code comes back in BL }
$00 : QueryAdapterType := None;
$01 : QueryAdapterType := MDA;
$02 : QueryAdapterType := CGA;
$04 : QueryAdapterType := EGAColor;
$05 : QueryAdapterType := EGAMono;
$07 : QueryAdapterType := VGAMono;
$08 : QueryAdapterType := VGAColor;
$0A,$0C : QueryAdapterType := MCGAColor;
$0B : QueryAdapterType := MCGAMono;
ELSE QueryAdapterType := CGA
END { CASE }
END
ELSE
{ If it's not PS/2 we have to check for the presence of an EGA BIOS: }
BEGIN
Regs.AH := $12; { Select Alternate Function service }
Regs.BX := $10; { BL=$10 means return EGA information }
Intr($10,Regs); { Call BIOS VIDEO }
IF Regs.BX <> $10 THEN { BX unchanged means EGA is NOT there...}
BEGIN
Regs.AH := $12; { Once we know Alt Function exists... }
Regs.BL := $10; { ...we call it again to see if it's... }
Intr($10,Regs); { ...EGA color or EGA monochrome. }
IF (Regs.BH = 0) THEN QueryAdapterType := EGAColor
ELSE QueryAdapterType := EGAMono
END
ELSE { Now we know we have an CGA or MDA; let's see which: }
BEGIN
Intr($11,Regs); { Equipment determination service }
Code := (Regs.AL AND $30) SHR 4;
CASE Code of
1 : QueryAdapterType := CGA;
2 : QueryAdapterType := CGA;
3 : QueryAdapterType := MDA
ELSE QueryAdapterType := None
END { Case }
END
END;
END;
[EXAMPLE 2]
PROCEDURE QueryAdapterType() : AdapterType;
VAR
Regs : Registers;
Code : SHORTCARD;
BEGIN
Regs.AH := 1AH; (* Attempt to call VGA Identify Adapter Function *)
Regs.AL := 0; (* Must clear AL to 0 ... *)
Intr(Regs,10H);
IF Regs.AL = 1AH THEN (* ...so that if $1A comes back in AL... *)
(* ...we know a PS/2 video BIOS is out there. *)
CASE Regs.BL OF (* Code comes back in BL *)
0 : RETURN None |
1 : RETURN MDA; |
2 : RETURN CGA; |
4 : RETURN EGAColor; |
5 : RETURN EGAMono; |
7 : RETURN VGAMono; |
8 : RETURN VGAColor; |
0AH,0CH : RETURN MCGAColor; |
0BH : RETURN MCGAMono; |
ELSE RETURN CGA
END (* CASE *)
ELSE
(* If it's not PS/2 we have to check for the presence of an EGA BIOS: *)
Regs.AH := 12H; (* Select Alternate Function service *)
Regs.BX := 10H; (* BL=$10 means return EGA information *)
Intr(Regs,10H); (* Call BIOS VIDEO *)
IF Regs.BX <> 10H THEN (* BX unchanged means EGA is NOT there...*)
Regs.AH := 12H; (* Once we know Alt Function exists... *)
Regs.BL := 10H; (* ...we call it again to see if it's... *)
Intr(Regs,10H); (* ...EGA color or EGA monochrome. *)
IF (Regs.BH = 0) THEN RETURN EGAColor
ELSE RETURN EGAMono
END
ELSE (* Now we know we have an CGA or MDA; let's see which: *)
Intr(Regs,11H); (* Equipment determination service *)
Code := SHORTCARD(BITSET(Regs.AL) * BITSET{4..5}) >> 4;
CASE Code OF
1 : RETURN CGA |
2 : RETURN CGA |
3 : RETURN MDA
ELSE RETURN None
END (* Case *)
END
END
END QueryAdapterType;