home *** CD-ROM | disk | FTP | other *** search
- UNIT Mouse;
-
- { TP5.5 unit for interface to mouse system }
-
- INTERFACE
- Type
- MouseButtons = (NonePressed, { No Buttons pressed }
- LeftPressed, { Left Button Only Pressed }
- RightPressed, { Right button only }
- MiddlePressed); { Middle Button Only }
-
- Procedure ShowMouseCursor; { Enables mouse cursor }
- Procedure HideMouseCursor; { Disables Mouse Cursor }
- Procedure GetTextMouseLocation(VAR Row,Col : WORD); { Return text location of mouse }
- Procedure SetTextMouseLocation(Row,Col : WORD); { Set cursor for mouse }
- Function GetMouseButtonStatus : MouseButtons;
-
-
-
- IMPLEMENTATION
- uses Dos,Crt;
-
- var
- Regs : Registers; { Used by initialization and all the procs }
-
-
- Procedure ShowMouseCursor;
-
- Begin
- Regs.AX := 1;
- Intr($33,Regs);
- End;
-
-
-
- Procedure HideMouseCursor;
-
- Begin
- Regs.AX := 2;
- Intr($33,Regs);
- End;
-
-
- Procedure GetTextMouseLocation(VAR Row, Col : WORD);
-
- Begin
- Regs.AX := 3;
- Intr($33,Regs);
- Col := (Regs.CX shr 3) + 1; { Adjust for scan lines }
- Row := (Regs.DX shr 3) + 1; { Adjust for scan lines }
- End;
-
-
- Procedure SetTextMouseLocation(Row, Col : WORD);
-
- Begin
- Regs.AX := 4;
- Regs.CX := (Col-1) shl 3; { Convert to CGA scan lines }
- Regs.DX := (Row-1) shl 3;
- Intr($33,Regs);
- End;
-
-
- Function GetMouseButtonStatus : MouseButtons;
- Var
- LeftCount, RightCount, MiddleCount : WORD;
- RetStat : MouseButtons;
-
- Begin
- Regs.AX := 5; Regs.BX := 4; Intr($33,Regs); LeftCount := Regs.BX;
- Regs.AX := 5; Regs.BX := 1; Intr($33,Regs); RightCount := Regs.BX;
- Regs.AX := 5; Regs.BX := 2; Intr($33,Regs); MiddleCount := Regs.BX;
- If (LeftCount > RightCount) and
- (LeftCount > MiddleCount)
- Then RetStat := LeftPressed
- Else If (RightCount > MiddleCount)
- Then RetStat := RightPressed
- Else If (MiddleCount > 0)
- Then RetStat := MiddlePressed
- Else RetStat := NonePressed;
- GetMouseButtonStatus := RetStat;
- End;
-
-
- Begin {Mouse unit initialization}
- Regs.AX := 0; { Call the mouse interrupt initialize }
- Intr($33,Regs); { Do the Interrupt }
- If Regs.AX <> $FFFF
- Then begin
- Writeln('ERROR 1 - No Mouse Driver Present.');
- Halt(1);
- end;
- ShowMouseCursor; { Do this }
- End.