home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1989 / 02 / dunteman.asc < prev    next >
Text File  |  1989-01-04  |  4KB  |  112 lines

  1. _Structured Programming Column_
  2. by Jeff Duntemann
  3.  
  4. [EXAMPLE 1]
  5.  
  6. FUNCTION QueryAdapterType : AdapterType;
  7.  
  8. VAR
  9.   Regs : Registers;
  10.   Code : Byte;
  11.  
  12. BEGIN
  13.   Regs.AH := $1A;  { Attempt to call VGA Identify Adapter Function }
  14.   Regs.AL := $00;  { Must clear AL to 0 ... }
  15.   Intr($10,Regs);
  16.   IF Regs.AL = $1A THEN  { ...so that if $1A comes back in AL...  }
  17.     BEGIN                { ...we know a PS/2 video BIOS is out there. }
  18.       CASE Regs.BL OF    { Code comes back in BL }
  19.         $00 : QueryAdapterType := None;
  20.         $01 : QueryAdapterType := MDA;
  21.         $02 : QueryAdapterType := CGA;
  22.         $04 : QueryAdapterType := EGAColor;
  23.         $05 : QueryAdapterType := EGAMono;
  24.         $07 : QueryAdapterType := VGAMono;
  25.         $08 : QueryAdapterType := VGAColor;
  26.         $0A,$0C : QueryAdapterType := MCGAColor;
  27.         $0B : QueryAdapterType := MCGAMono;
  28.         ELSE QueryAdapterType := CGA
  29.       END { CASE }
  30.     END
  31.   ELSE
  32.   { If it's not PS/2 we have to check for the presence of an EGA BIOS: }
  33.     BEGIN
  34.       Regs.AH := $12;       { Select Alternate Function service }
  35.       Regs.BX := $10;       { BL=$10 means return EGA information }
  36.       Intr($10,Regs);       { Call BIOS VIDEO }
  37.       IF Regs.BX <> $10 THEN { BX unchanged means EGA is NOT there...}
  38.         BEGIN
  39.           Regs.AH := $12;   { Once we know Alt Function exists... }
  40.           Regs.BL := $10;   { ...we call it again to see if it's... }
  41.           Intr($10,Regs);   { ...EGA color or EGA monochrome. }
  42.           IF (Regs.BH = 0) THEN QueryAdapterType := EGAColor
  43.             ELSE QueryAdapterType := EGAMono
  44.         END
  45.       ELSE  { Now we know we have an CGA or MDA; let's see which: }
  46.         BEGIN
  47.           Intr($11,Regs);   { Equipment determination service }
  48.           Code := (Regs.AL AND $30) SHR 4;
  49.           CASE Code of
  50.             1 : QueryAdapterType := CGA;
  51.             2 : QueryAdapterType := CGA;
  52.             3 : QueryAdapterType := MDA
  53.             ELSE QueryAdapterType := None
  54.           END { Case }
  55.         END
  56.     END;
  57. END;
  58.  
  59.  
  60. [EXAMPLE 2]
  61.  
  62. PROCEDURE QueryAdapterType() : AdapterType;
  63.  
  64. VAR
  65.   Regs : Registers;
  66.   Code : SHORTCARD;
  67.  
  68.  
  69. BEGIN
  70.   Regs.AH := 1AH;  (* Attempt to call VGA Identify Adapter Function *)
  71.   Regs.AL := 0;  (* Must clear AL to 0 ... *)
  72.   Intr(Regs,10H);
  73.   IF Regs.AL = 1AH THEN  (* ...so that if $1A comes back in AL...  *)
  74.                          (* ...we know a PS/2 video BIOS is out there. *)
  75.     CASE Regs.BL OF      (* Code comes back in BL *)
  76.       0 : RETURN None             |
  77.       1 : RETURN MDA;             |
  78.       2 : RETURN CGA;             |
  79.       4 : RETURN EGAColor;        |
  80.       5 : RETURN EGAMono;         |
  81.       7 : RETURN VGAMono;         |
  82.       8 : RETURN VGAColor;        |
  83.       0AH,0CH : RETURN MCGAColor; |
  84.       0BH : RETURN MCGAMono;      |
  85.       ELSE RETURN CGA
  86.     END (* CASE *)
  87.   ELSE
  88.   (* If it's not PS/2 we have to check for the presence of an EGA BIOS: *)
  89.     Regs.AH := 12H;       (* Select Alternate Function service *)
  90.     Regs.BX := 10H;       (* BL=$10 means return EGA information *)
  91.     Intr(Regs,10H);       (* Call BIOS VIDEO *)
  92.     IF Regs.BX <> 10H THEN (* BX unchanged means EGA is NOT there...*)
  93.         Regs.AH := 12H;   (* Once we know Alt Function exists... *)
  94.         Regs.BL := 10H;   (* ...we call it again to see if it's... *)
  95.         Intr(Regs,10H);   (* ...EGA color or EGA monochrome. *)
  96.         IF (Regs.BH = 0) THEN RETURN EGAColor
  97.         ELSE RETURN EGAMono
  98.         END
  99.     ELSE  (* Now we know we have an CGA or MDA; let's see which: *)
  100.       Intr(Regs,11H);   (* Equipment determination service *)
  101.       Code := SHORTCARD(BITSET(Regs.AL) * BITSET{4..5}) >> 4;
  102.       CASE Code OF
  103.         1 : RETURN CGA  |
  104.         2 : RETURN CGA  |
  105.         3 : RETURN MDA
  106.         ELSE RETURN None
  107.       END (* Case *)
  108.     END
  109.   END
  110. END QueryAdapterType;
  111.  
  112.