Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //**IMPORTANT** please read
- //This is old C++ code, runs on turbo C++, not recommended to learn anything from this, you can try and run this
- #include <iostream.h>
- #include <stdio.h>
- #include <conio.h>
- #include <dos.h>
- #include <bios.h>
- #define ASC(asciiValue) (char)asciiValue
- #define _DebugStop(a) cout<<a<<endl;getch()
- #define BLOCK 219
- #define NORMAL 178
- #define ONLCLICK 221
- #define ONRCLICK 222
- #define ONMCLICK 220
- #define oXlim 639
- #define oYlim 191
- #define xlim 80
- #define ylim 24
- union REGS in,out;
- class MOUSE{
- public:
- float oX,oY;
- int x,y;
- char pointer;
- unsigned short state;
- int Update(void);
- int SetLimits(int MAX, int MIN,char AXIS);
- void ShowP(void);
- };
- class KEYBRD{
- public:
- short isKeyDown;
- unsigned short keyCode;
- unsigned short splStatus;
- int Update(void);
- };
- class PAGE{
- public:
- char space[ylim][xlim];
- MOUSE mouse;
- KEYBRD keybrd;
- PAGE()
- {
- for(int i=0;i<ylim;i++)
- {
- for(int j=0;j<xlim;j++)
- space[i][j]='X';
- space[i][j-1]='\0';
- }
- }
- int Update(void);
- void Show(void);
- void Clear(void);
- void ShowP(void);
- void PrintC(int ,int ,char);
- void PrintS(int ,int ,char[]);
- };
- int MOUSE::Update(void)
- {
- in.x.ax = 3;
- int86(0x33,&in,&out);
- oX = out.x.cx;
- oY = out.x.dx;
- state = out.x.bx;
- x=(oX)/8;
- y=(oY)/8;
- switch (state)
- {
- case 0: pointer = NORMAL;
- break;
- case 1: pointer = ONLCLICK;
- break;
- case 2: pointer = ONRCLICK;
- break;
- case 3: pointer = ONMCLICK;
- }
- return 0;
- }
- int MOUSE::SetLimits(int MAX,int MIN, char AXIS)
- {
- switch(AXIS)
- {
- case 'x': in.x.ax = 7;
- break;
- case 'y': in.x.ax = 8;
- }
- in.x.cx = MAX;
- in.x.dx = MIN;
- int86(0x33,&in,&out);
- return 0;
- }
- /*void MOUSE::ShowP()
- {
- gotoxy(x+1,y+1);
- cout<<pointer;
- }*/
- int KEYBRD::Update(void)
- {
- keyCode = _bios_keybrd(1) & 0xFF;
- //splStatus = _bios_keybrd(_KEYBRD_SHIFTSTATUS);
- return 0;
- }
- int PAGE::Update(void)
- {
- keybrd.Update();
- mouse.Update();
- return 0;
- }
- void PAGE::Show(void)
- {
- //for(int x=0;x<ylim;x++) space[0][x]=ASC(65+x);
- //space[0][ylim-1]='\0';
- for(int i=0;i<ylim;i++){
- puts(space[i]);
- }
- Clear();
- ShowP();
- //for(int i = 0 ; i < ylim ; i++)
- {
- //gotoxy(1,1+i);
- //cout<<space[0];//delay(500);
- //puts(space[0]);
- //_DebugStop("Display space[0]");
- }
- }
- void PAGE::ShowP(void)
- {
- PrintC(mouse.x,mouse.y,mouse.pointer);
- }
- void PAGE::Clear(void)
- {
- for( int x=0 ; x < ylim ; x++ )
- {
- for( int y=0 ; y < xlim ; y++)
- space[x][y] = ' ';
- space[x][y-1]='\0';
- }
- }
- void PAGE::PrintC(int x, int y, char ch)
- {
- space[y][x] = ch;
- }
- void PAGE::PrintS(int x,int y, char* s)
- {
- for(int i = x ; s[i]!='\0' ; i++ ) space[y][i]=s[i];
- }
- class Shape{
- char tex[4][4];
- int isFlip;
- public:
- Shape(int rnd)
- {
- int i,j;
- switch(rnd)
- {
- case 0:{
- if(isFlip){
- for(i=0;i<4;i++)
- for(j=0;j<4;j++)
- {
- }
- }
- }break;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- }
- }
- };
- int main(void)
- {
- PAGE page;
- clrscr();
- _setcursortype(_NOCURSOR);
- page.mouse.SetLimits(191 ,0 ,'y');
- do{
- page.Update();
- gotoxy(1,1);
- //cout<<page.mouse.x<<","<<page.mouse.y<<" \n";
- page.Show();
- delay(10);
- }while(page.keybrd.keyCode != 'q');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement