Solved

Mouse Routines for DOS

Posted on 1998-01-19
2
246 Views
Last Modified: 2010-05-18
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
Comment
Question by:Egore
2 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 1257030
Are you referring to something other than the standard DOS mouse calls? If so, could you specify the required functionality?

0
 

Accepted Solution

by:
andersh012098 earned 100 total points
ID: 1257031
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now