
Stable Joystick routine for Qbasic 4.5?
: If I use the Stick(n) commands from Qbasic I get very unstable readings in
: the higher regions of the joystick values.I know it is not my joystick
: Is there a better way to do this? I was thinking of a routine that will
: trigger the monostables at address 0x201 in bios like they do in C/C++. This
: way I can send a trigger when I want to take a reading. Any routine or LIB
: file for Qbasic that can do it for me? Or can anybody tell me how I can
: read/write to address 0x201 with Qbasic?
Hi,
You'll find Phillip's routine in MISC.ABC in abc97mm.zip :)
Alright, here I'll save you the trouble:
SUB FastJoy (JoyX%, JoyY%, JoyNum%)
' Fast joystick routines by Phillip Jay Cohen
' JoyX% returns vertical postion of specified joystick
' JoyY% returns horizontal postion of specified joystick
' JoyNum% specifies whether joystick number one or two is to be read
SELECT CASE JoyNum% ' Choose appropriate bitmasks
CASE 1
XMask% = 1
YMask% = 2
CASE 2
XMask% = 4
YMask% = 8
CASE ELSE
EXIT SUB
END SELECT
JoyX% = 1: JoyY% = 1
OUT &H201, 0 ' Reset joystick port
DO
Joy% = INP(&H201) ' Poll joystick port
IF Joy% AND XMask% THEN JoyX% = JoyX% + 1
IF Joy% AND YMask% THEN JoyY% = JoyY% + 1
LOOP UNTIL (Joy% AND XMask%) = 0 AND (Joy% AND YMask%) = 0
END SUB
--
William Yu
http://www.*-*-*.com/ ~voxel/