annotate level2/modules/joydrv_joy.asm @ 1262:67e11bfc9cd4

More 6309 optimizations
author boisy
date Mon, 18 Aug 2003 22:54:07 +0000
parents 6641a883d6b0
children 205b4fbc08cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
1 ********************************************************************
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
2 * JoyDrv - Joystick Driver for CoCo 3 Hi-Res Mouse
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
3 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
4 * $Id$
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
5 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
6 * Ed. Comments Who YY/MM/DD
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
7 * ------------------------------------------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
8 * 6 L2 Upgrade distribution version
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
9 * Annotations by Robert Gault RG 98/10/09
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
10
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
11 nam JoyDrv
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
12 ttl Joystick Driver for CoCo 3 Hi-Res Mouse
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
13
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
14 * Disassembled 98/09/09 09:07:45 by Disasm v1.6 (C) 1988 by RML
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
15
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
16 ifp1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
17 use defsfile
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
18 endc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
19
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
20 tylg set Systm+Objct
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
21 atrv set ReEnt+rev
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
22 rev set $01
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
23 edition set 6
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
24
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
25 mod eom,name,tylg,atrv,start,size
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
26 size equ .
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
27
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
28 name fcs /JoyDrv/
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
29 fcb edition
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
30
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
31 start lbra Init setup for special button state & clear buttons
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
32 lbra Term clear button but don't change special flag
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
33 lbra SSMsBtn read and process button values
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
34 lbra SSMsXY read joystick values; with processing
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
35 lbra SSJoyBtn clear keyboard input and return raw button info
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
36
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
37 SSJoyXY pshs y,x,b,a read joystick values
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
38 pshs x,b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
39 ldx #PIA0Base point to PIA#1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
40 lda <$23,x read sound enable state?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
41 ldb <$20,x read 6-bit DAC
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
42 pshs b,a save current states
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
43 anda #%11110111 clear sound enable
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
44 sta <$23,x set switch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
45 lda $01,x read MUX SEL#1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
46 ldb $03,x read MUX SEL#2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
47 pshs b,a save current state
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
48 orb #$08 set SEL#2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
49 lda $08,s read ?what?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
50 anda #$02 keep only left or right joystick
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
51 bne L0047 if left then don't
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
52 andb #%11110111 clear SEL#2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
53 L0047 stb $03,x enable SEL#2 value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
54 leay <L0097,pcr point to high res routine
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
55 ldb $0D,s flag for high/low res
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
56 bne L0054
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
57 leay >L010F,pcr point to low res routine
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
58 L0054 lda ,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
59 ora #$08 set MUX SEL#1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
60 jsr ,y read pot
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
61 tst $0D,s here the same byte seems to be used for x/y flag??
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
62 beq L0060
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
63 bsr L00DB convert from width to height value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
64 L0060 std $06,s return joystick value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
65 lda ,s now read the other direction
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
66 anda #$F7 flip the MUX SEL#1 bit
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
67 jsr ,y read the second pot
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
68 std $04,s save the other value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
69 puls b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
70 sta $01,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
71 stb $03,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
72 puls b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
73 stb <$20,x reset the DAC and sound selector
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
74 sta <$23,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
75 puls y,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
76 lda ,s flag for double button?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
77 cmpa #$01
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
78 bne L0094
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
79 ldb #$80 minimum flag
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
80 lda $05,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
81 bne L008B
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
82 cmpx #32 minimum joystick value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
83 bcc L0092
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
84 L008B cmpx #320 maximum joystick value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
85 bcc L0092 if less than don't change flag
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
86 ldb #$C0 maximum flag
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
87 L0092 stb ,u save max/min flag value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
88 L0094 leas $06,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
89 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
90 L0097 pshs cc high res routine
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
91 sta $01,x select x/y pot
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
92 lda #$FF full DAC value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
93 sta <$20,x store in DAC to charge capacitor
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
94 lda #$5A timing loop; wait for voltage to settle
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
95 L00A2 deca
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
96 bne L00A2 wait
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
97 ldd #$0329
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
98 pshs a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
99 lda #$02
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
100 orcc #IntMasks kill interrupts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
101 sta <$20,x clear DAC; mask RS-232; start cap. discharge
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
102 L00B1 lda ,x test comparator
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
103 bmi L00C0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
104 decb counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
105 bne L00B1 loop until state change
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
106 dec ,s 3 -> 0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
107 bpl L00B1 loop again
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
108 puls a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
109 bra L00D6 branch to maximum value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
110 L00C0 puls a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
111 decb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
112 pshs b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
113 ldd #640
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
114 subd ,s++ convert from 640 -> 0 to 0 -> 640
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
115 bcc L00D0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
116 clra minimum value is $00
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
117 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
118 puls pc,cc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
119 L00D0 cmpd #639
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
120 bcs L00D9
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
121 L00D6 ldd #639 maximum value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
122 L00D9 puls pc,cc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
123 * This routine converts a pot value from width (640) to height (192) to match
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
124 * possible screen values; ie. value divided by 3.33
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
125 L00DB pshs a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
126 lda #$09
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
127 pshs a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
128 lda #$03
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
129 mul
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
130 pshs b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
131 lda $03,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
132 ldb #$03
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
133 mul
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
134 exg b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
135 addd ,s++
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
136 L00EF clr $01,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
137 cmpa #$0A
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
138 bcs L00F9
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
139 inc $01,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
140 suba #$0A
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
141 L00F9 lsr $01,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
142 rolb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
143 rola
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
144 dec ,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
145 bne L00EF
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
146 cmpb #$BF
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
147 beq L010B
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
148 cmpa #$0A
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
149 bcs L010B
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
150 addb #$01
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
151 L010B clra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
152 leas $02,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
153 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
154 * Low res binary tree search for joystick value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
155 L010F sta $01,x set MUX SEL#1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
156 lda #$7F DAC value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
157 ldb #$40
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
158 bra L0122
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
159 L0117 lsrb reset DAC offset value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
160 cmpb #$01
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
161 bhi L0122
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
162 lsra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
163 lsra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
164 tfr a,b
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
165 clra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
166 rts return with voltage
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
167 L0122 pshs b
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
168 sta <$20,x set DAC
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
169 tst ,x test comparator
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
170 bpl L012F
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
171 adda ,s+ adjust binary tree search
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
172 bra L0117
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
173 L012F suba ,s+ adjust binary tree search
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
174 bra L0117
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
175
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
176 SSMsXY leay ,y get flag??
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
177 lbne SSJoyXY go read joystick pots
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
178 lbsr SSJoyXY go read joystick pots and then convert values
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
179 tfr x,d multiply regX by 10 and regY by 3
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
180 lda #$0A
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
181 mul
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
182 tfr d,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
183 cmpx #630
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
184 bcs L014B
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
185 ldx #634 maximum limit on regX
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
186 * may be an error and could be 639
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
187 L014B tfr y,d
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
188 lda #$03
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
189 mul
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
190 tfr d,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
191 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
192
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
193 Init ldb #$80
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
194 stb ,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
195
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
196 Term clr $01,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
197 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
198
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
199 SSJoyBtn ldx #PIA0Base PIA#1 base address
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
200 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
201 comb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
202 stb $02,x clear PIA#1 key strobe lines
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
203 ldb ,x read data lines
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
204 comb only buttons and comparator valid
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
205 andb #$0F only buttons; 0=off 1=on
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
206 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
207
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
208 SSMsBtn bsr SSJoyBtn
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
209 tfr b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
210 anda #%11111010 regA=left buttons; should be $0A not $FA
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
211 pshs a save left button values
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
212 andb #$05 regB=right buttons
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
213 orb $01,u ORB with previous state??
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
214 leax <L0187,pcr point to sequential switch table possibilities
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
215 lda b,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
216 anda #%00001010 keep only left values
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
217 sta $01,u save for change test
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
218 ldb b,x repeat
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
219 andb #%10000101 keep flag and right values
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
220 bpl L0184
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
221 ldb ,u previous min/max state
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
222 L0184 orb ,s+ ORB with current left values and pop stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
223 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
224 L0187 fcb $00,$03,$00,$03,$08,$06,$02,$06,$80,$02,$00,$02,$08,$06,$0a,$06
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
225
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
226 emod
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
227 eom equ *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
228 end
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
229