Output of file : CHAP9.C contained in archive :
POWER-C.ZIP
/*
The programs contained herein are adapted from
C: Power User's Guide
by Herbert Schildt published by Osborne/McGraw-Hil, Copyright
1987, Osborne/McGraw-Hill. Used with the permission of
Osborne/McGraw-Hill. Program adaptations are solely the
work of Herbert Schildt and are not a publication of
Osborne/McGraw-Hill.
*/
listing 9-1
device=mouse.sys
listing 9-2
mouse
listing 9-3
/* Reset the mouse. */
void mouse_reset()
{
int fnum, arg2, arg3, arg4;
fnum = 0; /* reset the mouse */
cmouses(&fnum, &arg2, &arg3, &arg4);
if(fnum!=-1) {
printf("mouse hardware or software not installed");
exit(1);
}
if(arg2!=2) {
printf("two-button mouse required");
exit(1);
}
}
listing 9-4
/* Turn on the mouse cursor. */
void cursor_on()
{
int fnum;
fnum = 1; /* show the cursor */
cmouses(&fnum, &fnum, &fnum, &fnum);
}
/* Turn off the mouse cursor. */
void cursor_off()
{
int fnum;
fnum = 2; /* erase the cursor */
cmouses(&fnum, &fnum, &fnum, &fnum);
}
listing 9-5
/* Return true if right button is pressed;
false otherwise. */
rightb_pressed()
{
int fnum, arg2, arg3, arg4;
fnum = 3; /* get position and button status */
cmouses(&fnum, &arg2, &arg3, &arg4);
return arg2 & 2;
}
/* Return true if left button is pressed;
false otherwise. */
leftb_pressed()
{
int fnum, arg2, arg3, arg4;
fnum = 3; /* get position and button status */
cmouses(&fnum, &arg2, &arg3, &arg4);
return arg2 & 1;
}
listing 9-6
/* Return the direction of travel. */
void mouse_motion(deltax, deltay)
char *deltax, *deltay;
{
int fnum, arg2, arg3, arg4;
fnum = 11; /* get direction of motion */
cmouses(&fnum, &arg2, &arg3, &arg4);
if(arg3>0) *deltax = RIGHT;
else if(arg3<0) *deltax = LEFT;
else *deltax = NOT_MOVED;
if(arg4>0) *deltay = DOWN;
else if(arg4<0) *deltay = UP;
else *deltay = NOT_MOVED;
listing 9-7
#define NOT_MOVED 0
#define RIGHT 1
#define LEFT 2
#define UP 3
#define DOWN 4
listing 9-8
/* Set mouse cursor coordinates. */
void set_mouse_position(x, y)
int x, y;
{
int fnum, arg2;
fnum = 4; /* set position */
cmouses(&fnum, &arg2, &x, &y);
}
/* Return mouse cursor coordinates. */
void mouse_position(x, y)
int *x, *y;
{
int fnum, arg2, arg3, arg4;
fnum = 3; /* get position and button status */
cmouses(&fnum, &arg2, &arg3, &arg4);
*x = arg3;
*y = arg4;
}
listing 9-9
/* Interfacing to the Microsoft/IBM mouse. */
#include "dos.h"
#define NOT_MOVED 0
#define RIGHT 1
#define LEFT 2
#define UP 3
#define DOWN 4
void mouse_position(), mode(), goto_xy(), mouse_motion();
void cursor_on(), cursor_off(), mouse_reset();
main(argc, argv)
int argc;
char *argv[];
{
char deltax, deltay, x, y;
if(argc!=2) {
printf("usage:mouser
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/