Xref: news2.mv.net alt.msdos.programmer:13722 comp.os.msdos.djgpp:6311 comp.os.msdos.programmer:26868 From: boylesgj AT lion DOT cs DOT latrobe DOT edu DOT au (Gregary J Boyles) Newsgroups: alt.msdos.programmer,comp.os.msdos.programmer,comp.os.msdos.djgpp Subject: An key board handler ISR question. Date: 23 Jul 1996 13:42:17 GMT Organization: Comp.Sci & Comp.Eng, La Trobe Uni, Australia Lines: 131 Distribution: world Message-ID: <4t2krp$8jp@lion.cs.latrobe.edu.au> NNTP-Posting-Host: lion.cs.latrobe.edu.au To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Could any one tell me if there is any reason why this key board handler may fail. It is based on some info from Game Programmer's Encyclopedia but there was not enough info for me to be absolutely sure that this will work. You will notice refferences to a character table which is read in from a file by the function which installs the ISR (not included). Basically it looks up the scan code in a 2-D array where the scan code is the first array index and the second index is determined by the state of the numlock, capslock and shift keys. The table has also not been included due to its size. I am writing this with Borland C++ 3.1. #include /* ***************************************************************************** * * * THE KEY BOARD HANDLER * * * ***************************************************************************** */ // Shift key flags. bool NumLockOn=false,CapsLockOn=false,LeftShiftOn=false,RightShiftOn, CtrlOn=false,AltOn=false; // The character table. const int Width=88,Height=8; unsigned Table[Width][Height]; // The key buffer. const int BuffSize=50; unsigned Buff[BuffSize]; int BuffPos=0; // The key board ISR. void interrupt KeyBoardISR(...) { const unsigned char ExtendedCode=224,ScrollLockScanCode=70,CapsLockScanCode=58, NumLockScanCode=69,LeftShiftScanCode=42,RightShiftScanCode=54, AltScanCode=56,CtrlScanCode=29,Bit7Mask=128,AckValue=0x20; const unsigned KeyBoardPort=0x60,AckPort=0x20; unsigned char ScanCode=0; // Read the key's scan code from the key board port. ScanCode=inportb(KeyBoardPort); // Acknowledge the interrupt. outportb(AckPort,AckValue); // If the code 224 was read then an extended key was pressed and its scan // code will be available next time around so do nothing. if (ScanCode==ExtendedCode) { } // If there is room in the key buffer to put another key press. else if (BuffPos