home *** CD-ROM | disk | FTP | other *** search
- .MODEL LARGE
- .CODE
- PUBLIC CHKKEY
- PUBLIC GETKEY
- CHKKEY PROC Far
- push bp
- mov bp,sp
- IFDEF WATCOM
- push es
- push si
- mov es, dx ; DX is segment of return value
- mov si, ax ; AX is offset of return value
- ELSEIFDEF LAHEY
- les si, [bp+6] ; Load result addr
- ELSE ; MSOFT is default
- push si
- les si, [bp+6] ; Load result addr
- ENDIF
- ;
- ; Keyboard Status Routine
- ; Copyright 1992 Kenneth G. Hamilton
- ;
- ; Call from Lahey, Microsoft or Watcom real mode Fortran with:
- ; CALL CHKKEY(ISTAT)
- ; CALL GETKEY(ISTAT)
- ; where ISTAT is an INTEGER*2 variable.
- ;
- ; If CHKKEY was called, then the keyboard will be checked for
- ; input. If there has been none, then a return with ISTAT=0
- ; is performed. If a key has been pressed, then the low byte
- ; of ISTAT will contain the ASCII value, while the high byte
- ; will be the scan code, of the the key that was pressed.
- ;
- ; If GETKEY was called, then the program will wait for a key
- ; to be pressed, and then return it as described above.
- ;
- mov ah,01 ; Get keyboard status
- int 16h ; BIOS call
- jnz L10 ; Got a keystroke
- mov ax,0 ; No key input,so return zero
- jmp L20 ; Get out of here
- ;
- GETKEY label far
- push bp ; Second entry point
- mov bp,sp ; for when we want to wait
- IFDEF WATCOM
- push es
- push si
- mov es, dx ; DX is segment of return value
- mov si, ax ; AX is offset of return value
- ELSEIFDEF LAHEY
- les si, [bp+6] ; Load result addr
- ELSE ; MSOFT is default
- push si
- les si, [bp+6] ; Load result addr
- ENDIF
- ;
- L10: mov ah,00 ; We have a key: get it
- int 16h ; BIOS call; key info is put in AX
- ;
- L20: mov es:[si],ax ; Store the return value
- ;
- IFDEF WATCOM
- pop si
- pop es
- pop bp
- ret
- ELSEIFDEF LAHEY
- pop bp
- ret
- ELSE ; MSOFT is default
- pop si
- pop bp
- ret 4
- ENDIF
- ;
- CHKKEY ENDP
- END
-