mouse.h

Tags: cpp_tag

Founded in folder with old sources. I am not the author. Who is the author - do not know. cpp_tag

#include <dos.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>;
struct REGPACK reg;
//инициализирует мышу
void mouseinit()
{ reg.r_ax=0;
  intr(0x33,&reg);
  if (!reg.r_ax) {
      textcolor(15+128);
      gotoxy(23,10);printf("╔═════════E R R O R═════════╗");
      gotoxy(23,11);printf("║   MOUSE IS NOT PRESENT!   ║");
      gotoxy(23,12);printf("║  Press any key to exit... ║");
      gotoxy(23,13);printf("╚═══════════════════════════╝");
      getch();
      textcolor(7);
      exit(1);
  }
}
//показывает курсор мыши
void mouseon()
{reg.r_ax=1;
 intr(0x33,&reg);
}
//прячет курсор мыши
void mouseoff()
{reg.r_ax=2;
 intr(0x33,&reg);
}
// возвращает координаты мыши
void getmousexy(int *x,int *y){
  reg.r_ax=3;
  intr(0x33,&reg);
  *x=reg.r_cx;
  *y=reg.r_dx;
}
//устанавливает координаты
void mousexy(int x,int y){
  reg.r_cx=x;
  reg.r_dx=y;
  reg.r_ax=4;
  intr(0x33,&reg);
}
const left=1;
const right=2;


int getbutton(int but){
   reg.r_ax=5;
   reg.r_bx=but;
   intr(0x33,&reg);
   return (reg.r_ax)==but;
}

int mousein(int x1,int y1,int x2,int y2){
  int x,y;
  getmousexy(&x,&y);
  if (x>=x1 & x<=x2 & y>=y1 & y<=y2) return 1; else return 0;
}


And second file:

#include <dos.h>
void set_arrow(){

int arrowmasks[2][16];

struct REGPACK regs;
//  Screen Mask

  arrowmasks[0][0] = 0x9FFF;    // 1001111111111111}
  arrowmasks[0][1] = 0x8FFF;    // 1000111111111111}
  arrowmasks[0][2] = 0x87FF;    // 1000011111111111}
  arrowmasks[0][3] = 0x83FF;    // 1000001111111111}
  arrowmasks[0][4] = 0x81FF;    // 1000000111111111}
  arrowmasks[0][5] = 0x80FF;    // 1000000011111111}
  arrowmasks[0][6] = 0x807F;    // 1000000001111111}
  arrowmasks[0][7] = 0x803F;    // 1000000000111111}
  arrowmasks[0][8] = 0x801F;    // 1000000000011111}
  arrowmasks[0][9] = 0x800F;    // 1000000000001111}
  arrowmasks[0][10] = 0x80FF;   // 1000000011111111}
  arrowmasks[0][11] = 0x887F;   // 1000100001111111}
  arrowmasks[0][12] = 0x987F;   // 1001100001111111}
  arrowmasks[0][13] = 0xFC3F;   // 1111110000111111}
  arrowmasks[0][14] = 0xFC3F;   // 1111110000111111}
  arrowmasks[0][15] = 0xFE3F;   // 1111111000111111}

//  Cursor Mask }

  arrowmasks[1][0] = 0x0000;    // 0000000000000000}
  arrowmasks[1][1] = 0x2000;    // 0010000000000000}
  arrowmasks[1][2] = 0x3000;    // 0011000000000000}
  arrowmasks[1][3] = 0x3800;    // 0011100000000000}
  arrowmasks[1][4] = 0x3C00;    // 0011110000000000}
  arrowmasks[1][5] = 0x3E00;    // 0011111000000000}
  arrowmasks[1][6] = 0x3F00;    // 0011111100000000}
  arrowmasks[1][7] = 0x3F80;    // 0011111110000000}
  arrowmasks[1][8] = 0x3FC0;    // 0011111111000000}
  arrowmasks[1][9] = 0x3E00;    // 0011111000000000}
  arrowmasks[1][10] = 0x3600;   // 0011011000000000}
  arrowmasks[1][11] = 0x2300;   // 0010001100000000}
  arrowmasks[1][12] = 0x0300;   // 0000001100000000}
  arrowmasks[1][13] = 0x0180;   // 0000000110000000}
  arrowmasks[1][14] = 0x0180;   // 0000000110000000}
  arrowmasks[1][15] = 0x0000;   // 0000000000000000}
  regs.r_ax = 9;
  regs.r_bx = 1;
  regs.r_cx = 0;
  regs.r_dx = FP_OFF(arrowmasks);
  regs.r_es = FP_SEG(arrowmasks);
  intr(51,&regs);
}

void set_hand(){
int handmasks[2][16];
struct REGPACK regs;
//  Screen Mask

  handmasks[0][0] = 0xF3FF;    // 1111001111111111
  handmasks[0][1] = 0xE1FF;    // 1110000111111111
  handmasks[0][2] = 0xE1FF;    // 1110000111111111
  handmasks[0][3] = 0xE1FF;    // 1110000111111111
  handmasks[0][4] = 0xE1FF;    // 1110000111111111
  handmasks[0][5] = 0xE07F;    // 1110000001111111
  handmasks[0][6] = 0xC00F;    // 1100000000001111
  handmasks[0][7] = 0x8001;    // 1000000000000001
  handmasks[0][8] = 0x0000;    // 0000000000000000
  handmasks[0][9] = 0x0000;    // 0000000000000000
  handmasks[0][10] = 0x0000;   // 0000000000000000
  handmasks[0][11] = 0x0000;   // 0000000000000000
  handmasks[0][12] = 0x0000;   // 0000000000000000
  handmasks[0][13] = 0x8000;   // 1000000000000000
  handmasks[0][14] = 0xC001;   // 1100000000000001
  handmasks[0][15] = 0xE001;   // 1110000000000001

//  Cursor Mask }

  handmasks[1][0] = 0x0000;    // 0000000000000000
  handmasks[1][1] = 0x0C00;    // 0000110000000000
  handmasks[1][2] = 0x0C00;    // 0000110000000000
  handmasks[1][3] = 0x0C00;    // 0000110000000000
  handmasks[1][4] = 0x0C00;    // 0000110000000000
  handmasks[1][5] = 0x0C00;    // 0000110000000000
  handmasks[1][6] = 0x0D80;    // 0000110110000000
  handmasks[1][7] = 0x2DB0;    // 0010110110110000
  handmasks[1][8] = 0x6DB6;    // 0110110110110110
  handmasks[1][9] = 0x6DB6;    // 0110110110110110
  handmasks[1][10] = 0x6DB6;   // 0110110110110110
  handmasks[1][11] = 0x7FFE;   // 0111111111111110
  handmasks[1][12] = 0x7FFE;   // 0111111111111110
  handmasks[1][13] = 0x3FFE;   // 0011111111111110
  handmasks[1][14] = 0x1FFC;   // 0001111111111100
  handmasks[1][15] = 0x0000;   // 0000000000000000
  regs.r_ax = 9;
  regs.r_bx = 1;
  regs.r_cx = 0;
  regs.r_dx = FP_OFF(handmasks);
  regs.r_es = FP_SEG(handmasks);
  intr(51,&regs);
}

void set_vert(){
int vertmasks[2][16];

struct REGPACK regs;


// Screen Mask 
  vertmasks[0][0] = 0xF83F;    // 1111100000111111
  vertmasks[0][1] = 0xF01F;    // 1111000000011111
  vertmasks[0][2] = 0xF03F;    // 1111000000111111
  vertmasks[0][3] = 0xFC7F;    // 1111110001111111
  vertmasks[0][4] = 0xFC7F;    // 1111110001111111
  vertmasks[0][5] = 0xFC7F;    // 1111110001111111
  vertmasks[0][6] = 0xFC7F;    // 1111110001111111
  vertmasks[0][7] = 0xFC7F;    // 1111110001111111
  vertmasks[0][8] = 0xFC7F;    // 1111110001111111
  vertmasks[0][9] = 0xFC7F;    // 1111110001111111
  vertmasks[0][10] = 0xFC7F;   // 1111110001111111
  vertmasks[0][11] = 0xFC7F;   // 1111110001111111
  vertmasks[0][12] = 0xFC7F;   // 1111110001111111
  vertmasks[0][13] = 0xF83F;   // 1111100000111111
  vertmasks[0][14] = 0xF01F;   // 1111000000011111
  vertmasks[0][15] = 0xF83F;   // 1111100000111111

//  Cursor Mask 

  vertmasks[1][0] = 0x0000;    // 0000000000000000
  vertmasks[1][1] = 0x07C0;    // 0000011111000000
  vertmasks[1][2] = 0x0100;    // 0000000100000000
  vertmasks[1][3] = 0x0100;    // 0000000100000000
  vertmasks[1][4] = 0x0100;    // 0000000100000000
  vertmasks[1][5] = 0x0100;    // 0000000100000000
  vertmasks[1][6] = 0x0100;    // 0000000100000000
  vertmasks[1][7] = 0x0100;    // 0000000100000000
  vertmasks[1][8] = 0x0100;    // 0000000100000000
  vertmasks[1][9] = 0x0100;    // 0000000100000000
  vertmasks[1][10] = 0x0100;   // 0000000100000000
  vertmasks[1][11] = 0x0100;   // 0000000100000000
  vertmasks[1][12] = 0x0100;   // 0000000100000000
  vertmasks[1][13] = 0x0100;   // 0000000100000000
  vertmasks[1][14] = 0x07C0;   // 0000011111000000
  vertmasks[1][15] = 0x0000;   // 0000000000000000

  regs.r_ax = 9;
  regs.r_bx = 1;
  regs.r_cx = 0;
  regs.r_dx = FP_OFF(vertmasks);
  regs.r_es = FP_SEG(vertmasks);
  intr(51,&regs);
}




Comments