Advertisement
KAR98S

M&K_Trial

Jan 6th, 2018 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. //**IMPORTANT** please read
  2. //This is old C++ code, runs on turbo C++, not recommended to learn anything from this, you can try and run this
  3. #include <iostream>
  4. #include <conio.h>
  5. #include <dos.h>
  6. #include <bios.h>
  7.  
  8. union REGS in,out;
  9.  
  10. class MOUSE{
  11.     int x,y;
  12.     unsigned short state;
  13.     public:
  14.     int Update();
  15.     int SetLimits(int MAX, int MIN,char AXIS);
  16. };
  17.  
  18. class KEYBRD{
  19.     short isKeyDown;
  20.     unsigned short keyCode;
  21.     unsigned short splStatus;
  22.     public:
  23.     int Update();
  24.     unsigned short GetKey();
  25. };
  26.  
  27. class PAGE{
  28.     public:
  29.     MOUSE mouse;
  30.     KEYBRD keybrd;
  31.     int Update();
  32. };
  33.  
  34. int MOUSE::Update()
  35. {
  36.     in.x.ax = 3;
  37.     int86(0x33,&in,&out);
  38.     x = out.x.cx;
  39.     y = out.x.dx;
  40.     state = out.x.bx;
  41.     return 0;
  42. }
  43.  
  44. int MOUSE::SetLimits(int MAX,int MIN, char AXIS)
  45. {
  46.     switch(AXIS)
  47.     {
  48.     case 'x': in.x.ax = 7;
  49.         break;
  50.     case 'y': in.x.ax = 8;
  51.     }
  52.  
  53.     in.x.cx = MAX;
  54.     in.x.dx = MIN;
  55.     int86(0x33,&in.&out);
  56. }
  57.  
  58. int KEYBRD::Update()
  59. {
  60.     keyCode = _bios_keybrd(_KEYBRD_READ) & 0xFF;
  61.     return 0;
  62. }
  63.  
  64. unsigned short KEYBRD::GetKey()
  65. {
  66.     return (keyCode);
  67. }
  68.  
  69. int PAGE::Update()
  70. {
  71.     keybrd.Update();
  72.     mouse.Update();
  73.     return 0;
  74. }
  75.  
  76. int main()
  77. {
  78.     PAGE page;
  79.     clrscr();
  80.     do
  81.     {
  82.         page.Update();
  83.         delay(0.15);
  84.     }while(page.keybrd.GetKey() != 'q');
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement