home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / batch / library / batutl2 / timeread.asm < prev    next >
Assembly Source File  |  1988-04-20  |  2KB  |  107 lines

  1. TITLE    TIMEREAD    1-10-85    [4-18-88]
  2. ;Toad Hall Disassembly, tweak
  3.  
  4. ;Wait for user input (Y or N) in a timeout loop.
  5. ;Return Errorlevel =
  6. ; 0 = No
  7. ; 1 = Yes
  8. ; 2 = Timed out (no response)
  9.  
  10. LF    EQU    0AH
  11. CR    EQU    0DH
  12. ;
  13. ;INITIAL VALUES :    CS:IP    0000:0100
  14. ;            SS:SP    0000:FFFF
  15. CodeSeg    SEGMENT
  16.     ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
  17.     ORG    100H
  18.  
  19. TimeRead    proc    near
  20.     JMP    SHORT    PromptLup
  21.  
  22. ynStr    DB    ' (Y/N) $'
  23. beepStr    DB    7
  24. crlfStr    db    LF,CR,'$'
  25.  
  26. PromptLup:
  27.     MOV    DX,OFFSET ynStr        ;'Y/N'
  28.     mov    ah,9            ;display string
  29.     INT    21H
  30.     MOV    CX,0AH            ;10 retries
  31.  
  32. RetryLup:
  33.     call    Chk_Kbd            ;check kbd status
  34.     je    Get_Key            ; yep, go process it
  35.     xor    ah,ah            ;turn on cassette motor?
  36.     INT    15H            ;weird ...
  37.     MOV    AH,2            ;display char
  38.     MOV    DL,'.'
  39.     INT    21H
  40.     call    Delay            ;delay a bit
  41.     call    Chk_Kbd            ;check kbd status
  42.     je    Get_Key            ; yep
  43.     MOV    AH,1            ;turn off cassette motor
  44.     INT    15H            ; weird ...
  45.     call    Delay            ;delay a bit
  46.     LOOP    RetryLup        ;retry loop
  47.  
  48.     MOV    AL,2            ;timed out, return Errorlevel = 2
  49.     JMP    SHORT    Endit        ; and terminate
  50.  
  51. Get_Key:
  52.     MOV    AH,1            ;kbd input w/echo
  53.     INT    21H
  54.     and    al,5FH            ;uppercase it
  55.     CMP    AL,'Y'
  56.     JZ    Said_Yes
  57. ;    CMP    AL,'y'
  58. ;    JZ    Said_Yes
  59.     CMP    AL,'N'
  60.     JZ    Said_No
  61. ;    CMP    AL,'n'
  62. ;    JZ    Said_No
  63.     MOV    DX,OFFSET beepStr    ;Bell, newline
  64.     MOV    AH,9            ;display string
  65.     INT    21H
  66.     JMP    SHORT    PromptLup    ;reloop
  67.  
  68. Said_Yes:
  69.     MOV    AL,1            ;yes, return Errorlevel = 1
  70.     JMP    SHORT    Endit
  71.  
  72. Said_No:
  73.     xor    al,al            ;no, return Errorlevel = 0
  74. Endit:
  75.     mov    bx,ax            ;save Errorlevel in AL
  76.     mov    dx,offset crlfStr    ;newline
  77.     mov    ah,9            ;display string
  78.     int    21H
  79.     mov    ax,bx            ;restore Errorlevel in AL
  80.     MOV    AH,4CH            ;terminate process
  81.     INT    21H
  82. TimeRead    endp
  83.  
  84.  
  85. ;Common procedure (used twice) .. check kbd status,
  86. ;return zflag if char ready
  87. Chk_Kbd    proc    near
  88.     MOV    AH,0BH            ;check kbd status
  89.     INT    21H
  90.     CMP    AL,0FFH            ;anything there?
  91.     ret                ;with ZFlag set accordingly
  92. Chk_Kbd    endp
  93.  
  94.  
  95. ;Common procedure (used twice) .. delay a while
  96. Delay    proc    near
  97.     MOV    BX,0F100H        ;delay counter
  98. DelayLup:
  99.     nop
  100.     dec    bx
  101.     jne    DelayLup        ;delay loop
  102.     ret
  103. Delay    endp
  104.  
  105. CodeSeg    ENDS
  106.     END    TimeRead
  107.