Solved

Pixel Position from a Mouse in DOS

Posted on 1998-09-15
11
233 Views
Last Modified: 2012-05-04
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.
0
Comment
Question by:cilia091598
  • 4
  • 4
  • 3
11 Comments
 
LVL 1

Expert Comment

by:Bonev
Comment Utility
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
 
LVL 6

Expert Comment

by:WxW
Comment Utility
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
 

Author Comment

by:cilia091598
Comment Utility
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
 
LVL 1

Expert Comment

by:Bonev
Comment Utility
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
 
LVL 1

Expert Comment

by:Bonev
Comment Utility
Sometime later on I did a graphic mouse cursor for text mode (just like the Norton Utilities).

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 6

Expert Comment

by:WxW
Comment Utility
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
 

Author Comment

by:cilia091598
Comment Utility
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
 

Author Comment

by:cilia091598
Comment Utility
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
 
LVL 6

Expert Comment

by:WxW
Comment Utility
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
 

Author Comment

by:cilia091598
Comment Utility
Accept Answer
0
 
LVL 6

Accepted Solution

by:
WxW earned 100 total points
Comment Utility
:)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

743 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

17 Experts available now in Live!

Get 1:1 Help Now