home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ADC_TP3.ZIP / TBOMOUSE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-03-01  |  1.4 KB  |  65 lines

  1.  
  2. program MouseSketch;
  3. {
  4.        This program shows how to read the Microsoft Mouse.
  5.                        ***WARNING***
  6.        Be sure that you have loaded the mouse driver (by
  7.        running MOUSE.COM) before executing this program.
  8. }
  9.  
  10. type
  11.   RegPack =
  12.     record
  13.       AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Integer;
  14.     end;
  15.  
  16. var
  17.   OldX,OldY,X,Y : Integer;
  18.   M1,M2,M3,M4 :   Integer;
  19.   RegPak :        RegPack;
  20.  
  21. procedure Mouse(var M1,M2,M3,M4 : Integer);
  22. var
  23.   Regs : RegPack;
  24.  
  25. begin
  26.   with Regs do begin
  27.     AX := M1;                { Set up ax,bx,cx,dx for interrupt }
  28.     BX := M2;
  29.     CX := M3;
  30.     DX := M4
  31.   end;
  32.   Intr(51,Regs);             { Trip interrupt 51 }
  33.   with Regs do begin
  34.     M1 := AX;
  35.     M2 := BX;
  36.     M3 := CX;
  37.     M4 := DX
  38.   end
  39. end; { of proc Mouse }
  40.  
  41.  
  42. begin { main body of program MouseSketch }
  43.   M1 := 0;
  44.   M2 := 0;
  45.   M3 := 0;
  46.   M4 := 0;
  47.   HiRes;                     { Choose graphics mode and color }
  48.   HiResColor(Yellow);
  49.   M1 := 0;                   { Initialize mouse driver }
  50.   Mouse(M1,M2,M3,M4);
  51.   M1 := 1;                   { Turn on Mouse cursor }
  52.   Mouse(M1,M2,M3,M4);
  53.   M1 := 3;
  54.   OldX := 0;
  55.   OldY := 0;
  56.   while not KeyPressed do begin   { Exit mouse when any key pressed }
  57.     Mouse(M1,M2,M3,M4);
  58.     if M2 <> 0
  59.       then Draw(OldX,OldY,M3,M4,1); { Draw if button pushed }
  60.     OldX := M3;
  61.     OldY := M4
  62.   end
  63. end. { of program MouseSketch }
  64.  
  65.