NOTES ON USING MOUSERTN.OBJ AND MOUSE.H First a little backgound on the mouse. According to the Microsoft mouse users guide, the mouse supports IBM CGA, EGA, Mono, 3270 and Hercules graphics adapters. I have not had a chance to test these routines on all of these type of monitors, but have tested them on CGA, and some of the routines on Hercules. I will be able to finish checking all the routines on the hercules shortly, but do not anticipate any problems. The mouse driver software automatically senses the character cell size of different video modes. In text mode, the mouse will always give the characters upper left pixel as the position. For example, on a CGA card in 80 column mode, the character cells are 8 pixels by 8 pixels. If the mouse cursor is at 10,5 (starting from 0,0) the mouse will give the position 80,40. The mouse uses 3 types of cursors: graphics cursor-a shape that moves over the images on the screen. software text cursor-a character attribute that moves from character to character. hardware text cursor - a flashing block or partial block that moves from character to character. The graphics cursor is used in graphics mode. Usually, it is defined as a block of pixels in a 16 x 16 pixel area. The mouse cursor's appearance against the background depends on the mask used. The default appearance in graphics mode is an arrow. Mouse function 9 let's you change the mask. The mask is defined in an array of 32 integers, the first 16 defining the screen mask, and the second 16 defining the cursor mask. This table from the users guide shows the effects of the masks. SCREEN MASK CURSOR MASK RESULTING SCREEN BIT 0 0 0 0 1 1 1 0 Unchanged 1 1 Inverted When defining a graphics cursor, you also define a hot spot, meaning the individual pixel that the mouse software will use in determining its location. The software text cursor also has a mask defining its effect on the screen. The screen mask determines which of the characters attributes are preserved. The cursor mask defines how the attributes are changed to show the cursor. The 16 bits of each mask are: 15- set blinking or nonblinking 14-12 background color 11 intensity 10-8 foreground color 7-0 ascii value of char The mouse can also use the hardware cursor in text mode, in which case you can define the start/stop scan lines, to display a partial of full block blinking cursor. The number of scan lines depends on the type of video display. The mouse software keeps some internal counters. It increments a seperate counter each time a button is pressed or released, resetting them to 0 after they have been read or after function 0, initialization. I also keeps an internal cursor flag, which is always 0 or less. When the flag is 0 the mouse cursor is displayed. Each call to hide the cursor decrements the flag. Thus if you call hide_cursor() twice, you must call show_cursor() twice to get it to show again. The mouse measures distance in values called mickey's (Honest, I didn't make it up). A mickey is approximately 1/200th of an inch. There are functions which let you change the mickey/pixel ration (how far you have to move the mouse to move the same distance on the screen) and to change the speed doubling threshold (Default 64 mickeys/second). SPECIAL NOTES: For the mouse graphics cursor to show on a hercules graphics board, my understanding is that you have to poke 6 into location 40:49 hex for page 0, or a 5 for page 1. I have not had a chance to test it yet, but that is the information I got from the Microsoft forum on CIS. When printing to or updating the screen while the mouse cursor is showing, the mouse sometimes has problems not obliterating your changes when it moves away if you wrote directly accross where the mouse cursor was. It usually is best to hide the cursor momentarily while you update the screen. MOUSE FUNCTIONS --------------- Function 0 int mouse_init(void); Initializes the mouse software to its defaults,: cursor in the center of the screen, internal cursor flag -1 (not showing), graphics cursor arrow/-1,-1 hot spot text cursor an inverting box, horizontal mickey/pixel ration of 8:8, vertical mickey/pixel ratio of 16:8 minimum and maximum horizontal and vertical positions usually the entire screen. Returns 0 if mouse not installed. Function 1 void show_cursor(void); Show the cursor. Increments the internal cursor flag. Function 2 void hide_cursor(void); Hide the cursor. Decrements the internal cursor flag. Function 3 void get_status(int *,int *, int *); Get mouse position and status. gives button status and current position. status: 1=left button pressed, 2=right, 3=both Function 4 void pos_mouse(int,int); Position the mouse on the screen. It wants the pixel coordinates, not just character positions. Function 5 void b_press(int,int *,int *, int *,int *); Gets the current status of the button,(0=check left button,1=check right) and the number of times the button was pressed since the last call to this function. Also returns the position of the mouse the last time the button was pressed. Function 6 int b_release(int,int *,int *,int *,int *); Like function 5, but checks button releases instead. Function 7 void sethbounds(int,int); Set the left and right limits for the mouse to travel. Function 8 void setvbounds(int,int); Set the top and bottom limits for the mouse to travel. Function 9 void setgraphics(int,int, void (far *)); Sets the graphics cursor's hot spot and mask which defines what the graphics cursor will look like. The cursor hot spot must be within the range -16 to +16 pixels relative to the cursor. The mask values could be something like: int xmask[32]={0x07e0,0x0000,0x0180,0x700e,0x0000,0x1c38,0xc003,0x0660, 0xf00f,0x03c0,0xc003,0x0660,0x0000,0x1c38,0x0180,0x700e, 0x07e0,0x0000,0xffff,0x0000,0xffff,0x0000,0xffff,0x0000, 0xffff,0x0000,0xffff,0x0000,0xffff,0x0000,0xffff,0x0000 }; defines a graphics cursor like an x. See the reference earlier in this file for the table of the mask values effects on the screen. Function 10 void settext(int,int,int); sets the mouse text cursor to hardware or software cursor mode. The first integer defines the mode, 0= use software cursor, 1=use hardware cursor. The second 2 integers define either the screen and cursor masks (software mode) or the start and stop scan lines of the hardware cursor. Typical mask values might be settext(0,0xFFFF,0x7700); Function 11 void motion(int *,int *); This function reads the motion counters since the last call to this function. Returns the motion in "mickeys", always within the range of -32768 to +32767. Function 12 void set_subroutine(int,void (far *)()); This function sets a subroutine to be conditionally called by the mouse software. The condition of execution is defined by the mask. Bit 0 cursor position changes 1 left button pressed 2 left button released 3 right button pressed 4 tight button released 5-15 unused To disable an interrupt for a specified condition, call function again with the corresponding bit set to zero. Calling mouse function zero also resets everything. The subroutine to be called must be a far procedure, must save all registers, and must not do any dos or bios calls. Functions 13,14 void light_pen(int); These functions turn the light kpen emulation mode on or off. I don't know of any c programs that use light pen emulation, but the functions were easy to implement and included for completeness. A zero parameter turns on emulation, any other parameter turns it off. Function 15 void setspeed(int,int); Sets the mickey / pixel ratio vertically and horizontally. Default values are horizontal 8 mickeys to 8 pixels, vertically 16 to 8. Function 16 Void conditional_off(int,int,int,int); This function is similar to hide_cursor(), but only turns off the cursor if it is in the area defined when this function is called. If this function hides the cursor, show_cursor() must be called again later on to show the cursor again. Function 19 void set_threshold(int); This function sets how fast the mouse must move before its relative cursor movements on the screen are doubled. Default value is 64 mickeys per second.