;
; Read PC joystick (game) port: int joystick(int results[4], char flags)
; results = Integer array to receive the AX, AY, BX, and BY values
; flags = Bits 0,1,2,3 = Disable AX,AY,BX,BY (1 = Disable)
; Returns : Bits 0,1,2,3 = Error reading AX,AY,BX,BY (1 = Error)
; Bits 4,5,6,7 = Buttons A1,A2,B1,B2 (0 = Pressed)
;
; Values placed in 'results' will range from 0 to 'n', where 'n' is
; dependant on the speed of the hardware. Experiment with your system
; to determine the actual maximum values, and scale the results to
; the range of measurements you are taking.
;
; To add to DDS MICROC-C 8086 library: CD to LIB86 subdirectory, copy in
; this file, and issue the commands: (omit memory models you don't want)
; slib i=tiny a=joystick
; slib i=small a=joystick
;
; Copyright 1989-2000 Dave Dunfield
; All rights reserved.
;
; Permission granted for personal (non-commercial) use only.
;
joystick MOV BX,SP ;Address parms
MOV AH,2[BX] ;Get mask flags
MOV BX,4[BX] ;Get array address
MOV DX,#$0201 ;Address game port
XOR CX,CX ;Zero initial count
AND AX,#$0F00 ;Mask AH, AL=0
OUT DX,AL ;Write to I/O port
?1 IN AL,DX ;Read I/O port
OR AL,AH ;Mask already received ports
TEST AL,#$01 ;AX bit set
JNZ ?2 ;No, its not
MOV [BX],CX ;Save position
OR AH,#$01 ;Disable further AX
?2 TEST AL,#$02 ;AY bit set
JNZ ?3 ;No, try next
MOV 2[BX],CX ;Save position
OR AH,#$02 ;Disable further AY
?3 TEST AL,#$04 ;BX bit set?
JNZ ?4 ;No, try next
MOV 4[BX],CX ;Save position
OR AH,#$04 ;Disable further BX
?4 TEST AL,#$08 ;BY bit set?
JNZ ?5 ;No, try next
MOV 6[BX],CX ;Save position
OR AH,#$08 ;Disable further BY
?5 INC CX ;Advance count
JZ ?6 ;Overflow...
CMP AH,#$0F ;All bits set?
JNZ ?1 ;No, keep looking
?6 NOT AH ;Invert bits
AND AL,AH ;Set flags
XOR AH,AH ;Zero high
RET
| file: /techref/com/dunfield/ftp/embedpc/joystick_asm.htm, 5KB, , updated: 2002/11/1 16:54, local time: 2009/11/22 00:24,
38.107.191.103:LOG IN
|
| ©2009 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? Please DO link to this page! Digg it! <A HREF="http://www.piclist.com/techref/com/dunfield/ftp/embedpc/joystick_asm.htm"> Joystick.asm </A> |
| Did you find what you needed? |
|
|
Robotics nuts!Check out http://www.verinet.com/~dlc/ email: dlc@verinet.com... This guy ROCKS! He has made (and sells but also releases code, docs, etc...) for a number of cool little robotic modules including whiskers, IR proximity detect and remote control, Sonar proximity detect, PWM, Servo, compass. Most of these use the little PIC 12C508 controller which costs basically nothing and is soooo tiny.The 4 servos, 2400 baud serial servo controller is a wonder of magic and he sells the programmed chip for $8. Wow! |
.