home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
CPM
/
UTILS
/
F
/
MOUSE.LBR
/
MOUSE.PAS
< prev
Wrap
Pascal/Delphi Source File
|
2000-06-30
|
5KB
|
211 lines
{
Mouse Demo 1.0 11/22/92 (C) 1992 Steve Goldsmith
SG Tools Pro (C) 1992 Steve Goldsmith
SG Tools (C) 1992 Parsec, Inc.
This program requires SG Tools from Parsec, Inc. to compile. SG Tools Pro
is a set of professional add-ons for SG Tools and Turbo Pascal. You are
free to use the MOUSE.INC module in your own programs as you wish. If
you use any of my tools or programs a $5.00 payment is requested to:
Steve Goldsmith
2805 Jamaica Street
Sarasota, FL 34231
Send any comments to GEnie mail S.GOLDSMITH2
MOUSE.PAS shows how easy it is to add 1351 mouse input to your SG Tools
applications. The Run procedure polls the mouse, moves the cursor and
displays the button pressed until a key is pressed. The ReadMouse2
procedure is part of the MOUSE.INC module. I used the ADM-31 screen
codes for cursor plotting and colors. This was the easiest way until
Parsec releases the VDC Screen Manager for SG Tools.
}
program MouseDemo;
{$B-,C-,R-,U-,V-}
{SG Tools module to read cia and sid ports}
{$I PORT.INC}
{SG Tools Pro modules}
{$I JOYSTICK.INC}
{$I MOUSE.INC}
{codes for adm-31/commodore protocol}
const
appClrScr = #$1b#$3a;
appRvsOn = #$1b#$47#$34;
appRvsOff = #$1b#$47#$30;
appTitleColor = #$1b#$1b#$1b#$23;
appMouseColor = #$1b#$1b#$1b#$25;
appExitColor = #$1b#$1b#$1b#$21;
{text data}
appTitle = 'C128 CP/M Mouse Demo 1.0 11/22/92';
appCopyright = '(C) 1992 Steve Goldsmith';
appInfo = 'Move 1351 mouse in port 2 around';
appExit = 'Press any key to exit';
{other app related stuff}
appScrWidth = 80;
appScrHeight = 25;
appXFeel = 2;
appYFeel = 4;
appXOverflow = 10;
appYOverflow = 10;
type
appDispStr = string[255];
var
appMouseX, appMouseY, appCurX, appCurY : byte;
procedure PlotCursor (X,Y : byte);
begin
Write (#$1b#$3d+Chr (Y+$20)+Chr (X+$20))
end;
procedure CenterText (S : appDispStr; Y : byte);
begin
PlotCursor ((appScrWidth-Length (S)) div 2,Y);
Write (S)
end;
procedure PlotStr (X,Y : byte; S : appDispStr);
begin
PlotCursor (X,Y);
Write (S)
end;
procedure MoveCursorX;
var
XDiff : byte;
begin
XDiff := abs (appMouseX - mseX); {calc abs diff betewwn old and new pos}
if XDiff > appXFeel then {see if diff > feel}
begin
if XDiff < appXOverflow then {see if diff overflowed}
begin
if (appCurX < appScrWidth-1) and {which direction are we going?}
(mseX > appMouseX) then
appCurX := appCurX+1
else
if (appCurX > 0) and
(mseX < appMouseX) then
appCurX := appCurX-1
end;
appMouseX := mseX {old mouse pos = new pos}
end
end;
procedure MoveCursorY;
var
YDiff : byte;
begin
YDiff := abs (appMouseY - mseY);
if YDiff > appYFeel then
begin
if YDiff < appYOverflow then
begin
if (appCurY < appScrHeight-1) and
(mseY < appMouseY) then
appCurY := appCurY+1
else
if (appCurY > 0) and
(mseY > appMouseY) then
appCurY := appCurY-1
end;
appMouseY := mseY
end
end;
procedure MoveMouseCursor;
begin
Inline ($F3); {di ;disable hardware interrupt}
MoveCursorX; {calling the cursor plotting procedures with interrupts}
MoveCursorY; {off should be enough delay for key scan lines to}
ReadMouse2; {stablize before reading sid pots}
Inline ($FB); {ei ;enable hardware interrupt}
PlotCursor (appCurX,appCurY)
end;
procedure DispMouseInfo;
var
ButtonData : byte;
begin
MoveMouseCursor; {move cursor with mouse}
ButtonData := ReadJoy2; {get button data}
if ButtonData and joyFire = 0 then {display button status}
CenterText ('Left Button ',10);
if ButtonData and JoyUp = 0 then
CenterText ('Right Button',10)
end;
procedure Run;
var
K : char;
begin
Write (appMouseColor);
repeat
DispMouseInfo
until KeyPressed;
Read (Kbd,K);
end;
procedure Init;
begin
appMouseX := 0; {init app and module vars}
appMouseY := 0;
appCurX := appScrWidth div 2;
appCurY := appScrHeight div 2;
mseX := 0;
mseY := 0;
Write (appClrScr);
Write (appTitleColor);
CenterText (appTitle,0);
CenterText (appCopyright,2);
CenterText (appInfo,4);
CenterText (appExit,6)
end;
procedure Done;
begin
Write (appExitColor);
PlotCursor (0,appScrHeight-3)
end;
begin
Init;
Run;
Done
end.