1 ; THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
2 ; SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
3 ; END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
4 ; ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
5 ; IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
6 ; SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
7 ; FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
8 ; CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
9 ; AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
10 ; COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
13 _DATA SEGMENT BYTE PUBLIC USE32 'DATA'
23 _TEXT SEGMENT BYTE PUBLIC USE32 'CODE'
33 xor al, al ; Latch timer 0 command
34 out TCOMMAND, al ; Latch timer
35 in al, TDATA ; Read lo byte
37 in al, TDATA ; Read hi byte
42 PUBLIC joy_read_stick_asm_
46 ; edi = pointer to event buffer
48 ; returns in eax the number of events
49 and ebx, 01111b ; Make sure we only check the right values
50 ; number of events we found will be in bh, so this also clears it to zero.
54 cli ; disable interrupts while reading time...
55 call joy_get_timer ; Returns counter in EAX
56 sti ; enable interrupts after reading time...
59 waitforstable: in al, dx
61 jz ready ; Wait for the port in question to be done reading...
63 cli ; disable interrupts while reading time...
64 call joy_get_timer ; Returns counter in EAX
65 sti ; enable interrupts after reading time...
72 cmp TotalTicks, ecx ; Timeout at 1/200'th of a second
79 out dx, al ; Start joystick a readin'
81 call joy_get_timer ; Returns counter in EAX
85 mov [edi], eax ; Store initial count
88 again: in al, dx ; Read Joystick port
90 and al, bl ; Mask off channels we don't want to read
91 jnz flip ; See if any of the channels flipped
93 call joy_get_timer ; Returns counter in EAX
101 cmp TotalTicks, ecx ; Timeout at 1/200'th of a second
105 flip: and eax, 01111b ; Only care about axis values
106 mov [edi], eax ; Record what channel(s) flipped
108 xor bl, al ; Unmark the channels that just tripped
110 call joy_get_timer ; Returns counter in EAX
111 mov [edi], eax ; Record the time this channel flipped
113 inc bh ; Increment number of events
116 jne again ; If there are more channels to read, keep looping
119 movzx eax, bh ; Return number of events
125 PUBLIC joy_read_stick_polled_
127 joy_read_stick_polled_:
129 ; edi = pointer to event buffer
130 ; ecx = timeout value
131 ; returns in eax the number of events
132 and ebx, 01111b ; Make sure we only check the right values
133 ; number of events we found will be in bh, so this also clears it to zero.
139 waitforstable1: in al, dx
141 jz ready1 ; Wait for the port in question to be done reading...
144 cmp TotalTicks, ecx ; Timeout at 1/200'th of a second
150 out dx, al ; Start joystick a readin'
154 mov dword ptr [edi], 0 ; Store initial count
157 again1: in al, dx ; Read Joystick port
159 and al, bl ; Mask off channels we don't want to read
160 jnz flip1 ; See if any of the channels flipped
163 cmp TotalTicks, ecx ; Timeout at 1/200'th of a second
167 flip1: and eax, 01111b ; Only care about axis values
168 mov [edi], eax ; Record what channel(s) flipped
170 xor bl, al ; Unmark the channels that just tripped
173 mov [edi], eax ; Record the time this channel flipped
175 inc bh ; Increment number of events
178 jne again1 ; If there are more channels to read, keep looping
181 movzx eax, bh ; Return number of events
186 PUBLIC joy_read_stick_bios_
188 joy_read_stick_bios_:
190 ; edi = pointer to event buffer
191 ; ecx = timeout value
192 ; returns in eax the number of events
196 mov dword ptr [edi], 0
204 mov dword ptr [edi+4], 1 ; Axis 1
206 mov [edi+8], eax ; Axis 1 value
208 mov dword ptr [edi+12], 2 ; Axis 2
210 mov [edi+16], ebx ; Axis 2 value
212 mov dword ptr [edi+20], 4 ; Axis 3
214 mov [edi+24], ecx ; Axis 3 value
216 mov dword ptr [edi+28], 8 ; Axis 3
218 mov [edi+32], edx ; Axis 3 value
221 mov eax, 4 ; 4 events
226 PUBLIC joy_read_buttons_bios_
228 joy_read_buttons_bios_:
229 ; returns in eax the button settings
235 mov edx, 0 ; Read switches