Category : C Source Code
Archive   : C_ROTATE.ZIP
Filename : MOUSE.I

 
Output of file : MOUSE.I contained in archive : C_ROTATE.ZIP
/* MOUSE.I Turbo C++ source code for mouse interface object oriented...
#include DOS.H for registers to be defined...

Book Page 355
*/

#include
#include

#define call_mouse int86(0x33, &inreg, &outreg)

#define EVENTMASK 0x54
#define lower (x, y) (x < y) ? x : y
#define upper (x, y) (x > y) ? x : y

#define ButtonL 0
#define ButtonR 1
#define ButtonM 2

#define SOFTWARE 0
#define HARDWARE 1

#define FALSE 0
#define TRUE 1

#define OFF 0
#define ON 1

union REGS inreg, outreg;

typedef struct { int present, buttons; } Mresult;
typedef struct { int button_status, button_count, xaxis, yaxis; } Mstatus;
typedef struct { int x_count, y_count; } Mmovement;
typedef struct { unsigned flag, button, xaxis, yaxis; } mouse_event;


typedef struct { unsigned int ScreenMask[16], CursorMask[16],
xkey, ykey; } g_cursor;

static g_cursor ARROW =
{ 0x1FFF, 0x0FFF, 0x07FF, 0x03FF, 0x01FF, 0x00FF, 0x007F, 0x003F,
0x001F, 0x003F, 0x01FF, 0x01FF, 0xE0FF, 0xF0FF, 0xF8FF, 0xF8FF,

0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7C00, 0x7E00, 0x7F00,
0x7F80, 0x7C00, 0x4C00, 0x0600, 0x0600, 0x0300, 0x0300, 0x0000,

0x0001, 0x0001
};

static g_cursor CHECK =
{ 0xFFF0, 0xFFE0, 0xFFC0, 0xFF81, 0xFF03, 0x0607, 0x000F, 0x001F,
0x803F, 0xC07F, 0xE0FF, 0xF1FF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,

0x0000, 0x0006, 0x000C, 0x0018, 0x0030, 0x0060, 0x70C0, 0x3980,
0x1F00, 0x0E00, 0x0400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,

0x0005, 0x000A
};

static g_cursor CROSS =
{ 0xF01F, 0xE00F, 0xC007, 0x8003, 0x0441, 0x0C61, 0x0381, 0x0381,
0x0381, 0x0C61, 0x0441, 0x8003, 0xC007, 0xE00F, 0xF01F, 0xFFFF,

0x0000, 0x07C0, 0x0920, 0x1110, 0x2108, 0x4004, 0x4004, 0x783C,
0x4004, 0x4004, 0x2108, 0x1110, 0x0920, 0x07C0, 0x0000, 0x0000,

0x0007, 0x0007
};

static g_cursor GLOVE =
{ 0xF3FF, 0xE1FF, 0xE1FF, 0xE1FF, 0xE1FF, 0xE049, 0xE000, 0x8000,
0x0000, 0x0000, 0x07FC, 0x07F8, 0x9FF9, 0x8FF1, 0xC003, 0xE007,

0x0C00, 0x1200, 0x1200, 0x1200, 0x1200, 0x13B6, 0x1249, 0x7249,
0x9249, 0x9001, 0x9001, 0x8001, 0x4002, 0x4002, 0x2004, 0x1FF8,

0x0004, 0x0000
};

static g_cursor IBEAM =
{ 0xF39F, 0xFD7F, 0xFEFF, 0xFEFF, 0xFEFF, 0xFEFF, 0xFEFF, 0xFEFF,
0xFEFF, 0xFEFF, 0xFEFF, 0xFEFF, 0xFEFF, 0xFEFF, 0xFD7F, 0xF39F,

0x0C60, 0x0280, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0280, 0x0C60,

0x0007, 0x0008
};


class Mouse
{
int Mview;

protected:
Mouse();
~Mouse();

public:
static mouse_event far *Mevents;
Mmovement *Mmotion();
Mresult *Mreset();
Mstatus Mpos();
Mstatus Mpressed( int button );
Mstatus Mreleased( int button );
void Mshow( int showstat );
void Mmoveto( int xaxis, int yaxis );
void Mxlimit( int min_x, int max_x );
void Mylimit( int min_y, int max_y );
void Mmove_ratio( int xsize, int ysize );
void Mspeed( int speed );
void Mconceal( int left, int top, int right, int bottom );
};

class GMouse : public Mouse
{
private:
void set_cursor( int xaxis, int yaxis,
unsigned mask_Seg, unsigned mask_Ofs );

public:
void MCreate();
void Set_Cursor( g_cursor ThisCursor );
void Mlightpen( int set );
};

class TMouse : public Mouse
{
public:
void Set_Cursor( int cursor_type, unsigned s_start, unsigned s_stop );
void Mlightpen( int set );
};

// implement the standard mouse functions

Mouse::Mouse()
{}

Mouse::~Mouse()
{}

void GMouse::MCreate()
{
Mxlimit( 0, getmaxx() );
Mylimit( 0, getmaxy() );
Mmoveto( getmaxx() / 2, getmaxy() / 2 );
Mshow( TRUE );
}

Mresult *Mouse::Mreset()
{
static Mresult m;
Mview = OFF;
inreg.x.ax = 0;
call_mouse;
m.present = outreg.x.ax;
m.buttons = outreg.x.bx;
if( m.present ) Mshow( TRUE );
return( &m );
}

void Mouse::Mshow( int showstat )
{
if( showstat )
{
inreg.x.ax = 1;
if( !Mview ) call_mouse;
Mview = ON;
}
else
{
inreg.x.ax = 2;
if( Mview ) call_mouse;
Mview = OFF;
}
}

Mstatus Mouse::Mpos()
{
static Mstatus m;
inreg.x.ax = 3;
call_mouse;
m.button_status = outreg.x.bx;
m.xaxis = outreg.x.cx;
m.yaxis = outreg.x.dx;
return( m );
}

void Mouse::Mmoveto( int xaxis, int yaxis )
{
inreg.x.ax = 4;
inreg.x.cx = xaxis;
inreg.x.dx = yaxis;
call_mouse;
}

Mstatus Mouse::Mpressed( int button )
{
static Mstatus m;
inreg.x.ax = 5;
inreg.x.bx = button;
call_mouse;
m.button_status = outreg.x.ax;
m.button_count = outreg.x.bx;
m.xaxis = outreg.x.cx;
m.yaxis = outreg.x.dx;
return( m );
}

Mstatus Mouse::Mreleased( int button )
{
static Mstatus m;
inreg.x.ax = 6;
inreg.x.bx = button;
call_mouse;
m.button_status = outreg.x.ax;
m.button_count = outreg.x.bx;
m.xaxis = outreg.x.cx;
m.yaxis = outreg.x.dx;
return( m );
}

void Mouse::Mxlimit( int min_x, int max_x )
{
inreg.x.ax = 7;
inreg.x.cx = min_x;
inreg.x.dx = max_x;
call_mouse;
}

void Mouse::Mylimit( int min_y, int max_y )
{
inreg.x.ax = 8;
inreg.x.cx = min_y;
inreg.x.dx = max_y;
call_mouse;
}

void GMouse::set_cursor( int xaxis, int yaxis,
unsigned mask_Seg, unsigned mask_Ofs )
{
struct SREGS seg;

inreg.x.ax = 9;
inreg.x.bx = xaxis;
inreg.x.cx = yaxis;
inreg.x.dx = mask_Ofs;
seg.es = mask_Seg;
int86x( 0x33, &inreg, &outreg, &seg );
}

void TMouse::Set_Cursor( int cursor_type, unsigned s_start, unsigned s_stop )
{
inreg.x.ax = 10;
inreg.x.bx = cursor_type;
inreg.x.cx = s_start;
inreg.x.dx = s_stop;
call_mouse;
}

Mmovement* Mouse::Mmotion()
{
static Mmovement m;

inreg.x.ax = 11;
call_mouse;
m.x_count = _CX;
m.y_count = _DX;
return( &m );
}

void GMouse::Mlightpen(int set )
{
if( set )
inreg.x.ax = 13;
else
inreg.x.ax = 14;
call_mouse;
}

void TMouse::Mlightpen( int set )
{
if( set )
inreg.x.ax = 13;
else
inreg.x.ax = 14;
call_mouse;
}

void Mouse::Mmove_ratio( int xsize, int ysize )
{
inreg.x.ax = 15;
inreg.x.cx = xsize;
inreg.x.dx = ysize;
call_mouse;
}

void Mouse::Mconceal( int left, int top, int right, int bottom )
{
inreg.x.ax = 16;
inreg.x.cx = left;
inreg.x.dx = top;
inreg.x.si = right;
inreg.x.di = bottom;
call_mouse;
}

void Mouse::Mspeed( int speed )
{
inreg.x.ax = 19;
inreg.x.dx = speed;
call_mouse;
}

void GMouse::Set_Cursor( g_cursor ThisCursor )
{
set_cursor( ThisCursor.xkey, ThisCursor.ykey, _DS,
(unsigned) ThisCursor.ScreenMask );
}

GMouse gmouse;
TMouse tmouse;



  3 Responses to “Category : C Source Code
Archive   : C_ROTATE.ZIP
Filename : MOUSE.I

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/