Link to home
Start Free TrialLog in
Avatar of pr12
pr12

asked on

Mouse interrupts in DOS?

I need to develop a C++ graphics programme that will work in dos and draw simple graphics like circle and rectangle at the point where the user clicks the mouse. Can anyone help me?
Avatar of pr12
pr12

ASKER

Edited text of question
First, here is a header file for mouse operations in DOS:

/*
   This provides functions for polling the mouse.  The main routine,
   mouse, has this description.

   To do various functions (input) [output] set 'a' to
    0 - test if loaded [reg.ax = $ffff]
    1 - show cursor
    2 - hide cursor
    3 - get position [b buttons, c x, d y]
    4 - set position (c x,d y)
    5 - press button   (b buttons, c x, d y) [b count]
    6 - release button (b buttons, c x, d y) [b count]
    7 - set x range  (c min, d max)
    8 - set y range  (c min, d max)
    10- text cursor  (b 0=soft 1=hard, c ?, d ?)
    15- mickeys      (c xscale, d yscale?)
*/

#define MOUSEINT 0x33
#include <dos.h>
#include <cursors.h>

int mouse (int, int *, int *, int *);  // Main Mouse Function.
int init_mouse (void);                 // Starts mouse, check if loaded.
int show_mouse (void);                 // Shows the cursor.
int hide_mouse (void);                 // Hides the cursor.
int get_mouse (int *, int *);          // Get x, y. Return # buttons PRESSED
int set_mouse (int, int);              // Puts the mouse somewhere.
void change_mouse (unsigned int far *, int, int);

int mouse (int ax, int *bx, int *cx, int *dx)
{ static union REGS regs;
  regs.x.ax = ax;   // Set registers to the values given.
  regs.x.bx = *bx;
  regs.x.cx = *cx;
  regs.x.dx = *dx;
  int86 (MOUSEINT, &regs, &regs); // Do it.

  // Return Status:
  *bx = regs.x.bx;
  *cx = regs.x.cx;
  *dx = regs.x.dx;
  return regs.x.ax;
}

int init_mouse (void)
{ int x = 0;
  return mouse (0, &x, &x, &x);
}

int show_mouse (void)
{ int b = 0;
  return mouse (1, &b, &b, &b);
}

int hide_mouse (void)
{ int b = 0;
  return mouse (2, &b, &b, &b);
}

int get_mouse (int *x, int *y)
{ int b = 0;
  mouse (3, &b, x, y);
  return b;
}

int set_mouse (int x, int y)
{ int b = 0;
  return mouse (4, &b, &x, &y);
}

////////////////////////////////////////////////////
// CHANGEMOUSE                                    //
// Changes the shape of the mouse cursor          //
// Input: pointer to new shape, hot x, hot y      //
////////////////////////////////////////////////////
// Separate because this needs access to the      //
// segment registers                              //
////////////////////////////////////////////////////
void change_mouse (unsigned int far *shape, int hotx, int hoty)
{ union REGS regs;
      struct SREGS sregs;

      regs.x.ax = 0x09; // mouse function 9, change mouse
      regs.x.bx = hotx; // x hot spot
      regs.x.cx = hoty; // y hot spot
      regs.x.dx = FP_OFF (shape); // address of shape (mask/data)
      sregs.es = FP_SEG (shape);
  int86x (0x33, &regs, &regs, &sregs); // execute BIOS call
}

Second, do you already have functions for graphics operations or would you like me to give you a header file for that too?

If you have any questions regarding the use of the header file, please feel free to ask.  Thanks!
Note that some of the functions in the header will vary depending on the compiler you are using.  What compiler are you using?
ASKER CERTIFIED SOLUTION
Avatar of Noteran
Noteran

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Too bad it's assembly and pascal rather than C/C++.
Avatar of pr12

ASKER

This is not really helpful because all the code is in BASIC and I wanted some help in C++, but it helped me in understanding the working of the mouse and since then I have succeded in developing my own program to do the same.Thanks any way
With regards
Bart
You should have Rejected the answer then, I am certain that if you had left it open you could have gotten a sufficient answer.