{ SPX Library Version 2.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) flags below tells if that key is pressed. 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 enter and esc and space and lshft then { Some one is pressing the Enter, Esc, Space, AND, Left Shift key } 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 } cold, { TRUE - call old int } plus, { plus key pressed } minus, { minus key pressed } lshft,rshft, { shift keys pressed } space, { space key pressed } bspc, { backspace pressed } esc, { esc pressed } ctrl, { a ctrl key is pressed } alt, { an alt key is pressed } enter : boolean; { enter pressed } 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 } ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 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 any key is pressed ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure cli; inline($fa); Disable maskable interrupts ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure sti; inline($fb); Enable maskable interrupts ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ