Category : Files from Magazines
Archive   : ITP9005.ZIP
Filename : CALMOUSE.PAS

 
Output of file : CALMOUSE.PAS contained in archive : ITP9005.ZIP

PROGRAM CalMouse; {Exercise the mouse}

USES DOS,mouse,CRT;

VAR
Buttons, MPosX, MPosY, MouseCharacter,
FGColor, BGColor : Byte;

PROCEDURE CursorOn; {Flips cursor on}
VAR Regs : Registers;
BEGIN
WITH Regs DO
BEGIN
AH := 3;
BH := 0;
Intr($10,Regs);
CH := CH AND $0F;
AH := 1;
Intr($10,Regs)
END
END;

PROCEDURE CursorOff; {Turns cursor off}
VAR Regs : Registers;
BEGIN
WITH Regs DO
BEGIN
AH := 3;
BH := 0;
Intr($10,Regs);
CH := CH OR $20;
AH := 1;
Intr($10,Regs)
END
END;

PROCEDURE RevVideo; {Ignores intensity}
BEGIN
TextColor(BGColor); TextBackground(FGColor)
END;

PROCEDURE DspButtons (Buttons, PX, PY: Byte);
BEGIN
GotoXY(49,24);
CASE Buttons OF
PrMR: Write('Middle & right');
PrNone: Write('None ');
PrL: Write('Left ');
PrR: Write('Right ');
PrLr: Write('Left & right ');
PrM: Write('Middle ');
PrLM: Write('Left & middle ');
PrAll: Write('All ');
ELSE Write('Unknown ',Buttons:3)
END;

GotoXY(70, 24); Write(PX:2);
GotoXY(79, 24); Write(PY:2)
END;

FUNCTION IsMono: Boolean;
BEGIN
IsMono := (Lastmode = Mono)
END;

PROCEDURE SetUpGrid;
VAR
I : Byte;
BEGIN
GotoXY(1, 1);
FOR I := 1 TO 8 DO Write('1234567890');
GotoXY(1, 2);
FOR I := 2 TO 25 DO
BEGIN
GotoXY(1,I); Write(I:2)
END;
GotoXY(41, 24); Write('Buttons: ');
GotoXY(63, 24); Write(' XPos= ');
GotoXY(72, 24); Write(' YPos=')
END;

{Main PROGRAM}

BEGIN
Randomize;

IF IsMono THEN
FGColor := LightGray
ELSE
BEGIN
TextMode(CO80);
FGColor := Cyan
END;

TextColor(FGColor);
BGColor := Black;
TextBackground(BGColor);

ClrScr;
RevVideo;
IF ThereIsAMouse THEN
BEGIN
WriteLn('Mouse Installed');
IF NOT MouseReset THEN
BEGIN
WriteLn
('Error, no mouse reset');
NormVideo; Halt(1)
END
ELSE
WriteLn('Mouse Reset')
END
ELSE
BEGIN
WriteLn('No mouse Installed');
NormVideo; Halt(1)
END;
Delay(1000);
CursorOff;
NormVideo;
ClrScr;
RevVideo;
SetUpGrid;
GotoXY(1,23);

Write('(Press Left Button to change mouse');
Write(', Right Button to Quit) ');
Write(' ');
MouseOn;
ClearButton(ButtonLeft);
Buttons := PrNone;
WHILE Buttons <> PrR DO
BEGIN
Buttons:=GetMouseStatus(MPosX, MPosY);
DspButtons(Buttons, MPosX, MPosY);
IF Buttons = PrL THEN
BEGIN
MouseCharacter := Random(255);
IF NOT IsMono THEN
BEGIN
FGColor := Random(7);
BGColor := Random(7)
END;
SetMouseSoftCursor
(MouseCharacter, FGColor, BGColor);
MouseOn; GotoXY(40,2);
Write('MouseCharacter: ',
MouseCharacter:3);
GotoXY(40,3);
Write('MouseFGColor: ',FGColor:1);
GotoXY(40,4);
Write('MouseBGColor: ',BGColor:1);
ClearButton(ButtonLeft)
END
END;
MouseOff;
CursorOn;
NormVideo;
ClrScr
END.