home *** CD-ROM | disk | FTP | other *** search
- {
- Mouse Draw 1.0 11/25/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 and MOUSECUR.INC modules 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
-
- MDRAW.PAS is another 1351 mouse example. It allows you to move the cursor
- around and draw simple pictures. I created a new module since I released
- MOUSE.LBR called MOUSECUR.INC. MOUSECUR.INC removes mouse cursor logic
- from the main program and can be used in VDC bit map or interlace modes.
- Cursor plotting is still preformed by the main program.
-
- 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 MouseDraw;
-
- {$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}
- {$I MOUSECUR.INC}
-
- {codes for adm-31/commodore protocol}
-
- const
-
- appClrScr = #$1b#$3a;
- appRvsOn = #$1b#$47#$34;
- appRvsOff = #$1b#$47#$30;
- appTitleColor = #$1b#$1b#$1b#$21;
- appExitColor = #$1b#$1b#$1b#$21;
-
- {text data}
-
- appTitle = ' Mouse Draw 1.0 11/25/92 (C) 1992 Steve Goldsmith ';
- appCommands = 'Mouse Port 2, [LEFF] Draw, [RIGHT] Erase, [C] Color [S] Clr Scr, [ESC] exit';
-
- {other app related stuff}
-
- appScrWidth = 80; {screen size}
- appScrHeight = 25;
- appXFeel = 4; {feel is amount of change needed to move cursor}
- appYFeel = 8;
- appXOverflow = 16; {overflow is the max amount of change which}
- appYOverflow = 16; {prevents cursor movement}
-
- type
-
- appDispStr = string[255];
-
- var
-
- appCurColor : 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 DrawScr;
-
- var
-
- I : byte;
-
- begin
- Write (appClrScr);
- Write (appTitleColor+appRvsOn);
- CenterText (appTitle,0);
- Write (appRvsOff);
- CenterText (appCommands,1);
- for I := 0 to appScrWidth-1 do
- begin
- PlotCursor (I,2);
- Write (appRvsOn+'*'+appRvsOff);
- PlotCursor (I,appScrHeight-3);
- Write (appRvsOn+'*'+appRvsOff)
- end;
- for I := 3 to appScrHeight-4 do
- begin
- PlotCursor (0,I);
- Write (appRvsOn+'*'+appRvsOff);
- PlotCursor (appScrWidth-1,I);
- Write (appRvsOn+'*'+appRvsOff)
- end;
- PlotCursor (mseXCur,mseYCur);
- Write (#27#27#27+Chr ($20+appCurColor))
- end;
-
- procedure UpdateMouseCur;
-
- var
-
- ButtonData : byte;
-
- begin
- Inline ($F3); {di ;disable hardware interrupt}
- UpdateMouseCurX; {calling the cursor plotting procedures with interrupts}
- UpdateMouseCurY; {disabled stablize sid pots before reading}
- ReadMouse2;
- Inline ($FB); {ei ;enable hardware interrupt}
- PlotCursor (mseXCur,mseYCur);
- ButtonData := ReadJoy2; {get button data}
- if ButtonData and joyFire = 0 then {left button to draw}
- Write (appRvsOn+' '+appRvsOff)
- else
- if ButtonData and JoyUp = 0 then {right button to erase}
- Write (' ')
- end;
-
- procedure CurColor;
-
- begin
- if appCurColor < 15 then
- appCurColor := appCurColor+1
- else
- appCurColor := 1;
- Write (#27#27#27+Chr ($20+appCurColor)+appRvsOn+' '+appRvsOff);
- PlotCursor (mseXCur,mseYCur)
- end;
-
- procedure Run;
-
- var
-
- K : char;
-
- begin
- repeat
- repeat
- UpdateMouseCur {process mouse commands}
- until KeyPressed;
- Read (Kbd,K);
- case UpCase (K) of {process keyboard commands}
- 'C' : CurColor;
- 'S' : DrawScr
- end;
- until K = #27; {escape to exit}
- end;
-
- procedure Init;
-
- begin
- InitMouseCur (1,3,1,3,appScrWidth-2,appScrHeight-4, {init mouse cursor}
- appXFeel,appYFeel,appXOverflow,appYOverflow);
- appCurColor := 1; {init color to white}
- DrawScr {clear screen and display title}
- end;
-
- procedure Done;
-
- begin
- Write (appExitColor);
- PlotCursor (0,appScrHeight-3)
- end;
-
-
- begin
- Init;
- Run;
- Done
- end.