CoolMice.pas 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. Unit CoolMice;
  2. INTERFACE
  3. Type
  4. TMouseState = record
  5. Buttons : Integer;
  6. X,Y : Integer;
  7. end;
  8. PMouseState = ^TMouseState;
  9. Function InitMouse(var aMS:PMouseState):boolean;
  10. Procedure ShowMouse;
  11. Procedure HideMouse;
  12. Procedure GetMouseState(var aMS:TMouseState);
  13. Procedure SetMouseClip(x1,y1,x2,y2:integer);
  14. Procedure SetMouseShape(HotX,HotY : byte; Data:Pointer);
  15. Procedure DoneMouse;
  16. IMPLEMENTATION
  17. var
  18. MS : TMouseState;
  19. Procedure MouseHandler;far;assembler;
  20. asm
  21. mov MS.Buttons, bx
  22. mov MS.X, CX
  23. mov MS.Y, DX
  24. ENd;
  25. Procedure SetMouseHandler(EventMask:Word; Handler:Pointer);assembler;
  26. asm
  27. mov ax, 000cH
  28. mov cx, word ptr EventMask
  29. mov bx, word ptr [Handler+2]
  30. mov es, bx
  31. mov dx, word ptr [Handler]
  32. int 33h
  33. ENd;
  34. Procedure CloseMouseHandler(Handler:Pointer);assembler;
  35. asm
  36. mov ax, 000cH
  37. mov cx, 0
  38. mov bx, word ptr [Handler+2]
  39. mov es, bx
  40. mov dx, word ptr [Handler]
  41. int 33h
  42. ENd;
  43. Function InitMouse(var aMS:PMouseState):boolean;
  44. begin
  45. asm
  46. mov ax, 0
  47. int 33h
  48. end;
  49. aMS := @MS;
  50. { SetMouseHandler($7F,@MouseHandler);}
  51. InitMouse:=true;
  52. ENd;
  53. Procedure GetMouseState(var aMS:TMouseState);
  54. var
  55. b,x,y : integer;
  56. begin
  57. asm
  58. mov ax, 3
  59. int 33h
  60. mov word ptr b, bx
  61. mov word ptr x, cx
  62. mov word ptr y, dx
  63. end;
  64. aMs.Buttons := B;
  65. aMs.X := X;
  66. aMs.Y := Y;
  67. end;
  68. Procedure DoneMouse;
  69. begin
  70. { CloseMouseHandler(@MouseHandler);}
  71. end;
  72. Procedure ShowMouse;assembler;
  73. asm
  74. mov ax, 0001h
  75. int 33h
  76. ENd;
  77. Procedure HideMouse;assembler;
  78. asm
  79. mov ax, 0002h
  80. int 33h
  81. ENd;
  82. Procedure SetMouseClip(x1,y1,x2,y2:integer);assembler;
  83. asm
  84. mov ax, 07h
  85. mov cx, [x1]
  86. mov dx, [x2]
  87. int 33h
  88. mov ax, 08d
  89. mov cx, [y1]
  90. mov dx, [y2]
  91. int 33h
  92. end;
  93. Procedure SetMouseShape(HotX,HotY : byte; Data:Pointer);assembler;
  94. asm
  95. mov ax, 09h
  96. mov bx, word ptr [Data+2]
  97. mov es, bx
  98. mov dx, word ptr [Data]
  99. mov bx, word ptr [HotX]
  100. mov cx, word ptr [HotY]
  101. int 33h
  102. end;
  103. END.