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>)j)0 0= ^R!#^*^#V#N#F#^#V>2ͱ:1:*6 #-Nw#Fwq#p#6#w#w#w"~Â>">!DM!":*B:!>(>2>">!"2"~ʱ*w#wx(9* :O *-4 #4!*4 #4 *-N#Fq#pV+^Bq#pS[ѷR'* s#r$ s#rM <?*M!\  <( !\$>2>2M:>!(* \$\<(!4: [1ð\!(7"~> 2"S"Ns#FrB(Z#\: \<(?*"}K\! !*}#"}! x \* *>* 2""{_!"*nf}(HR0nf" ^VMDnfutqp*s#r*s#r"* vKB!1>( ~#fo{_"*R0RnfR0KqputsrNF( ^VNF^V*SutKqp R*R(~w~wnf ut"6#L*L*!""*NFy(* "*B0Cnf* [R*"*RS[s#r^#V""6#>O"w2x2*"!G"" 'z*"*>2"*"!G"""!\*: Os!~6go(\R*s#r_2x( s x(T]DMx(R0 U(͞O/o&9q# (!>F0#( ~ ( #]( ~ ( (#}(  i&T-a%ã}ͧo*!~6o&|:2!2}:__{ѯ2*|KB " z ^C User break+=  I/O Run-time error {͵, PC=*ͰNot enough memory Program aborted :m'1!?e!$=?>ú$"s?*s?"i?Ki?x2h?*h?&"u?*u?}2e?"f?*f?"Z?*e?&}2\?KZ?:\?y!!}2P?!!#!!!!|g}o}2Y?!*P?&#!*Y?&}2N?}2O?͜N=*N?&! e.>*O?&! e.>!ͫ }2E>!F>!P!F>;ͤR!*E>&͈!!F>;͜!ͫ !;=}2;>}2<>*<>&*;>&͈!!;=;͜!ͫ I!}2*=**=&!|g}o!̀Eʅ"!&! NUp"Ö"!&! N "**=&!|g}o!̀E"!%!NDown""!%!N "**=&!|g}o!̀E#! ! NLeft""#! ! N "**=&!|g}o!̀EV#!*! NRight"j#!*! N "**=&!|g}o!̀Eʝ#!%! NFire"ð#!%! N "͜ͻ% M"͠Eʿ#!ͪ!!=E ͜ͻ: ͜ͻ# N&C128 CP/M Joy Stick Demo 1.1 11/22/92 !!N(C) 1992 Steve Goldsmith!!N#Move the joy stick in port 2 around!!NPress any key to exit!!͜ͻ! !!!R͈!#ͱ#͗$ !N#Move the joy stick in port 2 around!!NPress { Joy Stick Demo 1.1 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 JOYSTICK.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 JOYDEMO.PAS shows how easy it is to add joy stick input to your SG Tools applications. The Run procedure polls the joystick and displays the direction(s) and fire button status until a key is pressed. The ReadJoy2 procedure is part of the JOYSTICK.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 JoyDemo; {$B-,C-,R-,U-,V-} {SG Tools module to read cia ports} {$I PORT.INC} {SG Tools Pro joystick module} {$I JOYSTICK.INC} {codes for adm-31/commodore protocol} const appClrScr = #$1b#$3a; appRvsOn = #$1b#$47#$34; appRvsOff = #$1b#$47#$30; appTitleColor = #$1b#$1b#$1b#$23; appJoyColor = #$1b#$1b#$1b#$25; appExitColor = #$1b#$1b#$1b#$21; {text data} appTitle = 'C128 CP/M Joy Stick Demo 1.1 11/22/92 '; appCopyright = '(C) 1992 Steve Goldsmith'; appInfo = 'Move the joy stick in port 2 around'; appExit = 'Press any key to exit'; {other app related stuff} appScrWidth = 80; appScrHeight = 25; type appDispStr = string[255]; 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 DispJoyInfo; var JoyData : byte; begin JoyData := ReadJoy2; if JoyData and joyUp = 0 then PlotStr (38,10,'Up') else PlotStr (38,10,' '); if JoyData and joyDown = 0 then PlotStr (37,14,'Down') else PlotStr (37,14,' '); if JoyData and joyLeft = 0 then PlotStr (32,12,'Left') else PlotStr (32,12,' '); if JoyData and joyRight = 0 then PlotStr (42,12,'Right') else PlotStr (42,12,' '); if JoyData and joyFire = 0 then PlotStr (37,12,'Fire') else PlotStr (37,12,' ') end; procedure Run; var K : char; begin Write (appJoyColor); repeat DispJoyInfo until KeyPressed; Read (Kbd,K) end; procedure Init; begin 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. { SG Tools Pro (C) 1992 Steve Goldsmith The Joystick module allows you to read joystick 2 } const cia1DataPortRegA = $dc00; cia1DataDirRegA = $dc02; {joystick direction masks} joyNone = $1f; joyFire = $10; joyUp = $01; joyDown = $02; joyLeft = $04; joyRight = $08; joyUpLeft = $05; joyUpRight = $09; joyDownLeft = $06; joyDownRight = $0a; function ReadJoy2 : byte; var RegSave : byte; begin RegSave := PortIn (cia1DataDirRegA); {save ddr} PortOut (cia1DataDirRegA,$0); {set ddr to all inputs} ReadJoy2 := PortIn (cia1DataPortRegA) and $1f; {read joystick 2} PortOut (cia1DataDirRegA,RegSave) {restore ddr} end;  ͫCopyright (C) 1985 BORLAND IncBLear-Siegler ADM-31dP= *EE RT)1(1~7#~=  oͦlԅ!!"~#(}:$= +*!6!*!!:(2!6:(>2!!!:O::O:!*! !45(! +/ 0y0( d!k6!{6``o&  :(͠|(  *"x2y( >28!"9!! og2"">~22!:05+:!Co&ͦͣ} [ (!e|ͧA8Q0G: x@!\w# (̓ ?(*( .( x_. _!h6# (?( *( ̓( w#>?> w#ͧ 8 !ɿ .,;:=?*[]<>{}a{ |͵};Ɛ'@'7||}>2Ͱ*Bک  "og"2>2! ""*B"[Rv*"^#V#^#V#N#FO/o&9O/o&9!9(> (G!9 w#Eͻw}8( RB0 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*s#r_2x( s x(T]DMx(R0 U(͞O/o&9q# (!>F0#( ~ ( #]( ~ ( (#}(  i&T-a%ã}ͧo*!~6o&|:2!2}:__{ѯ2*|KB " z ^C User break+=  I/O Run-time error {͵, PC=*ͰNot enough memory Program aborted :m'1!?e!&<?>&"s?*s?"i?Ki?x2h?*h?&"u?*u?}2e?"f?*f?"Z?*e?&}2\?KZ?:\?y!!}2P?!!#!!!!|g}o}2Y?!*P?&#!*Y?&!!!|g}o}2E?!!!|g}o}2D?*E?&!͓E!*E?&!W}2O?*D?&!͓E!*D?&!W}2N?}2>?}2??͜N=*>?&! e.>*??&! e.>!ͫ }25>!6>!P!6>;ͤR!*5>&!!6>;͜!ͫ !+=}2+>}2,>*,>&*+>&!!+=;͜!ͫ *C?&*O?&Ŕ}2=*=&!E}#*=&! Et#*A?&!P!R*O?&*C?&}oE<#*A?&!}2A?t#*A?&!*O?&*C?&}oEt#*A?&!R}2A?*O?&}2C?*B?&*N?&Ŕ}2=*=&!E;$*=&! E2$*@?&!!R*N?&*B?&}oE#*@?&!}2@?2$*@?&!*N?&*B?&}oE2$*@?&!R}2@?*N?&}2B?"~#͈!*A?&*@?&!<$I!}2=*=&!|g}o!̀Eʕ$N Left Button ! @"*=&!|g}o!̀E$N Right Button! @"͜ͻ% W$͠E$!ͪ!= 0 and <= 63 } procedure ReadMouse2; var NewX, NewY : byte; begin NewX := PortIn (sidPotX) and $7f; {read new pos and} NewY := PortIn (sidPotY) and $7f; {mask out high bit} if NewX <> $7f then {if new pos <> $7f then} mseX := NewX shr 1; {cur pos = new pos div 2} if NewY <> $7f then mseY := NewY shr 1 end; { 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.