home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TPRO.ZIP / TPRO5.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-01-30  |  3.8 KB  |  80 lines

  1. {
  2.  
  3.                    T P R O    N U M B E R    5
  4.  
  5.    The following is a set of procedures that we have been used in
  6. various commercial programs. Feel free to use them for commercial
  7. and noncomercial uses. We claim no responsibility to the outcome of
  8. the use of these procedures. You are using them at your own risk.
  9. Enough of the legalities. If you find these routines useful, we
  10. would greatly appreciate any small donation.
  11.  
  12.  
  13.  
  14.  
  15.                                 Soft-Touch Computers
  16.                                 James Billmeyer
  17.                                 7716 Balboa Blvd, Unit D
  18.                                 Van Nuys, Ca  91406
  19.  }
  20.  
  21. program joytest;
  22.  
  23. (********************************************************)
  24. (*  The joystick function is a high resolution routine  *)
  25. (*  written to handle joysticks  with  high resistance  *)
  26. (*  values. The integer value moved into the  cx  reg.  *)
  27. (*  on the fourth line of inline code controls the max  *)
  28. (*  resolution. Adjust this value for  desired resolu-  *)
  29. (*  tion/proformance.                                   *)
  30. (********************************************************)
  31.  
  32.  
  33. function joystick(axis: byte): integer;
  34.  
  35. (**************************************************)
  36. (*  The joystick function  returns  the  desired  *)
  37. (*  axis of the joystick.                         *)
  38. (*                                                *)
  39. (*         axis: 1 - stick A (right-left)         *)
  40. (*               2 - stick A (up-down)            *)
  41. (*               3 - stick B (right-left)         *)
  42. (*               4 - stick B (up-down)            *)
  43. (*                                                *)
  44. (**************************************************)
  45.  
  46. begin
  47.    Inline( $8B/$4E/$04/ {         mov       cx,[bp+4]   ; set joystick mask            }
  48.            $83/$E9/$01/ {         sub       cx,1                                       }
  49.            $bb/$01/$00/ {         mov       bx,1                                       }
  50.            $D3/$E3/     {         shl       bx,cl                                      }
  51.            $B9/$ff/$ff/ {         mov       cx,ffff     ; set max count (this value is
  52.                                                             usally set at 256 or 00ff).}
  53.            $31/$C0/     {         xor       ax,ax       ; clear ax register for output }
  54.            $31/$F6/     {         xor       si,si                                      }
  55.            $ba/$01/$02/ {         mov       dx,201                                     }
  56.            $FA/         {         cli                   ; disable interupts            }
  57.            $EE/         {         out       dx,al                                      }
  58.                         { next:                                                        }
  59.            $EC/         {         in        al,dx       ; read game adapter            }
  60.            $84/$c3/     {         test      al,bl       ; see if finished              }
  61.            $74/$03/     {         je        done        ; if so the exit loop          }
  62.            $46/         {         inc       si          ; else increment counter       }
  63.            $E2/$F8/     {         loop      next        ;  and repeat loop             }
  64.                         { done:                                                        }
  65.            $89/$76/$06/ {         mov       [bp+6],si   ; return function value        }
  66.            $FB  );      {         sti                   ; inable interupts             }
  67. end;
  68.  
  69.  
  70.  
  71. begin
  72.    clrscr;
  73.    writeln('Demo of high resolution joystick functions');
  74.    repeat
  75.       gotoxy(1,3); writeln('  value1: ',joystick(1),'  value2: ',joystick(2),'    ');
  76.    until  keypressed;
  77. end.
  78.  
  79.  repeat
  80.       gotoxy(1,3); writeln('  value1: ',joystick(1),'