home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / BBS_GAME / LOD400G.ZIP / MOUSE.PAS < prev   
Pascal/Delphi Source File  |  1991-04-06  |  30KB  |  740 lines

  1. Unit Mouse;
  2.  
  3. Interface
  4. Uses DOS;
  5.  
  6. var
  7.   MouseAvailable     : Boolean;
  8.   MouseType           : Word;
  9.   MouseName           : String[19];
  10.  
  11.  
  12. { Interrupt $33 Mouse Functions                                               }
  13.  
  14. {-----------------------------------------------------------------------------}
  15. {-----------------------------------------------------------------------------}
  16.  
  17. { $00 Mouse Reset                                                             }
  18. {                                                                             }
  19. function MouseReset:Boolean;
  20. {                                                                             }
  21. { MouseReset returns TRUE if a mouse is installed.                            }
  22. { MouseType = numeric value of type of mouse attached if MouseReset is TRUE.  }
  23. { MouseType = 2 for Microsoft Mouse, MouseType = 3 for Mouse Systems Mouse.   }
  24. { If MouseReset returns TRUE then the MSMOUSE internal variables have been    }
  25. { set as follows:                                                             }
  26. {                                                                             }
  27. {         internal cursor level counter                   -1                    }
  28. {         graphics cursor shape and hot spot            arrow and (-1,-1)     }
  29. {         text cursor                                   inverting box         }
  30. {         user-defined call mask                        all zeros             }
  31. {         light pen emulation mode                      on                    }
  32. {         horizontal mickey to pixel ratio              8 to 8                }
  33. {         vertical mickey to pixel ratio                16 to 8               }
  34. {         horizontal min and max cursor position limit  0 and 639             }
  35. {         vertical min and max cursor position limit    0 and 199             }
  36. {         double speed threshold                        64 mickeys per second }
  37.  
  38.  
  39. { $01 Show Cursor                                                             }
  40. {                                                                             }
  41. procedure MouseShowCursor;
  42. {                                                                             }
  43. { MouseShowCursor increments the internal cursor level counter.               }
  44. { The mouse cursor is visible if the cursor level counter = 0.                }
  45. { If the cursor level counter equals zero, this procedure has no effect.      }
  46.  
  47.  
  48. { $02 Hide Cursor                                                             }
  49. {                                                                             }
  50. procedure MouseHideCursor;
  51. {                                                                             }
  52. { MouseHideCursor decrements the internal cursor level counter                }
  53. { The mouse cursor is hidden if the cursor level counter < 0                  }
  54.  
  55.  
  56. { $03 Get Mouse Position and Button Status                                    }
  57. {                                                                             }
  58. function MouseGetButtonStatus(var MouseX,MouseY:Word):Word;
  59. {                                                                             }
  60. { MouseGetButtonStatus returns the state of the mouse buttons as follows:     }
  61. {                                                                             }
  62. { bit 0 = left button status                                                  }
  63. { bit 1 = right button status                                                 }
  64. { bit 2 = middle button status                                                }
  65. { The other bits are unused.                                                  }
  66. { The bits are at logic 0 if the button is up and at logic 1 if it is down.   }
  67. {                                                                             }
  68. { MouseX and MouseY return the X and Y coordinates of the mouse cursor.       }
  69.  
  70.  
  71. { $04 Set Mouse Cursor Position                                               }
  72. {                                                                             }
  73. procedure MouseSetPosition(MouseX,MouseY:Word);
  74. {                                                                             }
  75. { MouseSetPosition moves the mouse cursor to a new location.                  }
  76. { MouseX and MouseY should be passed the desired new cursor coordinates.      }
  77.  
  78.  
  79. { $05 Get Button Press Information                                            }
  80. {                                                                             }
  81. function MouseGetButtonPress(Button:Word;var Count,LastX,LastY:Word):Word;
  82. {                                                                             }
  83. { MouseGetButtonPress returns button status as described in function $03.     }
  84. { Button is passed the value of the button on which press information is      }
  85. { desired (0 for the left button, 1 for the right button, 2 for the middle    }
  86. { button).  Count returns the number of the times the indicated button was    }
  87. { pressed since a reset or the last call to MouseGetButtonPress.  Count will  }
  88. { be in the range 0 to 32767 ($7FFF) with no overflow detection.  LastX and   }
  89. { LastY return the cursor coordinates at the last button press.               }
  90.  
  91.  
  92. { $06 Get Button Release Information }
  93. {                                                                             }
  94. function MouseGetButtonRelease(Button:Word; var Count,LastX,LastY:Word):Word;
  95. {                                                                             }
  96. { MouseGetButtonRelease returns button status as described in function $03.   }
  97. { Button is passed the value of the button on which release information is    }
  98. { desired (0 for the left button, 1 for the right button, 2 for the middle    }
  99. { button).  Count returns the number of the times the indicated button was    }
  100. { released since a reset or the last call to MouseGetButtonRelease.  Count    }
  101. { will be in the range 0 to 32767 ($7FFF) with no overflow detection.  LastX  }
  102. { and LastY return the cursor coordinates at the last button release.         }
  103.  
  104.  
  105. { $07 Set Min/Max Horizontal  Position                                        }
  106. {                                                                             }
  107. procedure MouseSetX(MinX,MaxX:Word);
  108. {                                                                             }
  109. { MouseSetX limits horizontal mouse cursor movement to the values passed to   }
  110. { MinX and MaxX.                                                              }
  111.  
  112.  
  113. { $08 Set Min/Max Vertical Position }
  114. {                                                                             }
  115. procedure MouseSetY(MinY,MaxY:Word);
  116. {                                                                             }
  117. { MouseSetY limits vertical mouse cursor movement to the values passed to     }
  118. { MinY and MaxY.                                                              }
  119.  
  120.  
  121. { $09 Set Graphics Cursor Block }
  122. {                                                                             }
  123. procedure MouseSetGraphicsCursor(XHotSpot,YHotSpot:Word;CursorMap:Pointer);
  124. {                                                                             }
  125. { MouseSetGraphicsCursor sets up the definition of the graphics cursor array. }
  126. { On CGA systems, this function sets the shape, color, and center of the      }
  127. { graphic cursor.  A 32 word array defines a 16 by 16 pixel cursor for 640 by }
  128. { 200 mode, and an 8 by 16 pixel cursor for 320 by 200 mode.  The first 16    }
  129. { words define the screen mask, and the second 16 words define the cursor     }
  130. { mask, which function as follows:                                            }
  131. {                                                                             }
  132. { Screen Mask Bit       Cursor Mask Bit         Resulting Screen Bit          }
  133. { ---------------       ---------------         --------------------          }
  134. {       0                      0                         0                    }
  135. {       0                      1                         1                    }
  136. {       1                      0                same as original bit          }
  137. {       1                      1                inverse of original bit       }
  138. {                                                                             }
  139. { In 640 by 200 mode, each pixel corresponds to one bit in each of the masks. }
  140. {                                                                             }
  141. { In 320 by 200 mode, each pixel is made up of two such bits which together   }
  142. { define the color of the pixel.                                              }
  143. {                                                                             }
  144. { On EGA systems, each pixel corresponds to one bit in each of the masks. The }
  145. { cursor will appear as color MaxColors.  The mask bits function somewhat     }
  146. { differently than on CGA systems:                                            }
  147. {                                                                             }
  148. { Screen Mask Bit       Cursor Mask Bit         Resulting Screen Bit          }
  149. { ---------------       ---------------         --------------------          }
  150. {       0                      0                         0                    }
  151. {       0                      1                         1                    }
  152. {       1                      0                same as original bit          }
  153. {       1                      1                same as original bit          }
  154. {                                                                             }
  155. { Version 5.03 of MSMOUSE.SYS does not support the VGA adapter.               }
  156. {                                                                             }
  157. { The hot spot specifies the location of the mouse cursor with relation to    }
  158. { the graphics.  The upper left corner of the graphic cursor is (0,0).        }
  159. { Coordinate values increase down and to the right.                           }
  160.  
  161.  
  162. { $0A Set Text Cursor }
  163. {                                                                             }
  164. procedure MouseSetTextCursor(CursorSelect,ScreenMask,CursorMask:Word);
  165. {                                                                             }
  166. { MouseSetTextCursor sets up the definition of the text mode cursor.          }
  167. { Set CursorSelect to 0 for software cursor or to 1 for hardware cursor.      }
  168. { For the software cursor ScreenMask and CursorMask define the character and  }
  169. { attribute for the cursor.  For the hardware cursor ScreenMask is the scan   }
  170. { line start and CursorMask is the scan line end.  For the software cursor,   }
  171. { the screen mask is logically ANDed with the existing character then the     }
  172. { cursor mask is logically XORed with the result of the AND.  The high byte   }
  173. { defines the attribute and the low byte defines the character.               }
  174.  
  175.  
  176. { $0B Read Mouse Motion Counters }
  177. {                                                                             }
  178. procedure MouseReadMotion(var XMotion,YMotion:Integer);
  179. {                                                                             }
  180. { MouseReadMotion gets the raw horizontal and vertical mouse movement since   }
  181. { the last MouseReadMotion request.  XMotion and YMotion are relative cursor  }
  182. { movements with positive numbers representing movement to the right and down }
  183. { respectively.  Overflow of the integer range is ignored.                    }
  184.  
  185.  
  186. { $0C Set User-defined Subroutine Input Mask }
  187. {                                                                             }
  188. procedure MouseSetUserRoutine(EventMask:Word;UserRoutine:Pointer);
  189. {                                                                             }
  190. { MouseSetUserRoutine sets up the definition of the mouse user interrupt.     }
  191. { It sets the address of a user-defined routine to be called when a specified }
  192. { mouse event occurs.  The routine will be called as an interrupt when one or }
  193. { more of the enabled conditions occurs.  The routine will be called with the }
  194. { following register values:                                                  }
  195. {                                                                             }
  196. { Register      Contents                                                      }
  197. { --------      -------------------------------------------------             }
  198. {    AX         event identification word (see description below)             }
  199. {    BX         button state                                                  }
  200. {    CX         horizontal cursor position                                    }
  201. {    DX         vertical cursor position                                      }
  202. {    DI         raw horizontal mouse counts                                   }
  203. {    SI         raw vertical mouse counts                                     }
  204. {                                                                             }
  205. { The event mask bits are defined as follows:                                 }
  206. {                                                                             }
  207. { Mask Bit      Condition                                                     }
  208. { --------      -----------------------                                       }
  209. {    0          cursor position changed                                       }
  210. {    1          left button pressed                                           }
  211. {    2          left button released                                          }
  212. {    3          right button pressed                                          }
  213. {    4          right button released                                         }
  214. {    5          middle button pressed                                         }
  215. {    6          middle button released                                        }
  216. {  7-15         not used                                                      }
  217. {                                                                             }
  218. { A bit value of 1 will cause the the routine to be called when the specified }
  219. { event occurs.                                                               }
  220.  
  221.  
  222. { $0D Light Pen Emulation Mode ON }
  223. {                                                                             }
  224. procedure MouseLightPenOn;
  225. {                                                                             }
  226. { MouseLightPenOn enables light pen emulation.  If any mouse button is down   }
  227. { then the pen is down and if all mouse buttons are up then the pen is off    }
  228. { screen.  The cursor position is saved for the next pen function when any    }
  229. { mouse button is pressed.                                                    }
  230.  
  231.  
  232. { $0E Light Pen Emulation Mode OFF }
  233. {                                                                             }
  234. procedure MouseLightPenOff;
  235. {                                                                             }
  236. { MouseLightPenOff disables light pen emulation.                              }
  237.  
  238.  
  239. { $0F Set Mickey/Pixel Ratio }
  240. {                                                                             }
  241. procedure MouseSetMickeyToPixel(Horizontal,Vertical:Word);
  242. {                                                                             }
  243. { MouseSetMickeyToPixel defines the relationship between physical mouse       }
  244. { movement and mouse cursor movement.  Horizontal and Vertical specify the    }
  245. { number of mickeys required to move the mouse cursor 8 pixels.  The values   }
  246. { passed must be in the range 1 thuough 32767.                                }
  247.  
  248.  
  249. { $10 Protect Cursor Position }
  250. {                                                                             }
  251. procedure MouseProtectCursor(Left,Top,Right,Bottom:Word);
  252. {                                                                             }
  253. { MouseProtectCursor sets up a protected area of the screen.  If the cursor   }
  254. { moves into this area, an implicit MouseHideCursor will be performed.        }
  255.  
  256.  
  257. { $12 Set Large Graphics Cursor Block }
  258. {                                                                             }
  259. function MouseSetLargeGraphicsCursor(XSize,YSize,XHot,YHot:Byte;
  260.                                      CursorMap:Pointer):Boolean;
  261. {                                                                             }
  262. { MouseSetLargeGraphicsCursor sets up a cursor in a manner described for      }
  263. { function $09.  The cursor size is defined by Xsize (cursor width in words)  }
  264. { and Ysize (cursor height in pixels).  The actual cursor width depends on    }
  265. { the number of bits needed to define the pixel color.  The maximum cursor    }
  266. { size allowed is defined by the equation:                                    }
  267. {                                                                             }
  268. { ((XSize*2)+1)*YSize <= 144                                                  }
  269. {                                                                             }
  270. { The definition of the cursor map is the same as for function $09.           }
  271. {                                                                             }
  272. { The function returns True if the large graphics cursor is available, False  }
  273. { if it is not available.                                                     }
  274.  
  275.  
  276. { $13 Set Double Speed Treshold }
  277. {                                                                             }
  278. procedure MouseSetDoubleSpeed(Threshold:Word);
  279. {                                                                             }
  280. { This procedure sets the threshold (in mickeys per second) at which cursor   }
  281. { movement is doubled.  To disable the speed doubling action, set the         }
  282. { threshold to 32767 ($7FFF) mickeys per second.                              }
  283.  
  284.  
  285. { $42 Query MSMOUSE for Storage Requirements }
  286. {                                                                             }
  287. function MouseQueryStorage(var Space:Word):Word;
  288. {                                                                             }
  289. { MouseQueryStorage returns the availability status of the mouse state        }
  290. { storage and restoration functions.  If the return value is -1, then the     }
  291. { storage functions are available and Space is the number of bytes required   }
  292. { to store the mouse state.  If the return value is 66, then the functions    }
  293. { are not available.  If the return value is 0, then MSMOUSE.SYS is not       }
  294. { installed (MouseReset is the prefered method of determining this).          }
  295.  
  296.  
  297. { $50 Save MSMOUSE State }
  298. {                                                                             }
  299. function MouseSaveState(Space:Word;SaveSpace:Pointer):Boolean;
  300. {                                                                             }
  301. { MouseSaveState saves the current mouse setup.  The return value is True if  }
  302. { Space is large enough to hold the mouse state, and Flase if it is not.      }
  303. { MouseQueryStorage should always be called first to determine mouse storage  }
  304. { requirements.                                                               }
  305.  
  306.  
  307. { $52 Restore MSMOUSE State }
  308. {                                                                             }
  309. function MouseRestoreState(Space:Word;SaveSpace:Pointer):Boolean;
  310. {                                                                             }
  311. { MouseRestoreState restores a previosly saved mouse setup.  The return value }
  312. { is True if Space is large enough to hold the mouse state, and False if it   }
  313. { is not.                                                                     }
  314.  
  315. {-----------------------------------------------------------------------------}
  316. {-----------------------------------------------------------------------------}
  317.  
  318. implementation
  319.  
  320. {-----------------------------------------------------------------------------}
  321. {-----------------------------------------------------------------------------}
  322.  
  323. const
  324.  
  325.   IRET                = $CF;
  326.  
  327. var
  328.  
  329.   Mouse_Reg           : Registers;
  330.   MouseServicePointer : ^Byte;
  331.   MouseService        : Byte;
  332.   PreviousExit,
  333.   PreviousInt09,      { Keyboard Hardware Interrupt  (IRQ1)  } { Save any     }
  334.   PreviousInt0A,      { Possible Bus Mouse Interrupt (IRQ2)  } { interrupt    }
  335.   PreviousInt0B,      { COM2: and COM4: Interrupt    (IRQ3)  } { vectors that }
  336.   PreviousInt0C,      { COM1: and COM3: Interrupt    (IRQ4)  } { may be       }
  337.   PreviousInt0D,      { Possible Bus Mouse Interrupt (IRQ5)  } { modified     }
  338.   PreviousInt0F,      { Possible Bus Mouse Interrupt (IRQ7)  } { while using  }
  339.   PreviousInt10,      { Video I/O Interrupt                  } { the mouse.   }
  340.   PreviousInt16,      { Keyboard I/O Interrupt               }
  341.   PreviousInt72,      { Possible Bus Mouse Interrupt (IRQ10) }
  342.   PreviousInt73,      { Possible Bus Mouse Interrupt (IRQ11) }
  343.   PreviousInt74,      { Possible Bus Mouse Interrupt (IRQ12) }
  344.   PreviousInt77,      { Possible Bus Mouse Interrupt (IRQ15) }
  345.   MouseInterrupt      : Pointer;
  346.  
  347. {-----------------------------------------------------------------------------}
  348. {-----------------------------------------------------------------------------}
  349.  
  350. { Interrupt $33 Mouse Functions                                               }
  351.  
  352. {-----------------------------------------------------------------------------}
  353. {-----------------------------------------------------------------------------}
  354.  
  355. { $00 Mouse Reset }
  356.  
  357. function MouseReset:Boolean;
  358. begin
  359.   GetIntVec($33,MouseInterrupt);
  360.   MouseServicePointer:=MouseInterrupt;
  361.   MouseService:=MouseServicePointer^;
  362.   If (MouseInterrupt <> nil) and (MouseService <> IRET) then
  363.   With Mouse_Reg do
  364.   begin
  365.     Ax:=$00;
  366.     Intr($33,Mouse_Reg);
  367.     MouseType:=Bx;
  368.     MouseReset:=(Ax = $FFFF);
  369.   end
  370.   else MouseReset:=False;
  371. end;
  372.  
  373. {-----------------------------------------------------------------------------}
  374.  
  375. { $01 Show Cursor }
  376.  
  377. procedure MouseShowCursor;
  378. begin
  379.   Mouse_Reg.Ax:=$01;
  380.   Intr($33,Mouse_Reg);
  381. end;
  382.  
  383. {-----------------------------------------------------------------------------}
  384.  
  385. { $02 Hide Cursor }
  386.  
  387. procedure MouseHideCursor;
  388. begin
  389.   Mouse_Reg.Ax:=$02;
  390.   Intr($33,Mouse_Reg);
  391. end;
  392.  
  393. {-----------------------------------------------------------------------------}
  394.  
  395. { $03 Get Mouse Position and Button Status }
  396.  
  397. function MouseGetButtonStatus(var MouseX,MouseY:Word):Word;
  398. begin
  399.   With Mouse_Reg do
  400.   begin
  401.     Ax:=$03;
  402.     Intr($33,Mouse_Reg);
  403.     MouseX:=Cx;
  404.     MouseY:=Dx;
  405.     MouseGetButtonStatus:=Bx;
  406.   end;
  407. end;
  408.  
  409. {-----------------------------------------------------------------------------}
  410.  
  411. { $04 Set Mouse Cursor Position }
  412.  
  413. procedure MouseSetPosition(MouseX,MouseY:Word);
  414. begin
  415.   With Mouse_Reg do
  416.   begin
  417.     Ax:=$04;
  418.     Bx:=MouseX;
  419.     Cx:=MouseY;
  420.   end;
  421.   Intr($33,Mouse_Reg);
  422. end;
  423.  
  424. {-----------------------------------------------------------------------------}
  425.  
  426. { $05 Get Button Press Information }
  427.  
  428. function MouseGetButtonPress(Button:Word;var Count,LastX,LastY:Word):Word;
  429. begin
  430.   With Mouse_Reg do
  431.   begin
  432.     Ax:=$05;
  433.     Bx:=Button;
  434.     Intr($33,Mouse_Reg);
  435.     LastX:=Cx;
  436.     LastY:=Dx;
  437.     Count:=Bx;
  438.     MouseGetButtonPress:=Ax;
  439.   end;
  440. end;
  441.  
  442. {-----------------------------------------------------------------------------}
  443.  
  444. { $06 Get Button Release Information }
  445.  
  446. function MouseGetButtonRelease(Button:Word; var Count,LastX,LastY:Word):Word;
  447. begin
  448.   With Mouse_Reg do
  449.   begin
  450.     Ax:=$06;
  451.     Bx:=Button;
  452.     Intr($33,Mouse_Reg);
  453.     LastX:=Cx;
  454.     LastY:=Dx;
  455.     Count:=Bx;
  456.     MouseGetButtonRelease:=Ax;
  457.   end;
  458. end;
  459.  
  460. {-----------------------------------------------------------------------------}
  461.  
  462. { $07 Set Min/Max Horizontal  Position }
  463.  
  464. procedure MouseSetX(MinX,MaxX:Word);
  465. begin
  466.   With Mouse_Reg do
  467.   begin
  468.     Ax:=$07;
  469.     Cx:=MinX;
  470.     Dx:=MaxX;
  471.   end;
  472.   Intr($33,Mouse_Reg);
  473. end;
  474.  
  475. {-----------------------------------------------------------------------------}
  476.  
  477. { $08 Set Min/Max Vertical Position }
  478.  
  479. procedure MouseSetY(MinY,MaxY:Word);
  480. begin
  481.   With Mouse_Reg do
  482.   begin
  483.     Ax:=$08;
  484.     Cx:=MinY;
  485.     Dx:=MaxY;
  486.   end;
  487.   Intr($33,Mouse_Reg);
  488. end;
  489.  
  490. {-----------------------------------------------------------------------------}
  491.  
  492. { $09 Set Graphics Cursor Block }
  493.  
  494. procedure MouseSetGraphicsCursor(XHotSpot,YHotSpot:Word;CursorMap:Pointer);
  495. begin
  496.   With Mouse_Reg do
  497.   begin
  498.     Ax:=$09;
  499.     Bx:=XHotSpot;
  500.     Cx:=YHotSpot;
  501.     Es:=Seg(CursorMap^);
  502.     Dx:=Ofs(CursorMap^);
  503.   end;
  504.   Intr($33,Mouse_Reg);
  505. end;
  506.  
  507. {-----------------------------------------------------------------------------}
  508.  
  509. { $0A Set Text Cursor }
  510.  
  511. procedure MouseSetTextCursor(CursorSelect,ScreenMask,CursorMask:Word);
  512. begin
  513.   With Mouse_Reg do
  514.   begin
  515.     Ax:=$0A;
  516.     Bx:=CursorSelect;
  517.     Cx:=ScreenMask;
  518.     Dx:=CursorMask;
  519.   end;
  520.   Intr($33,Mouse_Reg);
  521. end;
  522.  
  523. {-----------------------------------------------------------------------------}
  524.  
  525. { $0B Read Mouse Motion Counters }
  526.  
  527. procedure MouseReadMotion(var XMotion,YMotion:Integer);
  528. begin
  529.   With Mouse_Reg do
  530.   begin
  531.     Ax:=$0B;
  532.     Intr($33,Mouse_Reg);
  533.     XMotion:=Cx;
  534.     YMotion:=Dx;
  535.   end;
  536. end;
  537.  
  538. {-----------------------------------------------------------------------------}
  539.  
  540. { $0C Set User-defined Subroutine Input Mask }
  541.  
  542. procedure MouseSetUserRoutine(EventMask:Word;UserRoutine:Pointer);
  543. begin
  544.   With Mouse_Reg do
  545.   begin
  546.     Ax:=$0C;
  547.     Cx:=EventMask;
  548.     Es:=Seg(UserRoutine^);
  549.     Dx:=Ofs(UserRoutine^);
  550.   end;
  551.   Intr($33,Mouse_Reg);
  552. end;
  553.  
  554. {-----------------------------------------------------------------------------}
  555.  
  556. { $0D Light Pen Emulation Mode ON }
  557.  
  558. procedure MouseLightPenOn;
  559. begin
  560.   Mouse_Reg.Ax:=$0D;
  561.   Intr($33,Mouse_Reg);
  562. end;
  563.  
  564. {-----------------------------------------------------------------------------}
  565.  
  566. { $0E Light Pen Emulation Mode OFF }
  567.  
  568. procedure MouseLightPenOff;
  569. begin
  570.   Mouse_Reg.Ax:=$0E;
  571.   Intr($33,Mouse_Reg);
  572. end;
  573.  
  574. {-----------------------------------------------------------------------------}
  575.  
  576. { $0F Set Mickey/Pixel Ratio }
  577.  
  578. procedure MouseSetMickeyToPixel(Horizontal,Vertical:Word);
  579. begin
  580.   With Mouse_Reg do
  581.   begin
  582.     Ax:=$0F;
  583.     Cx:=Horizontal;
  584.     Dx:=Vertical;
  585.   end;
  586.   Intr($33,Mouse_Reg)
  587. end;
  588.  
  589. {-----------------------------------------------------------------------------}
  590.  
  591. { $10 Protect Cursor Position }
  592.  
  593. procedure MouseProtectCursor(Left,Top,Right,Bottom:Word);
  594. begin
  595.   With Mouse_Reg do
  596.   begin
  597.     Ax:=$10;
  598.     Cx:=Left;
  599.     Dx:=Top;
  600.     Si:=Right;
  601.     Di:=Bottom;
  602.   end;
  603.   Intr($33,Mouse_Reg)
  604. end;
  605.  
  606. {-----------------------------------------------------------------------------}
  607.  
  608. { $12 Set Large Graphics Cursor Block }
  609.  
  610. function MouseSetLargeGraphicsCursor(XSize,YSize,XHot,YHot:Byte;
  611.                                      CursorMap:Pointer):Boolean;
  612. begin
  613.   With Mouse_Reg do
  614.   begin
  615.     Ax:=$12;
  616.     Bl:=XHot;
  617.     Bh:=XSize;
  618.     Cl:=YHot;
  619.     Ch:=YSize;
  620.     Es:=Seg(CursorMap^);
  621.     Dx:=Ofs(CursorMap^);
  622.     Intr($33,Mouse_Reg);
  623.     MouseSetLargeGraphicsCursor:=(Ax = $FFFF);
  624.   end;
  625. end;
  626.  
  627. {-----------------------------------------------------------------------------}
  628.  
  629. { $13 Set Double Speed Treshold }
  630.  
  631. procedure MouseSetDoubleSpeed(Threshold:Word);
  632. begin
  633.   With Mouse_Reg do
  634.   begin
  635.     Ax:=$13;
  636.     Dx:=Threshold;
  637.   end;
  638.   Intr($33,Mouse_Reg)
  639. end;
  640.  
  641. {-----------------------------------------------------------------------------}
  642.  
  643. { $42 Query MSMOUSE for Storage Requirements }
  644.  
  645. function MouseQueryStorage(var Space:Word):Word;
  646. begin
  647.   With Mouse_Reg do
  648.   begin
  649.     Ax:=$42;
  650.     Intr($33,Mouse_Reg);
  651.     Space:=Bx;
  652.     MouseQueryStorage:=Ax;
  653.   end;
  654. end;
  655.  
  656. {-----------------------------------------------------------------------------}
  657.  
  658. { $50 Save MSMOUSE State }
  659.  
  660. function MouseSaveState(Space:Word;SaveSpace:Pointer):Boolean;
  661. begin
  662.   With Mouse_Reg do
  663.   begin
  664.     Ax:=$50;
  665.     Bx:=Space;
  666.     Es:=Seg(SaveSpace^);
  667.     Dx:=Ofs(SaveSpace^);
  668.     Intr($33,Mouse_Reg);
  669.     MouseSaveState:=(Ax = $FFFF);
  670.   end;
  671. end;
  672.  
  673. {-----------------------------------------------------------------------------}
  674.  
  675. { $52 Restore MSMOUSE State }
  676.  
  677. function MouseRestoreState(Space:Word;SaveSpace:Pointer):Boolean;
  678. begin
  679.   With Mouse_Reg do
  680.   begin
  681.     Ax:=$52;
  682.     Bx:=Space;
  683.     Es:=Seg(SaveSpace^);
  684.     Dx:=Ofs(SaveSpace^);
  685.     Intr($33,Mouse_Reg);
  686.     MouseRestoreState:=(Ax = $FFFF);
  687.   end;
  688. end;
  689.  
  690. {-----------------------------------------------------------------------------}
  691.  
  692. {$F+}procedure MouseExitProc;{$F-}                { Mouse Unit Exit Procedure }
  693. begin
  694.   SetIntVec($09,PreviousInt09);
  695.   SetIntVec($0A,PreviousInt0A);
  696.   SetIntVec($0B,PreviousInt0B);
  697.   SetIntVec($0C,PreviousInt0C);
  698.   SetIntVec($0D,PreviousInt0D);
  699.   SetIntVec($0F,PreviousInt0F);
  700.   SetIntVec($10,PreviousInt10);
  701.   SetIntVec($16,PreviousInt16);
  702.   SetIntVec($72,PreviousInt72);
  703.   SetIntVec($73,PreviousInt73);
  704.   SetIntVec($74,PreviousInt74);
  705.   SetIntVec($77,PreviousInt77);
  706.   ExitProc:=PreviousExit;
  707. end;
  708.  
  709. {-----------------------------------------------------------------------------}
  710.  
  711. { Mouse Unit Initialization Procedure}
  712.  
  713. begin
  714.   GetIntVec($09,PreviousInt09);
  715.   GetIntVec($0A,PreviousInt0A);
  716.   GetIntVec($0B,PreviousInt0B);
  717.   GetIntVec($0C,PreviousInt0C);
  718.   GetIntVec($0D,PreviousInt0D);
  719.   GetIntVec($0F,PreviousInt0F);
  720.   GetIntVec($10,PreviousInt10);
  721.   GetIntVec($16,PreviousInt16);
  722.   GetIntVec($72,PreviousInt72);
  723.   GetIntVec($73,PreviousInt73);
  724.   GetIntVec($74,PreviousInt74);
  725.   GetIntVec($77,PreviousInt77);
  726.   PreviousExit:=ExitProc;
  727.   ExitProc:=@MouseExitProc;
  728.   MouseAvailable:=MouseReset;
  729.   mousename:='No Mouse Attached';
  730.   If MouseAvailable then case MouseType of
  731.    2:MouseName:='Microsoft Mouse';
  732.    3:MouseName:='Mouse Systems Mouse';
  733.   else
  734.    MouseName:='Generic Mouse';
  735.   end;
  736. end.
  737.  
  738. {-----------------------------------------------------------------------------}
  739. {-----------------------------------------------------------------------------}
  740.