home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_36.arc / MOUSE.SYS < prev    next >
Text File  |  1987-05-23  |  4KB  |  104 lines

  1. procedure TextCursor (Start, Stop: integer);
  2. {Sets hardware mouse text cursor}
  3. begin
  4.    Regs.AX := 10;                {Mouse function 10}
  5.    Regs.BX := 1;                 {Select hardware cursor}
  6.    Regs.CX := Start;             {Scan lines from start to stop are displayed}
  7.    Regs.DX := Stop;              {including all lines between start and stop}
  8.    intr (51, Regs);
  9. end;
  10.  
  11. procedure MakeGraphCursor (Cursor: CursorMasks; X, Y: integer);
  12. {Sets mouse graphics cursor.  X and Y control hot spot}
  13. {Cursor[0..31] defines cursor mask}
  14. begin
  15.    Regs.AX := 9;                 {Mouse function 9}
  16.    Regs.BX := X;                 {Cursor hot spot x coordinate}
  17.    Regs.CX := Y;                 {Cursor hot spot y coordinate}
  18.    Regs.DX := Ofs (Cursor[0]);   {Points to screen and cursor masks}
  19.    Regs.ES := Seg (Cursor[0]);
  20.    intr (51, Regs);
  21. end;
  22.  
  23. procedure MouseReset(var Result: integer);
  24. {Resets mouse and checks for driver installation}
  25. begin
  26.    Regs.AX := 0;                 {Mouse funtion 0}
  27.    intr (51, Regs);
  28.    Result := Regs.AX;            {Returns 0 if not installed, -1 if installed}
  29. end;
  30.  
  31. procedure IntSet (Mask: integer; Handler: integer);
  32. {Sets up an interrupt handler for mouse interrupt}
  33. {Conditions for interrupt are defined in Mask}
  34. const
  35.    DSegPas: integer = 0;        { reserve space to save DS                }
  36.        {set up executable code to call crambuffer}
  37.    b1: byte = $1E;              { PUSH DS         save DS                 }
  38.    b2: byte = $2E;              { CS:                                     }
  39.    b3: byte = $8E;              { MOV DS,[w2]     load DS from DSegPas    }
  40.    b4: byte = $1E;
  41.    w1: integer = 0;
  42.    b7: byte = $50;              { PUSH AX         push regs               }
  43.    b8: byte = $53;              { PUSH BX                                 }
  44.    b9: byte = $51;              { PUSH CX                                 }
  45.    b10: byte = $52;             { PUSH DX                                 }
  46.    b11: byte = $E8;             { CALL CramBuffer                         }
  47.    w2: integer = 0;
  48.    b14: byte = $1F;             { POP DS          restore DS              }
  49.    b15: byte = $CB;             { RETF                                    }
  50. begin
  51. {$R-}
  52.    DSegPas:=DSeg;               { store data seg }
  53.    w1:=Ofs(DSegPas);            { store address in executable code above }
  54.    w2:=Handler - Ofs(w2) - 2;   { for near call instruction above }
  55. {$R+}
  56.    Regs.AX := 12;               {Mouse routine 12}
  57.    Regs.CX := mask;             {interrupt condition}
  58.    Regs.ES := Cseg;             {type constants located in CS}
  59.    Regs.DX := Ofs(b1);          {start executing code at b1}
  60.    intr (51, Regs);
  61. end;
  62.  
  63. procedure SetXLimits(Min, Max: integer);
  64. {restricts horizontal mouse movement on screen}
  65. begin
  66.    Regs.AX := 7;          {Mouse function 7}
  67.    Regs.CX := Min;        {Minimum horizontal position}
  68.    Regs.DX := Max;        {Maximum horizontal position}
  69.    intr (51, Regs);
  70. end;
  71.  
  72. procedure SetYLimits(Min, Max: integer);
  73. {restricts vertical mouse movement on screen}
  74. begin
  75.    Regs.AX := 8;          {Mouse function 8}
  76.    Regs.CX := Min;        {Minimum vertical position}
  77.    Regs.DX := Max;        {Maximum vertical position}
  78.    intr (51, Regs);
  79. end;
  80.  
  81. procedure GetPosition(var Status, X, Y: integer);
  82. {returns mouse coordinates and status of buttons}
  83. begin
  84.    Regs.AX := 3;          {Mouse function 3}
  85.    intr (51, Regs);
  86.    Status:= Regs.BX;      {left=1, right=2, both=3}
  87.    X:= Regs.CX;           {New X coordinate}
  88.    Y:= Regs.DX;           {New Y coordinate}
  89. end;
  90.  
  91. procedure CursorOn;
  92. {display cursor}
  93. begin
  94.    Regs.AX := 1;          {Mouse function 1}
  95.    intr (51, Regs);
  96. end;
  97.  
  98. procedure CursorOff;
  99. {hide cursor}
  100. begin
  101.    Regs.AX := 2;          {Mouse function 2}
  102.    intr (51, Regs);
  103. end;
  104.