home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / EDITORES / TSCREDD2.ZIP / SCRDISK4.EXE / SCRMOUSE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-02-25  |  7.1 KB  |  386 lines

  1. {$R-}    {Range checking off}
  2. {$B+}    {Boolean complete evaluation on}
  3. {$S+}    {Stack checking on}
  4. {$I+}    {I/O checking on}
  5. {$N-}    {No numeric coprocessor}
  6.  
  7. Unit ScrMouse;
  8.  
  9. Interface
  10.  
  11. Uses Dos;
  12.  
  13. Type
  14. S_Str8 = String[8];
  15. Var
  16. S_PreviousEvent    : S_Str8;
  17. S_MouseExitSave    : Pointer;
  18. S_MouseInstalled,
  19. S_MouseVisable,
  20. S_MouseActive,
  21. S_MouseEvent,
  22. S_MsLeftPressed,
  23. S_MsRightPressed,
  24. S_MsMiddlePressed,
  25. S_MsLeftReleased,
  26. S_MsRightReleased,
  27. S_MsMiddleReleased : Boolean;
  28. S_MsAx,
  29. S_MsBx,
  30. S_MsCx,
  31. S_MsDx  : Word;
  32. S_MsReg : Registers;
  33. S_MsX,
  34. S_MsY,
  35. S_MsRowHold,
  36. S_MsColHold,
  37. S_MsRow,
  38. S_MsCol,
  39. S_Buttons  : Integer;
  40.  
  41.  
  42. Procedure S_ActivateMouse;
  43. Procedure S_AnalizeMouse;
  44. Procedure S_DisableMouse;
  45. Procedure S_HideMouse;
  46. Procedure S_MoveMouse;
  47. Procedure S_RemoveMouse;
  48. Procedure S_ResetMouseFlags;
  49. Procedure S_ResetMouse;
  50. Procedure S_RestoreMouse;
  51. Procedure S_SetMouseCursor(Mask1_Msb,
  52.                            Mask1_Lsb,
  53.                            Mask2_Msb,
  54.                            Mask2_Lsb:Byte);
  55. Procedure S_SetMouseEvent(Bit:S_Str8);
  56. Procedure S_SetMouseRange(Top_Col,
  57.                           Top_Row,
  58.                           Bot_Col,
  59.                           Bot_Row:Byte);
  60. Procedure S_ShowMouse;
  61.  
  62.  
  63. Implementation
  64. {$F+}
  65. Procedure S_SetMouseFlags(Flags,Cs,Ip,Ax,Bx,Cx,Dx,Si,Di,Ds,Es,Bp:Word);
  66. INTERRUPT;
  67. Begin
  68. S_MsAx := (Ax Or S_MsAx);
  69. S_MsBx := Bx;
  70. S_MsCx := Cx;
  71. S_MsDx := Dx;
  72. If  S_MouseActive Then
  73.     S_MouseEvent := True;
  74. InLine($8B/$E5/$5D/$07/$1F/$5F/$5E/$5A/$59/$5B/$58/$CB);
  75. End;
  76. {$F+}
  77.  
  78.  
  79.  
  80. Procedure S_SetMouseCursor(Mask1_Msb,
  81.                            Mask1_Lsb,
  82.                            Mask2_Msb,
  83.                            Mask2_Lsb:Byte);
  84. Begin
  85. If  S_MouseInstalled Then
  86.     Begin
  87.     S_MsReg.Ax := 10;
  88.     S_MsReg.Bx := 0;
  89.     S_MsReg.Ch := Mask1_Msb;
  90.     S_MsReg.Cl := Mask1_Lsb;
  91.     S_MsReg.Dh := Mask2_Msb;
  92.     S_MsReg.Dl := Mask2_Lsb;
  93.     Intr($33,S_MsReg);
  94.     End;
  95. End;
  96.  
  97.  
  98.  
  99.  
  100. Procedure S_ResetMouse;
  101. Begin
  102. If  S_MouseInstalled Then
  103.     Begin
  104.     S_MsReg.Ax := 0;
  105.     Intr($33,S_MsReg);
  106.     End;
  107. End;
  108.  
  109.  
  110.  
  111.  
  112.  
  113. Procedure S_ResetMouseFlags;
  114. Begin
  115. S_MsLeftPressed    := False;
  116. S_MsRightPressed   := False;
  117. S_MsMiddlePressed  := False;
  118. S_MsLeftReleased   := False;
  119. S_MsRightReleased  := False;
  120. S_MsMiddleReleased := False;
  121. End;
  122.  
  123.  
  124.  
  125.  
  126.  
  127. Procedure S_SetMouseEvent(Bit:S_Str8);
  128. Begin
  129. If  Not S_MouseInstalled Then
  130.     Exit;
  131.  
  132. Bit := Bit + '00000000';
  133.  
  134. If  Not S_MouseActive Then
  135.     S_PreviousEvent := Bit;
  136.  
  137. S_MsReg.Cx := 0;
  138.  
  139. If  Bit[1]='1' Then
  140.     Inc(S_MsReg.Cx,1);
  141. If  Bit[2]='1' Then
  142.     Inc(S_MsReg.Cx,2);
  143. If  Bit[3]='1' Then
  144.     Inc(S_MsReg.Cx,4);
  145. If  Bit[4]='1' Then
  146.     Inc(S_MsReg.Cx,8);
  147. If  Bit[5]='1' Then
  148.     Inc(S_MsReg.Cx,16);
  149. If  Bit[6]='1' Then
  150.     Inc(S_MsReg.Cx,32);
  151. If  Bit[7]='1' Then
  152.     Inc(S_MsReg.Cx,64);
  153.  
  154. S_MsReg.Ax        := 12;{Function #12:Set Mouse Event}
  155. S_MsReg.Es        := Seg(S_SetMouseFlags);
  156. S_MsReg.Dx        := Ofs(S_SetMouseFlags);
  157. Intr($33,S_MsReg);
  158.  
  159. End;
  160.  
  161.  
  162.  
  163.  
  164.  
  165. Procedure S_AnalizeMouse;
  166. Begin
  167. If  S_MouseActive Then
  168.     Begin
  169.     If (S_MsAx and 2) = 2 Then
  170.        S_MsLeftPressed := True;
  171.     If (S_MsAx and 4) = 4 Then
  172.        S_MsLeftReleased := True;
  173.     If (S_MsAx and 8) = 8 Then
  174.        S_MsRightPressed := True;
  175.     If (S_MsAx and 16) = 16 Then
  176.        S_MsRightReleased := True;
  177.     If (S_MsAx and 32) = 32 Then
  178.        S_MsMiddlePressed:= True;
  179.     If (S_MsAx and 64) = 64 Then
  180.        S_MsMiddleReleased := True;
  181.  
  182.     If (S_MsBx and 1) = 1 Then
  183.        S_MsLeftPressed := True;
  184.     If (S_MsBx and 2) = 2 Then
  185.        S_MsRightPressed := True;
  186.     If (S_MsBx and 4 ) = 4  Then
  187.        S_MsMiddlePressed:= True;
  188.  
  189.     S_MsCol := (S_MsCx Div 8) + 1;
  190.     S_MsRow := (S_MsDx Div 8) + 1;
  191.  
  192.     S_MsAx := 0;
  193.     S_MsCx := 0;
  194.     S_MsDx := 0;
  195.  
  196.     S_MouseEvent := False;
  197.     End;
  198. End;
  199.  
  200.  
  201.  
  202.  
  203.  
  204. Procedure S_MoveMouse;
  205. Begin
  206. If  S_MouseInstalled Then
  207.     Begin
  208.     S_MsReg.Ax := 4;
  209.     S_MsReg.Cx := ((S_MsCol-1) * 8)+1;
  210.     S_MsReg.Dx := ((S_MsRow-1) * 8)+1;
  211.     Intr($33,S_MsReg);
  212.     End;
  213. End;
  214.  
  215.  
  216.  
  217.  
  218.  
  219. Procedure S_SetMouseRange(Top_Col,
  220.                           Top_Row,
  221.                           Bot_Col,
  222.                           Bot_Row:Byte);
  223. Var
  224.    Work : Byte;
  225. Begin
  226. If  S_MouseInstalled Then
  227.     Begin
  228.     If  (Top_Col < 1)  Then Top_Col := 1;
  229.     If  (Top_Col > 80) Then Top_Col := 80;
  230.     If  (Bot_Col < 1)  Then Bot_Col := 1;
  231.     If  (Bot_Col > 80) Then Bot_Col := 80;
  232.     If  (Top_Row < 1)  Then Top_Row := 1;
  233.     If  (Top_Row > 25) Then Top_Row := 25;
  234.     If  (Bot_Row < 1)  Then Bot_Row := 1;
  235.     If  (Bot_Row > 25) Then Bot_Row := 25;
  236.  
  237.     If  (Top_Col > Bot_Col) Then
  238.         Begin
  239.         Work    := Top_Col;
  240.         Top_Col := Bot_Col;
  241.         Bot_Col := Work;
  242.         End;
  243.     If  (Top_Row > Bot_Row) Then
  244.         Begin
  245.         Work    := Top_Row;
  246.         Top_Row := Bot_Row;
  247.         Bot_Row := Work;
  248.         End;
  249.     S_MsReg.Ax := 7;
  250.     S_MsReg.Cx := ((Top_Col-1) * 8)+1;
  251.     S_MsReg.Dx := ((Bot_Col-1) * 8)+1;
  252.     Intr($33,S_MsReg);
  253.     S_MsReg.Ax := 8;
  254.     S_MsReg.Cx := ((Top_Row-1) * 8)+1;
  255.     S_MsReg.Dx := ((Bot_Row-1) * 8)+1;
  256.     Intr($33,S_MsReg);
  257.     End;
  258. End;
  259.  
  260.  
  261.  
  262.  
  263. Procedure S_ShowMouse;
  264. Begin
  265. If  S_MouseActive Then
  266.     Begin
  267.     S_MouseVisable := True;
  268.     S_MoveMouse;
  269.     End;
  270. End;
  271.  
  272.  
  273.  
  274.  
  275.  
  276. Procedure S_HideMouse;
  277. Begin
  278. If  S_MouseActive Then
  279.     S_MouseVisable := False;
  280. End;
  281.  
  282.  
  283.  
  284.  
  285.  
  286. Procedure S_RemoveMouse;
  287. Begin
  288. If  S_MouseActive And
  289.     S_MouseVisable Then
  290.     Begin
  291.     S_MsReg.Ax := 2;
  292.     Intr($33,S_MsReg);
  293.     End;
  294. End;
  295.  
  296.  
  297.  
  298.  
  299.  
  300. Procedure S_RestoreMouse;
  301. Begin
  302. If  S_MouseActive And
  303.     S_MouseVisable Then
  304.     Begin
  305.     S_MsReg.Ax := 1;
  306.     Intr($33,S_MsReg);
  307.     End;
  308. End;
  309.  
  310.  
  311.  
  312.  
  313.  
  314. Procedure S_ActivateMouse;
  315. Begin
  316. If  S_MouseInstalled Then
  317.     Begin
  318.     S_MouseActive := True;
  319.     S_SetMouseEvent(S_PreviousEvent);
  320.     End;
  321. End;
  322.  
  323.  
  324.  
  325.  
  326.  
  327. Procedure S_DisableMouse;
  328. Begin
  329. If  S_MouseActive Then
  330.     Begin
  331.     S_MouseActive := False;
  332.     S_SetMouseEvent('00000000');
  333.     End;
  334. End;
  335.  
  336.  
  337.  
  338.  
  339. {$F+}
  340. Procedure S_MouseExitProc;
  341. Begin
  342. ExitProc := S_MouseExitSave;
  343. S_DisableMouse;
  344. S_ResetMouse;
  345. End;
  346. {$F-}
  347.  
  348.  
  349.  
  350.  
  351.  
  352. Begin
  353. S_MouseExitSave  := ExitProc;
  354. ExitProc         := @S_MouseExitProc;
  355. S_Buttons        := 0;
  356. S_MsRow          := 0;
  357. S_MsRowHold      := 0;
  358. S_MsCol          := 0;
  359. S_MsColHold      := 0;
  360. S_MouseActive    := False;
  361. S_MouseVisable   := False;
  362. S_MouseEvent     := False;
  363. S_PreviousEvent  := '00000000';
  364. S_ResetMouseFlags;
  365. S_MsReg.Ax := 0;{Check Mouse For Driver}
  366. Intr($33,S_MsReg);
  367.  
  368. If  S_MsReg.Ax <> 0 Then
  369.     Begin
  370.     S_MouseInstalled := True;
  371.     S_Buttons        := S_MsReg.Bx;
  372.     S_MsReg.Ax       := 10;{Set Mouse Text Software Cursor}
  373.     S_MsReg.Bx       := 0; {Software cursor}
  374.     S_MsReg.Cx       := $0000;
  375.     S_MsReg.Dx       := $0718;
  376.     Intr($33,S_MsReg);
  377.     S_MsReg.Ax       := 4;{Move mouse to top left screen}
  378.     S_MsReg.Cx       := 1;
  379.     S_MsReg.Dx       := 1;
  380.     S_MsRow          := 1;{Mouse starts in top left corner.}
  381.     S_MsCol          := 1;
  382.     Intr($33,S_MsReg);
  383.     End
  384. Else
  385.     S_MouseInstalled := False;
  386. End.