home *** CD-ROM | disk | FTP | other *** search
- {
-
- T P R O N U M B E R 5
-
- The following is a set of procedures that we have been used in
- various commercial programs. Feel free to use them for commercial
- and noncomercial uses. We claim no responsibility to the outcome of
- the use of these procedures. You are using them at your own risk.
- Enough of the legalities. If you find these routines useful, we
- would greatly appreciate any small donation.
-
-
-
-
- Soft-Touch Computers
- James Billmeyer
- 7716 Balboa Blvd, Unit D
- Van Nuys, Ca 91406
- }
-
- program joytest;
-
- (********************************************************)
- (* The joystick function is a high resolution routine *)
- (* written to handle joysticks with high resistance *)
- (* values. The integer value moved into the cx reg. *)
- (* on the fourth line of inline code controls the max *)
- (* resolution. Adjust this value for desired resolu- *)
- (* tion/proformance. *)
- (********************************************************)
-
-
- function joystick(axis: byte): integer;
-
- (**************************************************)
- (* The joystick function returns the desired *)
- (* axis of the joystick. *)
- (* *)
- (* axis: 1 - stick A (right-left) *)
- (* 2 - stick A (up-down) *)
- (* 3 - stick B (right-left) *)
- (* 4 - stick B (up-down) *)
- (* *)
- (**************************************************)
-
- begin
- Inline( $8B/$4E/$04/ { mov cx,[bp+4] ; set joystick mask }
- $83/$E9/$01/ { sub cx,1 }
- $bb/$01/$00/ { mov bx,1 }
- $D3/$E3/ { shl bx,cl }
- $B9/$ff/$ff/ { mov cx,ffff ; set max count (this value is
- usally set at 256 or 00ff).}
- $31/$C0/ { xor ax,ax ; clear ax register for output }
- $31/$F6/ { xor si,si }
- $ba/$01/$02/ { mov dx,201 }
- $FA/ { cli ; disable interupts }
- $EE/ { out dx,al }
- { next: }
- $EC/ { in al,dx ; read game adapter }
- $84/$c3/ { test al,bl ; see if finished }
- $74/$03/ { je done ; if so the exit loop }
- $46/ { inc si ; else increment counter }
- $E2/$F8/ { loop next ; and repeat loop }
- { done: }
- $89/$76/$06/ { mov [bp+6],si ; return function value }
- $FB ); { sti ; inable interupts }
- end;
-
-
-
- begin
- clrscr;
- writeln('Demo of high resolution joystick functions');
- repeat
- gotoxy(1,3); writeln(' value1: ',joystick(1),' value2: ',joystick(2),' ');
- until keypressed;
- end.
-
- repeat
- gotoxy(1,3); writeln(' value1: ',joystick(1),'