home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / turbopas / pstui100.zip / PTUIVMSE.PAS < prev    next >
Pascal/Delphi Source File  |  1993-03-12  |  5KB  |  206 lines

  1. {
  2.  
  3.                                                       ╔══════════════════╗
  4.                                                       ║   PTUI Virtual   ║
  5.                                                       ║   Screen Mouse   ║
  6.                                                       ║    Rev.  1.00    ║
  7.                                                       ╚══════════════════╝
  8.  
  9. }
  10.  
  11. {$F+} {$O-} {$A+} {$G+}
  12. {$V-} {$B-} {$X-} {$N+} {$E+}
  13.  
  14. {$I FINAL.PAS}
  15.  
  16. {$IFDEF FINAL}
  17.   {$I-} {$R-}
  18.   {$D-} {$L-} {$S-}
  19. {$ENDIF}
  20.  
  21. Unit PTUIVMSE;
  22.  
  23. Interface
  24.  
  25. Uses PTUIVCRT;
  26.  
  27. Const
  28.   MouseGranularity =    8;
  29.  
  30. Var
  31.   OldMouseChar,
  32.   MouseX,
  33.   MouseY                :Word;
  34.   Busy                  :Boolean;
  35.   MouseHideCount        :Byte;
  36.  
  37. Procedure ControlVScreenMouse;
  38. Procedure Show;
  39. Procedure Hide;
  40. Procedure SetXY          (X,Y:Word);
  41. Procedure SetBounds      (X1,Y1,X2,Y2:Word);
  42.  
  43. Implementation
  44.  
  45. {$S-}
  46. Procedure ControlVScreenMouse;
  47.  
  48. Var
  49.   P        :^Word;
  50.  
  51. Begin
  52.   Asm
  53.     pusha
  54.     push     ds
  55.     push     es
  56.     mov      ax, SEG @Data
  57.     mov      ds, ax
  58.   End;
  59.  
  60.   If Not Busy Then
  61.   Begin
  62.     Busy:=True;
  63.     If MouseHideCount=255 Then
  64.     Begin
  65.       P:=VideoWriteAddress((MouseX Div MouseGranularity) + 1,(MouseY Div MouseGranularity) + 1);
  66.       P^:=OldMouseChar;
  67.       Asm
  68.         mov   ax, 3
  69.         int   33h
  70.         mov   MouseX, cx
  71.         mov   MouseY, dx
  72.       End;
  73.       P:=VideoWriteAddress((MouseX Div MouseGranularity) + 1,(MouseY Div MouseGranularity) + 1);
  74.       OldMouseChar:=P^;
  75.       If Card=ColorCard Then
  76.         P^:=P^ XOR 6144
  77.       Else
  78.         If (Hi(P^) in [$70,$78,$F0,$F8]) Then
  79.           P^:=(P^ And $FF) + (Word($1) Shl 9)
  80.         Else
  81.           P^:=(P^ And $FF) + (Word($70) Shl 8);
  82.  
  83.       While  (((MouseX Div MouseGranularity) + 1)>=VideoCard[Card].SX2) And
  84.               (VideoCard[Card].SX2<VideoCard[Card].XSize) do
  85.       Begin
  86.         ScreenOrigin((VideoCard[Card].SX1) * VideoCard[Card].CharacterLength,
  87.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  88.       End;
  89.  
  90.       While (((MouseY Div MouseGranularity) + 1)>=VideoCard[Card].SY2) And
  91.              (VideoCard[Card].SY2<VideoCard[Card].YSize) do
  92.       Begin
  93.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  94.                      (VideoCard[Card].SY1) * VideoCard[Card].CharacterHeight);
  95.       End;
  96.  
  97.       While  (((MouseX Div MouseGranularity) + 1)<=VideoCard[Card].SX1) And
  98.               (VideoCard[Card].SX1>1) do
  99.       Begin
  100.         ScreenOrigin((VideoCard[Card].SX1 - 2) * VideoCard[Card].CharacterLength,
  101.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  102.       End;
  103.  
  104.       While  (((MouseY Div MouseGranularity) + 1)<=VideoCard[Card].SY1) And
  105.               (VideoCard[Card].SY1>1) do
  106.       Begin
  107.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  108.                      (VideoCard[Card].SY1 - 2) * VideoCard[Card].CharacterHeight);
  109.       End;
  110.       Busy:=False;
  111.     End
  112.     Else
  113.     Asm
  114.       mov   ax, 3
  115.       int   33h
  116.       mov   MouseX, cx
  117.       mov   MouseY, dx
  118.     End;
  119.   End;
  120.  
  121.   Asm
  122.     pop      es
  123.     pop      ds
  124.     popa
  125.   End;
  126. End;
  127. {$IFNDEF FINAL} {$S+} {$ENDIF}
  128.  
  129. Procedure Show;
  130.  
  131. Var
  132.   P     :^Word;
  133.  
  134. Begin
  135.   Busy:=True;
  136.   If MouseHideCount<255 Then
  137.   Begin
  138.     Inc(MouseHideCount);
  139.     If MouseHideCount=255 Then
  140.     Begin
  141.       P:=VideoWriteAddress((MouseX Div MouseGranularity) + 1,(MouseY Div MouseGranularity) + 1);
  142.       OldMouseChar:=P^;
  143.       If Card=ColorCard Then
  144.         P^:=P^ XOR 6144
  145.       Else
  146.         If (Hi(P^)=$70) Or (Hi(P^)=$78) Then
  147.           P^:=(P^ And $FF) + (Word($1) Shl 8)
  148.         Else
  149.           P^:=(P^ And $FF) + (Word($70) Shl 8);
  150.     End;
  151.   End;
  152.   Busy:=False;
  153. End;
  154.  
  155. Procedure Hide;
  156.  
  157. Var
  158.   P     :^Word;
  159.  
  160. Begin
  161.   Busy:=True;
  162.   If MouseHideCount=255 Then
  163.   Begin
  164.     P:=VideoWriteAddress((MouseX Div MouseGranularity) + 1,(MouseY Div MouseGranularity) + 1);
  165.     P^:=OldMouseChar;
  166.   End;
  167.   If MouseHideCount>0 Then Dec(MouseHideCount);
  168.   Busy:=False;
  169. End;
  170.  
  171. Procedure SetXY(X,Y:Word);
  172. Begin
  173.   Hide;
  174.   Asm
  175.     mov  ax,4
  176.     mov  cx,X
  177.     mov  dx,Y
  178.     int  33h
  179.   End;
  180.   MouseX:=X;
  181.   MouseY:=Y;
  182.   Show;
  183. End;
  184.  
  185. Procedure SetBounds(X1,Y1,X2,Y2:Word);
  186. Begin
  187.   Hide;
  188.   Asm
  189.     mov  ax,7
  190.     mov  cx,X1
  191.     mov  dx,X2
  192.     int  33h
  193.     mov  ax,8
  194.     mov  cx,Y1
  195.     mov  dx,Y2
  196.     int  33h
  197.   End;
  198.   Show;
  199. End;
  200.  
  201. Begin
  202.   Busy  :=False;
  203. End.
  204.  
  205. { Copyright 1993, Michael Gallias }
  206.