Advertisement
KAR98S

M&K

Jan 26th, 2018 (edited)
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.58 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.h>
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <dos.h>
  7. #include <bios.h>
  8.  
  9. #define ASC(asciiValue) (char)asciiValue
  10. #define _DebugStop(a)   cout<<a<<endl;getch()
  11.  
  12. #define BLOCK       219
  13.  
  14. #define NORMAL      178
  15. #define ONLCLICK    221
  16. #define ONRCLICK    222
  17. #define ONMCLICK    220
  18.  
  19. #define oXlim       639
  20. #define oYlim       191
  21.  
  22. #define xlim        80
  23. #define ylim        24
  24.  
  25.  
  26. union REGS in,out;
  27.  
  28. class MOUSE{
  29.     public:
  30.     float oX,oY;
  31.     int x,y;
  32.     char pointer;
  33.     unsigned short state;
  34.     int Update(void);
  35.     int SetLimits(int MAX, int MIN,char AXIS);
  36.     void ShowP(void);
  37. };
  38.  
  39. class KEYBRD{
  40.     public:
  41.     short isKeyDown;
  42.     unsigned short keyCode;
  43.     unsigned short splStatus;
  44.     int Update(void);
  45. };
  46.  
  47. class PAGE{
  48.     public:
  49.     char space[ylim][xlim];
  50.     MOUSE mouse;
  51.     KEYBRD keybrd;
  52.  
  53.     PAGE()
  54.     {
  55.  
  56.     for(int i=0;i<ylim;i++)
  57.     {
  58.         for(int j=0;j<xlim;j++)
  59.         space[i][j]='X';
  60.         space[i][j-1]='\0';
  61.     }
  62.     }
  63.  
  64.     int Update(void);
  65.     void Show(void);
  66.     void Clear(void);
  67.     void ShowP(void);
  68.     void PrintC(int ,int ,char);
  69.     void PrintS(int ,int ,char[]);
  70. };
  71.  
  72. int MOUSE::Update(void)
  73. {
  74.     in.x.ax = 3;
  75.     int86(0x33,&in,&out);
  76.     oX = out.x.cx;
  77.     oY = out.x.dx;
  78.     state = out.x.bx;
  79.  
  80.     x=(oX)/8;
  81.     y=(oY)/8;
  82.  
  83.     switch (state)
  84.     {
  85.     case 0: pointer = NORMAL;
  86.         break;
  87.     case 1: pointer = ONLCLICK;
  88.         break;
  89.     case 2: pointer = ONRCLICK;
  90.         break;
  91.     case 3: pointer = ONMCLICK;
  92.     }
  93.  
  94.     return 0;
  95. }
  96.  
  97. int MOUSE::SetLimits(int MAX,int MIN, char AXIS)
  98. {
  99.     switch(AXIS)
  100.     {
  101.     case 'x': in.x.ax = 7;
  102.     break;
  103.     case 'y': in.x.ax = 8;
  104.     }
  105.  
  106.     in.x.cx = MAX;
  107.     in.x.dx = MIN;
  108.     int86(0x33,&in,&out);
  109.     return 0;
  110. }
  111.  
  112. /*void MOUSE::ShowP()
  113. {
  114.     gotoxy(x+1,y+1);
  115.     cout<<pointer;
  116. }*/
  117.  
  118. int KEYBRD::Update(void)
  119. {
  120.     keyCode = _bios_keybrd(1) & 0xFF;
  121.     //splStatus = _bios_keybrd(_KEYBRD_SHIFTSTATUS);
  122.     return 0;
  123. }
  124.  
  125. int PAGE::Update(void)
  126. {
  127.     keybrd.Update();
  128.     mouse.Update();
  129.  
  130.     return 0;
  131. }
  132.  
  133. void PAGE::Show(void)
  134. {
  135.     //for(int x=0;x<ylim;x++) space[0][x]=ASC(65+x);
  136.     //space[0][ylim-1]='\0';
  137.     for(int i=0;i<ylim;i++){
  138.         puts(space[i]);
  139.     }
  140.     Clear();
  141.     ShowP();
  142.     //for(int i = 0 ; i < ylim ; i++)
  143.     {
  144.     //gotoxy(1,1+i);
  145.     //cout<<space[0];//delay(500);
  146.     //puts(space[0]);
  147.     //_DebugStop("Display space[0]");
  148.     }
  149. }
  150.  
  151. void PAGE::ShowP(void)
  152. {
  153.     PrintC(mouse.x,mouse.y,mouse.pointer);
  154. }
  155.  
  156. void PAGE::Clear(void)
  157. {
  158.     for( int x=0 ; x < ylim ; x++ )
  159.     {
  160.     for( int y=0 ; y < xlim ; y++)
  161.         space[x][y] = ' ';
  162.     space[x][y-1]='\0';
  163.     }
  164. }
  165.  
  166. void PAGE::PrintC(int x, int y, char ch)
  167. {
  168.     space[y][x] = ch;
  169. }
  170.  
  171. void PAGE::PrintS(int x,int y, char* s)
  172. {
  173.     for(int i = x ; s[i]!='\0' ; i++ ) space[y][i]=s[i];
  174. }
  175.  
  176. class Shape{
  177.     char tex[4][4];
  178.     int isFlip;
  179.     public:
  180.     Shape(int rnd)
  181.     {
  182.         int i,j;
  183.         switch(rnd)
  184.         {
  185.             case 0:{
  186.                 if(isFlip){
  187.                     for(i=0;i<4;i++)
  188.                         for(j=0;j<4;j++)
  189.                         {
  190.  
  191.                         }
  192.                 }
  193.             }break;
  194.             case 1:
  195.             case 2:
  196.             case 3:
  197.             case 4:
  198.             case 5:
  199.             case 6:
  200.         }
  201.     }
  202.  
  203. };
  204.  
  205. int main(void)
  206. {
  207.     PAGE page;
  208.     clrscr();
  209.     _setcursortype(_NOCURSOR);
  210.     page.mouse.SetLimits(191 ,0 ,'y');
  211.     do{
  212.     page.Update();
  213.     gotoxy(1,1);
  214.  
  215.     //cout<<page.mouse.x<<","<<page.mouse.y<<"    \n";
  216.     page.Show();
  217.     delay(10);
  218.     }while(page.keybrd.keyCode != 'q');
  219.     return 0;
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement