home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / KEYBOARD / SCNCODTP.ZIP / KEYPAD_5.PAS next >
Encoding:
Pascal/Delphi Source File  |  1990-09-22  |  1.9 KB  |  64 lines

  1. {==============================================================}
  2. {                         KEYPAD_5.PAS                         }
  3. {                     Pat Anderson, Sysop                      }
  4. {        Pascal Alley, Fidonet 343/52, (206) 222-6224          }
  5. {                                                              }
  6. { Hook into the BIOS Int $09 interrupt service routine to      }
  7. { detect a keypress that ReadKey ignores - the [5] key on the  }
  8. { numeric keypad.  Easily expanded to handle many other keys   }
  9. { for "event driven" programming.  Based on Ohlsen & Stoker    }
  10. { Turbo Pascal Advanced Techniques, Chapter 7                  }
  11. {==============================================================}
  12.  
  13. unit KeyPad_5;
  14.  
  15. interface
  16.  
  17. uses
  18.   Dos,
  19.   Crt;
  20.  
  21. const
  22.   Key_5_Pressed : boolean = false;
  23.  
  24. var
  25.   OldInt09,
  26.   NewInt09  : pointer;
  27.  
  28. implementation
  29.  
  30. var
  31.   OldExit : pointer;
  32.  
  33. procedure JmpOldISR ( OldISR: pointer );
  34.   Inline ( $5B/$58/$87/$5E/$0E/$87/$46/$10/$89/
  35.            $EC/$5D/$07/$1F/$5F/$5E/$5A/$59/$CB );
  36.  
  37. {$F+}
  38. Procedure Int09_ISR; Interrupt;
  39.   begin
  40.     If ( Port[$60] = 76 ) Then
  41.       begin
  42.         Key_5_Pressed := true;
  43.         Inline ( $E4/$61/$8A/$E0/$0C/$80/$E6/$61/   { Clean up as the    }
  44.                  $86/$E0/$E6/$61/$B0/$20/$E6/$20 ); { Bios would         }
  45.        Exit;
  46.       end;
  47.     JmpOldISR( OldInt09 );       {Jump to Old Keyboard handler }
  48.   end;
  49.  
  50. Procedure Exitit;
  51.   begin
  52.     ExitProc := OldExit;        { Restore Old ExitProc pointer }
  53.     SetIntVec ( 9, OldInt09 );  { Restore Old Int9 Handler     }
  54.   end;
  55. {$F-}
  56.  
  57. begin
  58.   OldExit := ExitProc;           { Save old ExitProc pointer }
  59.   ExitProc := @Exitit;           { Set new ExitProc pointer  }
  60.   GetIntVec ( 9, OldInt09 );     { Get Current Int9  Vector  }
  61.   NewInt09 := @Int09_ISR;
  62.   SetIntVec ( 9, NewInt09 );     { Set Int9 to our routine   }
  63. end.
  64.