home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progbas / qbnws202.arj / RODENT.ZIP / MOUSE.MOU < prev    next >
Encoding:
Text File  |  1991-06-01  |  15.3 KB  |  390 lines

  1. ' ===========================================================================
  2. '   FILE: MOUSE.MOU
  3. '
  4. '   Microsoft (tm) Compatible Mouse Driver and Support routines
  5. '   for QuickBASIC 4.5.
  6. '
  7. '           Copyright (c) 1991
  8. '           Daniel R. Berry (Traveller Software)
  9. '           All Rights Reserved
  10. '
  11. '   This code is released to the Public Domain for distribution with the
  12. '   QBNews.
  13. '
  14. '   Daniel R. Berry
  15. '   3110-C S. Gen McMullen
  16. '   San Antonio, TX  78226
  17. '
  18. ' $INCLUDE: 'MOUSE.BI'
  19. '
  20. DECLARE SUB Mouse (M1%, M2%, M3%, M4%)
  21. DECLARE SUB MouseLimits (MouseX1%, MouseY1%, MouseX2%, MouseY2%)
  22. DECLARE SUB MouseStatus (Left%, Right%, MouseX%, MouseY%)
  23. DECLARE SUB MouseCheck (Flag%)
  24. DECLARE SUB MouseLocate (MouseX%, MouseY%)
  25. DECLARE SUB MouseLeft (LCount%, LMouseX%, LMouseY%)
  26. DECLARE SUB MouseRight (RCount%, RMouseX%, RMouseY%)
  27. DECLARE SUB GetHighLow (Number%, High%, Low%)
  28.  
  29. ' ===========================================================================
  30. '   SUBPROGRAM: Mouse - QBUTIL
  31. '   Version 1.0  By: Dan Bery (c) Traveller Software 1991
  32. ' ============================ Mouse SubProgram =============================
  33. SUB Mouse (M1%, M2%, M3%, M4%)
  34.     DEFINT A-Z
  35. '
  36. '   This utility drives all mouse functions for the mouse routines.
  37. '   Functions Currently Supported by this Library:
  38. '
  39. '       00h - Reset Mouse and Get Status
  40. '       01h - Show Mouse Cursor
  41. '       02h - Hide Mouse Cursor
  42. '       03h - Get Mouse Position and Button Status
  43. '       04h - Set Mouse Cursor Position
  44. '       05h - Get Button Press Information
  45. '       06h - Get Button Release Information
  46. '       07h - Set Horizontal Limits for Mouse Cursor
  47. '       08h - Set Vertical Limits for Mouse Cursor
  48. '       0Bh - Read Mouse Motion Counters
  49. '       0Dh - Turn On Light-Pen Emulation
  50. '       0Eh - Turn Off Light-Pen Emulation
  51. '       1Ah - Set Mouse Sensitivity
  52. '       1Bh - Get Mouse Sensitivity
  53. '       1Dh - Select Mouse Cursor Page
  54. '       1Eh - Get Mouse Cursor Page
  55. '       24h - Get Mouse Information
  56. '
  57. '   Note: There are other functions not currently supported.
  58. '
  59.     DIM Reg AS RegType
  60. '
  61. '   Setup for INT 33H/Mouse Interrupt - Functions are determined by M1
  62. '
  63.     Reg.ax = M1: Reg.bx = M2: Reg.cx = M3: Reg.dx = M4
  64.     CALL INTERRUPT(&H33, Reg, Reg)
  65. '
  66. '   Convert Registers back to usable format
  67. '
  68.     M1 = Reg.ax: M2 = Reg.bx: M3 = Reg.cx: M4 = Reg.dx
  69. ' ========================= End of Mouse SubProgram =========================
  70. END SUB
  71.  
  72. DEFSNG A-Z
  73. ' ===========================================================================
  74. '   SUBPROGRAM: MouseCheck  -  QBUTIL
  75. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  76. ' ========================== MouseCheck SubProgram ==========================
  77. SUB MouseCheck (Flag%) STATIC
  78.     DEFINT A-Z
  79. '
  80. '   If Flag = -1 then check to see if the mouse is available and install it.
  81. '   However, if MFlag = 1 then skip this step, the mouse is already
  82. '   installed and should only be reset by calling MouseReset.
  83. '
  84.     IF Flag = -1 AND MFlag = 0 THEN
  85.         MFlag = 0
  86.         CALL Mouse(MFlag, 0, 0, 0)
  87.         MouseStat = 0
  88.     '
  89.     '   If the Mouse is available then set MFlag to 1.
  90.     '
  91.         IF MFlag <> 0 THEN MFlag = 1
  92.     END IF
  93. '
  94. '   If Flag = -2 then disable the mouse.
  95. '
  96.     IF Flag = -2 THEN
  97.         MFlag = 0
  98.         CALL Mouse(0, 0, 0, 0)  ' We reset the mouse in order to turn it off.
  99.         MouseStat = 0
  100.     END IF
  101. '
  102. '   Note: Since this routine is STATIC the value of MFlag is held in memory
  103. '   for future reference for use by other mouse utilities.
  104. '
  105.     Flag = MFlag
  106.     MouseChk% = MFlag ' Set the COMMON MouseChk variable
  107. ' ====================== End of MouseCheck SubProgram =======================
  108.     END SUB
  109.  
  110. DEFSNG A-Z
  111. ' ===========================================================================
  112. '   SUBPROGRAM: MouseCRT  -  QBUTIL
  113. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  114. ' ============================ MouseCRT SubProgram ==========================
  115. SUB MouseCRT (CRT%, Flag%)
  116.     IF MouseChk% = 0 THEN EXIT SUB ' Is the MouseChk variable set?
  117.     IF Flag% = 1 THEN
  118.             CALL Mouse(30, CRT%, 0, 0)  '   Get the Mouse Display Page
  119.         ELSE
  120.             CALL Mouse(29, CRT%, 0, 0)  '   Set the Mouse Display Page
  121.     END IF
  122. ' ====================== End of MouseCRT SubProgram ======================
  123.     END SUB
  124.  
  125. ' ===========================================================================
  126. '   SUBPROGRAM: MouseInformation
  127. '   Version 1.0  By: Dan Berry (c) Traveller Software 1991
  128. ' ======================== MouseInformaton SubProgram =======================
  129. SUB MouseInformation (MouseVer$, MouseType%, MouseType$)
  130.     DEFINT A-Z
  131.     IF MouseChk = 0 THEN EXIT SUB ' Is the MouseChk variable set?
  132. '
  133. '   Get Mouse Information
  134. '
  135.     CALL Mouse(36, MouseVersion, MType, 0)
  136. '
  137. '   Convert Version to readable format
  138. '
  139.     CALL GetHighLow(MouseVersion, MajorVer, MinorVer)
  140.     MouseVer$ = LTRIM$(STR$(MajorVer)) + "." + LTRIM$(STR$(MinorVer))
  141. '
  142. '   Get MouseType
  143. '
  144.     CALL GetHighLow(MType, MouseType, M)
  145.     MouseType$ = "Undefined"
  146.     IF MouseType = 1 THEN MouseType$ = "Bus Mouse"
  147.     IF MouseType = 2 THEN MouseType$ = "Serial Mouse"
  148.     IF MouseType = 3 THEN MouseType$ = "InPort Mouse"
  149.     IF MouseType = 4 THEN MouseType$ = "PS/2 Mouse"
  150.     IF MouseType = 5 THEN MouseType$ = "HP Mouse"
  151. ' ==================== End of MouseInformaton SubProgram ====================
  152. END SUB
  153.  
  154. DEFSNG A-Z
  155. ' ===========================================================================
  156. '   SUBPROGRAM: MouseLeft  -  QBUTIL
  157. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  158. ' ========================== MouseLeft SubProgram ===========================
  159. SUB MouseLeft (LCount%, LMouseX%, LMouseY%)
  160.     IF MouseChk% = 0 THEN EXIT SUB  ' Is the MouseChk variable set?
  161.     '
  162.     '   Determine position of mouse at left button depression.
  163.     '
  164.     LCount% = 0: CALL Mouse(5, LCount%, LMouseX%, LMouseY%)
  165. ' ====================== End of MouseLeft SubProgram ========================
  166.     END SUB
  167.  
  168. ' ===========================================================================
  169. '   SUBPROGRAM: MouseLeftRC  -  QBUTIL
  170. '   Version 1.0  By: Dan Berry (c) Traveller Software 1990
  171. ' ========================= MouseLeftRC SubProgram ==========================
  172. SUB MouseLeftRC (LCount%, Row%, Col%)
  173.     DEFINT A-Z
  174.     IF MouseChk = 0 THEN EXIT SUB   ' Is the MouseChk variable set?
  175.     CALL MouseLeft(LCount, MouseX, MouseY)  ' Get the mouse status
  176. '
  177. '   Determine cursor Row and Column of the mouse position.
  178. '
  179.     Col = INT(MouseX / 8) + 1: Row = INT(MouseY / 8) + 1
  180. ' ===================== End of MouseLeftRC SubProgram =======================
  181. END SUB
  182.  
  183. DEFSNG A-Z
  184. ' ===========================================================================
  185. '   SUBPROGRAM: MouseLightPen  -  QBUTIL
  186. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  187. ' ========================= MouseLightPen SubProgram ========================
  188. SUB MouseLightPen (Status%)
  189.     IF MouseChk% = 0 THEN EXIT SUB  ' Is the MouseChk variable set?
  190.     '
  191.     '   Enable/Disable Light Pen Emulation
  192.     '
  193.     IF Status% = 1 THEN MFlag% = 13 ELSE MFlag% = 14
  194.     CALL Mouse(MFlag%, 0, 0, 0)
  195. ' ===================== End of MouseLightPen SubProgram =====================
  196.     END SUB
  197.  
  198. ' ===========================================================================
  199. '   SUBPROGRAM: MouseLimits  -  QBUTIL
  200. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  201. ' ========================== MouseLimits SubProgram =========================
  202. SUB MouseLimits (MouseX1%, MouseY1%, MouseX2%, MouseY2%)
  203.     IF MouseChk% = 0 THEN EXIT SUB  ' Is the MouseChk variable set?
  204.     '
  205.     '   Set the limits of the mouse movements
  206.     '
  207.     CALL Mouse(7, 0, MouseX1%, MouseX2%)
  208.     CALL Mouse(8, 0, MouseY1%, MouseY2%)
  209. ' ====================== End of MouseLimits SubProgram ======================
  210.     END SUB
  211.  
  212. ' ===========================================================================
  213. '   SUBPROGRAM: MouseLimitsRC  -  QBUTIL
  214. '   Version 1.0  By: Dan Berry (c) Traveller Software 1989
  215. ' ========================= MouseLimitsRC SubProgram ========================
  216. SUB MouseLimitsRC (Row1%, Col1%, Row2%, Col2%)
  217. '
  218. '   Set mouse limits according to row and column
  219. '
  220.     CALL MouseLimits(Col1% * 8 - 8, Row1% * 8 - 8, Col2% * 8 - 8, Row2% * 8 - 8)
  221. ' ===================== End of MouseLimitsRC SubProgram =====================
  222.     END SUB
  223.  
  224. ' ===========================================================================
  225. '   SUBPROGRAM: MouseLocate  -  QBUTIL
  226. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  227. ' ========================== MouseLocate SubProgram =========================
  228. SUB MouseLocate (MouseX%, MouseY%)
  229.     IF MouseChk% = 0 THEN EXIT SUB ' Is the MouseChk variable set?
  230.     CALL Mouse(4, 0, MouseX%, MouseY%) ' Locate the Mouse at Desired Location
  231. ' ====================== End of MouseLocate SubProgram ======================
  232.     END SUB
  233.  
  234. ' ===========================================================================
  235. '   SUBPROGRAM: MouseLocateRC  -  QBUTIL
  236. '   Version 1.0  By: Dan Berry (c) Traveller Software 1989
  237. ' ========================= MouseLocateRC SubProgram ========================
  238. SUB MouseLocateRC (Row%, Col%)
  239.     CALL MouseLocate(Col% * 8 - 8, Row% * 8 - 8)
  240. ' ===================== End of MouseLocateRC SubProgram =====================
  241.     END SUB
  242.  
  243. ' ===========================================================================
  244. '   SUBPROGRAM: MouseMotion  -  QBUTIL
  245. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  246. ' ========================== MouseMotion SubProgram =========================
  247. SUB MouseMotion (Horz%, Vert%)
  248.     IF MouseChk% = 0 THEN EXIT SUB ' Is the MouseChk variable set?
  249.     '
  250.     '   Returns motion counts since last call to this routine.
  251.     '
  252.     CALL Mouse(11, 0, Horz%, Vert%)
  253. ' ====================== End of MouseMotion SubProgram ======================
  254.     END SUB
  255.  
  256. ' ===========================================================================
  257. '   SUBPROGRAM: MouseOff  -  QBUTIL
  258. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  259. ' =========================== MouseOff SubProgram ===========================
  260. SUB MouseOff
  261.     DEFINT A-Z
  262. '
  263. '   Is the MouseChk variable set or is the Mouse Cursor Off?
  264. '
  265.     IF MouseChk = 0 OR MouseStat = 0 THEN EXIT SUB
  266.     CALL Mouse(2, 0, 0, 0)   '   Turn the Mouse Cursor Off
  267.     MouseStat = 0 ' Set COMMON Mouse On/Off Flag to Off
  268. ' ======================= End of MouseOff SubProgram ========================
  269.     END SUB
  270.  
  271. DEFSNG A-Z
  272. ' ===========================================================================
  273. '   SUBPROGRAM: MouseOn  -  QBUTIL
  274. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  275. ' =========================== MouseOn SubProgram ============================
  276. SUB MouseOn
  277.     DEFINT A-Z
  278. '
  279. '   Is the MouseChk variable set or is the Mouse Cursor On?
  280. '
  281.     IF MouseChk = 0 OR MouseStat = 1 THEN EXIT SUB
  282.     CALL Mouse(1, 0, 0, 0)  '   Turn the Mouse Cursor On
  283.     MouseStat = 1   ' Set COMMON Mouse On/Off Flag to ON
  284. ' ======================= End of MouseOn SubProgram =========================
  285.     END SUB
  286.  
  287. DEFSNG A-Z
  288. ' ===========================================================================
  289. '   SUBPROGRAM: MouseRelease  -  QBUTIL
  290. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  291. ' ========================= MouseRelease SubProgram =========================
  292. SUB MouseRelease (Button%, Count%, MouseX%, MouseY%)
  293.     IF MouseChk% = 0 THEN EXIT SUB  ' Is the MouseChk variable set?
  294.     '
  295.     '   Returns the position of the mouse after the button requested was last
  296.     '   released.
  297.     '
  298.     Count% = Button%: CALL Mouse(6, Count%, MouseX%, MouseY%)
  299.     MouseStat = 0 ' Set COMMON Mouse On/Off Flag to Off
  300. ' ===================== End of MouseRelease SubProgram ======================
  301. END SUB
  302.  
  303. ' ===========================================================================
  304. '   SUBPROGRAM: MouseReset  -  QBUTIL
  305. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  306. ' ========================== MouseReset SubProgram ==========================
  307. SUB MouseReset
  308.     IF MouseChk% = 0 THEN EXIT SUB  ' Is the MouseChk variable set?
  309.     CALL Mouse(0, 0, 0, 0)  ' Reset the Mouse
  310.     MouseStat% = 0  ' The Mouse cursor is off
  311. ' ====================== End of MouseReset SubProgram =======================
  312.     END SUB
  313.  
  314. ' ===========================================================================
  315. '   SUBPROGRAM: MouseRight  -  QBUTIL
  316. '   Version 1.0  By: Dan Berry (c) Traveller Software 1989
  317. ' ========================== MouseRight SubProgram ==========================
  318. SUB MouseRight (RCount%, RMouseX%, RMouseY%)
  319.     IF MouseChk% = 0 THEN EXIT SUB  ' Is the MouseChk variable set?
  320.     '
  321.     '   Determine position of mouse at right button depression
  322.     '
  323.     RCount% = 1: CALL Mouse(5, RCount%, RMouseX%, RMouseY%)
  324. ' ====================== End of MouseRight SubProgram =======================
  325.     END SUB
  326.  
  327. ' ===========================================================================
  328. '   SUBPROGRAM: MouseRightRC  -  QBUTIL
  329. '   Version 1.0  By: Dan Berry (c) Traveller Software 1990
  330. ' ======================== MouseRightRC SubProgram ==========================
  331. SUB MouseRightRC (RCount%, Row%, Col%)
  332.     DEFINT A-Z
  333.     IF MouseChk = 0 THEN EXIT SUB   ' Is the MouseChk variable set?
  334.     CALL MouseRight(RCount, MouseX, MouseY) ' Get the mouse status
  335. '
  336. '   Determine cursor Row and Column of the mouse position.
  337. '
  338.     Col = INT(MouseX / 8) + 1: Row = INT(MouseY / 8) + 1
  339. ' ==================== End of MouseRightRC SubProgram =======================
  340. END SUB
  341.  
  342. DEFSNG A-Z
  343. ' ===========================================================================
  344. '   SUBPROGRAM: MouseSensitivity
  345. '   Version 1.0  By: Dan Berry (c) Traveller Software 1991
  346. ' ===================== MouseSensitivity SubProgram =========================
  347. SUB MouseSensitivity (GetSet%, HMickey%, VMickey%, DoubleSpeed%)
  348.     DEFINT A-Z
  349.     IF MouseChk = 0 THEN EXIT SUB ' Is the MouseChk variable set?
  350.     IF GetSet = 1 THEN ' Set Mouse Sensitivity
  351.             CALL Mouse(26, HMickey, VMickey, DoubleSpeed)
  352.         ELSE ' Get Mouse Sensitivity
  353.             CALL Mouse(27, HMickey, VMickey, DoubleSpeed)
  354.     END IF
  355. ' =================== End of MouseSensitivity SubProgram ====================
  356. END SUB
  357.  
  358. DEFSNG A-Z
  359. ' ===========================================================================
  360. '   SUBPROGRAM: MouseStatus  -  QBUTIL
  361. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  362. ' ========================= MouseStatus SubProgram ==========================
  363. SUB MouseStatus (Left%, Right%, MouseX%, MouseY%)
  364.     DEFINT A-Z
  365.     IF MouseChk = 0 THEN EXIT SUB   ' Is the MouseChk variable set?
  366.     '
  367.     '   Determine Mouse Status to include Position and Buttons Depressed
  368.     '
  369.     CALL Mouse(3, Buttons, MouseX, MouseY)
  370.     Left = ((Buttons AND 1) <> 0): Right = ((Buttons AND 2) <> 0)
  371. ' ===================== End of MouseStatus SubProgram =======================
  372.     END SUB
  373.  
  374. DEFSNG A-Z
  375. ' ===========================================================================
  376. '   SUBPROGRAM: MouseStatusRC  -  QBUTIL
  377. '   Version 2.0  By: Dan Berry (c) Traveller Software 1989 - 1990
  378. ' ======================== MouseStatusRC SubProgram =========================
  379. SUB MouseStatusRC (Left%, Right%, Row%, Col%)
  380.     DEFINT A-Z
  381.     IF MouseChk = 0 THEN EXIT SUB   ' Is the MouseChk variable set?
  382.     CALL MouseStatus(Left, Right, MouseX, MouseY)   ' Get the Mouse status
  383. '
  384. '   Determine cursor Row and Column of the mouse position.
  385. '
  386.     Col = INT(MouseX / 8) + 1: Row = INT(MouseY / 8) + 1
  387. ' ==================== End of MouseStatusRC SubProgram ======================
  388.     END SUB
  389.  
  390.