home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0064_Fast.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  3.1 KB  |  176 lines

  1.   unit MyMouse;
  2.   { bare bones mouse unit used by the simulator -stolen from swag, sorta }
  3.  
  4.   interface
  5.  
  6.   uses dos;
  7.  
  8.   var
  9.     mousex, mousey:integer;
  10.  
  11.   procedure initmouse(var buttons:byte; var is:boolean);
  12.   Procedure showmouse;
  13.   Procedure hidemouse;
  14.   procedure getmousexy;
  15.   procedure mouseto80;
  16.   Procedure MouseExit;
  17.   function mouserightpressed:boolean; {??}
  18.   function mouseleftpressed:boolean;
  19.   function mouserightdown:boolean;
  20.   function mousebothdown:boolean;
  21.   function mouseleftdown:boolean;
  22.  
  23.  implementation
  24.  
  25.  Var
  26.    ExitPtr: pointer;
  27.    Regs: registers;
  28.    TempWord: word;
  29.  
  30.   procedure initmouse(var buttons:byte; var is:boolean);
  31.   var msavailable:boolean;
  32.       msbuttons:byte;
  33.   begin
  34.      msavailable:=false;
  35.      Asm
  36.        MOV MsButtons,0
  37.        MOV AX,0000h
  38.        INT 33h
  39.        CMP AX,0000h
  40.        JE  @Dne
  41.        CMP AX,0FFFFh
  42.        JNE @Dne
  43.        MOV MsAvailable,True
  44.        CMP BX,0002h
  45.        JE  @Two
  46.        CMP BX,0003h
  47.        JE  @Thr
  48.        CMP BX,0FFFFh
  49.        JE  @Thr
  50.  @Two: MOV MsButtons,2
  51.        JMP @Dne
  52.  @Thr: MOV MsButtons,3
  53.  @Dne:
  54.      End;
  55.      buttons:=msbuttons;
  56.      is:=msavailable;
  57.   end;
  58.  
  59.   Procedure showmouse; Assembler;
  60.   Asm
  61.     MOV AX,0001h
  62.     INT 33h
  63.   end;
  64.  
  65.   Procedure Hidemouse; Assembler;
  66.   Asm
  67.     MOV AX,0002h
  68.     INT 33h
  69.   end;
  70.  
  71.   procedure getmousexy; Assembler;
  72.   Asm
  73.     MOV AX,0003h
  74.     INT 33h
  75.     MOV mousex,CX
  76.     MOV mousey,DX
  77.   end;
  78.  
  79.   procedure mouseto80;
  80.   begin
  81.     {makes it a number for 80x25 text mode}
  82.     mousex:=(mousex div 8)+1;
  83.     mousey:=(mousey div 8)+1;
  84.   end;
  85.  
  86.   {dont know the diff between 'rghtDOWN and rightPRESSED'}
  87.  
  88.   function mouseleftpressed:boolean;
  89.   begin
  90.     asm
  91.       MOV @Result,False
  92.       MOV AX,0005h
  93.       MOV BX,0000h
  94.       INT 33h
  95.       {MOV Count,BX} {what is count?}
  96.       MOV mousex,CX
  97.       MOV mousey,DX
  98.       CMP AX,1
  99.       JNE @Done
  100.       MOV @Result,True
  101.       @Done:
  102.     end;
  103.   end;
  104.  
  105.   function mouserightpressed:boolean;
  106.   begin
  107.     asm
  108.       MOV @Result,False
  109.       MOV AX,0005h
  110.       MOV BX,0001h
  111.       INT 33h
  112.       {MOV Count,BX} {what is count?}
  113.       MOV mousex,CX
  114.       MOV mousey,DX
  115.       CMP AX,2
  116.       JNE @Done
  117.       MOV @Result,True
  118.       @Done:
  119.     end;
  120.   end;
  121.  
  122.   function mouserightdown:boolean;
  123.   begin
  124.     asm
  125.       MOV @Result,False
  126.       MOV AX,0003h
  127.       INT 33h
  128.       MOV mousex,CX
  129.       MOV mousey,DX
  130.       CMP BX,2
  131.       JNE @Done
  132.       MOV @Result,True
  133.       @Done:
  134.     end;
  135.   end;
  136.  
  137.   function mousebothdown:boolean;
  138.   begin
  139.     asm
  140.       MOV @Result,False
  141.       MOV AX,0003h
  142.       INT 33h
  143.       MOV MouseX,CX
  144.       MOV MouseY,DX
  145.       CMP BX,3
  146.       JNE @Done
  147.       MOV @Result,True
  148.       @Done:
  149.     end;
  150.   end;
  151.  
  152.   function mouseleftdown:boolean;
  153.   begin
  154.     Asm
  155.       MOV @Result,False
  156.       MOV AX,0003h
  157.       INT 33h
  158.       MOV mousex,CX
  159.       MOV mousey,DX
  160.       CMP BX,1
  161.       JNE @Done
  162.       MOV @Result,True
  163.       @Done:
  164.     end;
  165.   end;
  166.  
  167.   Procedure MouseExit;
  168.   begin
  169.     ExitProc:=ExitPtr;
  170.   end;
  171.  
  172.   begin
  173.     ExitPtr:=ExitProc;
  174.     ExitProc:=@MouseExit;
  175.   End.
  176.