0
|
1 ********************************************************************
|
|
2 * JoyDrv - Joystick Driver for CoCo 3 Hi-Res Mouse
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
1263
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
0
|
8 * ------------------------------------------------------------------
|
1288
|
9 * 6 1998/10/09 Robert Gault
|
|
10 * Added annotations to the L2 Upgrade distribution version
|
1263
|
11 *
|
2144
|
12 * 7 2003/08/28 Robert Gault
|
1933
|
13 * Contains routine for H6309 from VTIO
|
0
|
14
|
|
15 nam JoyDrv
|
|
16 ttl Joystick Driver for CoCo 3 Hi-Res Mouse
|
|
17
|
|
18 * Disassembled 98/09/09 09:07:45 by Disasm v1.6 (C) 1988 by RML
|
|
19
|
|
20 ifp1
|
|
21 use defsfile
|
2624
|
22 use cocovtio.d
|
0
|
23 endc
|
|
24
|
|
25 tylg set Systm+Objct
|
|
26 atrv set ReEnt+rev
|
1263
|
27 rev set $00
|
1288
|
28 edition set 7
|
0
|
29
|
|
30 mod eom,name,tylg,atrv,start,size
|
|
31 size equ .
|
|
32
|
|
33 name fcs /JoyDrv/
|
|
34 fcb edition
|
|
35
|
|
36 start lbra Init setup for special button state & clear buttons
|
|
37 lbra Term clear button but don't change special flag
|
|
38 lbra SSMsBtn read and process button values
|
|
39 lbra SSMsXY read joystick values; with processing
|
|
40 lbra SSJoyBtn clear keyboard input and return raw button info
|
|
41
|
|
42 SSJoyXY pshs y,x,b,a read joystick values
|
|
43 pshs x,b,a
|
|
44 ldx #PIA0Base point to PIA#1
|
|
45 lda <$23,x read sound enable state?
|
|
46 ldb <$20,x read 6-bit DAC
|
|
47 pshs b,a save current states
|
|
48 anda #%11110111 clear sound enable
|
|
49 sta <$23,x set switch
|
|
50 lda $01,x read MUX SEL#1
|
|
51 ldb $03,x read MUX SEL#2
|
|
52 pshs b,a save current state
|
|
53 orb #$08 set SEL#2
|
|
54 lda $08,s read ?what?
|
|
55 anda #$02 keep only left or right joystick
|
|
56 bne L0047 if left then don't
|
|
57 andb #%11110111 clear SEL#2
|
|
58 L0047 stb $03,x enable SEL#2 value
|
|
59 leay <L0097,pcr point to high res routine
|
|
60 ldb $0D,s flag for high/low res
|
|
61 bne L0054
|
|
62 leay >L010F,pcr point to low res routine
|
|
63 L0054 lda ,s
|
|
64 ora #$08 set MUX SEL#1
|
|
65 jsr ,y read pot
|
|
66 tst $0D,s here the same byte seems to be used for x/y flag??
|
|
67 beq L0060
|
|
68 bsr L00DB convert from width to height value
|
|
69 L0060 std $06,s return joystick value
|
|
70 lda ,s now read the other direction
|
|
71 anda #$F7 flip the MUX SEL#1 bit
|
|
72 jsr ,y read the second pot
|
|
73 std $04,s save the other value
|
|
74 puls b,a
|
|
75 sta $01,x
|
|
76 stb $03,x
|
|
77 puls b,a
|
|
78 stb <$20,x reset the DAC and sound selector
|
|
79 sta <$23,x
|
|
80 puls y,x
|
|
81 lda ,s flag for double button?
|
|
82 cmpa #$01
|
|
83 bne L0094
|
|
84 ldb #$80 minimum flag
|
|
85 lda $05,s
|
|
86 bne L008B
|
|
87 cmpx #32 minimum joystick value
|
|
88 bcc L0092
|
|
89 L008B cmpx #320 maximum joystick value
|
|
90 bcc L0092 if less than don't change flag
|
|
91 ldb #$C0 maximum flag
|
|
92 L0092 stb ,u save max/min flag value
|
|
93 L0094 leas $06,s
|
|
94 rts
|
|
95 L0097 pshs cc high res routine
|
|
96 sta $01,x select x/y pot
|
|
97 lda #$FF full DAC value
|
|
98 sta <$20,x store in DAC to charge capacitor
|
1288
|
99 IFNE H6309
|
|
100 lda #$80
|
|
101 ELSE
|
0
|
102 lda #$5A timing loop; wait for voltage to settle
|
1288
|
103 ENDC
|
0
|
104 L00A2 deca
|
|
105 bne L00A2 wait
|
1288
|
106 IFNE H6309
|
|
107 ldd #$2F0
|
|
108 lde #2
|
|
109 ELSE
|
|
110 ldd #$329
|
0
|
111 pshs a
|
|
112 lda #$02
|
1288
|
113 ENDC
|
0
|
114 orcc #IntMasks kill interrupts
|
1288
|
115 IFNE H6309
|
|
116 ste <$20,x
|
|
117 ELSE
|
0
|
118 sta <$20,x clear DAC; mask RS-232; start cap. discharge
|
1288
|
119 ENDC
|
|
120 L00B1 equ *
|
|
121 IFNE H6309
|
|
122 lde ,x
|
|
123 ELSE
|
|
124 lda ,x test comparator
|
|
125 ENDC
|
0
|
126 bmi L00C0
|
1288
|
127 IFNE H6309
|
|
128 decd
|
|
129 ELSE
|
|
130 decb counter
|
|
131 ENDC
|
0
|
132 bne L00B1 loop until state change
|
1288
|
133 IFNE H6309
|
|
134 ldd #MaxRows-1 Too big, force to highest possible coord
|
|
135 puls cc,pc
|
|
136 ELSE
|
0
|
137 dec ,s 3 -> 0
|
|
138 bpl L00B1 loop again
|
|
139 puls a
|
|
140 bra L00D6 branch to maximum value
|
|
141 L00C0 puls a
|
1288
|
142 ENDC
|
|
143 IFNE H6309
|
|
144 L00C0 equ *
|
|
145 ENDC
|
|
146 decb
|
|
147 IFNE H6309
|
|
148 ldw #MaxRows Max coord
|
|
149 subr d,w Subtract the timing ramp value we got
|
|
150 bhs L0A11 If didn't wrap, we're fine
|
|
151 clrd If went negative, force to 0 coord
|
|
152 puls cc,pc Turn interrupts back on & return
|
|
153 L0A11 tfr w,d Move to proper exit register for now
|
|
154 cmpd #MaxRows-1 Past maximum X coordinate?
|
|
155 blo L0A1A No, leave it alone
|
|
156 ldd #MaxRows-1 Don't let it get past end of screen
|
|
157 L0A1A puls pc,cc
|
|
158 ELSE
|
0
|
159 pshs b,a
|
|
160 ldd #640
|
|
161 subd ,s++ convert from 640 -> 0 to 0 -> 640
|
|
162 bcc L00D0
|
|
163 clra minimum value is $00
|
|
164 clrb
|
|
165 puls pc,cc
|
|
166 L00D0 cmpd #639
|
|
167 bcs L00D9
|
|
168 L00D6 ldd #639 maximum value
|
|
169 L00D9 puls pc,cc
|
1288
|
170 ENDC
|
0
|
171 * This routine converts a pot value from width (640) to height (192) to match
|
|
172 * possible screen values; ie. value divided by 3.33
|
|
173 L00DB pshs a
|
|
174 lda #$09
|
|
175 pshs a
|
|
176 lda #$03
|
|
177 mul
|
|
178 pshs b,a
|
|
179 lda $03,s
|
|
180 ldb #$03
|
|
181 mul
|
|
182 exg b,a
|
|
183 addd ,s++
|
|
184 L00EF clr $01,s
|
|
185 cmpa #$0A
|
|
186 bcs L00F9
|
|
187 inc $01,s
|
|
188 suba #$0A
|
|
189 L00F9 lsr $01,s
|
|
190 rolb
|
|
191 rola
|
|
192 dec ,s
|
|
193 bne L00EF
|
|
194 cmpb #$BF
|
|
195 beq L010B
|
|
196 cmpa #$0A
|
|
197 bcs L010B
|
|
198 addb #$01
|
|
199 L010B clra
|
|
200 leas $02,s
|
|
201 rts
|
|
202 * Low res binary tree search for joystick value
|
|
203 L010F sta $01,x set MUX SEL#1
|
|
204 lda #$7F DAC value
|
|
205 ldb #$40
|
|
206 bra L0122
|
|
207 L0117 lsrb reset DAC offset value
|
|
208 cmpb #$01
|
|
209 bhi L0122
|
|
210 lsra
|
|
211 lsra
|
|
212 tfr a,b
|
|
213 clra
|
|
214 rts return with voltage
|
|
215 L0122 pshs b
|
|
216 sta <$20,x set DAC
|
|
217 tst ,x test comparator
|
|
218 bpl L012F
|
|
219 adda ,s+ adjust binary tree search
|
|
220 bra L0117
|
|
221 L012F suba ,s+ adjust binary tree search
|
|
222 bra L0117
|
|
223
|
|
224 SSMsXY leay ,y get flag??
|
|
225 lbne SSJoyXY go read joystick pots
|
|
226 lbsr SSJoyXY go read joystick pots and then convert values
|
|
227 tfr x,d multiply regX by 10 and regY by 3
|
|
228 lda #$0A
|
|
229 mul
|
|
230 tfr d,x
|
|
231 cmpx #630
|
|
232 bcs L014B
|
|
233 ldx #634 maximum limit on regX
|
|
234 * may be an error and could be 639
|
|
235 L014B tfr y,d
|
|
236 lda #$03
|
|
237 mul
|
|
238 tfr d,y
|
|
239 rts
|
|
240
|
|
241 Init ldb #$80
|
|
242 stb ,u
|
|
243
|
|
244 Term clr $01,u
|
|
245 rts
|
|
246
|
|
247 SSJoyBtn ldx #PIA0Base PIA#1 base address
|
|
248 clrb
|
|
249 comb
|
|
250 stb $02,x clear PIA#1 key strobe lines
|
|
251 ldb ,x read data lines
|
|
252 comb only buttons and comparator valid
|
|
253 andb #$0F only buttons; 0=off 1=on
|
|
254 rts
|
|
255
|
|
256 SSMsBtn bsr SSJoyBtn
|
|
257 tfr b,a
|
|
258 anda #%11111010 regA=left buttons; should be $0A not $FA
|
|
259 pshs a save left button values
|
|
260 andb #$05 regB=right buttons
|
|
261 orb $01,u ORB with previous state??
|
|
262 leax <L0187,pcr point to sequential switch table possibilities
|
|
263 lda b,x
|
|
264 anda #%00001010 keep only left values
|
|
265 sta $01,u save for change test
|
|
266 ldb b,x repeat
|
|
267 andb #%10000101 keep flag and right values
|
|
268 bpl L0184
|
|
269 ldb ,u previous min/max state
|
|
270 L0184 orb ,s+ ORB with current left values and pop stack
|
|
271 rts
|
|
272 L0187 fcb $00,$03,$00,$03,$08,$06,$02,$06,$80,$02,$00,$02,$08,$06,$0a,$06
|
|
273
|
|
274 emod
|
|
275 eom equ *
|
|
276 end
|
|
277
|