The following example examines the section of Poll where the driver calculates the coordinate values. In this section, Poll performs the following tasks:
The following code fragment continues where the previous fragment ended:
pushf ; Push the flags register
cli ; No interrupts allowed!
mov wClear, 1 ; Set stabilization loop flag
Real_Poll:
mov dx,JOYPORT ; Set joystick port address
mov si,offset _JoyCal ; Point to first JOYCALIBRATE structure
mov bx,JOY1_XY_MASK ; Place bit mask in bx
cmp id,0 ; Are we polling joystick 1?
jz @f ; If so, use first structure
cmp zOnly, 0 ; Are we polling the z axis?
jnz @f ; If so, use first structure
; Polling the second joystick
add si,(size JOYCALIBRATE) ; Use second JOYCALIBRATE structure
mov bx,JOY2_XY_MASK ; and bit mask
@@:
; Note zOnly values:
; 0 if polling x and y
; -1 if z axis is on the second joystick's x potentiometer
; 1 if z axis is on the second joystick's y potentiometer
cmp zOnly, 0 ; Are we polling the z axis?
jz poll_setxy ; No
jl @f ; Yes, on y potentiometer
; Yes, on x potentiometer
mov ax,[si].jcal_wZbase ; Set x-pos. counter to z base value
neg ax ; Start off negative
cwd
mov _wXpos,ax
mov _wXpos_hi,dx ; used to check for roll-over error
mov cx,[si].jcal_wZdelta ; Establish z delta value
mov bx,JOY2_X_MASK ; Put bit mask into dx
jmp poll_timers ; Start the timers!
; Set up for z-axis poll, using joystick 2's y potentiometer
@@: mov ax,[si].jcal_wZbase ; Set y-pos. counter to z base value
neg ax
cwd
mov _wYpos,ax
mov _wYpos_Hi,dx ; used to check for roll-over error
mov di,[si].jcal_wZdelta ; Establish z delta value
mov bx,JOY2_Y_MASK ; Put bit mask into bx
jmp poll_timers ; Start the timers!
; Set up for x- and y-axis poll
poll_setxy:
mov ax,[si].jcal_wXbase ; Set x-pos. counter to x base value
neg ax
cwd
mov _wXpos,ax
mov _wXpos_hi,dx ; used to check for roll-over error
mov ax,[si].jcal_wYbase ; Set y-pos. counter to y base value
neg ax ; Start off negative
cwd
mov _wYpos,ax
mov _wYpos_Hi,dx ; used to check for roll-over error
mov cx,[si].jcal_wXdelta ; Establish x and y deltas
mov di,[si].jcal_wYdelta
.
. ; Sample continued in next section
.