{ JOYSTICK.PAS } { Unit v ktorom je vsetko co potrebujete pre pracu s joystickom. } { } { Datum:03.08.1997 http://www.trsek.com } unit joystick; interface procedure ReadJoyA( var XAxis,YAxis : word ); { kde sa nachadza A } procedure ReadJoyB( var XAxis,YAxis : word ); { kde sa nachadza B } function ButtonA1 : boolean; { stlacene tlacitko 1 } function ButtonA2 : boolean; { stlacene tlacitko 2 } function ButtonB1 : boolean; { stlacene tlacitko 3 } function ButtonB2 : boolean; { stlacene tlacitko 4 } function JoystickPressent : boolean; { Existuje joystick } implementation uses Dos; type ReadJoyProc = procedure ( a,b : byte; var c,d:word ); ButtonFunc = function ( a:byte ):boolean; var ReadJoy : ReadJoyProc; Button : ButtonFunc; Reg : Registers; function NewBIOS : boolean; var DecadeChar : char absolute $f000:$fffb; YearChar : char absolute $f000:$fffc; begin { an optimistic view of software life } NewBIOS:=(DecadeChar in ['9','0']) or ((DecadeChar='8') and (YearChar in ['4'..'9'])); end; {$F+} procedure OldReadJoy( xbit,ybit:byte; var XAxis,YAxis:word ); begin inline( $ba/$01/$02/ { mov dx,201h ;load dx with joystick port adress } $c4/$be/>XAxis/ { les di,XAxis[bp] ;load es with segment and di w/offset } $8a/$66/YAxis/ { les di,YAxis[bp] } $8a/$66/ 0); end; begin if NewBIOS then begin { pouzi novu rutinu pre BIOS } ReadJoy:=NewReadJoy; Button:=NewButton; end else begin { inac stara rutina } ReadJoy:=OldReadJoy; Button:=OldButton; end; end.