fmouse.pp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,97 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************
  11. }
  12. Unit FMouse;
  13. Interface
  14. {
  15. Mouse support functions and procedures,with error checking if mouse
  16. isn't present then the routine ends,if you want to remove error checking
  17. remove the next define.
  18. }
  19. {$DEFINE MOUSECHECK}
  20. {check if mouse is present and sets the mouse variable}
  21. Function Check_Mouse:Boolean;
  22. {shows mouse pointer,text+graphics screen support}
  23. Procedure Show_Mouse;
  24. {hides mouse pointer}
  25. Procedure Hide_Mouse;
  26. {reads mouse position in pixels,divide by 8 to get text position,and reads
  27. buttons state(1-left button,2=right button,7=middle button)}
  28. Procedure read_mouse (var x,y:Longint;var buttons:Longint);
  29. {sets mouse pointer in text mode}
  30. Procedure Mouse_Cur(X,Y:Longint);
  31. {sets the mouse shape in text mode}
  32. Procedure Mouse_Shape(BackColor,ForColor,Ascii:LongInt);
  33. {sets the mouse ascii in text mode}
  34. Procedure Mouse_Ascii(Ascii:LongInt);
  35. {returns which button was pressed after last call to function}
  36. Function mouse_press(var x,y:Longint;button:Longint):Longint;
  37. {returns which button was realeased after last call to function}
  38. Function mouse_release (var row,col:Longint;button : Longint):integer;
  39. {set's mouse y range}
  40. Procedure mouse_yrange (min,max:Longint);
  41. {set's mouse y range}
  42. Procedure mouse_xrange (min,max:Longint);
  43. {set mouse speed}
  44. Procedure Micky(Horizontal ,Vertical:Longint);
  45. {return if right button pressed}
  46. Function IsRPres:Boolean;
  47. {return if left button pressed}
  48. Function IsLPres:Boolean;
  49. {set rectangle on screen that mouse will disappear if will point on it}
  50. Procedure Unseen_Mouse(x1,y1,x2,y2:Longint);
  51. {set window for mouse}
  52. Procedure MWindow(x1,y1,x2,y2:Longint);
  53. Var
  54. Mouse:Boolean;
  55. Implementation
  56. Function Check_Mouse:Boolean;
  57. begin
  58. asm
  59. xorl %eax,%eax
  60. pushl %ebp
  61. int $0x33
  62. popl %ebp
  63. cmpw $0xffff,%ax
  64. setz %al
  65. movb %al,U_FMOUSE_MOUSE
  66. movb %al,__RESULT
  67. end;
  68. end;
  69. procedure show_mouse;
  70. begin
  71. {$IFDEF MOUSECHECK}
  72. If (Not Mouse) Then Exit;
  73. {$ENDIF}
  74. asm
  75. movl $1,%eax
  76. pushl %ebp
  77. int $0x33
  78. popl %ebp
  79. end;
  80. end;
  81. procedure hide_mouse;
  82. begin
  83. {$IFDEF MOUSECHECK}
  84. If (Not Mouse) Then Exit;
  85. {$ENDIF}
  86. asm
  87. movl $2,%eax
  88. pushl %ebp
  89. int $0x33
  90. popl %ebp
  91. end;
  92. end;
  93. procedure read_mouse (var x,y,buttons:Longint);
  94. begin
  95. {$IFDEF MOUSECHECK}
  96. If (Not Mouse) Then Exit;
  97. {$ENDIF}
  98. asm
  99. movl $3,%eax
  100. pushl %ebp
  101. int $0x33
  102. popl %ebp
  103. andl $0xffff,%ecx
  104. andl $0xffff,%edx
  105. movl x,%eax
  106. movl %ecx,(%eax)
  107. movl y,%eax
  108. movl %edx,(%eax)
  109. movl buttons,%eax
  110. movw %bx,(%eax)
  111. end;
  112. end;
  113. function mouse_press(var x,y:Longint;button:Longint):Longint;
  114. begin
  115. {$IFDEF MOUSECHECK}
  116. If (Not Mouse) Then Exit;
  117. {$ENDIF}
  118. asm
  119. movl $5,%eax
  120. movl button,%ebx
  121. pushl %ebp
  122. int $0x33
  123. popl %ebp
  124. andl $0xffff,%ecx
  125. andl $0xffff,%edx
  126. movl x,%ebx
  127. movl %ecx,(%ebx)
  128. movl y,%ebx
  129. movl %edx,(%ebx)
  130. movl %eax,__RESULT
  131. end;
  132. end;
  133. function mouse_release (var row,col:Longint;button : Longint):integer;
  134. begin
  135. {$IFDEF MOUSECHECK}
  136. If (Not Mouse) Then Exit;
  137. {$ENDIF}
  138. asm
  139. movl $6,%eax
  140. movl button,%ebx
  141. pushl %ebp
  142. int $0x33
  143. popl %ebp
  144. andl $0xffff,%ecx
  145. andl $0xffff,%edx
  146. movl x,%ebx
  147. movl %ecx,(%ebx)
  148. movl y,%ebx
  149. movl %edx,(%ebx)
  150. movl %eax,__RESULT
  151. end;
  152. end;
  153. procedure mouse_yrange (min,max:Longint);
  154. begin
  155. {$IFDEF MOUSECHECK}
  156. If (Not Mouse) Then Exit;
  157. {$ENDIF}
  158. asm
  159. movl $8,%eax
  160. movl min,%ecx
  161. movl max,%edx
  162. pushl %ebp
  163. int $0x33
  164. popl %ebp
  165. end;
  166. end;
  167. procedure mouse_xrange (min,max:Longint);
  168. begin
  169. {$IFDEF MOUSECHECK}
  170. If (Not Mouse) Then Exit;
  171. {$ENDIF}
  172. asm
  173. movl $7,%eax
  174. movl min,%ecx
  175. movl max,%edx
  176. pushl %ebp
  177. int $0x33
  178. popl %ebp
  179. end;
  180. end;
  181. Procedure Mouse_Cur(X,Y:Longint);
  182. Begin
  183. {$IFDEF MOUSECHECK}
  184. If (Not Mouse) Then Exit;
  185. {$ENDIF}
  186. asm
  187. movl $4,%eax
  188. movl X,%ecx
  189. movl Y,%edx
  190. shll $3,%ecx
  191. shll $3,%edx
  192. pushl %ebp
  193. int $0x33
  194. popl %ebp
  195. End;
  196. End;
  197. Procedure Mouse_Shape(BackColor,ForColor,Ascii:LongInt);
  198. Begin
  199. {$IFDEF MOUSECHECK}
  200. If (Not Mouse) Then Exit;
  201. {$ENDIF}
  202. asm
  203. xorl %ebx,%ebx
  204. movl $0xa,%ax
  205. movl $0xff,%ecx
  206. xorl %edx,%edx
  207. movb 8(%ebp),%dh
  208. shlb $4,%dh
  209. addb ForColor,%dh
  210. pushl %ebp
  211. int $0x33
  212. popl %ebp
  213. End;
  214. End;
  215. Procedure Mouse_Ascii(Ascii:LongInt);
  216. Begin
  217. {$IFDEF MOUSECHECK}
  218. If (Not Mouse) Then Exit;
  219. {$ENDIF}
  220. asm
  221. xorl %ebx,%ebx
  222. movl $0xa,%eax
  223. movl $0xff00,%ecx
  224. xorl %edx,%edx
  225. movb 8(%ebp),%dl
  226. pushl %ebp
  227. int $0x33
  228. popl %ebp
  229. End;
  230. End;
  231. Procedure Unseen_Mouse(x1,y1,x2,y2:Longint);
  232. Begin
  233. {$IFDEF MOUSECHECK}
  234. If (Not Mouse) Then Exit;
  235. {$ENDIF}
  236. asm
  237. movl $0x0010,%eax
  238. movl x1,%ecx
  239. movl y1,%edx
  240. movl x2,%esi
  241. movl y2,%edi
  242. pushl %ebp
  243. int $0x33
  244. popl %ebp
  245. end;
  246. End;
  247. Procedure Micky(Horizontal ,Vertical:Longint);
  248. Begin
  249. {$IFDEF MOUSECHECK}
  250. If (Not Mouse) Then Exit;
  251. {$ENDIF}
  252. asm
  253. movl $0x0f,%eax
  254. movl Horizontal,%ecx
  255. movl Vertical,%edx
  256. pushl %ebp
  257. int $0x33
  258. popl %ebp
  259. end;
  260. End;
  261. Function IsRPres:Boolean;
  262. Begin
  263. {$IFDEF MOUSECHECK}
  264. If (Not Mouse) Then Exit;
  265. {$ENDIF}
  266. asm
  267. movl $3,%eax
  268. pushl %ebp
  269. int $0x33
  270. popl %ebp
  271. shrl $1,%eax
  272. andl $1,%eax
  273. movb %al,__RESULT
  274. end;
  275. end;
  276. Function IsLPres:Boolean;
  277. Begin
  278. {$IFDEF MOUSECHECK}
  279. If (Not Mouse) Then Exit;
  280. {$ENDIF}
  281. asm
  282. movl $3,%eax
  283. pushl %ebp
  284. int $0x33
  285. popl %ebp
  286. andl $1,%eax
  287. movb %al,__RESULT
  288. end;
  289. end;
  290. Procedure MWindow(x1,y1,x2,y2:Longint);
  291. Begin
  292. {$IFDEF MOUSECHECK}
  293. If (Not Mouse) Then Exit;
  294. {$ENDIF}
  295. mouse_xrange(x1,x2);
  296. mouse_yrange(y1,y2);
  297. End;
  298. Begin
  299. Check_Mouse;
  300. End.
  301. {
  302. $Log$
  303. Revision 1.1.1.1 1998-03-25 11:18:41 root
  304. * Restored version
  305. Revision 1.4 1998/03/24 15:53:12 peter
  306. * cleanup and doesn't give warnings when compiling
  307. Revision 1.3 1998/01/26 11:56:24 michael
  308. + Added log at the end
  309. Revision 1.2
  310. date: 1997/12/01 12:15:45; author: michael; state: Exp; lines: +14 -12
  311. + added copyright reference in header.
  312. Revision 1.1
  313. date: 1997/11/27 08:33:49; author: michael; state: Exp;
  314. Initial revision
  315. Revision 1.1.1.1
  316. date: 1997/11/27 08:33:49; author: michael; state: Exp; lines: +0 -0
  317. FPC RTL CVS start
  318. }