Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Mouse Routines for DOS

I need a set of routines to access the mouse through DOS.  I already have one, but it has problems with mode 13h.  I need a routine that works with mode 13h, it DOES NOT have to be compatible with any other screen modes.

Thanks in advance!
0
Egore
Asked:
Egore
1 Solution
 
imladrisCommented:
Are you referring to something other than the standard DOS mouse calls? If so, could you specify the required functionality?

0
 
andersh012098Commented:
Here are some very basic mouse routines.
I haven't written any error checking but if initmouse() doesn't return 0 everything should work just fine.
Remember that in mode 13h you have to divide the mouse X coordinate with 2 too get the correct screen X coordinate. (This is due to historical reasons)
I haven't made any comments because the code is so simple. It just calls diffrent functions on interrupt 33h.
To use this first call initmouse() and check so it doesn't return 0. Then call showmouse() to make the mouse vissible on the screen.
To get the status of the mouse just call getmouse with four integers and you'll get X and Y coordinate of the mouse and the status of the left and right mouse buttons.
I haven't included support for 3 buttons because I don't have one to test if it works... You can write it ourself if you want to. In initmouse() BX will contain the number of mouse buttons and in getmouse ((_BX & 4) == 4) will get the status of the center button.

int initmouse()
{
   asm {
      mov ax,0
      int 33h
   }
   return _AX;
}

void showmouse()
{
   asm {
      mov ax,1
      int 33h
   }
}

void hidemouse()
{
   asm {
      mov ax,2
      int 33h
   }
}

void getmouse(int& x,int &y,int left_button_down,int right_button_down)
{
   asm {
      mov ax,3
      int 33h
   }
   x = _CX;
   y = _DX;
   left_button_down = ((_BX & 1) == 1);
   right_button_down = ((_BX & 2) == 2);
}

void setmouse(int x,int y)
{
   asm {
      mov ax,4
      mov cx,x
      mov dx,y
      int 33h
   }
}

void setxlimits(int minx,int maxx)
{
   asm {
      mov ax,7
      mov cx,minx
      mov dx,maxx
      int 33h
   }
}

void setylimits(int miny,int maxy)
{
   asm {
      mov ax,8
      mov cx,miny
      mov dx,maxy
      int 33h
   }
}

Hope that you can get it to work correctly.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now