home *** CD-ROM | disk | FTP | other *** search
- {$R-} {Range checking off}
- {$B+} {Boolean complete evaluation on}
- {$S+} {Stack checking on}
- {$I+} {I/O checking on}
- {$N-} {No numeric coprocessor}
-
- Unit ScrMouse;
-
- Interface
-
- Uses Dos;
-
- Type
- S_Str8 = String[8];
- Var
- S_PreviousEvent : S_Str8;
- S_MouseExitSave : Pointer;
- S_MouseInstalled,
- S_MouseVisable,
- S_MouseActive,
- S_MouseEvent,
- S_MsLeftPressed,
- S_MsRightPressed,
- S_MsMiddlePressed,
- S_MsLeftReleased,
- S_MsRightReleased,
- S_MsMiddleReleased : Boolean;
- S_MsAx,
- S_MsBx,
- S_MsCx,
- S_MsDx : Word;
- S_MsReg : Registers;
- S_MsX,
- S_MsY,
- S_MsRowHold,
- S_MsColHold,
- S_MsRow,
- S_MsCol,
- S_Buttons : Integer;
-
-
- Procedure S_ActivateMouse;
- Procedure S_AnalizeMouse;
- Procedure S_DisableMouse;
- Procedure S_HideMouse;
- Procedure S_MoveMouse;
- Procedure S_RemoveMouse;
- Procedure S_ResetMouseFlags;
- Procedure S_ResetMouse;
- Procedure S_RestoreMouse;
- Procedure S_SetMouseCursor(Mask1_Msb,
- Mask1_Lsb,
- Mask2_Msb,
- Mask2_Lsb:Byte);
- Procedure S_SetMouseEvent(Bit:S_Str8);
- Procedure S_SetMouseRange(Top_Col,
- Top_Row,
- Bot_Col,
- Bot_Row:Byte);
- Procedure S_ShowMouse;
-
-
- Implementation
- {$F+}
- Procedure S_SetMouseFlags(Flags,Cs,Ip,Ax,Bx,Cx,Dx,Si,Di,Ds,Es,Bp:Word);
- INTERRUPT;
- Begin
- S_MsAx := (Ax Or S_MsAx);
- S_MsBx := Bx;
- S_MsCx := Cx;
- S_MsDx := Dx;
- If S_MouseActive Then
- S_MouseEvent := True;
- InLine($8B/$E5/$5D/$07/$1F/$5F/$5E/$5A/$59/$5B/$58/$CB);
- End;
- {$F+}
-
-
-
- Procedure S_SetMouseCursor(Mask1_Msb,
- Mask1_Lsb,
- Mask2_Msb,
- Mask2_Lsb:Byte);
- Begin
- If S_MouseInstalled Then
- Begin
- S_MsReg.Ax := 10;
- S_MsReg.Bx := 0;
- S_MsReg.Ch := Mask1_Msb;
- S_MsReg.Cl := Mask1_Lsb;
- S_MsReg.Dh := Mask2_Msb;
- S_MsReg.Dl := Mask2_Lsb;
- Intr($33,S_MsReg);
- End;
- End;
-
-
-
-
- Procedure S_ResetMouse;
- Begin
- If S_MouseInstalled Then
- Begin
- S_MsReg.Ax := 0;
- Intr($33,S_MsReg);
- End;
- End;
-
-
-
-
-
- Procedure S_ResetMouseFlags;
- Begin
- S_MsLeftPressed := False;
- S_MsRightPressed := False;
- S_MsMiddlePressed := False;
- S_MsLeftReleased := False;
- S_MsRightReleased := False;
- S_MsMiddleReleased := False;
- End;
-
-
-
-
-
- Procedure S_SetMouseEvent(Bit:S_Str8);
- Begin
- If Not S_MouseInstalled Then
- Exit;
-
- Bit := Bit + '00000000';
-
- If Not S_MouseActive Then
- S_PreviousEvent := Bit;
-
- S_MsReg.Cx := 0;
-
- If Bit[1]='1' Then
- Inc(S_MsReg.Cx,1);
- If Bit[2]='1' Then
- Inc(S_MsReg.Cx,2);
- If Bit[3]='1' Then
- Inc(S_MsReg.Cx,4);
- If Bit[4]='1' Then
- Inc(S_MsReg.Cx,8);
- If Bit[5]='1' Then
- Inc(S_MsReg.Cx,16);
- If Bit[6]='1' Then
- Inc(S_MsReg.Cx,32);
- If Bit[7]='1' Then
- Inc(S_MsReg.Cx,64);
-
- S_MsReg.Ax := 12;{Function #12:Set Mouse Event}
- S_MsReg.Es := Seg(S_SetMouseFlags);
- S_MsReg.Dx := Ofs(S_SetMouseFlags);
- Intr($33,S_MsReg);
-
- End;
-
-
-
-
-
- Procedure S_AnalizeMouse;
- Begin
- If S_MouseActive Then
- Begin
- If (S_MsAx and 2) = 2 Then
- S_MsLeftPressed := True;
- If (S_MsAx and 4) = 4 Then
- S_MsLeftReleased := True;
- If (S_MsAx and 8) = 8 Then
- S_MsRightPressed := True;
- If (S_MsAx and 16) = 16 Then
- S_MsRightReleased := True;
- If (S_MsAx and 32) = 32 Then
- S_MsMiddlePressed:= True;
- If (S_MsAx and 64) = 64 Then
- S_MsMiddleReleased := True;
-
- If (S_MsBx and 1) = 1 Then
- S_MsLeftPressed := True;
- If (S_MsBx and 2) = 2 Then
- S_MsRightPressed := True;
- If (S_MsBx and 4 ) = 4 Then
- S_MsMiddlePressed:= True;
-
- S_MsCol := (S_MsCx Div 8) + 1;
- S_MsRow := (S_MsDx Div 8) + 1;
-
- S_MsAx := 0;
- S_MsCx := 0;
- S_MsDx := 0;
-
- S_MouseEvent := False;
- End;
- End;
-
-
-
-
-
- Procedure S_MoveMouse;
- Begin
- If S_MouseInstalled Then
- Begin
- S_MsReg.Ax := 4;
- S_MsReg.Cx := ((S_MsCol-1) * 8)+1;
- S_MsReg.Dx := ((S_MsRow-1) * 8)+1;
- Intr($33,S_MsReg);
- End;
- End;
-
-
-
-
-
- Procedure S_SetMouseRange(Top_Col,
- Top_Row,
- Bot_Col,
- Bot_Row:Byte);
- Var
- Work : Byte;
- Begin
- If S_MouseInstalled Then
- Begin
- If (Top_Col < 1) Then Top_Col := 1;
- If (Top_Col > 80) Then Top_Col := 80;
- If (Bot_Col < 1) Then Bot_Col := 1;
- If (Bot_Col > 80) Then Bot_Col := 80;
- If (Top_Row < 1) Then Top_Row := 1;
- If (Top_Row > 25) Then Top_Row := 25;
- If (Bot_Row < 1) Then Bot_Row := 1;
- If (Bot_Row > 25) Then Bot_Row := 25;
-
- If (Top_Col > Bot_Col) Then
- Begin
- Work := Top_Col;
- Top_Col := Bot_Col;
- Bot_Col := Work;
- End;
- If (Top_Row > Bot_Row) Then
- Begin
- Work := Top_Row;
- Top_Row := Bot_Row;
- Bot_Row := Work;
- End;
- S_MsReg.Ax := 7;
- S_MsReg.Cx := ((Top_Col-1) * 8)+1;
- S_MsReg.Dx := ((Bot_Col-1) * 8)+1;
- Intr($33,S_MsReg);
- S_MsReg.Ax := 8;
- S_MsReg.Cx := ((Top_Row-1) * 8)+1;
- S_MsReg.Dx := ((Bot_Row-1) * 8)+1;
- Intr($33,S_MsReg);
- End;
- End;
-
-
-
-
- Procedure S_ShowMouse;
- Begin
- If S_MouseActive Then
- Begin
- S_MouseVisable := True;
- S_MoveMouse;
- End;
- End;
-
-
-
-
-
- Procedure S_HideMouse;
- Begin
- If S_MouseActive Then
- S_MouseVisable := False;
- End;
-
-
-
-
-
- Procedure S_RemoveMouse;
- Begin
- If S_MouseActive And
- S_MouseVisable Then
- Begin
- S_MsReg.Ax := 2;
- Intr($33,S_MsReg);
- End;
- End;
-
-
-
-
-
- Procedure S_RestoreMouse;
- Begin
- If S_MouseActive And
- S_MouseVisable Then
- Begin
- S_MsReg.Ax := 1;
- Intr($33,S_MsReg);
- End;
- End;
-
-
-
-
-
- Procedure S_ActivateMouse;
- Begin
- If S_MouseInstalled Then
- Begin
- S_MouseActive := True;
- S_SetMouseEvent(S_PreviousEvent);
- End;
- End;
-
-
-
-
-
- Procedure S_DisableMouse;
- Begin
- If S_MouseActive Then
- Begin
- S_MouseActive := False;
- S_SetMouseEvent('00000000');
- End;
- End;
-
-
-
-
- {$F+}
- Procedure S_MouseExitProc;
- Begin
- ExitProc := S_MouseExitSave;
- S_DisableMouse;
- S_ResetMouse;
- End;
- {$F-}
-
-
-
-
-
- Begin
- S_MouseExitSave := ExitProc;
- ExitProc := @S_MouseExitProc;
- S_Buttons := 0;
- S_MsRow := 0;
- S_MsRowHold := 0;
- S_MsCol := 0;
- S_MsColHold := 0;
- S_MouseActive := False;
- S_MouseVisable := False;
- S_MouseEvent := False;
- S_PreviousEvent := '00000000';
- S_ResetMouseFlags;
- S_MsReg.Ax := 0;{Check Mouse For Driver}
- Intr($33,S_MsReg);
-
- If S_MsReg.Ax <> 0 Then
- Begin
- S_MouseInstalled := True;
- S_Buttons := S_MsReg.Bx;
- S_MsReg.Ax := 10;{Set Mouse Text Software Cursor}
- S_MsReg.Bx := 0; {Software cursor}
- S_MsReg.Cx := $0000;
- S_MsReg.Dx := $0718;
- Intr($33,S_MsReg);
- S_MsReg.Ax := 4;{Move mouse to top left screen}
- S_MsReg.Cx := 1;
- S_MsReg.Dx := 1;
- S_MsRow := 1;{Mouse starts in top left corner.}
- S_MsCol := 1;
- Intr($33,S_MsReg);
- End
- Else
- S_MouseInstalled := False;
- End.