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.
VeriAnsi
   Example  Back  Contents  Index
──────────────────────────────────────────────────────────────────────────────
 
;* VeriAnsi - Checks for ANSI driver by writing ANSI sequence to report
;* cursor position. If report compares with position returned from
;* GetCurPos procedure, then ANSI driver is operating.
;*
;* Shows:   DOS Functions - 06h (Direct Console I/O)
;*                          0Ch (Flush Input Buffer then Input)
;*
;* Params:  None
;*
;* Return:  Short integer, 1 for yes or 0 for no
 
        .DATA
        PUBLIC report
report  DB      ESCAPE, '[6n$'          ; ANSI Report Cursor sequence
        .CODE
 
VeriAnsi PROC
 
        call    GetCurPos               ; Cursor position from BIOS
        mov     cx, ax                  ; Save it in CX
        mov     dx, OFFSET report       ; ANSI string to get position
        mov     ah, 9                   ; Request DOS String Output
        int     21h                     ; Write ANSI escape sequence
 
        mov     ah, 6                   ; Skip Esc character in
        mov     dl, 0FFh                ;   keyboard buffer
        int     21h
        jz      e_exit                  ; If no key, ANSI not loaded
        mov     ah, 6                   ; Skip '[' character
        int     21h
        jz      e_exit                  ; If no key, ANSI not loaded
        mov     ah, 6                   ; Get 1st digit of cursor row
        int     21h
        jz      e_exit                  ; If no key, ANSI not loaded
        mov     bh, al                  ; Store in BH
        mov     ah, 6                   ; Get 2nd digit of cursor row
        int     21h
        jz      e_exit                  ; If no key, ANSI not loaded
        mov     bl, al                  ; Store in BL
        mov     al, ch                  ; Get original row # in AL
        cbw                             ; AX = row # from GetCurPos
        inc     ax                      ; Add 1 to it
        call    IntToAsc                ; Make ASCII digits
        cmp     ax, bx                  ; ANSI and BIOS reports match?
        jne     e_exit                  ; No?  Then ANSI not loaded
 
        mov     ax, 0C06h               ; Flush remaining ANSI keys
        mov     dl, 0FFh                ;   from buffer
        int     21h
        mov     ax, 1                   ; Set 1 for true
        jmp     SHORT exit              ;   and exit
 
e_exit: sub     ax, ax                  ; Set 0 return code if no
exit:   ret                             ;   ANSI driver installed
 
VeriAnsi ENDP
                                    -♦-