home *** CD-ROM | disk | FTP | other *** search
- 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
- Newsgroups: comp.lang.pascal
- Subject: Re: int 19h APOLOGIZE.......
- Message-ID: <1992Dec10.212824.17605@wisipc.weizmann.ac.il>
- From: dov@menora.weizmann.ac.il (Dov Grobgeld)
- Date: Thu, 10 Dec 1992 21:28:24 GMT
- Sender: news@wisipc.weizmann.ac.il
- References: <1g63d9INNij6@matt.ksu.ksu.edu>
- Organization: Weizmann Institute of Science, Computation Center.
- Lines: 66
-
- Here's a small program of mine from a couple of years ago which gives
- an example of how to take over the keyboard interrupt and read the
- scancode of the key that was pressed. How to call the old INT 9
- interrupt routine from inside our new routine is left as an exercise
- to the reader. :-)
-
- Excuse my use of my routines strings and fastscr. You'll have to tweak
- with the code a bit to work around them.
-
- <<File: scancode.pas>>
- USES Crt, Dos, FastScr, Strings;
-
- VAR
- Org9: POINTER;
- ScanCode: BYTE;
- Quit: BOOLEAN;
- Regs: Registers;
-
- PROCEDURE KeyboardInt(Flags,CS,IP,AX,BX,CX,DX,SI,DI,DS,ES,BP: WORD); INTERRUPT;
-
- CONST
- EOI = $20;
- KB_DATA = $60;
- KB_CTL = $61;
- INT_CTL = $20;
-
- BEGIN
- WITH Regs DO BEGIN
- ScanCode:= Port[KB_DATA];
- AL:= Port[KB_CTL];
- Port[KB_CTL]:= AL OR $80;
- Port[KB_CTL]:= AL;
- Port[INT_CTL]:= EOI;
- END;
- END;
-
- BEGIN
- GetIntVec(9, Org9);
- SetIntVec(9, @KeyBoardInt);
- ScanCode:= 0;
- Quit:= FALSE;
- ClrScr;
- WriteForm(1,1,' ^BS C A N C O D E ^B(^Bc^B)^B 1988 Peter Grobgeld^B');
- WriteForm(1,3,'^WDecimal Hexadecimal Binary ^U');
- WriteForm(55,4,'Press [^BEsc^B] to');
- WriteForm(55,5,'quit.');
- Window(1,4,50,25); GotoXY(1,1);
- REPEAT
- IF ScanCode <> 0 THEN BEGIN
- GotoXY(1,1);
- writeln(ScanCode:3,' ', HexStr(ScanCode):2,' ',BinStr(ScanCode));
- IF ScanCode = 1 THEN Quit:= TRUE;
- ScanCode:= 0;
- END;
- UNTIL Quit;
- SetIntVec(9, Org9);
- END.
-
- --
- ___ ___
- / o \ o \
- Dov Grobgeld ( o o ) o |
- The Weizmann Institute of Science, Israel \ o /o o /
- "Where the tree of wisdom carries oranges" | | | |
- _| |_ _| |_
-
-