Page 1 of 1

Detect VGA Sub-System ???

Posted: Mon Apr 25, 2011 2:00 am
by bitshifter
I used RBIL to make this, is it enough to be proper?

Code: Select all

   ; Get display combination code. 
   ; See RBIL INTERRUP.A - V-101A00. 

   mov   ax,1A00h 
   int   10h 

   cmp   al,1Ah   ; AL = 1Ah if function is supported. 
   jne   @@novga 

   ; BL = Active display code. 
   ; BH = Alternate display code. 

   cmp   bl,8      ; Is color analog VGA active? 
   jne   @@novga 

   ; Make sure an ATI EGA Wonder isnt lying to us. 
   ; See RBIL INTERRUP.A - V-101A00 and V-101C. 

   mov   ax,1C00h   ; Video save/restore state function. 
   mov   cx,2       ; Only video hardware (CX=0) is supported on EGA Wonder. 
   int   10h        ; So lets check for color registers and DAC state. (CX=2) 

   cmp   al,1Ch     ; AL = 1Ch if function is supported. 
   jne   @@novga 

   ; Yes, we have an active color analog VGA! 

   mov   ax,1    ; Indicate success, VGA support was detected!
   jmp   @@done 

@@novga: 

   xor   ax,ax   ; Indicate failure, no VGA was detected! 

@@done: 

   ret

Re: Detect VGA Sub-System ???

Posted: Mon Apr 25, 2011 2:54 am
by Brendan
Hi,
bitshifter wrote:I used RBIL to make this, is it enough to be proper?
That should be enough to detect if a "VGA or later" is present. It won't detect if there's a monitor attached or not, or guarantee that the video card isn't in an SVGA mode. Therefore it can't reliably be used to determine if the computer is "headless" or not; or determine if it's safe to use legacy VGA IO ports.

Mostly, it's only really useful as a hint.

For example, I use "int 0x10, al=0x1A" in an attempt to detect if the computer is "headless" or not in boot code, but also provide a way for the user to override this (which is also why I don't feel the need to care about "ATI EGA Wonder" for my code); and use BIOS functions (including VBE) to ensure that I never need to use any legacy VGA IO ports (excluding within native video drivers).


Cheers,

Brendan

Re: Detect VGA Sub-System ???

Posted: Mon Apr 25, 2011 10:04 am
by egos
Hi, guys. I use this technique too:

Code: Select all

        mov ax,1A00h
        int 10h
        cmp al,1Ah
        jne .error_7 ; now I don't support EGA