home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / ansi / avatar1.arj / AVATEST.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-07-25  |  4.3 KB  |  170 lines

  1. page 55, 132
  2. Title   Avatar test
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. ;;
  5. ;;      Check for the presence of an AVATAR console driver
  6. ;;
  7. ;;      Copyright (C) 1990 G. Adam Stanislav
  8. ;;      All Rights Reserved
  9. ;;
  10. ;;      AVATAR and AVATAR console are trademarks of G. Adam Stanislav
  11. ;;      and Stanislav Publishing
  12. ;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. data    segment para    public  'DATA'
  16.  
  17.  
  18.         db      'Copyright (C) 1990 G. Adam Stanislav', 13, 10, 10, 26 ; ^Z
  19. msg     db      'AVATAR console not found.', 13, 10
  20.         db      'Make sure to place the following in your CONFIG.SYS:'
  21.         db      13, 10, 10, 9
  22.         db      'DEVICE=AVATAR.SYS', 13, 10, 10, '$'
  23. slpmsg  db      'Warning: AVATAR console present but asleep.', 13
  24. twolfs  db      10, 10
  25.         db      '$'
  26.  
  27. active  db      'AVATAR console present and active.', 13, 10, 10, '$'
  28.  
  29. tm      db      'AVATAR and AVATAR console are trademarks of G. Adam Sta'
  30.         db      'nislav', 13, 10, 'and Stanislav Publishing.', 13, 10, 10
  31.         db      '$'
  32.  
  33. query   db      16h, 11h, 11h           ; ^V ^Q ^Q = Query the driver
  34.         db      13                      ; CR = if no Avatar, delete the query
  35.         db      '   ', 13               ; 3 blanks, another CR
  36.         db      '$'                     ; End of string
  37.  
  38. qsleep  db      16h, 11h, 1Ch           ; ^V ^Q FS = Query the sleep state
  39.         db      '$'
  40.  
  41. data    ends
  42.  
  43. code    segment para    public  'CODE'
  44.  
  45.         assume  cs:code, ds:data, ss:stack
  46.  
  47. begin:
  48.         mov     ax, data
  49.         mov     ds, ax          ; Find our data
  50.  
  51.         ; Print the query, hopefully via AVATAR.SYS
  52.         lea     dx, query
  53.         mov     ah, 9
  54.         int     21h
  55.  
  56.         ; If AVATAR console is in control, it will reply with a
  57.         ; string that starts "AVT"
  58.  
  59.         mov     ah, 0Bh
  60.         int     21h             ; Anything there?
  61.         inc     al
  62.         jne     noAVT
  63.  
  64.         ; see if we got an 'A'
  65.         mov     ah, 01h         ; Read with echo
  66.         int     21h
  67.         cmp     al, 'A'
  68.         jne     noAVT
  69.  
  70.         ; is 'V' next?
  71.         mov     ah, 0Bh
  72.         int     21h
  73.         inc     al
  74.         jne     noAVT
  75.         mov     ah, 01h
  76.         int     21h
  77.         cmp     al, 'V'
  78.         jne     noAVT
  79.  
  80.         ; is 'T' next?
  81.         mov     ah, 0Bh
  82.         int     21h
  83.         inc     al
  84.         jne     noAVT
  85.         mov     ah, 01h
  86.         int     21h
  87.         cmp     al, 'T'
  88.         jne     noAVT
  89.  
  90.         ; We have received 'AVT'. This is followed by more text
  91.         ; and ends with a CR. If not, this is not an AVATAR console.
  92.  
  93. checkmore:
  94.         mov     ah, 0Bh
  95.         int     21h
  96.         inc     al
  97.         jne     noAVT
  98.         mov     ah, 01h
  99.         int     21h
  100.         cmp     al, 13          ; CR?
  101.         jne     checkmore
  102.  
  103.         lea     dx, twolfs
  104.         mov     ah, 9
  105.         int     21h             ; move two lines down
  106.  
  107.         mov     si, 4C00h       ; no-error exit value
  108.         call    sleeptest       ; check if Avatar is active
  109.         jnc     commonexit
  110.         inc     si              ; Avatar there but inactive, errorlevel = 1
  111.  
  112. commonexit:
  113.         lea     dx, tm
  114.         mov     ah, 9
  115.         int     21h
  116.  
  117.         mov     ax, si
  118.         int     21h
  119.  
  120. noAVT:
  121.         lea     dx, msg
  122.         mov     ah, 9
  123.         int     21h
  124.  
  125.         mov     si, 4C02h       ; errorlevel = 2
  126.         jmp     commonexit
  127.  
  128. sleeptest:
  129.         lea     dx, qsleep      ; Query the sleep state
  130.         mov     ah, 9
  131.         int     21h
  132.  
  133.         mov     ah, 8
  134.         int     21h             ; Character input without echo
  135.         cmp     al, 16h         ; ^V?
  136.         jne     asleep          ; this should never happen, but...
  137.  
  138.         mov     ah, 8
  139.         int     21h             ; Next character
  140.         cmp     al, 1Ch
  141.         je      asleep
  142.  
  143.         lea     dx, active
  144.         mov     ah, 9
  145.         int     21h
  146.  
  147.         clc                     ; active, clear carry
  148.         ret
  149.  
  150. asleep:
  151.         lea     dx, slpmsg
  152.         mov     ah, 9
  153.         int     21h
  154.  
  155.         stc                     ; asleep, set carry
  156.         ret
  157.  
  158. code    ends
  159.  
  160. stack   segment stack
  161.  
  162.         dw      128 dup(1990h)
  163.  
  164. stack   ends
  165.  
  166.         end     begin
  167.  
  168.  
  169.  
  170.