home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_01 / 2n01043b < prev    next >
Text File  |  1990-06-26  |  2KB  |  101 lines

  1. (*
  2.         Int16 Unit  --  Provides Bios Int $16 
  3.                         keyboard functions $0 and $1
  4.                         and constants for use with them
  5.  
  6.         **************************************************
  7.         NOTE:   All compilations should have the boolean
  8.                 evaluation option set to "short-circuit"
  9.         **************************************************
  10.  
  11.         June 26, 1990       Michael Kelly    Version 1.01    *)
  12.  
  13. Unit Int16;
  14.  
  15. Interface
  16. Uses Dos;
  17.  
  18.  Const              { byte values of key scan codes or ascii codes }
  19.      InsKey = 82;
  20.      DelKey = 83;
  21.      F1Key = 59;
  22.      F2Key = 60;
  23.      F3Key = 61;
  24.      BkSpaceKey = 8;
  25.      SpaceKey = 32;
  26.      ControlC = 3;
  27.      ControlLeft = 115;
  28.      ControlRight = 116;
  29.      ControlEnd = 117;
  30.      ControlHome = 119;
  31.      CReturn = 13;
  32.      EscapeKey = 27;
  33.      TabKey = 9;
  34.      HomeKey = 71;
  35.      EndKey = 79;
  36.      UpKey = 72;
  37.      DownKey = 80;
  38.      LeftKey = 75;
  39.      RightKey = 77;
  40.      PageUpKey = 73;
  41.      PageDownKey = 81;
  42.  
  43.  
  44. (*
  45.  *  if keystroke waiting in keyboard buffer, stores ascii and
  46.  *  scan codes in parameters
  47.  *
  48.  *  notes:  1) does not wait for a keystroke
  49.  *          2) non-destructive input, does not remove keystroke from buffer
  50.  *          3) uses Bios interrupt $16 function 0
  51.  *
  52.  *  returns:
  53.  *              True if keystroke in keyboard buffer
  54.  *
  55.  *              False if no keystroke ready to be read
  56.  *)
  57. Function key_ready(Var ascii, scan : Byte) : Boolean;
  58.  
  59. (*
  60.  *  stores ascii and scan codes of keystroke in parameters
  61.  *
  62.  *  notes:  1) waits for a keystroke
  63.  *          2) destructive input, removes keystroke from buffer
  64.  *          3) uses Bios interrupt $16 function 1
  65.  *)
  66. Procedure get_key(Var ascii, scan : Byte);
  67.  
  68. Implementation
  69.  
  70. Function key_ready(Var ascii, scan : Byte) : Boolean;
  71.     Var
  72.         regs : registers;
  73.  
  74. Begin
  75.   regs.ax := $0100;
  76.   intr($16, regs);
  77.   If((regs.flags and FZero) <> 0) then  { if zero flag set, no key ready }
  78.     key_ready := False
  79.   Else
  80.   Begin
  81.     ascii := regs.al;
  82.     scan := regs.ah;
  83.     key_ready := True;
  84.   End;
  85. End;
  86. (* key_ready *)
  87.  
  88. Procedure get_key(Var ascii, scan : Byte);
  89.     Var
  90.         regs : registers;
  91.  
  92. Begin
  93.   regs.ax := $0000;
  94.   intr($16, regs);
  95.   ascii := regs.al;
  96.   scan := regs.ah;
  97. End;
  98. (* get_key *)
  99.  
  100. End.
  101.