home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / JOYSTICK.LBR / JOYDEMO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  2019-04-13  |  2.8 KB  |  135 lines

  1. {
  2. Joy Stick Demo 1.0 11/19/92 (C) 1992 Steve Goldsmith
  3. SG Tools Pro (C) 1992 Steve Goldsmith
  4. SG Tools (C) 1992 Parsec, Inc.
  5.  
  6. This program requires SG Tools from Parsec, Inc. to compile.  SG Tools Pro
  7. is a set of professional add-ons for SG Tools and Turbo Pascal.  You are
  8. free to use the JOYSTICK.INC module in your own programs as you wish.  If
  9. you use any of my tools or programs a $5.00 payment is requested to:
  10.  
  11. Steve Goldsmith
  12. 2805 Jamaica Street
  13. Sarasota, FL 34231
  14.  
  15. Send any comments to GEnie mail S.GOLDSMITH2
  16.  
  17. JOYDEMO.PAS shows how easy it is to add joy stick input to your SG Tools
  18. applications.  The Run procedure polls the joystick and displays the
  19. direction(s) and fire button status until a key is pressed.  The ReadJoy2
  20. procedure is part of the JOYSTICK.INC module.  I used the ADM-31 screen
  21. codes for cursor plotting and colors.  This was the easiest way until
  22. Parsec releases the VDC Screen Manager for SG Tools.
  23. }
  24.  
  25. program JoyDemo;
  26.  
  27. {$B-,C-,R-,U-,V-}
  28.  
  29. {SG Tools module to read cia ports}
  30.  
  31. {$I PORT.INC}
  32.  
  33. {SG Tools Pro joystick module}
  34.  
  35. {$I JOYSTICK.INC}
  36.  
  37. {codes for adm-31/commodore protocol}
  38.  
  39. const
  40.  
  41.   appClrScr = #$1b#$3a;
  42.   appRvsOn = #$1b#$47#$34;
  43.   appRvsOff = #$1b#$47#$30;
  44.   appTitleColor = #$1b#$1b#$1b#$23;
  45.   appJoyColor = #$1b#$1b#$1b#$25;
  46.   appExitColor = #$1b#$1b#$1b#$21;
  47.  
  48. {text data}
  49.  
  50.   appTitle = ' C128 CP/M Joy Stick Demo 1.0 11/19/92 ';
  51.   appCopyright = ' (C) 1992 Steve Goldsmith ';
  52.   appInfo = ' Move the joy stick in port 2 around';
  53.   appExit = ' Press any key to exit ';
  54.  
  55. {other app related stuff}
  56.  
  57.   appScrWidth = 80;
  58.  
  59. type
  60.  
  61.   appDispStr = string[255];
  62.  
  63. procedure PlotCursor (X,Y : byte);
  64.  
  65. begin
  66.   Write (#$1b#$3d+Chr (Y+$20)+Chr (X+$20))
  67. end;
  68.  
  69. procedure CenterText (S : appDispStr; Y : byte);
  70.  
  71. begin
  72.   PlotCursor ((appScrWidth-Length (S)) div 2,Y);
  73.   Write (S)
  74. end;
  75.  
  76. procedure PlotStr (X,Y : byte; S : appDispStr);
  77.  
  78. begin
  79.   PlotCursor (X,Y);
  80.   Write (S)
  81. end;
  82.  
  83. procedure DispJoyInfo;
  84.  
  85. var
  86.  
  87.   JoyData : byte;
  88.  
  89. begin
  90.   JoyData := ReadJoy2;
  91.   if JoyData and joyUp = 0 then
  92.     PlotStr (38,10,'Up');
  93.   if JoyData and joyDown = 0 then
  94.     PlotStr (37,14,'Down');
  95.   if JoyData and joyLeft = 0 then
  96.     PlotStr (32,12,'Left');
  97.   if JoyData and joyRight = 0 then
  98.     PlotStr (42,12,'Right');
  99.   if JoyData and joyFire = 0 then
  100.     PlotStr (37,12,'Fire')
  101. end;
  102.  
  103. procedure Run;
  104.  
  105. begin
  106.   Write (appJoyColor);
  107.   repeat
  108.     DispJoyInfo
  109.   until KeyPressed
  110. end;
  111.  
  112. procedure Init;
  113.  
  114. begin
  115.   Write (appClrScr);
  116.   Write (appTitleColor);
  117.   CenterText (appTitle,0);
  118.   CenterText (appCopyright,2);
  119.   CenterText (appInfo,4);
  120.   CenterText (appExit,6)
  121. end;
  122.  
  123. procedure Done;
  124.  
  125. begin
  126.   Write (appExitColor);
  127. end;
  128.  
  129.  
  130. begin
  131.   Init;
  132.   Run;
  133.   Done
  134. end.
  135.