home *** CD-ROM | disk | FTP | other *** search
- { SPX Library Version 3.0 Copyright 1993 Scott D. Ramsay }
-
- SPX_KEY is the keyboard handling unit. It takes over the keyboard
- interrupt to allow for reading of multiple keys at the same time.
-
- The (boolean) flag map tells if that key is pressed.
-
- var
- key : array[0..255] of boolean;
-
- The array corresponds to the keys actual scan code (See SPX_KEY.INT for
- list of keyboard constants). If the flag is TRUE then a user has key down. FALSE means the key
- is not pressed.
-
- Look at the following IF-THEN Pascal code:
-
- if key[F1_KEY] or key[KEY_A]
- then { the function key F1 or the key A was pressed }
-
- There is also a custom array flag build specfically for one/two player
- games.
-
- NP[1..9,1..2] of boolean;
-
- Think of the first index as a key grid like the numeric key pad and
- the second index as which player then your program can use
-
- NP[n,1] Direction NP[n,2]
- Player One Player Two
- ┌───┬───┬───┐ ┌───┬───┬───┐ ┌───┬───┬───┐
- │n=7│n=8│n=9│ │ \ │/|\│ / │ │n=7│n=8│n=9│
- ├───┼───┼───┤ ├───┼───┼───┤ ├───┼───┼───┤
- │n=4│n=5│n=6│ │<- │ │ ->│ │n=4│n=5│n=6│
- ├───┼───┼───┤ ├───┼───┼───┤ ├───┼───┼───┤
- │n=1│n=2│n=3│ │ / │\|/│ \ │ │n=1│n=2│n=3│
- └───┴───┴───┘ └───┴───┴───┘ └───┴───┴───┘
-
-
- You can use NP[8,x] as the up key, NP[6,x] as the right key etc.
-
- e.g.
-
- if np[6,1]
- then { Move player 1 to the right }
- if np[1,2]
- then { Move player 2 left and down }
-
- ───────────────────────────────────────────────────────────────────────────
- cleared, { TRUE - if int is disabled(not installed) }
- funct, { TRUE if the last key from ReadKey was an }
- { extended character }
- allowReboot : boolean; { Set to TRUE to enable CTRL-ALT-DEL in your }
- { program }
- portb : byte; { returns the current scan code from the }
- { keyboard, if the hi-bit is set then portb }
- { indicates that the key has been released }
-
- ───────────────────────────────────────────────────────────────────────────
- Three functions/procedures are duplicated to simulate CRT unit functions:
-
- function KeyPressed : boolean;
- function ReadKey : char;
- procedure Readln;
-
- ───────────────────────────────────────────────────────────────────────────
- procedure clearbuffer;
-
- Waits until no key is pressed
-
- ───────────────────────────────────────────────────────────────────────────
- procedure clearkeyint;
-
- Restores the old keyboard interrupt
-
- ───────────────────────────────────────────────────────────────────────────
- procedure installkeyint;
-
- Installs the SPX_KEY keyboard interrupt
-
- Use with clearkeyint. To install and remove the interrupt multiple
- times during the program.
-
- ───────────────────────────────────────────────────────────────────────────
- function anykey:boolean;
-
- Returns TRUE if there is a key in the keyboard buffer
-
- ───────────────────────────────────────────────────────────────────────────
- function Keypressed:boolean;
-
- Returns TRUE if there is a key in the keyboard buffer
-
- ───────────────────────────────────────────────────────────────────────────
- procedure Readln;
-
- Waits until the user presses the ENTER key.
- ───────────────────────────────────────────────────────────────────────────
- function ReadKey : char;
-
- Reads a key from the keyboard buffer.
-
- ───────────────────────────────────────────────────────────────────────────