mouse.inc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. {
  2. System independent mouse interface for tp7
  3. $Id$
  4. }
  5. procedure MouseInt;far;assembler;
  6. asm
  7. mov si,seg @data
  8. mov ds,si
  9. mov si,cx
  10. mov MouseButtons,bl
  11. mov MouseWhereX,si
  12. mov MouseWhereY,dx
  13. cmp PendingMouseEvents,MouseEventBufSize
  14. je @@20
  15. les di,PendingMouseTail
  16. cld
  17. xchg ax,bx
  18. stosw
  19. xchg ax,cx
  20. shr ax,3
  21. stosw
  22. xchg ax,dx
  23. shr ax,3
  24. stosw
  25. xor ax,ax
  26. stosw
  27. mov ax,offset PendingMouseEvent
  28. add ax,MouseEventBufSize*8
  29. cmp di,ax
  30. jne @@10
  31. mov di,offset PendingMouseEvent
  32. @@10: mov word ptr PendingMouseTail,di
  33. inc PendingMouseEvents
  34. @@20:
  35. end;
  36. procedure InitMouse;
  37. begin
  38. PendingMouseHead:=@PendingMouseEvent;
  39. PendingMouseTail:=@PendingMouseEvent;
  40. PendingMouseEvents:=0;
  41. FillChar(LastMouseEvent,sizeof(TMouseEvent),0);
  42. asm
  43. mov ax,0ch
  44. mov cx,0ffffh
  45. mov dx,offset MouseInt
  46. push cs
  47. pop es
  48. push bp
  49. int 33h
  50. pop bp
  51. end;
  52. ShowMouse;
  53. end;
  54. procedure DoneMouse;
  55. begin
  56. HideMouse;
  57. asm
  58. mov ax,0ch
  59. xor cx,cx
  60. xor dx,dx
  61. mov es,cx
  62. push bp
  63. int 33h
  64. pop bp
  65. end;
  66. end;
  67. function DetectMouse:byte;assembler;
  68. asm
  69. mov ax,3533h
  70. push bp
  71. int 21h
  72. pop bp
  73. mov ax,es
  74. or ax,bx
  75. jz @@99
  76. xor ax,ax
  77. push bp
  78. int 33h
  79. pop bp
  80. or ax,ax
  81. jz @@99
  82. mov ax,bx
  83. @@99:
  84. end;
  85. procedure ShowMouse;assembler;
  86. asm
  87. mov ax,1
  88. push bp
  89. int 33h
  90. pop bp
  91. end;
  92. procedure HideMouse;assembler;
  93. asm
  94. mov ax,2
  95. push bp
  96. int 33h
  97. pop bp
  98. end;
  99. function GetMouseX:word;assembler;
  100. asm
  101. mov ax,3
  102. push bp
  103. int 33h
  104. pop bp
  105. mov ax,cx
  106. shr ax,3
  107. inc ax
  108. end;
  109. function GetMouseY:word;assembler;
  110. asm
  111. mov ax,3
  112. push bp
  113. int 33h
  114. pop bp
  115. mov ax,dx
  116. shr ax,3
  117. inc ax
  118. end;
  119. function GetMouseButtons:word;assembler;
  120. asm
  121. mov ax,3
  122. push bp
  123. int 33h
  124. pop bp
  125. mov ax,bx
  126. end;
  127. procedure SetMouseXY(x,y:word);assembler;
  128. asm
  129. mov ax,4
  130. mov cx,x
  131. mov dx,y
  132. push bp
  133. int 33h
  134. pop bp
  135. end;
  136. procedure GetMouseEvent(var MouseEvent: TMouseEvent);
  137. begin
  138. repeat until PendingMouseEvents>0;
  139. MouseEvent:=PendingMouseHead^;
  140. inc(PendingMouseHead);
  141. if longint(PendingMouseHead)=longint(@PendingMouseEvent)+sizeof(PendingMouseEvent) then
  142. PendingMouseHead:=@PendingMouseEvent;
  143. dec(PendingMouseEvents);
  144. if (LastMouseEvent.x<>MouseEvent.x) or (LastMouseEvent.y<>MouseEvent.y) then
  145. MouseEvent.Action:=MouseActionMove;
  146. if (LastMouseEvent.Buttons<>MouseEvent.Buttons) then
  147. begin
  148. if (LastMouseEvent.Buttons=0) then
  149. MouseEvent.Action:=MouseActionDown
  150. else
  151. MouseEvent.Action:=MouseActionUp;
  152. end;
  153. LastMouseEvent:=MouseEvent;
  154. end;
  155. function PollMouseEvent(var MouseEvent: TMouseEvent):boolean;
  156. begin
  157. if PendingMouseEvents>0 then
  158. begin
  159. MouseEvent:=PendingMouseHead^;
  160. PollMouseEvent:=true;
  161. end
  162. else
  163. PollMouseEvent:=false;
  164. end;
  165. {
  166. $Log$
  167. Revision 1.2 2000-07-13 11:32:27 michael
  168. + removed logs
  169. }