home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / hacking / phreak_utils_pc / mouseio.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-04-01  |  2.2 KB  |  128 lines

  1. unit mouseio;
  2.  
  3. interface
  4. function MouseLeftClicked:boolean;
  5. function MouseRightClicked:boolean;
  6. function InitMouse:boolean;
  7. procedure MouseOn;
  8. procedure MouseOff;
  9. procedure MoveMouseTo(x,y:word);
  10. procedure MouseRange(xmin,ymin,xmax,ymax:word);
  11. function  MouseX:word;
  12. function  MouseY:word;
  13. procedure GetNextClick(var x,y:word);
  14.  
  15. var mouseison :boolean;
  16.  
  17. implementation
  18. uses dos,bitmani;
  19.  
  20. function MouseLeftClicked:boolean;
  21. var r:registers;
  22. begin
  23.   r.ax:=$0003;
  24.   intr($33,r);
  25.   MouseLeftClicked:=gesetztinword(0,r.bx);
  26. end;
  27.  
  28. function MouseRightClicked:boolean;
  29. var r:registers;
  30. begin
  31.   r.ax:=$0003;
  32.   intr($33,r);
  33.   MouseRightClicked:=gesetztinword(1,r.bx);
  34. end;
  35.  
  36. function InitMouse:boolean;
  37. var r:registers;
  38. begin
  39.   with r do begin
  40.     ax:=$0000;
  41.     intr($33,r);
  42.     if ax=$0000 then begin
  43.       initmouse:=false;
  44.       exit;
  45.     end;
  46.     ax:=$0001;
  47.     intr($33,r);
  48.   end;
  49.   initmouse:=true;
  50. end;
  51.  
  52. procedure MouseOn;
  53. var r:registers;
  54. begin
  55.   if not(mouseison) then begin
  56.     r.ax:=$0001;
  57.     intr($33,r);
  58.     mouseison:=true;
  59.   end;
  60. end;
  61.  
  62. procedure MouseOff;
  63. var r:registers;
  64. begin
  65.   if mouseison then begin
  66.     r.ax:=$0002;
  67.     intr($33,r);
  68.     mouseison:=false;
  69.   end;
  70. end;
  71.  
  72. procedure MoveMouseTo(x,y:word);
  73. var r:registers;
  74. begin
  75.   r.ax:=$0004;
  76.   r.cx:=x*8-1;
  77.   r.dx:=x*8-1;
  78.   intr($33,r);
  79. end;
  80.  
  81. procedure MouseRange(xmin,ymin,xmax,ymax:word);
  82. var r:registers;
  83. begin
  84.   r.ax:=$0007;
  85.   r.cx:=xmin*8-1;
  86.   r.dx:=xmax*8-1;
  87.   intr($33,r);
  88.   r.ax:=$0008;
  89.   r.cx:=ymin*8-1;
  90.   r.dx:=ymax*8-1;
  91.   intr($33,r);
  92. end;
  93.  
  94. function mousex:word;
  95. var r:registers;
  96. begin
  97.   r.ax:=$0003;
  98.   intr($33,r);
  99.   mousex:=r.cx div 8+1;
  100. end;
  101.  
  102. function mousey:word;
  103. var r:registers;
  104. begin
  105.   r.ax:=$0003;
  106.   intr($33,r);
  107.   mousey:=r.dx div 8+1;
  108. end;
  109.  
  110. procedure GetNextClick(var x,y:word);
  111. var r:registers;
  112. begin
  113.   repeat r.ax:=$0003; intr($33,r); until r.bx<>0;
  114.   x:=r.cx div 8+1;
  115.   y:=r.dx div 8+1;
  116.   repeat until not mouseleftclicked;
  117. end;
  118.  
  119. begin
  120.   if paramstr(1)='/(C)' then begin
  121.     writeln('MOUSEIO.PAS  v1.30   Mouse Interface Routines via Interrupt 33h');
  122.     writeln('                     Copyright (C) 1993 by Onkel Dittmeyer/SLAM');
  123.     writeln;
  124.     readln;
  125.   end;
  126.   mouseison:=false;
  127. end.
  128.