home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SPX30.ZIP / SPX_DOC.ZIP / SPX_KEY.DOC < prev    next >
Encoding:
Text File  |  1994-06-13  |  3.6 KB  |  102 lines

  1. { SPX Library Version 3.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.   SPX_KEY is the keyboard handling unit.  It takes over the keyboard
  4. interrupt to allow for reading of multiple keys at the same time.
  5.  
  6.   The (boolean) flag map tells if that key is pressed.
  7.  
  8.   var
  9.     key : array[0..255] of boolean;
  10.  
  11.   The array corresponds to the keys actual scan code (See SPX_KEY.INT for
  12.   list of keyboard constants). If the flag is TRUE then a user has key down.  FALSE means the key
  13.   is not pressed.
  14.  
  15.   Look at the following IF-THEN Pascal code:
  16.  
  17.   if key[F1_KEY] or key[KEY_A]
  18.     then { the function key F1 or the key A was pressed }
  19.  
  20.   There is also a custom array flag build specfically for one/two player
  21.   games.
  22.  
  23.       NP[1..9,1..2] of boolean;
  24.  
  25.   Think of the first index as a key grid like the numeric key pad and
  26.   the second index as which player then your program can use
  27.  
  28.        NP[n,1]            Direction           NP[n,2]
  29.      Player  One                            Player  Two
  30.     ┌───┬───┬───┐       ┌───┬───┬───┐      ┌───┬───┬───┐
  31.     │n=7│n=8│n=9│       │ \ │/|\│ / │      │n=7│n=8│n=9│
  32.     ├───┼───┼───┤       ├───┼───┼───┤      ├───┼───┼───┤
  33.     │n=4│n=5│n=6│       │<- │   │ ->│      │n=4│n=5│n=6│
  34.     ├───┼───┼───┤       ├───┼───┼───┤      ├───┼───┼───┤
  35.     │n=1│n=2│n=3│       │ / │\|/│ \ │      │n=1│n=2│n=3│
  36.     └───┴───┴───┘       └───┴───┴───┘      └───┴───┴───┘
  37.  
  38.  
  39.     You can use NP[8,x] as the up key, NP[6,x] as the right key etc.
  40.  
  41.     e.g.
  42.  
  43.     if np[6,1]
  44.       then { Move player 1 to the right }
  45.     if np[1,2]
  46.       then { Move player 2 left and down }
  47.  
  48. ───────────────────────────────────────────────────────────────────────────
  49.   cleared,                  { TRUE - if int is disabled(not installed) }
  50.   funct,                    { TRUE if the last key from ReadKey was an }
  51.                             {  extended character }
  52.   allowReboot : boolean;    { Set to TRUE to enable CTRL-ALT-DEL in your }
  53.                             {  program }
  54.   portb            : byte;  { returns the current scan code from the }
  55.                             { keyboard, if the hi-bit is set then portb }
  56.                             { indicates that the key has been released }
  57.  
  58. ───────────────────────────────────────────────────────────────────────────
  59.   Three functions/procedures are duplicated to simulate CRT unit functions:
  60.  
  61.    function KeyPressed : boolean;
  62.    function ReadKey : char;
  63.    procedure Readln;
  64.  
  65. ───────────────────────────────────────────────────────────────────────────
  66. procedure clearbuffer;
  67.  
  68.    Waits until no key is pressed
  69.  
  70. ───────────────────────────────────────────────────────────────────────────
  71. procedure clearkeyint;
  72.  
  73.    Restores the old keyboard interrupt
  74.  
  75. ───────────────────────────────────────────────────────────────────────────
  76. procedure installkeyint;
  77.  
  78.    Installs the SPX_KEY keyboard interrupt
  79.  
  80.    Use with clearkeyint.  To install and remove the interrupt multiple
  81. times during the program.
  82.  
  83. ───────────────────────────────────────────────────────────────────────────
  84. function anykey:boolean;
  85.  
  86.    Returns TRUE if there is a key in the keyboard buffer
  87.  
  88. ───────────────────────────────────────────────────────────────────────────
  89. function Keypressed:boolean;
  90.  
  91.    Returns TRUE if there is a key in the keyboard buffer
  92.  
  93. ───────────────────────────────────────────────────────────────────────────
  94. procedure Readln;
  95.  
  96.    Waits until the user presses the ENTER key.
  97. ───────────────────────────────────────────────────────────────────────────
  98. function ReadKey : char;
  99.  
  100.    Reads a key from the keyboard buffer.
  101.  
  102. ───────────────────────────────────────────────────────────────────────────