home *** CD-ROM | disk | FTP | other *** search
/ HOT Scene Stuff / hotscenestuffzyklop1996.iso / demos / sunknown / keyscan.cpp < prev    next >
C/C++ Source or Header  |  1994-04-06  |  1KB  |  58 lines

  1. // KEYSCAN_C ////////////////////////////////////////////////////////////////
  2.  
  3. // Ronny H./ Thomas H.
  4.  
  5. // INCLUDES /////////////////////////////////////////////////////////////////
  6.  
  7. #include <stdio.h>
  8. #include <conio.h>
  9. #include <stdlib.h>
  10.  
  11. #include "keyscan.h"
  12.  
  13. // DEFINES //////////////////////////////////////////////////////////////////
  14.  
  15. // EXTERNALS ////////////////////////////////////////////////////////////////
  16.  
  17. extern void interrupt newkbdhandler(...);
  18. extern void interrupt (*oldkbdhandler)(...);
  19. extern byte *pressed;
  20.  
  21. // FUNCTIONS ////////////////////////////////////////////////////////////////
  22.  
  23. void interrupt newkbdhandler(...)
  24. {
  25.     char scan=inportb(0x60);
  26.     oldkbdhandler();
  27.     pressed[scan&0x7f]=!(scan&0x80);
  28.     int head=peek(0x40,0x1a);
  29.     poke(0x40,0x1c,head);
  30. }
  31.  
  32. // METHODS //////////////////////////////////////////////////////////////////
  33.  
  34. // CONSTRUCTOR
  35.  
  36. keyscan_C::keyscan_C()
  37. {
  38.     pressed=new byte[128];
  39.     for(int count=0; count<128; count++)
  40.         pressed[count]=0;
  41.     oldkbdhandler=getvect(0x09);
  42.     setvect(0x09,newkbdhandler);
  43.     pokeb(0,0x417,peekb(0,0x417)&223);
  44.     pokeb(0,0x0500,1);
  45. }
  46.  
  47. // DESTRUCTOR
  48.  
  49. keyscan_C::~keyscan_C()
  50. {
  51.   if (pressed)
  52.       delete pressed;
  53.   if (oldkbdhandler)
  54.       setvect(0x09,oldkbdhandler);
  55. }
  56.  
  57.  
  58.