home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / pascal / 7448 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  2.3 KB

  1. Path: sparky!uunet!spool.mu.edu!think.com!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!frmop11!barilvm!vms.huji.ac.il!wisipc.weizmann.ac.il!menora.weizmann.ac.il!dov
  2. Newsgroups: comp.lang.pascal
  3. Subject: Re: int 19h APOLOGIZE.......
  4. Message-ID: <1992Dec10.212824.17605@wisipc.weizmann.ac.il>
  5. From: dov@menora.weizmann.ac.il (Dov Grobgeld)
  6. Date: Thu, 10 Dec 1992 21:28:24 GMT
  7. Sender: news@wisipc.weizmann.ac.il
  8. References: <1g63d9INNij6@matt.ksu.ksu.edu>
  9. Organization: Weizmann Institute of Science, Computation Center.
  10. Lines: 66
  11.  
  12. Here's a small program of mine from a couple of years ago which gives
  13. an example of how to take over the keyboard interrupt and read the
  14. scancode of the key that was pressed. How to call the old INT 9
  15. interrupt routine from inside our new routine is left as an exercise
  16. to the reader. :-)
  17.  
  18. Excuse my use of my routines strings and fastscr. You'll have to tweak
  19. with the code a bit to work around them.
  20.  
  21. <<File: scancode.pas>>
  22. USES Crt, Dos, FastScr, Strings;
  23.  
  24. VAR
  25.   Org9: POINTER;
  26.   ScanCode: BYTE;
  27.   Quit: BOOLEAN;
  28.   Regs: Registers;
  29.  
  30. PROCEDURE KeyboardInt(Flags,CS,IP,AX,BX,CX,DX,SI,DI,DS,ES,BP: WORD); INTERRUPT;
  31.  
  32. CONST
  33.   EOI = $20;
  34.   KB_DATA = $60;
  35.   KB_CTL = $61;
  36.   INT_CTL = $20;
  37.  
  38. BEGIN
  39.   WITH Regs DO BEGIN
  40.     ScanCode:= Port[KB_DATA];
  41.     AL:= Port[KB_CTL];
  42.     Port[KB_CTL]:= AL OR $80;
  43.     Port[KB_CTL]:= AL;
  44.     Port[INT_CTL]:= EOI;
  45.   END;
  46. END;
  47.  
  48. BEGIN
  49.   GetIntVec(9, Org9);
  50.   SetIntVec(9, @KeyBoardInt);
  51.   ScanCode:= 0;
  52.   Quit:= FALSE;
  53.   ClrScr;
  54.   WriteForm(1,1,'       ^BS C A N C O D E       ^B(^Bc^B)^B 1988 Peter Grobgeld^B');
  55.   WriteForm(1,3,'^WDecimal   Hexadecimal   Binary                   ^U');
  56.   WriteForm(55,4,'Press [^BEsc^B] to');
  57.   WriteForm(55,5,'quit.');
  58.   Window(1,4,50,25); GotoXY(1,1);
  59.   REPEAT
  60.     IF ScanCode <> 0 THEN BEGIN
  61.       GotoXY(1,1);
  62.       writeln(ScanCode:3,'         ', HexStr(ScanCode):2,'        ',BinStr(ScanCode));
  63.       IF ScanCode = 1 THEN Quit:= TRUE;
  64.       ScanCode:= 0;
  65.     END;
  66.   UNTIL Quit;
  67.   SetIntVec(9, Org9);
  68. END.
  69.  
  70. --
  71.                                                         ___   ___
  72.                                                       /  o  \   o \
  73. Dov Grobgeld                                         ( o  o  ) o   |
  74. The Weizmann Institute of Science, Israel             \  o  /o  o /
  75. "Where the tree of wisdom carries oranges"              | |   | |
  76.                                                        _| |_ _| |_
  77.  
  78.