home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
C
/
OMEGA2
/
OMMOUSE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-25
|
5KB
|
242 lines
//
// *************************************************************************
// * *
// * OMEGA C++ Windowing Class Library *
// * ================================= *
// * *
// * Copyright 1991,92 Tom Clancy *
// * Submitted to the public domain, April 1992 *
// * *
// *************************************************************************
// * *
// * Mouse Class Methods *
// * *
// *************************************************************************
//
#include <dos.h>
#include <mem.h>
#include "ommouse.hpp"
#define MOUSE 0x33
union REGS mregs;
struct SREGS sregs;
int amouse;
int installmousedriver(void) {
//void far *gag;
//unsigned char c=0xCF;
//
//gag=getvect(MOUSE);
//if(gag==NULL || !memcmp(gag,(void far *)c,1)) {
// amouse=0;
// return amouse;
// }
mregs.x.ax=0x0000;
int86(MOUSE,&mregs,&mregs);
amouse=mregs.x.ax;
return mregs.x.ax;
}
void initmouse() {
installmousedriver();
}
//
// Constructor initializes the mouse and sets the amouse boolean to
// -1 if a mouse is installed or 0 if it isn't.
//
mouse::mouse(void){}
//
// hides the mouse upon exiting the program.
//
mouse::~mouse(void)
{
//hidemouse();
}
//
// Resets the mouse. Returns a -1 if a mouse driver is installed
// otherwise it returns a 0.
//
int mouse::mouseinstalled() {
return amouse;
}
int mouse::myint() {
if(amouse) {
int86(MOUSE,&mregs,&mregs);
return 1;
}
return 0;
}
//
// Resets the mouse driver.
//
void mouse::resetmouse(void) {
mregs.h.ah=0;
myint();
}
//
// Shows the mouse on screen if mouse is hidden.
//
void mouse::showmouse(void)
{
mregs.x.ax=1;
myint();
}
//
// Hides the mouse.
//
void mouse::hidemouse(void)
{
mregs.x.ax=2;
myint();
}
void mouse::mouse_exclusion(int x, int y, int x2, int y2) {
mregs.x.ax=16;
mregs.x.cx=x;
mregs.x.dx=y;
mregs.x.si=x2;
mregs.x.di=y2;
myint();
}
//
// Text based getmouse routines. Returns x and y with a max of
// 80 x 25.
//
void mouse::getmouse(int &x, int &y, int &button)
{
mregs.x.ax=3;
x=0;
y=0;
button=0;
if(myint()) {
x=(mregs.x.cx/8)+1;
y=(mregs.x.dx/8)+1;
button=mregs.x.bx;
}
}
//
// Puts the mouse at location x,y (uses text mode coordinates).
//
void mouse::setmouse(int x, int y)
{
mregs.x.ax=4;
mregs.x.cx=(x-1)*8;
mregs.x.dx=(y-1)*8;
myint();
}
//
// Returns number of presses, xpresses and ypresses for button "button"
//
void mouse::getbuttonpress(int button, int &stat, int &presses, int &xpress, int &ypress)
{
mregs.x.ax=5;
mregs.x.bx=button;
stat=0;
presses=0;
xpress=0;
ypress=0;
if(myint()) {
stat=mregs.x.ax;
presses=mregs.x.bx;
xpress=mregs.x.cx;
ypress=mregs.x.dx;
}
}
void mouse::getbuttonrelease(int button, int &status, int &presses, int &xrelease, int &yrelease)
{
mregs.x.ax=6;
mregs.x.bx=button;
status=0;
presses=0;
xrelease=0;
yrelease=0;
if(myint()) {
status=mregs.x.ax;
presses=mregs.x.bx;
xrelease=mregs.x.cx;
yrelease=mregs.x.dx;
}
}
//
// Sets the mouses horizontal limit between min and max.
//
void mouse::hmouselimit(int min, int max)
{
mregs.x.ax=7;
mregs.x.cx=min;
mregs.x.dx=max;
myint();
}
//
// Sets the mouses vertical limit between min and max.
//
void mouse::vmouselimit(int min, int max)
{
mregs.x.ax=8;
mregs.x.cx=min;
mregs.x.dx=max;
myint();
}
//
// Sets the text cursor attribute and character
//
void mouse::settextcursor(int cursorselect, int screenmask, int cursormask)
{
mregs.x.ax=10;
mregs.x.bx=cursorselect;
mregs.x.cx=screenmask;
mregs.x.dx=cursormask;
myint();
}
//
// Sets the mouse ratio
//
void mouse::setmickeyratio(int xmickey, int ymickey)
{
mregs.x.ax=15;
mregs.x.cx=xmickey;
mregs.x.dx=ymickey;
myint();
}