home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 26
/
CD_ASCQ_26_1295.iso
/
vrac
/
user_int.zip
/
MHANDLER.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-25
|
2KB
|
91 lines
#include <dos.h>
/*-- Mouse software interrupt --*/
#define MOUSEINT geninterrupt(0x33)
/*-- Mouse button status macros --*/
#define L_DOWN (M_buttonstatus & 0x01)
#define R_DOWN (M_buttonstatus & 0x02)
#define HANDLER_EXIT_PROCESSING() \
__emit__( (unsigned char) 0x5D, \
(unsigned char) 0x5F, \
(unsigned char) 0x5E, \
(unsigned char) 0x1F, \
(unsigned char) 0x07, \
(unsigned char) 0x5A, \
(unsigned char) 0x59, \
(unsigned char) 0x5B, \
(unsigned char) 0x58, \
(unsigned char) 0xCB ) ;
/*-- Global mouse status variables --*/
int M_xpos, M_ypos, /* cursor location in 1,1,80,25 screen coordinates */
M_buttonstatus, /* bits 0-2 ON if button is down */
M_event; /* flags a mouse event */
/*-- Reset mouse - returns # of buttons or 0 if problems --*/
int Mreset(void)
{
_AX = 0;
MOUSEINT;
return(_AX ? _BX : _AX);
}
/*-- Show mouse cursor --*/
void Mshow(void)
{
_AX = 1;
MOUSEINT;
}
/*-- Hide mouse cursor --*/
void Mhide(void)
{
_AX = 2;
MOUSEINT;
}
/*-- Trap mouse cursor within screen coordinates --*/
void Mtrap(int leftx, int upy, int rightx, int downy)
{
int cx, dx;
cx=(leftx-1)*8; /* all converted to 1,1,80,25 screen coordinates */
dx=(rightx-1)*8;
_AX = 7;
_CX = cx;
_DX = dx;
MOUSEINT;
cx=(upy-1)*8;
dx=(downy-1)*8;
_AX = 8;
_CX = cx;
_DX = dx;
MOUSEINT;
}
/*-- Mouse event handler to update mouse information --*/
void interrupt mousehandler(void)
{
M_event = _AX;
M_buttonstatus = _BX;
M_xpos = _CX/8+1; /* all converted to 1,1,80,25 screen coordinates */
M_ypos = _DX/8+1;
HANDLER_EXIT_PROCESSING();
}
/*-- Installs mouse handler --*/
void Minsthandler(void)
{
union REGS reg;
struct SREGS seg;
reg.x.ax = 20;
reg.x.cx = 0x1|0x2|0x4|0x8|0x10; /* track move, click, or release */
reg.x.dx = FP_OFF(mousehandler);
seg.es = FP_SEG(mousehandler);
int86x(0x33, ®, ®, &seg);
}