home *** CD-ROM | disk | FTP | other *** search
- ***** Mike Duffy's Xmouse routines *****
- released April 28,1992
- Version 1.1
-
- I threw these routines together rather quickly, so if you find any
- bugs please let me know.
-
- My Internet address is mduffy@aludra.usc.edu if you need to contact
- me.
-
- So, What exactly is this?
-
- These routines work in the VGA graphics mode ModeX as put
- forth in the July 1991 issue of "Dr. Dobbs Journal" by Michael
- Abrash. The routines that set up the mode, draw a pixel, and draw
- a filled rectangle as included in the MXLIB.OBJ file are pretty
- much taken from the articles in DDJ with few changes. The source
- code is available in archives handling code from DDJ. Try
- anonymous ftp from SIMTEL20.ARMY.MIL in their mirrors directory.
- Seek and ye shall find.
- As far as the mouse routines, I wrote those suckers. They are
- designed to create a mouse cursor for you since most mouse drivers
- do not handle the undocumented ModeX.
-
- Da Instructions:
-
- Ok, the following is a description of each of the various
- routines available.
-
- unsigned int minitialize(unsigned int MouseX,
- unsigned int MouseY,
- unsigned char Color);
-
- This is called to check if the mouse is there, initialize it,
- and set up various variables. MouseX and MouseY are the starting
- coordinates of the mouse on the screen, and Color is the color of
- the mouse cursor. For simplicity, the mouse is only one color.
- The routine will return a 1 if everything is fine and a 0 if a
- mouse is not installed (i.e. no mouse driver). The global variable
- "mpresent" is set to 1 if a mouse is present and 0 otherwise.
-
- void muninitialize();
-
- This should be called at the end of your program when you are
- done with the mouse. It releases the interrupt vectors the
- initialize routine set up.
-
- void mshowcursor(void);
-
- This routine tells the driver to make the mouse cursor
- visible. While the mouse cursor is visible, the global variables
- "mousex" and "mousey" contain the current x and y coordinates of
- the mouse cursor. These variables are not updated when the cursor
- is hidden because it is rather silly to use an invisible cursor.
-
- void mhidecursor(void);
-
- This routine hides the cursor from view. Hence its name.
-
- void setmlimits(unsigned int x1,
- unsigned int y1,
- unsigned int x2,
- unsigned int y2);
-
- This routine allow you to set the maximum and the minimum x
- and y coordinates that the mouse can travel, thus allowing you to
- restrict it to a certain rectangle on the screen. The values for
- x1 and x2 can go from 0 to 319 and the y1 and y2 values can go from
- 0 to 239. The top left corner of this rectangle is defined by
- (x1,y1) and the lower right corner is defined by (x2,y2). Mix them
- up and your computer will probably take on a life of its own, grab
- the nearest piece of heavy furniture, and beat you into a small
- lifeless pile of muck.
-
-
-
- unsigned int mnonepresssed();
- unsigned int mleftpressed();
- unsigned int mrightpressed();
- unsigned int mbothpressed();
- unsigned int mcenterpressed();
- unsigned int mcenterleftpressed();
- unsigned int mcenterrightpressed();
- unsigned int mallpressed();
-
- This set of routines lets you find out the state of your mouse
- buttons. They return a 1 if the button is pressed and a 0 if not.
- Both means left and right button and all means all three buttons
- (that is of course, if you have a three button mouse.) You ought
- to be able to figure out which routine does what, and if you can't
- then you probably shouldn't be programming anyway.
-
-
- void setcursshape(enum curstype thetype);
-
- This is a neat feature of the Xmouse driver. You can change
- the shape of the cursor by placing the name of the cursor you want
- in the variable passed to the routine. The following are the
- cursors available:
-
- Standard, UpArrow, LeftArrow, CheckMark, PointingHand,
- DiagonalCross, RectangularCross, HourGlass, UserDef1, UserDef2,
- UserDef3, UserDef4
-
- The last four, the UserDef selections, can be defined by the user.
- The format for the cursor information is a bitmap 8 bits wide by
- 8 rows high. This is stored in an array of 8 unsigned chars. This
- bitmap is a bit unique in that you have to draw your cursor
- backwards to get it to display forwards (VGA registers are screwy,
- aren't they?) For example the bitmap for the standard cursor is:
-
- 00111111 The '1's are colored in and the '0's are masked out.
- 00011111 figure the value out for each row as if each row
- 00001111 were a binary value (because by golly, they ARE
- 00011111 binary values!)
- 00111011
- 01110001 <---- This line represents the value 113.
- 11100000 If you don't know binary.... learn it!
- 11000000
-
- Also included in the definition of a mouse cursor is a hot spot.
- The hot spot is the pixel that is considered the mouse's
- coordinate. On the cursor above, it is at the tip of the arrow and
- has a value of HorizHotSpot = 0 and VertHotSpot = 0. This is the
- upper right corner of the bitmap above, but since it will be
- flipped left to right when displayed, the hot spot will be the
- upper left corner. The value of the hot spot can go from 0 to 7,
- and dat's it. To make things easier I type set them as a
- structure. The variables are UserDefCurs1, UserDefCurs2,
- UserDefCurs3, UserDefCurs4. Shouldn't be too hard to figure out.
-
-
-
- Da Technical Stuff:
-
- First off, the driver needs the last 97 bytes in the display
- memory segment (i.e. segment 0xa000). Don't mess with them.
-
- Secondly, the driver attaches into the standard mouse driver
- via mouse interrupt function 0C hex. Don't mess with this either.
- The uninitialize function releases the interrupt vector set up with
- this function so that everything is nice and clean.
-
- As far as memory models go, the Xmouse will work on tiny,
- small, compact, medium, and large memory models. Just include the
- correct object file in your project (tiny = TXMOUSE.OBJ,
- small = SXMOUSE.OBJ, and medium = MXMOUSE.OBJ). Xmouse take up 146
- bytes out of your data segment. If you need other memory models to
- be supported and you beg and plead, then I MIGHT consider altering
- my source code and recompiling, my schedule permitting. Try the
- medium memory model first though; it's a good one.
-
-
- Licencing
-
- The object code for these routines is hereby released to the
- public (i.e. they are public domain). In exception to the above
- sentence are the routines drawn from the Michael Abrash articles
- in Dr. Dobb's Journal, July 1991, August 1991, and September 1991
- issues.
-
- The routines based on routines in Michael Abrash's articles
- are as follows, with the names of Abrash's routine in parenthasis
- setmodex() (a variant of Set320x240Mode()), xputpix() (WritePixelX()),
- xgetpix() (ReadPixelX()), xbar() (FillRectangleX()), and showpage()
- (ShowPage()). The rest of the routines are hereby public domain.
-
- Furthermore, the user shall use these routines at his own
- risk. The author is not responsible for any damages to computer,
- projects, programs, time, scheduling, hardware, software, loss of
- hair, sanity, or sleep due to correct or incorrect use of the
- routines. In other words ....
-
- Don't blame me for problems.... I'm not responsible.
-
- Mike Duffy
- (mduffy@aludra.usc.edu)
-
-
- /***********************************************/
-
- Release History (as if you cared):
-
- Ver 1.0 April 28, 1992
- The basic package released to the hungry public.
-
- Ver 1.1 May 7, 1992
- I fixed a couple of bugs in the mshowcursor and mhidecursor routines.
- Compact and Large memory models now supported.
- A few of the routines in the xlib package were renamed. Sorry for the
- inconvenience (just use search and replace to fix yer programs).
- Finally, the order of variables in a few of the routines were changed
- so that the color would always be the last variable, instead of the
- page to draw to.
- The mouse cursor can now be shown on any of the pages in display
- memory.
- A showpage() routine has been added to xlib.