{ SPX Library Version 2.0 Copyright 1993 Scott D. Ramsay } The MOUSE unit provides basic routines for reading the mouse inputs. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Global Variables: visible TRUE if the mouse pointer is visiable. mousehere TRUE is a mouse is connected and the driver is installed mousewason TRUE if the mouse was on before the procedure MOUSEOFF was called nomouse same as MOUSEHERE (for compatability) mseshp SPX default small mouse pointer shape skl horzontal scale factor. Some mouse drivers set the horzontal range in 320x200 mode at 0..639 instead of 0..319. This variable can be used to adjust the value. Set by the procedure NORMALIZEMX m1,m2,m3,m4 : integer; { scratch variables, can use for any purpose } ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure mset(var m1,m2,m3,m4:integer); For users who are familar with the mouse driver interrupt number, they can use this procedure for direct interrupt mouse calls. m1 = register AX m2 = register BX m3 = register CX m4 = register DX ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ function mousereset:integer; Resets the mouse. Must be called first to use any of the other functions. Returns 0 if successful ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure mouseon; Turns on the mouse. (display) ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ function mouseoff:boolean; Turns off the mouse. (hide) ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure getmouse(var m2,m3,m4:integer); Gets the mouse inputs m2 Mouse button mask. Bit set indicates mouse button is down. bit 0 set - button 1 bit 1 set - button 2 bit 2 set - button 3 m3 Mouse current X position m4 Mouse current Y position ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure setmouse(m3,m4:integer); Move the mouse to a location. m3,m4 (x,y) position (in pixels) to move the mouse. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure getmousepresses(var m2,m3,m4:integer); Get the number of mouse button presses. Since last call m2 number of presses. m3,m4 Mouse (x,y) position ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure getmousereleases(var m2,m3,m4:integer); Get the number of mouse button releases. Since last call m2 number of releases. m3,m4 Mouse (x,y) position ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure getmousemotion(var m3,m4:integer); Get the mouse motion m3 mouse horzontal speed. 0 = not moving horzontally m4 mouse vertical speed. 0 = not moving vertically ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure setmousecursor(m2,m3:integer; var mask); Set the mouse to a new shape. m2,m3 (x,y) offset of the mouse hot spot. mask 64 bytes describing the mouse shape. Maximum size of a cursor is 32x32. The first 32 bytes is a bit level mask. The next 32 bytes is the cursor shape. A bit set in the mask defines transparency. A bit set in the cursor shape defines white. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure setmouseratio(m3,m4:integer); Set the mouse movement speed. m3 Set the horzontal speed m3 Set the vertical speed ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure setmouseoff(x1,y1,x2,y2:integer); Set a rectangular region which the mouse will not be displayed (if on) x1,y1 top-left position of rectangle x2,y2 bottom-right position of rectangle ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure setmousepage(f:byte); Sets the visual page of the mouse. (Does not work in 320x200x256 mode) ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure cleanmouse; Waits until not mouse button is pressed ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure chkmouseon; Displays the mouse if it was turned off by the procedure MOUSEOFF ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure setdefptr; Sets the mouse shape to the SPX default cursor arrow ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ procedure normalizemx; Sets the SKL variable accoring to the mouse driver width range in 320x200x256 mode. Call right after the function mousereset. Works only in mode 13h. example: openmode(1); { set to 320x200 mode } if mousereset<>0 { reset mouse driver } then writeln('No mouse is installed') else begin normalizemx; { set skl variable according to driver } getmouse(m2,m3,m4); { get the mouse position } y_position := m4; { vertical position of mouse } x_position := m3 div skl; { horzontal position of mouse } end;