qa.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DisableCGA
   Example  Back  Contents  Index
──────────────────────────────────────────────────────────────────────────────
 
;* DisableCGA - Disables CGA video by reprogramming the control register.
;*
;* Shows:   Instructions - cli     sti     loopz     loopnz
;*
;* Uses:    vconfig - Video configuration structure, declared in the
;*          DEMO.INC include file. The structure must first be
;*          initialized by calling the GetVidConfig procedure.
;*
;* Params:  None
;*
;* Return:  None
 
DisableCGA PROC \
        USES ax cx dx                   ; Preserve registers
 
        mov     cx, -1                  ; Set maximum loop count
        mov     dx, 03DAh               ; Address of status register
wait1:  in      al, dx                  ; Get video status
        test    al, 8                   ; Vertical retrace active?
        loopnz  wait1                   ; Yes?  Wait for end/timeout
        cli                             ; Disallow interruptions
        mov     cx, -1                  ; Reset loop count
wait2:  in      al, dx                  ; Get video status
        test    al, 8                   ; Start of vertical retrace?
        loopz   wait2                   ; No?  Wait for start/timeout
        sub     dx, 2                   ; DX = address of control reg
        mov     al, 1                   ; Value to disable CGA video
        out     dx, al                  ; Disable video
        sti                             ; Reenable interrupts
        ret
 
DisableCGA ENDP
                                    -♦-