• C

Pixel Position from a Mouse in DOS

I need to use a DOS program in a Win95/98 DOS box that uses a mouse to get position information (resolution 512x480) with single pixel point increments in x and y. The DOS program does not have a mouse driver of it's own but used to a 16 bit driver and a memory resident program that converted mouse movements to look like single keyboard strokes (arrows). In my hands the mouse commands that use int 33 only return the mouse position in increments of 8, with a maximun row number of 200 (a text mode).  
Basically I need to get every incremental step movement of the mouse so that I can drive the pixel location of a pointer in frame frabber card.
Thanks for your help.
cilia091598Asked:
Who is Participating?
 
WxWConnect With a Mentor Commented:
:)
0
 
BonevCommented:
I remember that I had the same problem once and I did something with the parameters of the mouse driver (that's int 33h). I'm not quite sure, but I think I set a large mouse area (basically multiplied the current dimensions by 8).

0
 
WxWCommented:
If you want to be notified when a mouse event occurs , you must install a mouse handler . There are 2 mouse driver functions that do that . I maybe give you details when I return home ( since now I don't have the exact info here :)
0
Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

 
cilia091598Author Commented:
To Expert Bonev:

I have increased the area that the mouse can move within by 8 as suggested using the int 33h (area now =x, 0 to 4096, y, 0-3840).
This seems to works but it takes large mouse movements to cross the screen(x 8 I expect). This suggests I should still try to detect each mouse step. But this is still a good improvement. Thanks

To Expert WxW  
Your suggestion of a mouse handler to detect each mouse event sounds as if it might be the addition solution required. I would appreciate the chance to see the functions.

To either expert: What/Where is the best source/listing of information on the various interupts, their functions and register settings?    
0
 
BonevCommented:
Now I remember that I did it for a graphics program based on TurboVision (Borland Pascal 7.0). Borland provided the source code of their runtime library and the source of TurboVision.
I modified their mouse interrupt handler and it worked. Unfortunately this happened about 5 years ago and I'm not sure I can find my sources. But if you are interested in that, I would try.

0
 
BonevCommented:
Sometime later on I did a graphic mouse cursor for text mode (just like the Norton Utilities).

0
 
WxWCommented:
Here I will give a simple example
--------------

Call Int 33h with  AX = 18h , with CX =
1.01h : Enable MouseMove
2.06h : Enable Left Click
3.018h: Enable Right Click

ES:DX hold the proc you want to be called ( the Mouse Driver calls this with CALL FAR , so declare it as far )

Anytime a mouse event occurs , your proc will be called from the mouse driver , with CX,DX the x,y of the point , AX = the bits as described in CX above , and BX holds the button status ( pressed/released )

Be sure to load/save DS,ES within your proc .
0
 
cilia091598Author Commented:
To WxW

I inderstand the basic idea of the routine you suggest but my C skills are moderate. I simple don't know how to set up the code so that when the interupt occurs a function will be called. Some help in that direction would be great.
I have the mouse responding and basically doing what I want. It moves a cursors and draws a line. However, the mouse outruns the line drawing. Thus instead of lines, a series of dots appears.
It would therfore seem like I need a buffer. The old drivers seemed to put the cursor movement into the keyboard stack. Thus, for each cursor movement, an arrow stroke is set to the keyboard (this would be the function called) and then this is read by the program to generate a smooth line. Perhaps there is an easier way of making a buffer.
Thanks  
   
0
 
cilia091598Author Commented:
To Bonev
I think the routine provide by WxW is similar to the idea you suggested. So there is no need to go looking.
Thanks.

0
 
WxWCommented:
To install the handler interrupt , use the Int86x function , passing REGS unions containing the calls , as follows :

#include <dos.h>

REGS inRegs;
REGS outRegs;

inRegs.r_ax = 0x18;
inRegs.r_bx =....
.
int86x(0x33,&inRegs,&outRegs);

etc

unfortunately , there are too many other details not possible to discuss here , and , the whole mouse thing works better using Assembly , because it is easier to check the AX etc registers within assembly , than C++
0
 
cilia091598Author Commented:
Accept Answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.