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